diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 7110ef97d1..217381860b 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -34,18 +34,16 @@ #include "RiuProcessMonitor.h" #include "RiaPreferences.h" // -#include "RimResultCase.h" -#include "RimInputCase.h" -#include "RimReservoirView.h" +#include "RimEclipseResultCase.h" +#include "RimEclipseInputCase.h" +#include "RimEclipseView.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimOilField.h" -#include "RimAnalysisModels.h" +#include "RimEclipseCaseCollection.h" #include "RimFaultCollection.h" -#include "RimFaultResultSlot.h" +#include "RimEclipseFaultColors.h" -#include "cafCeetronNavigation.h" -#include "cafCadNavigation.h" #include "RiaSocketServer.h" #include "cafUiProcess.h" // @@ -58,10 +56,10 @@ #include "RimProject.h" -#include "RimResultSlot.h" +#include "RimEclipseCellColors.h" #include "RimIdenticalGridCaseGroup.h" -#include "RimInputPropertyCollection.h" +#include "RimEclipseInputPropertyCollection.h" #include "RimDefines.h" #include "RimScriptCollection.h" @@ -72,17 +70,21 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" #include "RimReservoirCellResultsStorage.h" -#include "RimCellEdgeResultSlot.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" #include "Rim3dOverlayInfoConfig.h" -#include "RimWellCollection.h" -#include "RimStatisticsCase.h" +#include "RimEclipseWellCollection.h" +#include "RimEclipseStatisticsCase.h" #include "cafCeetronPlusNavigation.h" #include "cvfProgramOptions.h" #include "cvfqtUtils.h" #include "RimCommandObject.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechModels.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCellColors.h" namespace caf @@ -92,11 +94,12 @@ void AppEnum< RiaApplication::RINavigationPolicy >::setUp() { addItem(RiaApplication::NAVIGATION_POLICY_CEETRON, "NAVIGATION_POLICY_CEETRON", "Ceetron"); addItem(RiaApplication::NAVIGATION_POLICY_CAD, "NAVIGATION_POLICY_CAD", "CAD"); - setDefault(RiaApplication::NAVIGATION_POLICY_CAD); + addItem(RiaApplication::NAVIGATION_POLICY_GEOQUEST, "NAVIGATION_POLICY_GEOQUEST", "GEOQUEST"); + addItem(RiaApplication::NAVIGATION_POLICY_RMS, "NAVIGATION_POLICY_RMS", "RMS"); + setDefault(RiaApplication::NAVIGATION_POLICY_RMS); } } - namespace RegTestNames { const QString generatedFolderName = "RegTestGeneratedImages"; @@ -170,6 +173,8 @@ RiaApplication::RiaApplication(int& argc, char** argv) // instead of using the application font m_standardFont = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD); m_resViewUpdateTimer = NULL; + + m_runningRegressionTests = false; } @@ -314,7 +319,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; if (analysisModels == NULL) continue; for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); ++cgIdx) @@ -348,7 +353,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; if (analysisModels) { analysisModels->recomputeStatisticsForAllCaseGroups(); @@ -366,17 +371,17 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx) { - RimCase* ri = casesToLoad[cIdx]; - CVF_ASSERT(ri); + RimCase* cas = casesToLoad[cIdx]; + CVF_ASSERT(cas); - caseProgress.setProgressDescription(ri->caseUserDescription()); - - caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views"); + caseProgress.setProgressDescription(cas->caseUserDescription()); + std::vector views = cas->views(); + caf::ProgressInfo viewProgress(views.size() , "Creating Views"); size_t j; - for (j = 0; j < ri->reservoirViews().size(); j++) + for (j = 0; j < views.size(); j++) { - RimReservoirView* riv = ri->reservoirViews[j]; + RimView* riv = views[j]; CVF_ASSERT(riv); viewProgress.setProgressDescription(riv->name()); @@ -630,15 +635,15 @@ bool RiaApplication::openEclipseCaseFromFile(const QString& fileName) //-------------------------------------------------------------------------------------------------- bool RiaApplication::openEclipseCase(const QString& caseName, const QString& caseFileName) { - RimResultCase* rimResultReservoir = new RimResultCase(); + RimEclipseResultCase* rimResultReservoir = new RimEclipseResultCase(); rimResultReservoir->setCaseInfo(caseName, caseFileName); - RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL; if (analysisModels == NULL) return false; analysisModels->cases.push_back(rimResultReservoir); - RimReservoirView* riv = rimResultReservoir->createAndAddReservoirView(); + RimEclipseView* riv = rimResultReservoir->createAndAddReservoirView(); // Select SOIL as default result variable riv->cellResult()->setResultType(RimDefines::DYNAMIC_NATIVE); @@ -647,7 +652,7 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas { riv->cellResult()->setResultVariable("SOIL"); } - riv->animationMode = true; + riv->hasUserRequestedAnimation = true; riv->loadDataAndUpdate(); @@ -671,20 +676,20 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas //-------------------------------------------------------------------------------------------------- bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNames) { - RimInputCase* rimInputReservoir = new RimInputCase(); + RimEclipseInputCase* rimInputReservoir = new RimEclipseInputCase(); m_project->assignCaseIdToCase(rimInputReservoir); rimInputReservoir->openDataFileSet(fileNames); - RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL; if (analysisModels == NULL) return false; analysisModels->cases.push_back(rimInputReservoir); - RimReservoirView* riv = rimInputReservoir->createAndAddReservoirView(); + RimEclipseView* riv = rimInputReservoir->createAndAddReservoirView(); riv->cellResult()->setResultType(RimDefines::INPUT_PROPERTY); - riv->animationMode = true; + riv->hasUserRequestedAnimation = true; riv->loadDataAndUpdate(); @@ -702,6 +707,53 @@ bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNa } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaApplication::openOdbCaseFromFile(const QString& fileName) +{ + if (!QFile::exists(fileName)) return false; + + QFileInfo gridFileName(fileName); + QString caseName = gridFileName.completeBaseName(); + + RimGeoMechCase* geoMechCase = new RimGeoMechCase(); + geoMechCase->setFileName(fileName); + geoMechCase->caseUserDescription = caseName; + + RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels() : NULL; + + // Create the geoMech model container if it is not there already + if (geoMechModelCollection == NULL) + { + geoMechModelCollection = new RimGeoMechModels(); + m_project->activeOilField()->geoMechModels = geoMechModelCollection; + } + + geoMechModelCollection->cases.push_back(geoMechCase); + + RimGeoMechView* riv = geoMechCase->createAndAddReservoirView(); + caf::ProgressInfo progress(11, "Loading Case"); + progress.setNextProgressIncrement(10); + + riv->loadDataAndUpdate(); + + //if (!riv->cellResult()->hasResult()) + //{ + // riv->cellResult()->setResultVariable(RimDefines::undefinedResultName()); + //} + progress.incrementProgress(); + progress.setProgressDescription("Loading results information"); + RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel(); + + uiModel->updateUiSubTree(m_project); + + RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult()); + + return true; +} + + //-------------------------------------------------------------------------------------------------- /// @@ -748,7 +800,7 @@ void RiaApplication::createInputMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimReservoirView* RiaApplication::activeReservoirView() const +const RimView* RiaApplication::activeReservoirView() const { return m_activeReservoirView; } @@ -756,7 +808,7 @@ const RimReservoirView* RiaApplication::activeReservoirView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView* RiaApplication::activeReservoirView() +RimView* RiaApplication::activeReservoirView() { return m_activeReservoirView; } @@ -764,7 +816,7 @@ RimReservoirView* RiaApplication::activeReservoirView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaApplication::setActiveReservoirView(RimReservoirView* rv) +void RiaApplication::setActiveReservoirView(RimView* rv) { m_activeReservoirView = rv; } @@ -1325,15 +1377,7 @@ void RiaApplication::applyPreferences() { if (m_activeReservoirView && m_activeReservoirView->viewer()) { - if (m_preferences->navigationPolicy() == NAVIGATION_POLICY_CAD) - { - m_activeReservoirView->viewer()->setNavigationPolicy(new caf::CadNavigation); - } - else - { - m_activeReservoirView->viewer()->setNavigationPolicy(new caf::CeetronPlusNavigation); - } - + m_activeReservoirView->viewer()->updateNavigationPolicy(); m_activeReservoirView->viewer()->enablePerfInfoHud(m_preferences->showHud()); } @@ -1483,12 +1527,14 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) for (size_t i = 0; i < projectCases.size(); i++) { - RimCase* ri = projectCases[i]; - if (!ri) continue; + RimCase* cas = projectCases[i]; + if (!cas) continue; - for (size_t j = 0; j < ri->reservoirViews().size(); j++) + std::vector views = cas->views(); + + for (size_t j = 0; j < views.size(); j++) { - RimReservoirView* riv = ri->reservoirViews()[j]; + RimView* riv = views[j]; if (riv && riv->viewer()) { @@ -1500,7 +1546,7 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) // Process all events to avoid a black image when grabbing frame buffer QCoreApplication::processEvents(); - QString fileName = ri->caseUserDescription() + "-" + riv->name(); + QString fileName = cas->caseUserDescription() + "-" + riv->name(); fileName.replace(" ", "_"); QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png"); @@ -1556,6 +1602,8 @@ void removeDirectoryWithContent(QDir dirToDelete ) //-------------------------------------------------------------------------------------------------- void RiaApplication::runRegressionTest(const QString& testRootPath) { + m_runningRegressionTests = true; + QString generatedFolderName = RegTestNames::generatedFolderName; QString diffFolderName = RegTestNames::diffFolderName; QString baseFolderName = RegTestNames::baseFolderName; @@ -1677,6 +1725,8 @@ void RiaApplication::runRegressionTest(const QString& testRootPath) } } } + + m_runningRegressionTests = false; } //-------------------------------------------------------------------------------------------------- @@ -1724,7 +1774,7 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) // First file is read completely including grid. // The main grid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RimResultCase* mainResultCase = NULL; + RimEclipseResultCase* mainResultCase = NULL; std::vector< std::vector > mainCaseGridDimensions; RimIdenticalGridCaseGroup* gridCaseGroup = NULL; @@ -1734,7 +1784,7 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) QString caseName = gridFileName.completeBaseName(); - RimResultCase* rimResultReservoir = new RimResultCase(); + RimEclipseResultCase* rimResultReservoir = new RimEclipseResultCase(); rimResultReservoir->setCaseInfo(caseName, firstFileName); if (!rimResultReservoir->openEclipseGridFile()) { @@ -1762,7 +1812,7 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) QString caseName = gridFileName.completeBaseName(); - RimResultCase* rimResultReservoir = new RimResultCase(); + RimEclipseResultCase* rimResultReservoir = new RimEclipseResultCase(); rimResultReservoir->setCaseInfo(caseName, caseFileName); std::vector< std::vector > caseGridDimensions; @@ -1921,7 +1971,7 @@ QString RiaApplication::commandLineParameterHelp() const /// Schedule a creation of the Display model and redraw of the reservoir view /// The redraw will happen as soon as the event loop is entered //-------------------------------------------------------------------------------------------------- -void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resViewToUpdate) +void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate) { m_resViewsToUpdate.push_back(resViewToUpdate); @@ -1944,13 +1994,13 @@ void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resVi void RiaApplication::slotUpdateScheduledDisplayModels() { // Compress to remove duplicates - std::set resViewsToUpdate; + std::set resViewsToUpdate; for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i) { resViewsToUpdate.insert(m_resViewsToUpdate[i]); } - for (std::set::iterator it = resViewsToUpdate.begin(); it != resViewsToUpdate.end(); ++it ) + for (std::set::iterator it = resViewsToUpdate.begin(); it != resViewsToUpdate.end(); ++it ) { if (*it) { @@ -2028,6 +2078,14 @@ void RiaApplication::executeCommandObjects() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaApplication::isRunningRegressionTests() const +{ + return m_runningRegressionTests; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2059,14 +2117,17 @@ void RiaApplication::regressionTestConfigureProject() std::vector projectCases; m_project->allCases(projectCases); + for (size_t i = 0; i < projectCases.size(); i++) { - RimCase* ri = projectCases[i]; - if (!ri) continue; + RimCase* cas = projectCases[i]; + if (!cas) continue; + + std::vector views = cas->views(); - for (size_t j = 0; j < ri->reservoirViews().size(); j++) + for (size_t j = 0; j < views.size(); j++) { - RimReservoirView* riv = ri->reservoirViews()[j]; + RimView* riv = views[j]; if (riv && riv->viewer()) { @@ -2074,9 +2135,13 @@ void RiaApplication::regressionTestConfigureProject() riv->viewer()->setFixedSize(1000, 745); } - riv->faultCollection->setShowFaultsOutsideFilters(false); - riv->faultResultSettings->showCustomFaultResult.setValueFromUi(false); + RimEclipseView* resvView = dynamic_cast(riv); + + if (resvView) + { + resvView->faultCollection->setShowFaultsOutsideFilters(false); + resvView->faultResultSettings->showCustomFaultResult.setValueFromUi(false); + } } } } - diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 1d04f1ace7..d2a45b6dab 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -33,11 +33,12 @@ class RIProcess; class RigCaseData; -class RimCase; +class RimEclipseCase; class Drawable; class RiaSocketServer; class RiaPreferences; -class RimReservoirView; +class RimEclipseView; +class RimView; class RimProject; class RimCommandObject; class RiaProjectModifier; @@ -60,7 +61,9 @@ class RiaApplication : public QApplication enum RINavigationPolicy { NAVIGATION_POLICY_CEETRON, - NAVIGATION_POLICY_CAD + NAVIGATION_POLICY_CAD, + NAVIGATION_POLICY_GEOQUEST, + NAVIGATION_POLICY_RMS }; public: @@ -72,11 +75,11 @@ class RiaApplication : public QApplication void executeRegressionTests(const QString& regressionTestPath); - void setActiveReservoirView(RimReservoirView*); - RimReservoirView* activeReservoirView(); - const RimReservoirView* activeReservoirView() const; + void setActiveReservoirView(RimView*); + RimView* activeReservoirView(); + const RimView* activeReservoirView() const; - void scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resViewToUpdate); + void scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate); RimProject* project(); @@ -94,6 +97,8 @@ class RiaApplication : public QApplication bool addEclipseCases(const QStringList& fileNames); bool openInputEclipseCaseFromFileNames(const QStringList& fileNames); + bool openOdbCaseFromFile(const QString& fileName); + QString currentProjectFileName() const; QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath); bool loadProject(const QString& projectFileName); @@ -149,6 +154,8 @@ class RiaApplication : public QApplication void addCommandObject(RimCommandObject* commandObject); void executeCommandObjects(); + bool isRunningRegressionTests() const; + private: enum ProjectLoadAction { @@ -169,10 +176,10 @@ private slots: void slotUpdateScheduledDisplayModels(); private: - caf::PdmPointer m_activeReservoirView; + caf::PdmPointer m_activeReservoirView; caf::PdmPointer m_project; - std::vector > m_resViewsToUpdate; + std::vector > m_resViewsToUpdate; QTimer* m_resViewUpdateTimer; RiaSocketServer* m_socketServer; @@ -193,8 +200,9 @@ private slots: QMap m_sessionCache; // Session cache used to store username/passwords per session - std::list m_commandQueue; - QMutex m_commandQueueLock; + std::list m_commandQueue; + QMutex m_commandQueueLock; - QString m_helpText; + QString m_helpText; + bool m_runningRegressionTests; }; diff --git a/ApplicationCode/Application/RiaImageFileCompare.cpp b/ApplicationCode/Application/RiaImageFileCompare.cpp index fa66a6eb12..19ad991a88 100644 --- a/ApplicationCode/Application/RiaImageFileCompare.cpp +++ b/ApplicationCode/Application/RiaImageFileCompare.cpp @@ -75,9 +75,9 @@ bool RiaImageFileCompare::runComparison(QString imgFileName, QString refFileName // The ImageMagick compare tool on RedHat 5 does not support the lowlight-color options // Use GCC version as a crude mechanism for disabling use of this option on RedHat5 #if (__GNUC__ == 4 && __GNUC_MINOR__ <= 1) - QString args = QString("-metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName)); + QString args = QString("-fuzz 0.4% -metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName)); #else - QString args = QString("-lowlight-color white -metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName)); + QString args = QString("-fuzz 0.4% -lowlight-color white -metric ae \"%1\" \"%2\" \"%3\"").arg(imgFileName).arg(refFileName).arg((diffFileName)); #endif QString completeCommand = QString("\"%1\" %2").arg(m_compareExecutable).arg(args); diff --git a/ApplicationCode/Application/RiaProjectModifier.cpp b/ApplicationCode/Application/RiaProjectModifier.cpp index 6de42bef55..e4e5f16246 100644 --- a/ApplicationCode/Application/RiaProjectModifier.cpp +++ b/ApplicationCode/Application/RiaProjectModifier.cpp @@ -22,22 +22,22 @@ #include "RiaProjectModifier.h" #include "RimProject.h" -#include "RimAnalysisModels.h" +#include "RimEclipseCaseCollection.h" #include "RimOilField.h" #include "RimIdenticalGridCaseGroup.h" #include "RimCaseCollection.h" -#include "RimResultCase.h" +#include "RimEclipseResultCase.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RimWellPathCollection.h" #include "RimScriptCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimCellPropertyFilter.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipsePropertyFilter.h" #include "RimReservoirCellResultsStorage.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" @@ -145,7 +145,7 @@ bool RiaProjectModifier::replaceSourceCases(RimProject* project) for (size_t oilFieldIdx = 0; oilFieldIdx < project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = project->oilFields[oilFieldIdx]; - RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; if (analysisModels) { const size_t numCaseGroups = analysisModels->caseGroups.size(); @@ -164,7 +164,7 @@ bool RiaProjectModifier::replaceSourceCases(RimProject* project) QString caseName = caseNameFromGridFileName(fileName); // Use this slightly hackish method in order to get a new unique ID - RimResultCase* resCase = new RimResultCase; + RimEclipseResultCase* resCase = new RimEclipseResultCase; resCase->setCaseInfo(caseName, fileName); caseCollection->reservoirs.push_back(resCase); @@ -191,30 +191,24 @@ bool RiaProjectModifier::replaceSourceCases(RimProject* project) bool RiaProjectModifier::replaceCase(RimProject* project) { bool didReplacement = false; + std::vector allCases; + project->allCases(allCases); - for (size_t oilFieldIdx = 0; oilFieldIdx < project->oilFields().size(); oilFieldIdx++) + for (size_t caseIdx = 0; caseIdx < allCases.size(); ++caseIdx) { - RimOilField* oilField = project->oilFields[oilFieldIdx]; - RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL; - if (analysisModels) + RimEclipseResultCase* resultCase = dynamic_cast(allCases[caseIdx]); + if (resultCase) { - for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); ++caseIdx) + if (m_replaceCase_caseId == FIRST_OCCURENCE || + m_replaceCase_caseId == resultCase->caseId()) { - RimResultCase* resultCase = dynamic_cast(analysisModels->cases[caseIdx]); - if (resultCase) + resultCase->setGridFileName(m_replaceCase_gridFileName); + resultCase->caseUserDescription = caseNameFromGridFileName(m_replaceCase_gridFileName); + didReplacement = true; + + if (m_replaceCase_caseId == FIRST_OCCURENCE) { - if (m_replaceCase_caseId == FIRST_OCCURENCE || - m_replaceCase_caseId == resultCase->caseId()) - { - resultCase->setGridFileName(m_replaceCase_gridFileName); - resultCase->caseUserDescription = caseNameFromGridFileName(m_replaceCase_gridFileName); - didReplacement = true; - - if (m_replaceCase_caseId == FIRST_OCCURENCE) - { - return true; - } - } + return true; } } } diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index b392fbbf8e..8ad8c91b38 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -18,12 +18,20 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization ${CMAKE_CURRENT_SOURCE_DIR}/UserInterface ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel + ${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache ${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel ${CMAKE_CURRENT_SOURCE_DIR}/WellPathImportSsihub + ${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader + ${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechDataModel + ${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechVisualization + ${CMAKE_BINARY_DIR}/Generated ${CMAKE_CURRENT_BINARY_DIR} ) +############################################################################# +# Defining all the source (and header) files +############################################################################# # Use all h files in the subdirectories to make them available in the project file( GLOB_RECURSE HEADER_FILES *.h ) @@ -43,12 +51,17 @@ set( APPLICATION_FILES set( USER_INTERFACE_FILES UserInterface/RiuCursors.cpp UserInterface/RiuResultTextBuilder.cpp + UserInterface/RiuFemResultTextBuilder.cpp UserInterface/RiuMainWindow.cpp UserInterface/RiuResultInfoPanel.cpp UserInterface/RiuViewer.cpp UserInterface/RiuSimpleHistogramWidget.cpp UserInterface/RiuMultiCaseImportDialog.cpp UserInterface/RiuProcessMonitor.cpp + UserInterface/RiuViewerCommands.cpp + UserInterface/RiuCadNavigation.cpp + UserInterface/RiuRmsNavigation.cpp + UserInterface/RiuGeoQuestNavigation.cpp ) set( SOCKET_INTERFACE_FILES @@ -76,6 +89,7 @@ list( APPEND REFERENCED_CMAKE_FILES FileInterface/CMakeLists_files.cmake ProjectDataModel/CMakeLists_files.cmake ModelVisualization/CMakeLists_files.cmake + GeoMech/GeoMechVisualization/CMakeLists_files.cmake ) # Include source file lists from *.cmake files @@ -87,10 +101,30 @@ list( APPEND CPP_SOURCES ${CODE_SOURCE_FILES} ) +############################################################################# +# Sub-directory projects +############################################################################# + add_subdirectory(WellPathImportSsihub) +add_subdirectory(ResultStatisticsCache) + +# +# Odb api +# +set(RESINSIGHT_ODB_API_DIR "" CACHE PATH "Path to the ODB api from Simulia") +if(NOT ${RESINSIGHT_ODB_API_DIR} EQUAL "") + add_definitions(-DUSE_ODB_API) + add_subdirectory(GeoMech/OdbReader) + SET(RESINSIGHT_USE_ODB_API 1) + MESSAGE( STATUS "Using ODB-Api from : ${RESINSIGHT_ODB_API_DIR}" ) +endif() +add_subdirectory(GeoMech/GeoMechDataModel) + +############################################################################# +# Qt specifics: Moc, ui, resources +############################################################################# -# Define files for MOC-ing set ( QT_MOC_HEADERS Application/RiaApplication.h @@ -104,6 +138,8 @@ set ( QT_MOC_HEADERS UserInterface/RiuProcessMonitor.h SocketInterface/RiaSocketServer.h UserInterface/RiuMultiCaseImportDialog.h + UserInterface/RiuViewerCommands.h + ) qt4_wrap_cpp( MOC_FILES_CPP ${QT_MOC_HEADERS} ) @@ -139,55 +175,55 @@ endif() # creating PCH's for MSVC and GCC on Linux ############################################################################# -set( RAW_SOURCES ${CPP_SOURCES} ) - -list( REMOVE_ITEM RAW_SOURCES - RiaStdInclude.cpp - - ${CODE_SOURCE_FILES} - - ModelVisualization/RivCellEdgeEffectGenerator.cpp - ModelVisualization/RivPipeGeometryGenerator.cpp - ModelVisualization/RivWellPipesPartMgr.cpp - ModelVisualization/RivWellHeadPartMgr.cpp - - Application/RiaImageFileCompare.cpp - Application/RiaImageCompareReporter.cpp - Application/RiaRegressionTest.cpp - - SocketInterface/RiaSocketDataTransfer.cpp - - FileInterface/RifEclipseInputFileTools.cpp - FileInterface/RifEclipseOutputFileTools.cpp - FileInterface/RifEclipseRestartFilesetAccess.cpp - FileInterface/RifEclipseRestartDataAccess.cpp - FileInterface/RifEclipseUnifiedRestartFileAccess.cpp - FileInterface/RifReaderEclipseInput.cpp - FileInterface/RifReaderEclipseOutput.cpp - - UserInterface/RiuSimpleHistogramWidget.cpp - UserInterface/RiuMultiCaseImportDialog.cpp - UserInterface/RiuResultTextBuilder.cpp -) - -include( CustomPCH.cmake ) -set( ALL_INCLUDES - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} - ${QT_INCLUDES} -) - -set( PCH_NAME RiaStdInclude ) -set( GCC_PCH_TARGET gccPCH ) -set( PCH_COMPILER_DEFINE EMPTY ) -IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set( PCH_COMPILER_DEFINE CVF_LINUX) -ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - -precompiled_header( RAW_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ${PCH_COMPILER_DEFINE} ) +#set( RAW_SOURCES ${CPP_SOURCES} ) +# +#list( REMOVE_ITEM RAW_SOURCES +# RiaStdInclude.cpp +# +# ${CODE_SOURCE_FILES} +# +# ModelVisualization/RivCellEdgeEffectGenerator.cpp +# ModelVisualization/RivPipeGeometryGenerator.cpp +# ModelVisualization/RivWellPipesPartMgr.cpp +# ModelVisualization/RivWellHeadPartMgr.cpp +# +# Application/RiaImageFileCompare.cpp +# Application/RiaImageCompareReporter.cpp +# Application/RiaRegressionTest.cpp +# +# SocketInterface/RiaSocketDataTransfer.cpp +# +# FileInterface/RifEclipseInputFileTools.cpp +# FileInterface/RifEclipseOutputFileTools.cpp +# FileInterface/RifEclipseRestartFilesetAccess.cpp +# FileInterface/RifEclipseRestartDataAccess.cpp +# FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +# FileInterface/RifReaderEclipseInput.cpp +# FileInterface/RifReaderEclipseOutput.cpp +# +# UserInterface/RiuSimpleHistogramWidget.cpp +# UserInterface/RiuMultiCaseImportDialog.cpp +# UserInterface/RiuResultTextBuilder.cpp +#) +# +#include( CustomPCH.cmake ) +#set( ALL_INCLUDES +# ${LibCore_SOURCE_DIR} +# ${LibGeometry_SOURCE_DIR} +# ${LibGuiQt_SOURCE_DIR} +# ${LibRender_SOURCE_DIR} +# ${LibViewing_SOURCE_DIR} +# ${QT_INCLUDES} +#) +# +#set( PCH_NAME RiaStdInclude ) +#set( GCC_PCH_TARGET gccPCH ) +#set( PCH_COMPILER_DEFINE EMPTY ) +#IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +# set( PCH_COMPILER_DEFINE CVF_LINUX) +#ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +# +#precompiled_header( RAW_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ${PCH_COMPILER_DEFINE} ) ################################################################################ @@ -199,6 +235,10 @@ source_group( "UserInterface" FILES ${USER_INTERFACE_FILES} ) source_group( "SocketInterface" FILES ${SOCKET_INTERFACE_FILES} ) +############################################################################# +# Set up the main executable with its source files +############################################################################# + # Default behaviour for a Qt application is a console application, resulting in a console window always being launced at startup # The following statement is used to control this behaviour # set_target_properties( MY_TARGET PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") @@ -209,6 +249,8 @@ source_group( "SocketInterface" FILES ${SOCKET_INTERFACE_FILES} ) if (MSVC) set( EXE_FILES WIN32) +elseif (APPLE) + set( EXE_FILES MACOSX_BUNDLE) endif() set( EXE_FILES ${EXE_FILES} @@ -218,13 +260,33 @@ set( EXE_FILES ${QRC_FILES_CPP} ${WIN_RESOURCE} ${HEADER_FILES} - ${REFERENCED_CMAKE_FILES} + ${REFERENCED_CMAKE_FILES} ../ResInsightVersion.cmake ) add_executable( ResInsight ${EXE_FILES} ) +############################################################################# +# Application icon for MacOS X bundle +############################################################################# + +if (APPLE) + add_custom_command (OUTPUT Resources/ResInsight.icns + COMMAND sips -s format icns ${CMAKE_CURRENT_SOURCE_DIR}/Resources/AppLogo48x48.png --out ${CMAKE_CURRENT_BINARY_DIR}/Resources/ResInsight.icns + COMMENT Converting application icon + ) + add_custom_target (ResInsight-icns + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Resources/ResInsight.icns) + add_dependencies (ResInsight ResInsight-icns) + set_target_properties (ResInsight PROPERTIES + MACOSX_BUNDLE_ICON_FILE ${CMAKE_CURRENT_BINARY_DIR}/Resources/ResInsight.icns) +endif () + +############################################################################# +# Set up libraries and dependent projects to link with +############################################################################# + set( LINK_LIBRARIES WellPathImportSsihub @@ -233,6 +295,7 @@ set( LINK_LIBRARIES cafProjectDataModel cafViewer cafAnimControl + cafTensor CommonCode LibGuiQt LibViewing @@ -240,6 +303,9 @@ set( LINK_LIBRARIES LibGeometry LibCore + ResultStatisticsCache + RigGeoMechDataModel + ecl ert_util ert_geometry @@ -258,18 +324,49 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") ) endif() +# Add the odb reader if we are compiling with odb support +IF (${RESINSIGHT_USE_ODB_API}) + set ( LINK_LIBRARIES ${LINK_LIBRARIES} RifOdbReader) +ENDIF() + target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES}) -# Copy Dlls -if (MSVC) +############################################################################# +# Copy Dlls on MSVC +############################################################################# + +# Copy Odb Dlls + +if ((MSVC) AND (${RESINSIGHT_USE_ODB_API})) + # Find all the dlls + file (GLOB RI_ALL_ODB_DLLS ${RESINSIGHT_ODB_API_DIR}/lib/*.dll) + + # Strip off the path + foreach (aDLL ${RI_ALL_ODB_DLLS}) + get_filename_component(filenameWithExt ${aDLL} NAME) + list(APPEND RI_ODB_DLLS ${filenameWithExt} ) + endforeach(aDLL) + + # Copy to target directory + foreach (aDLL ${RI_ODB_DLLS}) + add_custom_command(TARGET ResInsight POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${RESINSIGHT_ODB_API_DIR}/lib/${aDLL}" + "${CMAKE_CURRENT_BINARY_DIR}/$") + endforeach() + +endif() # Qt DLLs + +if (MSVC) + set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd QtScript QtScriptd QtScriptTools QtScriptToolsd) foreach (qtlib ${QTLIBLIST}) add_custom_command(TARGET ResInsight POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QT_BINARY_DIR}/${qtlib}4.dll" - ${CMAKE_CURRENT_BINARY_DIR}/$) + "${CMAKE_CURRENT_BINARY_DIR}/$") endforeach( qtlib ) endif(MSVC) @@ -288,7 +385,15 @@ if (RESINSIGHT_PRIVATE_INSTALL) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") # tell binary to first attempt to load libraries from its own directory - set_target_properties (ResInsight PROPERTIES INSTALL_RPATH "\$ORIGIN") + + if (${RESINSIGHT_USE_ODB_API}) + # This is a "hack" to make ResInsight runtime find the ODB so files used when compiling. + # statoil wanted it this way, but we should probbly make a different installoptions that does things this way, + # and really do copy them when doing PRIVATE_INSTALL + set_target_properties (ResInsight PROPERTIES INSTALL_RPATH "\$ORIGIN;${RESINSIGHT_ODB_API_DIR}/lib") + else() + set_target_properties (ResInsight PROPERTIES INSTALL_RPATH "\$ORIGIN") + endif() # Find Qt libraries and sym links file (GLOB RESINSIGHT_FILES @@ -314,6 +419,11 @@ if (RESINSIGHT_PRIVATE_INSTALL) ${QT_BINARY_DIR}/QtScript4.dll ${QT_BINARY_DIR}/QtScriptTools4.dll ) + + if (${RESINSIGHT_USE_ODB_API}) + set (RESINSIGHT_FILES ${RESINSIGHT_FILES} ${RI_ALL_ODB_DLLS}) + endif() + endif() set (RESINSIGHT_FILES ${RESINSIGHT_FILES} ${RESINSIGHT_LICENSE_FILES}) diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 34a6ec93be..2e7a6a4c61 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -40,4 +40,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ) +source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt index 092d8d9098..c8fe5f4f85 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt @@ -10,7 +10,8 @@ include (${QT_USE_FILE}) include_directories( ${ResInsight_SOURCE_DIR}/ApplicationCode - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel + ${ResInsight_SOURCE_DIR}/ApplicationCode/ResultStatisticsCache + ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel ${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface ${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel ${ResInsight_SOURCE_DIR}/ThirdParty @@ -55,6 +56,7 @@ source_group( "Headers" FILES ${CODE_HEADER_FILES} ) set( UNIT_TEST_CPP_SOURCES main.cpp RifReaderEclipseOutput-Test.cpp + RifEclipseInputFileTools-Test.cpp Ert-Test.cpp ) @@ -62,6 +64,8 @@ set( LINK_LIBRARIES cafProjectDataModel CommonCode + ResultStatisticsCache + LibViewing LibRender LibGeometry @@ -75,6 +79,10 @@ set( LINK_LIBRARIES ${QT_LIBRARIES} ) +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_CXX_FLAGS "-DGTEST_USE_OWN_TR1_TUPLE=1") +endif() + add_executable( ${ProjectName} ${CODE_HEADER_FILES} diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifEclipseInputFileTools-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifEclipseInputFileTools-Test.cpp new file mode 100644 index 0000000000..7cfd2859de --- /dev/null +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifEclipseInputFileTools-Test.cpp @@ -0,0 +1,113 @@ +#include "gtest/gtest.h" + +#include "RigCaseData.h" + +#include "RifEclipseInputFileTools.h" + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifEclipseInputFileToolsTest, FaultFaces) +{ + { + QStringList faceTexts; + faceTexts << "X" << "X+" << "I" << "I+" << "x" << "x+" << "i" << "i+"; + + cvf::StructGridInterface::FaceEnum faceType; + foreach (QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::POS_I, faceType); + } + } + + { + QStringList faceTexts; + faceTexts << "X-" << "I-" << "x-" << "i-"; + + cvf::StructGridInterface::FaceEnum faceType; + foreach(QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::NEG_I, faceType); + } + } + + { + QStringList faceTexts; + faceTexts << "Y" << "Y+" << "J" << "J+" << "y" << "y+" << "j" << "j+"; + + cvf::StructGridInterface::FaceEnum faceType; + foreach(QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::POS_J, faceType); + } + } + + { + QStringList faceTexts; + faceTexts << "Y-" << "J-" << "y-" << "j-"; + + cvf::StructGridInterface::FaceEnum faceType; + foreach(QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::NEG_J, faceType); + } + } + + { + QStringList faceTexts; + faceTexts << "Z" << "Z+" << "K" << "k+" << "z" << "z+" << "k" << "k+"; + + cvf::StructGridInterface::FaceEnum faceType; + foreach(QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::POS_K, faceType); + } + } + + { + QStringList faceTexts; + faceTexts << "Z-" << "K-" << "z-" << "k-"; + + cvf::StructGridInterface::FaceEnum faceType; + foreach(QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::NEG_K, faceType); + } + } + + + // Invalid faces + { + QStringList faceTexts; + faceTexts << "Z--" << "z--" << "-k-" << " -k " << " +k- "; + + cvf::StructGridInterface::FaceEnum faceType; + foreach(QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::NO_FACE, faceType); + } + } + + // Valid cases with whitespace + { + QStringList faceTexts; + faceTexts << " X" << " X+ " << " I " << " i+ "; + + cvf::StructGridInterface::FaceEnum faceType; + foreach(QString text, faceTexts) + { + faceType = RifEclipseInputFileTools::faceEnumFromText(text); + EXPECT_EQ(cvf::StructGridInterface::POS_I, faceType); + } + } + +} diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index dff538c9d7..7746b8b15d 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -848,14 +848,20 @@ bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively(QF return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- cvf::StructGridInterface::FaceEnum RifEclipseInputFileTools::faceEnumFromText(const QString& faceString) { - if (faceString == "X" || faceString == "I" ) return cvf::StructGridInterface::POS_I; - if (faceString == "X-" || faceString == "I-") return cvf::StructGridInterface::NEG_I; - if (faceString == "Y" || faceString == "J" ) return cvf::StructGridInterface::POS_J; - if (faceString == "Y-" || faceString == "J-") return cvf::StructGridInterface::NEG_J; - if (faceString == "Z" || faceString == "K" ) return cvf::StructGridInterface::POS_K; - if (faceString == "Z-" || faceString == "K-") return cvf::StructGridInterface::NEG_K; + QString upperCaseText = faceString.toUpper().trimmed(); + + if (upperCaseText == "X" || upperCaseText == "X+" || upperCaseText == "I" || upperCaseText == "I+") return cvf::StructGridInterface::POS_I; + if (upperCaseText == "Y" || upperCaseText == "Y+" || upperCaseText == "J" || upperCaseText == "J+") return cvf::StructGridInterface::POS_J; + if (upperCaseText == "Z" || upperCaseText == "Z+" || upperCaseText == "K" || upperCaseText == "K+") return cvf::StructGridInterface::POS_K; + + if (upperCaseText == "X-" || upperCaseText == "I-") return cvf::StructGridInterface::NEG_I; + if (upperCaseText == "Y-" || upperCaseText == "J-") return cvf::StructGridInterface::NEG_J; + if (upperCaseText == "Z-" || upperCaseText == "K-") return cvf::StructGridInterface::NEG_K; return cvf::StructGridInterface::NO_FACE; } @@ -906,7 +912,7 @@ void RifEclipseInputFileTools::readFaults(QFile &data, qint64 filePos, cvf::Coll // Replace tab with space to be able to split the string using space as splitter line.replace("\t", " "); - // Replace character ' used to mark start and end of fault name + // Remove character ' used to mark start and end of fault name, possibly also around face definition; 'I+' line.remove("'"); QStringList entries = line.split(" ", QString::SkipEmptyParts); diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h index 461c5aeee9..29422773a2 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h @@ -76,6 +76,8 @@ class RifEclipseInputFileTools : public cvf::Object static bool readFaultsAndParseIncludeStatementsRecursively(QFile& file, qint64 startPos, cvf::Collection& faults, std::vector& filenamesWithFaults, bool* isEditKeywordDetected); + static cvf::StructGridInterface::FaceEnum faceEnumFromText(const QString& faceString); + private: static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector& resultData); static void findGridKeywordPositions(const std::vector< RifKeywordAndFilePos >& keywords, qint64* coordPos, qint64* zcornPos, qint64* specgridPos, qint64* actnumPos, qint64* mapaxesPos); @@ -83,6 +85,4 @@ class RifEclipseInputFileTools : public cvf::Object static size_t findFaultByName(const cvf::Collection& faults, const QString& name); static qint64 findKeyword(const QString& keyword, QFile& file, qint64 startPos); - - static cvf::StructGridInterface::FaceEnum faceEnumFromText(const QString& faceString); }; diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index 85926f9b81..500efe7c86 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -73,7 +73,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector 0) + { + ecl_nnc_type * eclNNCData= new ecl_nnc_type[numNNC]; - ecl_nnc_export( mainEclGrid , init_file , eclNNCData); + ecl_nnc_export(mainEclGrid, init_file, eclNNCData); - // Transform to our own datastructures - //cvf::Trace::show("Reading NNC. Count: " + cvf::String(numNNC)); + // Transform to our own datastructures + //cvf::Trace::show("Reading NNC. Count: " + cvf::String(numNNC)); - mainGrid->nncData()->connections().resize(numNNC); - std::vector& transmissibilityValues = mainGrid->nncData()->makeConnectionScalarResult(cvf::UNDEFINED_SIZE_T); - for (int nIdx = 0; nIdx < numNNC; ++nIdx) - { - RigGridBase* grid1 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr1); - mainGrid->nncData()->connections()[nIdx].m_c1GlobIdx = grid1->reservoirCellIndex(eclNNCData[nIdx].global_index1); - RigGridBase* grid2 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr2); - mainGrid->nncData()->connections()[nIdx].m_c2GlobIdx = grid2->reservoirCellIndex(eclNNCData[nIdx].global_index2); - transmissibilityValues[nIdx] = eclNNCData[nIdx].trans; - } + mainGrid->nncData()->connections().resize(numNNC); + std::vector& transmissibilityValues = mainGrid->nncData()->makeConnectionScalarResult(cvf::UNDEFINED_SIZE_T); + for (int nIdx = 0; nIdx < numNNC; ++nIdx) + { + RigGridBase* grid1 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr1); + mainGrid->nncData()->connections()[nIdx].m_c1GlobIdx = grid1->reservoirCellIndex(eclNNCData[nIdx].global_index1); + RigGridBase* grid2 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr2); + mainGrid->nncData()->connections()[nIdx].m_c2GlobIdx = grid2->reservoirCellIndex(eclNNCData[nIdx].global_index2); + transmissibilityValues[nIdx] = eclNNCData[nIdx].trans; + } - delete[] eclNNCData; + delete[] eclNNCData; + } } @@ -1132,19 +1135,19 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo // Production type well_type_enum ert_well_type = well_state_get_type(ert_well_state); - if (ert_well_type == PRODUCER) + if (ert_well_type == ERT_PRODUCER) { wellResFrame.m_productionType = RigWellResultFrame::PRODUCER; } - else if (ert_well_type == WATER_INJECTOR) + else if (ert_well_type == ERT_WATER_INJECTOR) { wellResFrame.m_productionType = RigWellResultFrame::WATER_INJECTOR; } - else if (ert_well_type == GAS_INJECTOR) + else if (ert_well_type == ERT_GAS_INJECTOR) { wellResFrame.m_productionType = RigWellResultFrame::GAS_INJECTOR; } - else if (ert_well_type == OIL_INJECTOR) + else if (ert_well_type == ERT_OIL_INJECTOR) { wellResFrame.m_productionType = RigWellResultFrame::OIL_INJECTOR; } diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt new file mode 100644 index 0000000000..b7fbf20e04 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required (VERSION 2.8) + +project (RigGeoMechDataModel) + +include_directories( + ${LibCore_SOURCE_DIR} + ${cafTensor_SOURCE_DIR} + ../../ResultStatisticsCache + ../OdbReader +) + + +add_library( ${PROJECT_NAME} + RigFemPart.h + RigFemPart.cpp + RigFemTypes.h + RigFemTypes.cpp + RigGeoMechCaseData.cpp + RigGeoMechCaseData.h + RigFemPartCollection.cpp + RigFemPartCollection.h + RigFemPartResults.h + RigFemPartResults.cpp + RigFemPartResultsCollection.h + RigFemPartResultsCollection.cpp + RigFemScalarResultFrames.h + RigFemScalarResultFrames.cpp + RigFemNativeStatCalc.h + RigFemNativeStatCalc.cpp + RigFemFaceComparator.h + RigFemPartGrid.h + RigFemPartGrid.cpp + RigFemResultAddress.h + RigFemResultPosEnum.h +) + +target_link_libraries( ${PROJECT_NAME} LibCore cafTensor ResultStatisticsCache) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h new file mode 100644 index 0000000000..ebcc482dde --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h @@ -0,0 +1,92 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +#include +#include + +class RigFemFaceComparator +{ +public: + void setMainFace(const int* elmNodes, const int * localFaceIndices, int faceNodeCount) + { + m_canonizedMainFaceIdxes.resize(faceNodeCount); + m_minMainFaceNodeIdx = INT_MAX; + m_faceIdxToMinMainFaceNodeIdx = 0; + + for(int fnIdx = 0; fnIdx < faceNodeCount; ++fnIdx) + { + int nodeIdx = elmNodes[localFaceIndices[fnIdx]]; + m_canonizedMainFaceIdxes[fnIdx] = nodeIdx; + if (nodeIdx < m_minMainFaceNodeIdx) + { + m_minMainFaceNodeIdx = nodeIdx; + m_faceIdxToMinMainFaceNodeIdx = fnIdx; + } + } + } + + bool isSameButOposite(const int* elmNodes, const int * localFaceIndices, int faceNodeCount) + { + if (faceNodeCount != static_cast(m_canonizedMainFaceIdxes.size())) return false; + + // Find min node index in face + int minNodeIdx = INT_MAX; + int faceIdxToMinNodeIdx = 0; + + for (int fnIdx = 0; fnIdx < faceNodeCount; ++fnIdx) + { + int nodeIdx = elmNodes[localFaceIndices[fnIdx]]; + if (nodeIdx < minNodeIdx) + { + minNodeIdx = nodeIdx; + faceIdxToMinNodeIdx = fnIdx; + } + } + + // Compare faces + { + if (minNodeIdx != m_minMainFaceNodeIdx ) return false; + + int canFaceIdx = m_faceIdxToMinMainFaceNodeIdx; + int fnIdx = faceIdxToMinNodeIdx; + int count = 0; + + for (; count < faceNodeCount; + --fnIdx, ++canFaceIdx, ++count) + { + if (fnIdx < 0) fnIdx = faceNodeCount - 1; + if (canFaceIdx == faceNodeCount) canFaceIdx = 0; + + if (elmNodes[localFaceIndices[fnIdx]] != m_canonizedMainFaceIdxes[canFaceIdx]) return false; + } + + return true; + } + } + +private: + std::vector m_canonizedMainFaceIdxes; + int m_minMainFaceNodeIdx; + int m_faceIdxToMinMainFaceNodeIdx; +}; + + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp new file mode 100644 index 0000000000..246eb857d9 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp @@ -0,0 +1,153 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemNativeStatCalc.h" +#include "RigFemScalarResultFrames.h" +#include "RigFemPartResultsCollection.h" + +#include +#include "RigStatisticsMath.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemNativeStatCalc::RigFemNativeStatCalc(RigFemPartResultsCollection* femResultCollection, const RigFemResultAddress& resVarAddr) +: m_resVarAddr(resVarAddr) +{ + m_resultsData = femResultCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) +{ + for (int pIdx = 0; pIdx < static_cast(m_resultsData->m_femPartResults.size()); ++pIdx) + { + const std::vector& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex); + + size_t i; + for (i = 0; i < values.size(); i++) + { + if (values[i] == HUGE_VAL) // TODO + { + continue; + } + + if (values[i] < min) + { + min = values[i]; + } + + if (values[i] > max) + { + max = values[i]; + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) +{ + for (int pIdx = 0; pIdx < static_cast(m_resultsData->m_femPartResults.size()); ++pIdx) + { + const std::vector& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex); + + for (size_t i = 0; i < values.size(); i++) + { + if (values[i] == HUGE_VAL) + { + continue; + } + + if (values[i] < pos && values[i] > 0) + { + pos = values[i]; + } + + if (values[i] > neg && values[i] < 0) + { + neg = values[i]; + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemNativeStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount) +{ + int timestepCount = (int)(this->timeStepCount()); + int partCount = static_cast(m_resultsData->m_femPartResults.size()); + + for (int pIdx = 0; pIdx < partCount; ++pIdx) + { + for (int tIdx = 0; tIdx < timestepCount; tIdx++) + { + const std::vector& values = m_resultsData->resultValues(m_resVarAddr, pIdx, tIdx); + size_t undefValueCount = 0; + for (size_t cIdx = 0; cIdx < values.size(); ++cIdx) + { + double value = values[cIdx]; + if (value == HUGE_VAL || value != value) + { + ++undefValueCount; + continue; + } + + valueSum += value; + } + + sampleCount += values.size(); + sampleCount -= undefValueCount; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemNativeStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator) +{ + int timestepCount = (int)(this->timeStepCount()); + int partCount = static_cast(m_resultsData->m_femPartResults.size()); + for (int pIdx = 0; pIdx < partCount; ++pIdx) + { + for (int tIdx = 0; tIdx < timestepCount; tIdx++) + { + const std::vector& values = m_resultsData->resultValues(m_resVarAddr, pIdx, tIdx); + + histogramCalculator.addData(values); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemNativeStatCalc::timeStepCount() +{ + return m_resultsData->frameCount(); +} + + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.h new file mode 100644 index 0000000000..c351594f0d --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigStatisticsCalculator.h" +#include "RigFemResultAddress.h" + + +class RigFemPartResultsCollection; + + +class RigFemNativeStatCalc : public RigStatisticsCalculator +{ +public: + RigFemNativeStatCalc(RigFemPartResultsCollection* femResultCollection, const RigFemResultAddress& resVarAddr); + + virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max); + virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg); + virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount); + + virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator); + virtual size_t timeStepCount(); + +private: + RigFemPartResultsCollection* m_resultsData; + RigFemResultAddress m_resVarAddr; +}; + + + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp new file mode 100644 index 0000000000..7fdea55199 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp @@ -0,0 +1,340 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemPart.h" + +#include "RigFemPartGrid.h" +#include "cvfBoundingBox.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPart::RigFemPart() + :m_elementPartId(-1), m_characteristicElementSize(std::numeric_limits::infinity()) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPart::~RigFemPart() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPart::preAllocateElementStorage(int elementCount) +{ + m_elementId.reserve(elementCount); + m_elementTypes.reserve(elementCount); + m_elementConnectivityStartIndices.reserve(elementCount); + + m_allAlementConnectivities.reserve(elementCount*8); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPart::appendElement(RigElementType elmType, int id, const int* connectivities) +{ + m_elementId.push_back(id); + m_elementTypes.push_back(elmType); + m_elementConnectivityStartIndices.push_back(m_allAlementConnectivities.size()); + + int nodeCount = RigFemTypes::elmentNodeCount(elmType); + for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx) + { + m_allAlementConnectivities.push_back(connectivities[lnIdx]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFemPartGrid* RigFemPart::structGrid() +{ + if (m_structGrid.isNull()) + { + m_structGrid = new RigFemPartGrid(this); + } + + return m_structGrid.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPart::assertNodeToElmIndicesIsCalculated() +{ + if (m_nodeToElmRefs.size() != nodes().nodeIds.size()) + { + this->calculateNodeToElmRefs(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPart::calculateNodeToElmRefs() +{ + m_nodeToElmRefs.resize(nodes().nodeIds.size()); + + for (int eIdx = 0; eIdx < static_cast(m_elementId.size()); ++eIdx) + { + int elmNodeCount = RigFemTypes::elmentNodeCount(elementType(eIdx)); + const int* elmNodes = connectivities(eIdx); + for (int enIdx = 0; enIdx < elmNodeCount; ++enIdx) + { + m_nodeToElmRefs[elmNodes[enIdx]].push_back(eIdx); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const int* RigFemPart::elementsUsingNode(int nodeIndex) +{ + return &(m_nodeToElmRefs[nodeIndex][0]); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPart::numElementsUsingNode(int nodeIndex) +{ + return static_cast(m_nodeToElmRefs[nodeIndex].size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPart::assertElmNeighborsIsCalculated() +{ + if (m_elmNeighbors.size() != m_elementId.size()) + { + this->calculateElmNeighbors(); + } +} + +#include "RigFemFaceComparator.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPart::calculateElmNeighbors() +{ + // Calculate elm neighbors: elmIdxs matching each face of the element + + RigFemFaceComparator fComp; // Outside loop to avoid memory alloc/dealloc. Rember to set as private in opm parallelization + std::vector candidates;// + + m_elmNeighbors.resize(this->elementCount()); + + for (int eIdx = 0; eIdx < this->elementCount(); ++eIdx) + { + RigElementType elmType = this->elementType(eIdx); + const int* elmNodes = this->connectivities(eIdx); + + int faceCount = RigFemTypes::elmentFaceCount(elmType); + int neighborCount = 0; + for (int faceIdx = 0; faceIdx < faceCount; ++faceIdx) + { + m_elmNeighbors[eIdx].indicesToNeighborElms[faceIdx] = -1; + m_elmNeighbors[eIdx].faceInNeighborElm[faceIdx] = -1; + int faceNodeCount = 0; + const int* localFaceIndices = RigFemTypes::localElmNodeIndicesForFace(elmType, faceIdx, &faceNodeCount); + + // Get neighbor candidates + candidates.clear(); + { + int firstNodeIdxOfFace = elmNodes[localFaceIndices[0]]; + int candidateCount1 = this->numElementsUsingNode(firstNodeIdxOfFace); + const int* candidates1 = this->elementsUsingNode(firstNodeIdxOfFace); + + if (candidateCount1) + { + // Get neighbor candidates from the diagonal node + + int thirdNodeIdxOfFace = elmNodes[localFaceIndices[3]]; + int candidateCount2 = this->numElementsUsingNode(thirdNodeIdxOfFace); + const int* candidates2 = this->elementsUsingNode(thirdNodeIdxOfFace); + + // The candidates are sorted from smallest to largest, so we do a linear search to find the + // (two) common cells in the two arrays, and leaving this element out, we have one candidate left + + int idx1 = 0; + int idx2 = 0; + + while (idx1 < candidateCount1 && idx2 < candidateCount2) + { + if (candidates1[idx1] < candidates2[idx2]){ ++idx1; continue; } + if (candidates1[idx1] > candidates2[idx2]){ ++idx2; continue; } + if (candidates1[idx1] == candidates2[idx2]) + { + if (candidates1[idx1] != eIdx) + { + candidates.push_back(candidates1[idx1]); + } + ++idx1; ++idx2; + } + } + } + } + + if (candidates.size()) + { + fComp.setMainFace(elmNodes, localFaceIndices, faceNodeCount); + } + + // Check if any of the neighbor candidates faces matches + for (int nbcIdx = 0; nbcIdx < static_cast(candidates.size()); ++nbcIdx) + { + int nbcElmIdx = candidates[nbcIdx]; + + RigElementType nbcElmType = this->elementType(nbcElmIdx); + const int* nbcElmNodes = this->connectivities(nbcElmIdx); + + int nbcFaceCount = RigFemTypes::elmentFaceCount(nbcElmType); + bool isNeighborFound = false; + for (int nbcFaceIdx = 0; nbcFaceIdx < nbcFaceCount; ++nbcFaceIdx) + { + int nbcFaceNodeCount = 0; + const int* nbcLocalFaceIndices = RigFemTypes::localElmNodeIndicesForFace(nbcElmType, nbcFaceIdx, &nbcFaceNodeCount); + + // Compare faces + if (fComp.isSameButOposite(nbcElmNodes, nbcLocalFaceIndices, nbcFaceNodeCount)) + { + m_elmNeighbors[eIdx].indicesToNeighborElms[faceIdx] = nbcElmIdx; + m_elmNeighbors[eIdx].faceInNeighborElm[faceIdx] = nbcFaceIdx; + isNeighborFound = true; + + break; + } + } + + if (isNeighborFound) + { + ++neighborCount; + break; + } + } + } + + if ((faceCount - neighborCount) >= 3) + { + m_possibleGridCornerElements.push_back(eIdx); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3f RigFemPart::faceNormal(int elmIdx, int faceIdx) +{ + const std::vector& nodeCoordinates = this->nodes().coordinates; + + RigElementType eType = this->elementType(elmIdx); + const int* elmNodeIndices = this->connectivities(elmIdx); + + int faceNodeCount = 0; + const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(eType, faceIdx, &faceNodeCount); + + if (faceNodeCount == 4) + { + const cvf::Vec3f* quadVxs[4]; + + quadVxs[0] = &(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]]); + quadVxs[1] = &(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]]); + quadVxs[2] = &(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]]); + quadVxs[3] = &(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]]); + + cvf::Vec3f normal = (*(quadVxs[2]) - *(quadVxs[0])) ^ (*(quadVxs[3]) - *(quadVxs[1])); + return normal; + } + else if (faceNodeCount != 4) + { + CVF_ASSERT(false); + } + + return cvf::Vec3f::ZERO; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RigFemPart::characteristicElementSize() +{ + if (m_characteristicElementSize != std::numeric_limits::infinity()) return m_characteristicElementSize; + + // take 100 elements + float elmIdxJump = elementCount() / 100.0f; + int elmIdxIncrement = elmIdxJump < 1 ? 1: (int) elmIdxJump; + int elmsToAverageCount = 0; + float sumMaxEdgeLength = 0; + for (int elmIdx = 0; elmIdx < elementCount(); elmIdx += elmIdxIncrement) + { + RigElementType eType = this->elementType(elmIdx); + + if (eType == HEX8) + { + const int* elmentConn = this->connectivities(elmIdx); + cvf::Vec3f nodePos0 = this->nodes().coordinates[elmentConn[0]]; + cvf::Vec3f nodePos1 = this->nodes().coordinates[elmentConn[1]]; + cvf::Vec3f nodePos3 = this->nodes().coordinates[elmentConn[3]]; + cvf::Vec3f nodePos4 = this->nodes().coordinates[elmentConn[4]]; + + float l1 = (nodePos1-nodePos0).length(); + float l3 = (nodePos3-nodePos0).length(); + float l4 = (nodePos4-nodePos0).length(); + + float maxLength = l1 > l3 ? l1: l3; + maxLength = maxLength > l4 ? maxLength: l4; + + sumMaxEdgeLength += maxLength; + ++elmsToAverageCount; + } + } + + CVF_ASSERT(elmsToAverageCount); + + m_characteristicElementSize = sumMaxEdgeLength/elmsToAverageCount; + + return m_characteristicElementSize; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RigFemPart::boundingBox() +{ + if (m_boundingBox.isValid()) return m_boundingBox; + + size_t nodeCount = nodes().coordinates.size(); + for (size_t nIdx = 0; nIdx < nodeCount; ++nIdx) + { + m_boundingBox.add(nodes().coordinates[nIdx]); + } + + return m_boundingBox; +} + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h new file mode 100644 index 0000000000..1e2763765f --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 + +#include "RigFemTypes.h" +#include "cvfObject.h" +#include "cvfAssert.h" +#include "cvfBoundingBox.h" +#include "cvfVector3.h" +#include + +class RigFemPartGrid; + +class RigFemPartNodes +{ +public: + std::vector nodeIds; + std::vector coordinates; + + +}; + +class RigFemPart : public cvf::Object +{ +public: + RigFemPart(); + virtual ~RigFemPart(); + + int elementPartId() const { return m_elementPartId; } + void setElementPartId(int partId) { m_elementPartId = partId; } + + void preAllocateElementStorage(int elementCount); + void appendElement(RigElementType elmType, int elementId, const int* connectivities); + + int elementCount() const { return static_cast(m_elementId.size()); } + + int elmId(size_t elementIdx) const { return m_elementId[elementIdx]; } + RigElementType elementType(size_t elementIdx) const { return m_elementTypes[elementIdx]; } + const int* connectivities(size_t elementIdx) const { return &m_allAlementConnectivities[m_elementConnectivityStartIndices[elementIdx]];} + + size_t elementNodeResultIdx(int elementIdx, int elmLocalNodeIdx) const { return m_elementConnectivityStartIndices[elementIdx] + elmLocalNodeIdx;} + int nodeIdxFromElementNodeResultIdx(size_t elmNodeResultIdx) const { return m_allAlementConnectivities[elmNodeResultIdx]; } + + RigFemPartNodes& nodes() {return m_nodes;} + const RigFemPartNodes& nodes() const {return m_nodes;} + + void assertNodeToElmIndicesIsCalculated(); + const int* elementsUsingNode(int nodeIndex); + int numElementsUsingNode(int nodeIndex); + + void assertElmNeighborsIsCalculated(); + int elementNeighbor(int elementIndex, int faceIndex) const + { return m_elmNeighbors[elementIndex].indicesToNeighborElms[faceIndex]; } + int neighborFace(int elementIndex, int faceIndex) const + { return m_elmNeighbors[elementIndex].faceInNeighborElm[faceIndex]; } + + cvf::BoundingBox boundingBox(); + float characteristicElementSize(); + const std::vector& possibleGridCornerElements() const { return m_possibleGridCornerElements; } + + cvf::Vec3f faceNormal(int elmentIndex, int faceIndex); + + const RigFemPartGrid* structGrid(); + +private: + int m_elementPartId; + + std::vector m_elementId; + std::vector m_elementTypes; + std::vector m_elementConnectivityStartIndices; + std::vector m_allAlementConnectivities; + + RigFemPartNodes m_nodes; + + cvf::ref m_structGrid; + + void calculateNodeToElmRefs(); + std::vector > m_nodeToElmRefs; // Needs a more memory friendly structure + + void calculateElmNeighbors(); + struct Neighbors { int indicesToNeighborElms[6]; char faceInNeighborElm[6];}; + std::vector< Neighbors > m_elmNeighbors; + std::vector m_possibleGridCornerElements; + + float m_characteristicElementSize; + cvf::BoundingBox m_boundingBox; + +}; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp new file mode 100644 index 0000000000..6afa7383cb --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp @@ -0,0 +1,114 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemPartCollection.h" +#include "cvfBoundingBox.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartCollection::RigFemPartCollection() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartCollection::~RigFemPartCollection() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartCollection::addFemPart(RigFemPart* part) +{ + m_femParts.push_back(part); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPart* RigFemPartCollection::part(size_t index) +{ + return m_femParts[index].p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFemPart* RigFemPartCollection::part(size_t index) const +{ + return m_femParts[index].p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPartCollection::partCount() const +{ + return static_cast(m_femParts.size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartCollection::totalElementCount() const +{ + size_t elementCount = 0; + + for (int i = 0; i < partCount(); i++) + { + elementCount += part(i)->elementCount(); + } + + return elementCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RigFemPartCollection::characteristicElementSize() +{ + if (partCount()) + { + return part(0)->characteristicElementSize(); + } + else + { + return 0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RigFemPartCollection::boundingBox() +{ + cvf::BoundingBox bBox; + for (int i = 0; i < partCount(); i++) + { + bBox.add(part(i)->boundingBox()); + } + return bBox; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h new file mode 100644 index 0000000000..99af25738c --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemPart.h" +#include "cvfCollection.h" + + +class RigFemPartCollection: public cvf::Object +{ +public: + RigFemPartCollection(); + ~RigFemPartCollection(); + + void addFemPart(RigFemPart* part); + RigFemPart* part(size_t index); + const RigFemPart* part(size_t index) const ; + + int partCount() const; + + size_t totalElementCount() const; + float characteristicElementSize(); + cvf::BoundingBox boundingBox(); + + +private: + cvf::Collection m_femParts; + +}; + + + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp new file mode 100644 index 0000000000..27eddfdb6f --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp @@ -0,0 +1,450 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemPartGrid.h" + + +#include "RigFemPart.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartGrid::RigFemPartGrid(RigFemPart* femPart) +{ + m_femPart = femPart; + generateStructGridData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartGrid::~RigFemPartGrid() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartGrid::generateStructGridData() +{ + //[X] 1. Calculate neighbors for each element + //[X] record the ones with 3 or fewer neighbors as possible grid corners + //[X] 2. Loop over the possible corner cells, + //[X] find the one that corresponds to IJK = 000 + //[X] by finding the one closest to origo // Does not work + //[X] by Determining what surfs correspond to NEG IJK surfaces in that element, + // and that none of those faces have a neighbor + //[X] 4. Assign IJK = 000 to that element + //[X] Store IJK in elm idx array + //[X] 5. Loop along POS I surfaces increment I for each element and assign IJK + //[X] when at end, go to POS J neighbor, increment J, repeat above. + //[X] etc for POS Z + //[X] Find max IJK as you go, + //[ ] also assert that there are no NEG I/NEG J/NEG Z neighbors when starting on a new row + //[ ] (Need to find min, and offset IJK values if there exists such) + //[ ] 6. If IJK to elm idx is needed, allocate "grid" with maxI,maxJ,maxZ values + //[ ] Loop over elms, assign elmIdx to IJK address in grid + + int elmIdxForIJK_000 = findElmIdxForIJK000(); + + CVF_ASSERT (elmIdxForIJK_000 != -1); // Debug. When we have run enough tests, remove + + if (elmIdxForIJK_000 == -1) return; + + // Find the IJK faces based on the corner cell + + cvf::Vec3i ijkMainFaceIndices = findMainIJKFaces(elmIdxForIJK_000); + + // assign ijk to cells + { + m_ijkPrElement.resize(m_femPart->elementCount(), cvf::Vec3i(-1,-1,-1)); + + int posIFaceIdx = ijkMainFaceIndices[0]; + int posJFaceIdx = ijkMainFaceIndices[1]; + int posKFaceIdx = ijkMainFaceIndices[2]; + + m_elmentIJKCounts = cvf::Vec3st(0, 0, 0); + + int elmIdxInK = elmIdxForIJK_000; + cvf::Vec3f posKNormal = m_femPart->faceNormal(elmIdxInK, posKFaceIdx); + int kCoord = 0; + while (true) + { + int elmIdxInJ = elmIdxInK; + cvf::Vec3f startElmInKNormalJ = m_femPart->faceNormal(elmIdxInJ, posJFaceIdx); + cvf::Vec3f startElmInKNormalI = m_femPart->faceNormal(elmIdxInJ, posIFaceIdx); + + int jCoord = 0; + while (true) + { + int elmIdxInI = elmIdxInJ; + cvf::Vec3f startElmInJNormalI = m_femPart->faceNormal(elmIdxInI, posIFaceIdx); + int iCoord = 0; + while (true) + { + // Assign ijk coordinate + m_ijkPrElement[elmIdxInI] = cvf::Vec3i(iCoord, jCoord, kCoord); + + ++iCoord; + + // Find neighbor and exit if at end + int neighborElmIdx = m_femPart->elementNeighbor(elmIdxInI, posIFaceIdx); + if (neighborElmIdx == -1) break; + + // Find the continuing face in the neighbor element (opposite of the neighbor face) + int neighborNegFaceIdx = m_femPart->neighborFace(elmIdxInI, posIFaceIdx); + + RigElementType eType = m_femPart->elementType(neighborElmIdx); + posIFaceIdx = RigFemTypes::oppositeFace(eType, neighborNegFaceIdx); + + // Step to neighbor + elmIdxInI = neighborElmIdx; + + } + + // Scoped to show that nothing bleeds further to K-loop + { + if (iCoord > static_cast(m_elmentIJKCounts[0])) m_elmentIJKCounts[0] = iCoord; + + ++jCoord; + + // Find neighbor and exit if at end + int neighborElmIdx = m_femPart->elementNeighbor(elmIdxInJ, posJFaceIdx); + if (neighborElmIdx == -1) break; + + // Find the continuing face in the neighbor element (opposite of the neighbor face) + int neighborNegFaceIdx = m_femPart->neighborFace(elmIdxInJ, posJFaceIdx); + + RigElementType eType = m_femPart->elementType(neighborElmIdx); + posJFaceIdx = RigFemTypes::oppositeFace(eType, neighborNegFaceIdx); + + // Now where is posIFace of the new J cell ? + posIFaceIdx = perpendicularFaceInDirection(startElmInJNormalI, neighborNegFaceIdx, neighborElmIdx); + + // Step to neighbor + elmIdxInJ = neighborElmIdx; + + } + } + + { + if (jCoord > static_cast(m_elmentIJKCounts[1])) m_elmentIJKCounts[1] = jCoord; + + ++kCoord; + + // Find neighbor and exit if at end + int neighborElmIdx = m_femPart->elementNeighbor(elmIdxInK, posKFaceIdx); + if (neighborElmIdx == -1) break; + + // Find the continuing face in the neighbor element (opposite of the neighbor face) + int neighborNegFaceIdx = m_femPart->neighborFace(elmIdxInK, posKFaceIdx); + + RigElementType eType = m_femPart->elementType(neighborElmIdx); + posKFaceIdx = RigFemTypes::oppositeFace(eType, neighborNegFaceIdx); + + // Now where is posJFace of the new K cell ? + posJFaceIdx = perpendicularFaceInDirection(startElmInKNormalJ, neighborNegFaceIdx, neighborElmIdx); + posIFaceIdx = perpendicularFaceInDirection(startElmInKNormalI, neighborNegFaceIdx, neighborElmIdx); + + // Step to neighbor + elmIdxInK = neighborElmIdx; + + } + } + + if (kCoord > static_cast(m_elmentIJKCounts[2])) m_elmentIJKCounts[2] = kCoord; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPartGrid::findElmIdxForIJK000() +{ + const std::vector& possibleGridCorners = m_femPart->possibleGridCornerElements(); + size_t possibleCornerCount = possibleGridCorners.size(); + + for (size_t pcIdx = 0; pcIdx < possibleCornerCount; ++pcIdx) + { + int elmIdx = possibleGridCorners[pcIdx]; + cvf::Vec3i ijkMainFaceIndices = findMainIJKFaces(elmIdx); + + if ( m_femPart->elementNeighbor(elmIdx, ijkMainFaceIndices[0]) != -1 + && m_femPart->elementNeighbor(elmIdx, ijkMainFaceIndices[0]) != -1 + && m_femPart->elementNeighbor(elmIdx, ijkMainFaceIndices[0]) != -1 ) + { + return elmIdx; + } + } + + return -1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3i RigFemPartGrid::findMainIJKFaces(int elementIndex) +{ + cvf::Vec3i ijkMainFaceIndices = cvf::Vec3i(-1, -1, -1); + + RigElementType eType = m_femPart->elementType(elementIndex); + int faceCount = RigFemTypes::elmentFaceCount(eType); + std::vector normals(faceCount); + for (int faceIdx = 0; faceIdx < faceCount; ++faceIdx) + { + normals[faceIdx] = m_femPart->faceNormal(elementIndex, faceIdx); + } + + // Record three independent main direction vectors for the element, and what face they are created from + cvf::Vec3f mainElmDirections[3]; + int mainElmDirOriginFaces[3]; + if (eType == HEX8) + { + mainElmDirections[0] = normals[0] - normals[1]; // To get a better "average" direction vector + mainElmDirections[1] = normals[2] - normals[3]; + mainElmDirections[2] = normals[4] - normals[5]; + mainElmDirOriginFaces[0] = 0; + mainElmDirOriginFaces[1] = 2; + mainElmDirOriginFaces[2] = 4; + + } + else + { + mainElmDirections[0] = cvf::Vec3f::ZERO; + mainElmDirections[1] = cvf::Vec3f::ZERO; + mainElmDirections[2] = cvf::Vec3f::ZERO; + + CVF_ASSERT(false); + } + + // Match the element main directions with best XYZ match (IJK respectively) + // Find the max component of a mainElmDirection. + // Assign the index of that mainElmDirection to the mainElmDirectionIdxForIJK at the index of the max component. + + int mainElmDirectionIdxForIJK[3] ={ -1, -1, -1 }; + for (int dIdx = 0; dIdx < 3; ++dIdx) + { + double maxAbsComp = 0; + for (int cIdx = 2; cIdx >= 0 ; --cIdx) + { + float absComp = fabs(mainElmDirections[dIdx][cIdx]); + if (absComp > maxAbsComp) + { + maxAbsComp = absComp; + mainElmDirectionIdxForIJK[cIdx] = dIdx; + } + } + } + + // make sure all the main directions are used + + bool mainDirsUsed[3] ={ false, false, false }; + mainDirsUsed[mainElmDirectionIdxForIJK[0]] = true; + mainDirsUsed[mainElmDirectionIdxForIJK[1]] = true; + mainDirsUsed[mainElmDirectionIdxForIJK[2]] = true; + + int unusedDir = -1; + if (!mainDirsUsed[0]) unusedDir = 0; + if (!mainDirsUsed[1]) unusedDir = 1; + if (!mainDirsUsed[2]) unusedDir = 2; + + if (unusedDir >= 0) + { + if (mainElmDirectionIdxForIJK[0] == mainElmDirectionIdxForIJK[1]) mainElmDirectionIdxForIJK[0] = unusedDir; + else if (mainElmDirectionIdxForIJK[1] == mainElmDirectionIdxForIJK[2]) mainElmDirectionIdxForIJK[1] = unusedDir; + else if (mainElmDirectionIdxForIJK[2] == mainElmDirectionIdxForIJK[0]) mainElmDirectionIdxForIJK[2] = unusedDir; + } + + // Assign the correct face based on the main direction + + ijkMainFaceIndices[0] = (mainElmDirections[mainElmDirectionIdxForIJK[0]] * cvf::Vec3f::X_AXIS > 0) ? mainElmDirOriginFaces[mainElmDirectionIdxForIJK[0]]: RigFemTypes::oppositeFace(eType, mainElmDirOriginFaces[mainElmDirectionIdxForIJK[0]]); + ijkMainFaceIndices[1] = (mainElmDirections[mainElmDirectionIdxForIJK[1]] * cvf::Vec3f::Y_AXIS > 0) ? mainElmDirOriginFaces[mainElmDirectionIdxForIJK[1]]: RigFemTypes::oppositeFace(eType, mainElmDirOriginFaces[mainElmDirectionIdxForIJK[1]]); + ijkMainFaceIndices[2] = (mainElmDirections[mainElmDirectionIdxForIJK[2]] * -cvf::Vec3f::Z_AXIS > 0) ? mainElmDirOriginFaces[mainElmDirectionIdxForIJK[2]]: RigFemTypes::oppositeFace(eType, mainElmDirOriginFaces[mainElmDirectionIdxForIJK[2]]); + + return ijkMainFaceIndices; +} + +//-------------------------------------------------------------------------------------------------- +/// Find the face that is not perpFaceIdx or its opposite, and has normal closest to direction +//-------------------------------------------------------------------------------------------------- + +int RigFemPartGrid::perpendicularFaceInDirection(cvf::Vec3f direction, int perpFaceIdx, int elmIdx) +{ + RigElementType eType = m_femPart->elementType(elmIdx); + int faceCount = RigFemTypes::elmentFaceCount(eType); + + int oppFace = RigFemTypes::oppositeFace(eType, perpFaceIdx); + + double minDiffSqLength = HUGE_VAL; + cvf::Vec3f faceNormal; + direction.normalize(); + int bestFace = -1; + for (int faceIdx = 0; faceIdx < faceCount; ++faceIdx) + { + if (faceIdx == perpFaceIdx || faceIdx == oppFace) continue; + + faceNormal = m_femPart->faceNormal(elmIdx, faceIdx); + faceNormal.normalize(); + float diffSqLength = (direction - faceNormal).lengthSquared(); + if (diffSqLength < minDiffSqLength) + { + bestFace = faceIdx; + minDiffSqLength = diffSqLength; + } + } + + return bestFace; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartGrid::gridPointCountI() const +{ + + return m_elmentIJKCounts[0] + 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartGrid::gridPointCountJ() const +{ + return m_elmentIJKCounts[1] + 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartGrid::gridPointCountK() const +{ + return m_elmentIJKCounts[2] + 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigFemPartGrid::isCellValid(size_t i, size_t j, size_t k) const +{ + CVF_ASSERT(false); + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RigFemPartGrid::minCoordinate() const +{ + CVF_ASSERT(false); + return cvf::Vec3d::ZERO; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RigFemPartGrid::maxCoordinate() const +{ + CVF_ASSERT(false); + return cvf::Vec3d::ZERO; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigFemPartGrid::cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex) const +{ + CVF_ASSERT(false); + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartGrid::cellIndexFromIJK(size_t i, size_t j, size_t k) const +{ + CVF_ASSERT(false); + return cvf::UNDEFINED_SIZE_T; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigFemPartGrid::ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const +{ + *i = m_ijkPrElement[cellIndex][0]; + *j = m_ijkPrElement[cellIndex][1]; + *k = m_ijkPrElement[cellIndex][2]; + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigFemPartGrid::cellIJKFromCoordinate(const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k) const +{ + CVF_ASSERT(false); + return false; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartGrid::cellCornerVertices(size_t cellIndex, cvf::Vec3d vertices[8]) const +{ + CVF_ASSERT(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RigFemPartGrid::cellCentroid(size_t cellIndex) const +{ + CVF_ASSERT(false); + return cvf::Vec3d::ZERO; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartGrid::cellMinMaxCordinates(size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate) const +{ + CVF_ASSERT(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartGrid::gridPointIndexFromIJK(size_t i, size_t j, size_t k) const +{ + CVF_ASSERT(false); + return cvf::UNDEFINED_SIZE_T; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RigFemPartGrid::gridPointCoordinate(size_t i, size_t j, size_t k) const +{ + CVF_ASSERT(false); + return cvf::Vec3d::ZERO; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h new file mode 100644 index 0000000000..c56422677b --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfStructGrid.h" + +class RigFemPart; + +class RigFemPartGrid : public cvf::StructGridInterface +{ +public: + RigFemPartGrid(RigFemPart* femPart); + virtual ~RigFemPartGrid(); + + virtual size_t gridPointCountI() const; + virtual size_t gridPointCountJ() const; + virtual size_t gridPointCountK() const; + + virtual bool isCellValid(size_t i, size_t j, size_t k) const; + virtual cvf::Vec3d minCoordinate() const; + virtual cvf::Vec3d maxCoordinate() const; + virtual bool cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex) const; + virtual size_t cellIndexFromIJK(size_t i, size_t j, size_t k) const; + virtual bool ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const; + virtual bool cellIJKFromCoordinate(const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k) const; + virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d vertices[8]) const; + virtual cvf::Vec3d cellCentroid(size_t cellIndex) const; + virtual void cellMinMaxCordinates(size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate) const; + virtual size_t gridPointIndexFromIJK(size_t i, size_t j, size_t k) const; + virtual cvf::Vec3d gridPointCoordinate(size_t i, size_t j, size_t k) const; + + + private: + void generateStructGridData(); + + cvf::Vec3i findMainIJKFaces(int elementIndex); + + int findElmIdxForIJK000(); + + int perpendicularFaceInDirection(cvf::Vec3f direction, int perpFaceIdx, int elmIdx); + RigFemPart* m_femPart; + + std::vector m_ijkPrElement; + cvf::Vec3st m_elmentIJKCounts; + +}; + + + + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp new file mode 100644 index 0000000000..3dab449ba8 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +#include "RigFemPartResults.h" +#include "RigFemResultAddress.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartResults::RigFemPartResults() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartResults::~RigFemPartResults() +{ + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResults::initResultSteps(const std::vector& stepNames) +{ + m_stepNames = stepNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResults::createScalarResult(const RigFemResultAddress& resVarAddr) +{ + CVF_ASSERT(m_stepNames.size()); + + RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(static_cast(m_stepNames.size())); + resultSets[resVarAddr] = resFrames; + return resFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResults::findScalarResult(const RigFemResultAddress& resVarAddr) +{ + return resultSets[resVarAddr].p(); +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h new file mode 100644 index 0000000000..42ff852145 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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" +#include "RigFemResultPosEnum.h" +#include +#include +#include + +#include "RigFemScalarResultFrames.h" +#include "RigFemResultAddress.h" + +//================================================================================================== +/// +//================================================================================================== + +class RigFemPartResults : public cvf::Object +{ +public: + RigFemPartResults(); + ~RigFemPartResults(); + + void initResultSteps(const std::vector& stepNames); + + RigFemScalarResultFrames* createScalarResult(const RigFemResultAddress& resVarAddr); + RigFemScalarResultFrames* findScalarResult(const RigFemResultAddress& resVarAddr); + +private: + + std::vector m_stepNames; + std::map > resultSets; +}; + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp new file mode 100644 index 0000000000..b56f1793a0 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -0,0 +1,656 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemPartResultsCollection.h" + +#include "RifGeoMechReaderInterface.h" + +#ifdef USE_ODB_API +#include "RifOdbReader.h" +#endif +#include "RigFemScalarResultFrames.h" +#include "RigStatisticsDataCache.h" +#include "RigFemPartResults.h" +#include "RigFemPartCollection.h" + +#include "cafProgressInfo.h" +#include "cvfBoundingBox.h" +#include + +#include +#include +#include "RigFemNativeStatCalc.h" +#include "cafTensor3.h" +#include "cafProgressInfo.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection) +{ + CVF_ASSERT(readerInterface); + m_readerInterface = readerInterface; + m_femParts = femPartCollection; + + m_femPartResults.resize(m_femParts->partCount()); + std::vector stepNames = m_readerInterface->stepNames(); + for (int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx) + { + m_femPartResults[pIdx] = new RigFemPartResults; + m_femPartResults[pIdx]->initResultSteps(stepNames); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartResultsCollection::~RigFemPartResultsCollection() +{ + +} + + +//-------------------------------------------------------------------------------------------------- +/// Will always return a valid object, but it can be empty +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(int partIndex, + const RigFemResultAddress& resVarAddr) +{ + CVF_ASSERT(partIndex < (int)(m_femPartResults.size())); + CVF_ASSERT(m_readerInterface.notNull()); + CVF_ASSERT(resVarAddr.isValid()); + + // If we have it in the cache, return it + RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr); + if (frames) return frames; + + // Check whether a derived result is requested + + frames = calculateDerivedResult(partIndex, resVarAddr); + if (frames) return frames; + + // We need to read the data as bulk fields, and populate the correct scalar caches + + std::vector< RigFemResultAddress> resultAddressOfComponents = this->getResAddrToComponentsToRead(resVarAddr); + + if (resultAddressOfComponents.size()) + { + std::vector resultsForEachComponent; + for (size_t cIdx = 0; cIdx < resultAddressOfComponents.size(); ++cIdx) + { + resultsForEachComponent.push_back(m_femPartResults[partIndex]->createScalarResult(resultAddressOfComponents[cIdx])); + } + + int frameCount = this->frameCount(); + caf::ProgressInfo progress(frameCount, ""); + progress.setProgressDescription(QString("Loading %1 %2").arg(resVarAddr.fieldName.c_str(), resVarAddr.componentName.c_str())); + + for (int stepIndex = 0; stepIndex < frameCount; ++stepIndex) + { + std::vector frameTimes = m_readerInterface->frameTimes(stepIndex); + + for (int fIdx = 1; (size_t)fIdx < frameTimes.size() && fIdx < 2 ; ++fIdx) // Read only the second frame + { + std::vector*> componentDataVectors; + for (size_t cIdx = 0; cIdx < resultsForEachComponent.size(); ++cIdx) + { + componentDataVectors.push_back(&(resultsForEachComponent[cIdx]->frameData(stepIndex))); + } + + switch (resVarAddr.resultPosType) + { + case RIG_NODAL: + m_readerInterface->readNodeField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors); + break; + case RIG_ELEMENT_NODAL: + m_readerInterface->readElementNodeField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors); + break; + case RIG_INTEGRATION_POINT: + m_readerInterface->readIntegrationPointField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors); + break; + } + } + + progress.incrementProgress(); + } + + // Now fetch the particular component requested, which should now exist and be read. + frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr); + } + + if (!frames) + { + frames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); // Create a dummy empty result, if the request did not specify the component. + } + + return frames; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RigFemPartResultsCollection::scalarFieldAndComponentNames(RigFemResultPosEnum resPos) +{ + std::map > fieldCompNames; + + if (m_readerInterface.notNull()) + { + if (resPos == RIG_NODAL) + { + fieldCompNames = m_readerInterface->scalarNodeFieldAndComponentNames(); + } + else if (resPos == RIG_ELEMENT_NODAL) + { + fieldCompNames = m_readerInterface->scalarElementNodeFieldAndComponentNames(); + fieldCompNames["SE"].push_back("S11"); + fieldCompNames["SE"].push_back("S22"); + fieldCompNames["SE"].push_back("S33"); + fieldCompNames["SE"].push_back("S12"); + fieldCompNames["SE"].push_back("S13"); + fieldCompNames["SE"].push_back("S23"); + fieldCompNames["SE"].push_back("S1"); + fieldCompNames["SE"].push_back("S2"); + fieldCompNames["SE"].push_back("S3"); + + fieldCompNames["ST"].push_back("S11"); + fieldCompNames["ST"].push_back("S22"); + fieldCompNames["ST"].push_back("S33"); + fieldCompNames["ST"].push_back("S12"); + fieldCompNames["ST"].push_back("S13"); + fieldCompNames["ST"].push_back("S23"); + fieldCompNames["ST"].push_back("S1"); + fieldCompNames["ST"].push_back("S2"); + fieldCompNames["ST"].push_back("S3"); + + fieldCompNames["Gamma"].push_back("Gamma1"); + fieldCompNames["Gamma"].push_back("Gamma2"); + fieldCompNames["Gamma"].push_back("Gamma3"); + fieldCompNames["Gamma"].push_back("Gamma11"); + fieldCompNames["Gamma"].push_back("Gamma22"); + fieldCompNames["Gamma"].push_back("Gamma33"); + + fieldCompNames["NE"].push_back("E11"); + fieldCompNames["NE"].push_back("E22"); + fieldCompNames["NE"].push_back("E33"); + fieldCompNames["NE"].push_back("E12"); + fieldCompNames["NE"].push_back("E13"); + fieldCompNames["NE"].push_back("E23"); + } + else if (resPos == RIG_INTEGRATION_POINT) + { + fieldCompNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); + fieldCompNames["SE"].push_back("S11"); + fieldCompNames["SE"].push_back("S22"); + fieldCompNames["SE"].push_back("S33"); + fieldCompNames["SE"].push_back("S12"); + fieldCompNames["SE"].push_back("S13"); + fieldCompNames["SE"].push_back("S23"); + fieldCompNames["SE"].push_back("S1"); + fieldCompNames["SE"].push_back("S2"); + fieldCompNames["SE"].push_back("S3"); + + fieldCompNames["ST"].push_back("S11"); + fieldCompNames["ST"].push_back("S22"); + fieldCompNames["ST"].push_back("S33"); + fieldCompNames["ST"].push_back("S12"); + fieldCompNames["ST"].push_back("S13"); + fieldCompNames["ST"].push_back("S23"); + fieldCompNames["ST"].push_back("S1"); + fieldCompNames["ST"].push_back("S2"); + fieldCompNames["ST"].push_back("S3"); + + fieldCompNames["Gamma"].push_back("Gamma1"); + fieldCompNames["Gamma"].push_back("Gamma2"); + fieldCompNames["Gamma"].push_back("Gamma3"); + fieldCompNames["Gamma"].push_back("Gamma11"); + fieldCompNames["Gamma"].push_back("Gamma22"); + fieldCompNames["Gamma"].push_back("Gamma33"); + + fieldCompNames["NE"].push_back("E11"); + fieldCompNames["NE"].push_back("E22"); + fieldCompNames["NE"].push_back("E33"); + fieldCompNames["NE"].push_back("E12"); + fieldCompNames["NE"].push_back("E13"); + fieldCompNames["NE"].push_back("E23"); + } + } + + return fieldCompNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr) +{ + if (resVarAddr.fieldName == "NE") + { + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "E", resVarAddr.componentName)); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + int frameCount = srcDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + size_t valCount = srcFrameData.size(); + dstFrameData.resize(valCount); + + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + dstFrameData[vIdx] = -srcFrameData[vIdx]; + } + } + + return dstDataFrames; + } + + if ((resVarAddr.fieldName == "SE") + && !(resVarAddr.componentName == "S1" || resVarAddr.componentName == "S2" || resVarAddr.componentName == "S3" )) + { + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S", resVarAddr.componentName)); + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR", "")); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + const RigFemPart * femPart = m_femParts->part(partIndex); + float inf = std::numeric_limits::infinity(); + + int frameCount = srcDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + size_t valCount = srcFrameData.size(); + dstFrameData.resize(valCount); + + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); + + int nodeIdx = 0; + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(vIdx); + float por = srcPORFrameData[nodeIdx]; + + if (por == inf) + dstFrameData[vIdx] = inf; + else + dstFrameData[vIdx] = -srcFrameData[vIdx]; + } + } + + return dstDataFrames; + } + + if ( (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST" ) + && (resVarAddr.componentName == "S1" || resVarAddr.componentName == "S2" || resVarAddr.componentName == "S3" )) + { + RigFemScalarResultFrames * s11Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S11")); + RigFemScalarResultFrames * s22Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S22")); + RigFemScalarResultFrames * s33Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S33")); + RigFemScalarResultFrames * s12Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S12")); + RigFemScalarResultFrames * s13Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S13")); + RigFemScalarResultFrames * s23Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S23")); + + RigFemScalarResultFrames * s1Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1")); + RigFemScalarResultFrames * s2Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2")); + RigFemScalarResultFrames * s3Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3")); + + int frameCount = s11Frames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& s11 = s11Frames->frameData(fIdx); + const std::vector& s22 = s22Frames->frameData(fIdx); + const std::vector& s33 = s33Frames->frameData(fIdx); + const std::vector& s12 = s12Frames->frameData(fIdx); + const std::vector& s13 = s13Frames->frameData(fIdx); + const std::vector& s23 = s23Frames->frameData(fIdx); + + std::vector& s1 = s1Frames->frameData(fIdx); + std::vector& s2 = s2Frames->frameData(fIdx); + std::vector& s3 = s3Frames->frameData(fIdx); + + size_t valCount = s11.size(); + + s1.resize(valCount); + s2.resize(valCount); + s3.resize(valCount); + + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx] ); + + cvf::Vec3f principals = T.calculatePrincipals(NULL); + s1[vIdx] = principals[0]; + s2[vIdx] = principals[1]; + s3[vIdx] = principals[2]; + } + } + + RigFemScalarResultFrames* requestedPrincipal = this->findOrLoadScalarResult(partIndex,resVarAddr); + + return requestedPrincipal; + } + + if ( resVarAddr.fieldName == "ST" + && ( resVarAddr.componentName == "S11" + || resVarAddr.componentName == "S22" + || resVarAddr.componentName == "S33" )) + { + RigFemScalarResultFrames * srcNSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S", resVarAddr.componentName)); + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR", "")); + + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + const RigFemPart * femPart = m_femParts->part(partIndex); + int frameCount = srcNSDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcNSFrameData = srcNSDataFrames->frameData(fIdx); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); + + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + + size_t valCount = srcNSFrameData.size(); + dstFrameData.resize(valCount); + int nodeIdx = 0; + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(vIdx); + float por = srcPORFrameData[nodeIdx]; + if (por == std::numeric_limits::infinity()) por = 0.0f; + dstFrameData[vIdx] = -srcNSFrameData[vIdx] + por; + } + } + return dstDataFrames; + } + + if ( resVarAddr.fieldName == "ST" + && ( resVarAddr.componentName == "S12" + || resVarAddr.componentName == "S13" + || resVarAddr.componentName == "S23" )) + { + RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S", resVarAddr.componentName)); + + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + const RigFemPart * femPart = m_femParts->part(partIndex); + int frameCount = srcSDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcNSFrameData = srcSDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + + size_t valCount = srcNSFrameData.size(); + dstFrameData.resize(valCount); + int nodeIdx = 0; + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + dstFrameData[vIdx] = -srcNSFrameData[vIdx]; + } + } + return dstDataFrames; + } + + if (resVarAddr.fieldName == "ST" && resVarAddr.componentName == "") + { + // Create and return an empty result + return m_femPartResults[partIndex]->createScalarResult(resVarAddr); + } + + + if (resVarAddr.fieldName == "Gamma" + && ( resVarAddr.componentName == "Gamma1" + || resVarAddr.componentName == "Gamma2" + || resVarAddr.componentName == "Gamma3" + || resVarAddr.componentName == "Gamma11" + || resVarAddr.componentName == "Gamma22" + || resVarAddr.componentName == "Gamma33" + )) + { + RigFemScalarResultFrames * srcDataFrames = NULL; + if (resVarAddr.componentName == "Gamma1"){ + srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S1")); + }else if (resVarAddr.componentName == "Gamma2"){ + srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S2")); + }else if (resVarAddr.componentName == "Gamma3"){ + srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S3")); + }else if (resVarAddr.componentName == "Gamma11"){ + srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S11")); + }else if (resVarAddr.componentName == "Gamma22"){ + srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S22")); + }else if (resVarAddr.componentName == "Gamma33"){ + srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S33")); + } + + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR", "")); + + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + const RigFemPart * femPart = m_femParts->part(partIndex); + int frameCount = srcDataFrames->frameCount(); + float inf = std::numeric_limits::infinity(); + + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcSTFrameData = srcDataFrames->frameData(fIdx); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); + + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + + size_t valCount = srcSTFrameData.size(); + dstFrameData.resize(valCount); + int nodeIdx = 0; + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(vIdx); + float por = srcPORFrameData[nodeIdx]; + + if (por == inf || abs(por) < 0.01e6) + dstFrameData[vIdx] = inf; + else + dstFrameData[vIdx] = srcSTFrameData[vIdx]/por; + } + } + return dstDataFrames; + } + + if (resVarAddr.fieldName == "Gamma" && resVarAddr.componentName == "") + { + // Create and return an empty result + return m_femPartResults[partIndex]->createScalarResult(resVarAddr); + } + + return NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector< RigFemResultAddress> RigFemPartResultsCollection::getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr) +{ + std::map > fieldAndComponentNames; + switch (resVarAddr.resultPosType) + { + case RIG_NODAL: + fieldAndComponentNames = m_readerInterface->scalarNodeFieldAndComponentNames(); + break; + case RIG_ELEMENT_NODAL: + fieldAndComponentNames = m_readerInterface->scalarElementNodeFieldAndComponentNames(); + break; + case RIG_INTEGRATION_POINT: + fieldAndComponentNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); + break; + } + + std::vector< RigFemResultAddress> resAddressToComponents; + + std::map >::iterator fcIt = fieldAndComponentNames.find(resVarAddr.fieldName); + + if (fcIt != fieldAndComponentNames.end()) + { + std::vector compNames = fcIt->second; + if (resVarAddr.componentName != "") // If we did not request a particular component, do not add the components + { + for (size_t cIdx = 0; cIdx < compNames.size(); ++cIdx) + { + resAddressToComponents.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, compNames[cIdx])); + } + } + + if (compNames.size() == 0) // This is a scalar field. Add one component named "" + { + CVF_ASSERT(resVarAddr.componentName == ""); + resAddressToComponents.push_back(resVarAddr); + } + } + + return resAddressToComponents; +} + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigFemPartResultsCollection::stepNames() +{ + CVF_ASSERT(m_readerInterface.notNull()); + return m_readerInterface->stepNames(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPartResultsCollection::frameCount() +{ + return static_cast(stepNames().size()); +} + +//-------------------------------------------------------------------------------------------------- +/// Returns whether any of the parts actually had any of the requested results +//-------------------------------------------------------------------------------------------------- +bool RigFemPartResultsCollection::assertResultsLoaded(const RigFemResultAddress& resVarAddr) +{ + if (!resVarAddr.isValid()) return false; + + bool foundResults = false; + + for (int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx) + { + if (m_femPartResults[pIdx].notNull()) + { + RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult(pIdx, resVarAddr); + for (int fIdx = 0; fIdx < scalarResults->frameCount(); ++fIdx) + { + foundResults = foundResults || scalarResults->frameData(fIdx).size(); + } + } + } + + return foundResults; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFemPartResultsCollection::resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex) +{ + CVF_ASSERT(resVarAddr.isValid()); + + RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult(partIndex, resVarAddr); + return scalarResults->frameData(frameIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigStatisticsDataCache* RigFemPartResultsCollection::statistics(const RigFemResultAddress& resVarAddr) +{ + RigStatisticsDataCache* statCache = m_resultStatistics[resVarAddr].p(); + if (!statCache) + { + RigFemNativeStatCalc* calculator = new RigFemNativeStatCalc(this, resVarAddr); + statCache = new RigStatisticsDataCache(calculator); + m_resultStatistics[resVarAddr] = statCache; + } + + return statCache; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex, + double* localMin, double* localMax) +{ + this->statistics(resVarAddr)->minMaxCellScalarValues(frameIndex, *localMin, *localMax); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::minMaxScalarValues(const RigFemResultAddress& resVarAddr, + double* globalMin, double* globalMax) +{ + this->statistics(resVarAddr)->minMaxCellScalarValues(*globalMin, *globalMax); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero) +{ + this->statistics(resVarAddr)->posNegClosestToZero(frameIndex, *localPosClosestToZero, *localNegClosestToZero); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero) +{ + this->statistics(resVarAddr)->posNegClosestToZero(*globalPosClosestToZero, *globalNegClosestToZero); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::meanScalarValue(const RigFemResultAddress& resVarAddr, double* meanValue) +{ + CVF_ASSERT(meanValue); + + this->statistics(resVarAddr)->meanCellScalarValues(*meanValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::p10p90ScalarValues(const RigFemResultAddress& resVarAddr, double* p10, double* p90) +{ + this->statistics(resVarAddr)->p10p90CellScalarValues(*p10, *p90); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFemPartResultsCollection::scalarValuesHistogram(const RigFemResultAddress& resVarAddr) +{ + return this->statistics(resVarAddr)->cellScalarValuesHistogram(); +} + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h new file mode 100644 index 0000000000..a3daf3db0e --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemResultAddress.h" + +#include "cvfCollection.h" +#include "cvfObject.h" +#include +#include + +class RifGeoMechReaderInterface; +class RigFemScalarResultFrames; +class RigFemPartResultsCollection; +class RigFemPartResults; +class RigStatisticsDataCache; +class RigFemPartCollection; + +class RigFemPartResultsCollection: public cvf::Object +{ +public: + RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection); + ~RigFemPartResultsCollection(); + + std::map > scalarFieldAndComponentNames(RigFemResultPosEnum resPos); + std::vector stepNames(); + bool assertResultsLoaded(const RigFemResultAddress& resVarAddr); + const std::vector& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); + + int frameCount(); + + + void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax); + void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero); + void minMaxScalarValues (const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax); + void posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero); + void meanScalarValue(const RigFemResultAddress& resVarAddr, double* meanValue); + void p10p90ScalarValues(const RigFemResultAddress& resVarAddr, double* p10, double* p90); + const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr); + +private: + RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex, + const RigFemResultAddress& resVarAddr); + + RigFemScalarResultFrames* calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr); + + friend class RigFemNativeStatCalc; + cvf::Collection m_femPartResults; + cvf::ref m_readerInterface; + cvf::cref m_femParts; + + RigStatisticsDataCache* statistics(const RigFemResultAddress& resVarAddr); + std::vector< RigFemResultAddress> getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr); + std::map > m_resultStatistics; +}; + + + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h new file mode 100644 index 0000000000..c1533ff9fc --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemResultPosEnum.h" +#include + +//================================================================================================== +/// +//================================================================================================== + +class RigFemResultAddress +{ +public: +RigFemResultAddress(RigFemResultPosEnum resPosType, + const std::string& aFieldName, + const std::string& aComponentName) + : resultPosType(resPosType), fieldName(aFieldName), componentName(aComponentName) + {} + + RigFemResultPosEnum resultPosType; + std::string fieldName; + std::string componentName; + + bool isValid() const + { + bool isTypeValid = resultPosType == RIG_NODAL + || resultPosType == RIG_ELEMENT_NODAL + || resultPosType == RIG_INTEGRATION_POINT; + bool isFieldValid = fieldName != ""; + return isTypeValid && isFieldValid; + } + + bool operator< (const RigFemResultAddress& other ) const + { + if (resultPosType != other.resultPosType) + { + return (resultPosType < other.resultPosType); + } + + if (fieldName != other.fieldName) + { + return (fieldName < other.fieldName); + } + + return (componentName < other.componentName); + } +}; + + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h new file mode 100644 index 0000000000..add7f3eed3 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h @@ -0,0 +1,7 @@ +#pragma once + +enum RigFemResultPosEnum { + RIG_NODAL, + RIG_ELEMENT_NODAL, + RIG_INTEGRATION_POINT +}; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp new file mode 100644 index 0000000000..f32a35549d --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +#include "RigFemScalarResultFrames.h" +#include "RigStatisticsDataCache.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames::RigFemScalarResultFrames(int frameCount) +{ + m_dataForEachFrame.resize(frameCount); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames::~RigFemScalarResultFrames() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemScalarResultFrames::frameCount() +{ + return static_cast(m_dataForEachFrame.size()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector& RigFemScalarResultFrames::frameData(size_t frameIndex) +{ + return m_dataForEachFrame[frameIndex]; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.h new file mode 100644 index 0000000000..7489286caf --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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" +#include +#include + +//================================================================================================== +/// +//================================================================================================== +class RigStatisticsDataCache; + +class RigFemScalarResultFrames: public cvf::Object +{ +public: + RigFemScalarResultFrames(int frameCount); + virtual ~RigFemScalarResultFrames(); + + std::vector& frameData(size_t frameIndex); + int frameCount(); + +private: + std::vector< std::vector > m_dataForEachFrame; +}; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp new file mode 100644 index 0000000000..a25f66ab9f --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp @@ -0,0 +1,99 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RigFemTypes.h" + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemTypes::elmentNodeCount(RigElementType elmType) +{ + static int elementTypeCounts[2] ={ 8, 4 }; + + return elementTypeCounts[elmType]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemTypes::elmentFaceCount(RigElementType elmType) +{ + const static int elementFaceCounts[2] ={ 6, 1 }; + + return elementFaceCounts[elmType]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +// HEX8 +// 7---------6 +// /| /| |k +// / | / | | /j +// 4---------5 | |/ +// | 3------|--2 *---i +// | / | / +// |/ |/ +// 0---------1 + +const int* RigFemTypes::localElmNodeIndicesForFace(RigElementType elmType, int faceIdx, int* faceNodeCount) +{ + static const int HEX8_Faces[6][4] ={ { 1, 2, 6, 5 }, { 0, 4, 7, 3 }, { 3, 7, 6, 2 }, { 0, 1, 5, 4 }, { 4, 5, 6, 7 }, { 0, 3, 2, 1 } }; + static const int CAX4_Faces[4] ={ 0, 1, 2, 3 }; + + switch (elmType) + { + case HEX8: + (*faceNodeCount) = 4; + return HEX8_Faces[faceIdx]; + break; + case CAX4: + (*faceNodeCount) = 4; + return CAX4_Faces; + break; + default: + assert(false); // Element type not supported + break; + } + + return CAX4_Faces; +} + +int RigFemTypes::oppositeFace(RigElementType elmType, int faceIdx) +{ + static const int HEX8_OppositeFaces[6]={ 1, 0, 3, 2, 5, 4}; + + switch (elmType) + { + case HEX8: + return HEX8_OppositeFaces[faceIdx]; + break; + case CAX4: + return faceIdx; + break; + default: + assert(false); // Element type not supported + break; + } + + return faceIdx; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h new file mode 100644 index 0000000000..926af7981f --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 + +enum RigElementType +{ + HEX8, + CAX4, + UNKNOWN_ELM_TYPE +}; + +class RigFemTypes +{ +public: + static int elmentNodeCount(RigElementType elmType); + static int elmentFaceCount(RigElementType elmType); + static const int* localElmNodeIndicesForFace(RigElementType elmType, int faceIdx, int* faceNodeCount); + static int oppositeFace(RigElementType elmType, int faceIdx); +}; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp new file mode 100644 index 0000000000..67e2f1d59c --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -0,0 +1,119 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 + +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" +#include "RigFemPartCollection.h" +#include "RifGeoMechReaderInterface.h" + +#ifdef USE_ODB_API +#include "RifOdbReader.h" +#endif +#include "RigFemScalarResultFrames.h" +#include "RigStatisticsDataCache.h" +#include +#include "cvfBoundingBox.h" +#include "cafProgressInfo.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGeoMechCaseData::RigGeoMechCaseData(const std::string& fileName) +{ + m_geoMechCaseFileName = fileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGeoMechCaseData::~RigGeoMechCaseData() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartCollection* RigGeoMechCaseData::femParts() +{ + return m_femParts.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFemPartCollection* RigGeoMechCaseData::femParts() const +{ + return m_femParts.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFemPartResultsCollection* RigGeoMechCaseData::femPartResults() const +{ + return m_femPartResultsColl.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartResultsCollection* RigGeoMechCaseData::femPartResults() +{ + return m_femPartResultsColl.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) +{ + +#ifdef USE_ODB_API + m_readerInterface = new RifOdbReader; +#endif + + if (m_readerInterface.notNull() && m_readerInterface->openFile(m_geoMechCaseFileName, errorMessage)) + { + m_femParts = new RigFemPartCollection(); + + caf::ProgressInfo progress(10, ""); // Here because the next call uses progress + progress.setNextProgressIncrement(9); + if (m_readerInterface->readFemParts(m_femParts.p())) + { + progress.incrementProgress(); + progress.setProgressDescription("Calculating element neighbors"); + + // Initialize results containers + m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_femParts.p()); + + // Calculate derived Fem data + for (int pIdx = 0; pIdx < m_femParts->partCount(); ++pIdx) + { + m_femParts->part(pIdx)->assertNodeToElmIndicesIsCalculated(); + m_femParts->part(pIdx)->assertElmNeighborsIsCalculated(); + } + return true; + } + } + return false; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h new file mode 100644 index 0000000000..dec8eaf7ac --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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" +#include +#include +#include +#include "RigFemResultPosEnum.h" +#include "cvfCollection.h" +#include "RigFemPartResults.h" +#include "RigFemResultAddress.h" + +class RifGeoMechReaderInterface; +class RigFemPartCollection; +class RigFemScalarResultFrames; +class RigFemPartResultsCollection; + +class RigGeoMechCaseData: public cvf::Object +{ +public: + RigGeoMechCaseData(const std::string& fileName); + ~RigGeoMechCaseData(); + + bool openAndReadFemParts(std::string* errorMessage); + + RigFemPartCollection* femParts(); + const RigFemPartCollection* femParts() const; + + RigFemPartResultsCollection* femPartResults(); + const RigFemPartResultsCollection* femPartResults() const; + +private: + std::string m_geoMechCaseFileName; + cvf::ref m_femParts; + cvf::ref m_femPartResultsColl; + cvf::ref m_readerInterface; +}; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake b/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake new file mode 100644 index 0000000000..adb8e6856c --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake @@ -0,0 +1,37 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + +set (SOURCE_GROUP_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.h +${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.h +${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.h +${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgrCache.h +${CEE_CURRENT_LIST_DIR}RivGeoMechVizLogic.h +${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.h +${CEE_CURRENT_LIST_DIR}RivFemElmVisibilityCalculator.h + +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp +${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.cpp +${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp +${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgrCache.cpp +${CEE_CURRENT_LIST_DIR}RivGeoMechVizLogic.cpp +${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.cpp +${CEE_CURRENT_LIST_DIR}RivFemElmVisibilityCalculator.cpp + +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "GeoMechViz" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp new file mode 100644 index 0000000000..00694111b3 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -0,0 +1,168 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RivFemElmVisibilityCalculator.h" +#include "cvfBase.h" +#include "RigFemPart.h" +#include "RigFemPartGrid.h" +#include "cvfStructGrid.h" +#include "cvfStructGridGeometryGenerator.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimEclipsePropertyFilter.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCase.h" + +#include "RigGeoMechCaseData.h" +#include "RigFemPartResultsCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemElmVisibilityCalculator::computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart) +{ + elmVisibilities->resize(femPart->elementCount()); + elmVisibilities->setAll(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemElmVisibilityCalculator::computeRangeVisibility(cvf::UByteArray* elmVisibilities, RigFemPart* femPart, + const cvf::CellRangeFilter& rangeFilter) +{ + elmVisibilities->resize(femPart->elementCount()); + + const RigFemPartGrid* grid = femPart->structGrid(); + + if (rangeFilter.hasIncludeRanges()) + { + for (int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx) + { + size_t mainGridI; + size_t mainGridJ; + size_t mainGridK; + + grid->ijkFromCellIndex(elmIdx, &mainGridI, &mainGridJ, &mainGridK); + (*elmVisibilities)[elmIdx] = rangeFilter.isCellVisible(mainGridI, mainGridJ, mainGridK, false); + } + } + else + { + for (int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx) + { + size_t mainGridI; + size_t mainGridJ; + size_t mainGridK; + + grid->ijkFromCellIndex(elmIdx, &mainGridI, &mainGridJ, &mainGridK); + (*elmVisibilities)[elmIdx] = !rangeFilter.isCellExcluded(mainGridI, mainGridJ, mainGridK, false); + } + } +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* cellVisibility, + const RigFemPart* grid, + int timeStepIndex, + const cvf::UByteArray* rangeFilterVisibility, + RimGeoMechPropertyFilterCollection* propFilterColl) +{ + CVF_ASSERT(cellVisibility != NULL); + CVF_ASSERT(rangeFilterVisibility != NULL); + CVF_ASSERT(propFilterColl != NULL); + + CVF_ASSERT(grid->elementCount() > 0); + CVF_ASSERT(rangeFilterVisibility->size() == static_cast(grid->elementCount())); + + // Copy if not equal + if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility; + const int elementCount = grid->elementCount(); + + if (propFilterColl->hasActiveFilters()) + { + for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; + + if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) + { + const double lowerBound = propertyFilter->lowerBound(); + const double upperBound = propertyFilter->upperBound(); + + RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress(); + + size_t adjustedTimeStepIndex = timeStepIndex; + + const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); + + RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData(); + + const std::vector& resVals = caseData->femPartResults()->resultValues(resVarAddress, + grid->elementPartId(), + timeStepIndex); + #pragma omp parallel for schedule(dynamic) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + { + if ( (*cellVisibility)[cellIndex] ) + { + RigElementType eType = grid->elementType(cellIndex); + int elmNodeCount = RigFemTypes::elmentNodeCount(eType); + + const int* elmNodeIndices = grid->connectivities(cellIndex); + for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx) + { + size_t resultValueIndex = cvf::UNDEFINED_SIZE_T; + if (resVarAddress.resultPosType == RIG_NODAL) + { + resultValueIndex = elmNodeIndices[enIdx]; + } + else + { + resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx); + } + + double scalarValue = resVals[resultValueIndex]; + if (lowerBound <= scalarValue && scalarValue <= upperBound) + { + if (filterType == RimCellFilter::EXCLUDE) + { + (*cellVisibility)[cellIndex] = false; + } + } + else + { + if (filterType == RimCellFilter::INCLUDE) + { + (*cellVisibility)[cellIndex] = false; + } + } + } + } + } + } + } + } +} + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h new file mode 100644 index 0000000000..defd9f4f4f --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cvfArray.h" + +namespace cvf +{ + class CellRangeFilter; +} + +class RigFemPart; +class RimGeoMechPropertyFilterCollection; + +class RivFemElmVisibilityCalculator +{ +public: + static void computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart ); + static void computeRangeVisibility(cvf::UByteArray* elmVisibilities, RigFemPart* femPart, + const cvf::CellRangeFilter& rangeFilter); + + static void computePropertyVisibility(cvf::UByteArray* cellVisibility, + const RigFemPart* grid, + int timeStepIndex, + const cvf::UByteArray* rangeFilterVisibility, + RimGeoMechPropertyFilterCollection* propFilterColl); +}; + + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp new file mode 100644 index 0000000000..1e18c0a359 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp @@ -0,0 +1,267 @@ +#include +#include "RivFemPartGeometryGenerator.h" + +#include "cvfBase.h" + +#include "RigFemPart.h" +//#include "RigFemPartScalarDataAccess.h" + +#include "cvfDebugTimer.h" +#include "cvfGeometryBuilderDrawableGeo.h" +#include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfScalarMapper.h" + +#include "cvfArray.h" +#include "cvfOutlineEdgeExtractor.h" +#include + + +using namespace cvf; + +//================================================================================================== +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivFemPartGeometryGenerator::RivFemPartGeometryGenerator(const RigFemPart* part) +: m_part(part) +{ + CVF_ASSERT(part); + m_triangleMapper = new RivFemPartTriangleToElmMapper; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivFemPartGeometryGenerator::~RivFemPartGeometryGenerator() +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// Generate surface drawable geo from the specified region +/// +//-------------------------------------------------------------------------------------------------- +ref RivFemPartGeometryGenerator::generateSurface() +{ + computeArrays(); + + CVF_ASSERT(m_quadVertices.notNull()); + + if (m_quadVertices->size() == 0) return NULL; + + ref geo = new DrawableGeo; + geo->setFromQuadVertexArray(m_quadVertices.p()); + + return geo; +} + + + +//-------------------------------------------------------------------------------------------------- +/// Generates simplified mesh as line drawing +/// Must call generateSurface first +//-------------------------------------------------------------------------------------------------- +ref RivFemPartGeometryGenerator::createMeshDrawable() +{ + + if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL; + + ref geo = new DrawableGeo; + geo->setVertexArray(m_quadVertices.p()); + + ref indices = lineIndicesFromQuadVertexArray(m_quadVertices.p()); + ref prim = new PrimitiveSetIndexedUInt(PT_LINES); + prim->setIndices(indices.p()); + + geo->addPrimitiveSet(prim.p()); + return geo; +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ref RivFemPartGeometryGenerator::createOutlineMeshDrawable(double creaseAngle) +{ + if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL; + + cvf::OutlineEdgeExtractor ee(creaseAngle, *m_quadVertices); + + ref indices = lineIndicesFromQuadVertexArray(m_quadVertices.p()); + ee.addPrimitives(4, *indices); + + ref lineIndices = ee.lineIndices(); + if (lineIndices->size() == 0) + { + return NULL; + } + + ref prim = new PrimitiveSetIndexedUInt(PT_LINES); + prim->setIndices(lineIndices.p()); + + ref geo = new DrawableGeo; + geo->setVertexArray(m_quadVertices.p()); + geo->addPrimitiveSet(prim.p()); + + return geo; +} + + +//-------------------------------------------------------------------------------------------------- +/// +/// +/// +/// +//-------------------------------------------------------------------------------------------------- +ref RivFemPartGeometryGenerator::lineIndicesFromQuadVertexArray(const Vec3fArray* vertexArray) +{ + CVF_ASSERT(vertexArray); + + size_t numVertices = vertexArray->size(); + int numQuads = static_cast(numVertices/4); + CVF_ASSERT(numVertices%4 == 0); + + ref indices = new UIntArray; + indices->resize(numQuads*8); + +#pragma omp parallel for + for (int i = 0; i < numQuads; i++) + { + int idx = 8*i; + indices->set(idx + 0, i*4 + 0); + indices->set(idx + 1, i*4 + 1); + indices->set(idx + 2, i*4 + 1); + indices->set(idx + 3, i*4 + 2); + indices->set(idx + 4, i*4 + 2); + indices->set(idx + 5, i*4 + 3); + indices->set(idx + 6, i*4 + 3); + indices->set(idx + 7, i*4 + 0); + } + + return indices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemPartGeometryGenerator::computeArrays() +{ + std::vector vertices; + std::vector& trianglesToElements = m_triangleMapper->triangleToElmIndexMap(); + std::vector& trianglesToElementFaces = m_triangleMapper->triangleToElmFaceMap(); + + m_quadVerticesToNodeIdx.clear(); + m_quadVerticesToGlobalElmNodeIdx.clear(); + trianglesToElements.clear(); + trianglesToElementFaces.clear(); + + size_t estimatedQuadVxCount = m_part->elementCount()*6*4; + + vertices.reserve(estimatedQuadVxCount); + m_quadVerticesToNodeIdx.reserve(estimatedQuadVxCount); + m_quadVerticesToGlobalElmNodeIdx.reserve(estimatedQuadVxCount); + trianglesToElements.reserve(estimatedQuadVxCount/2); + trianglesToElementFaces.reserve(estimatedQuadVxCount/2); + + cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset(); + const std::vector& nodeCoordinates = m_part->nodes().coordinates; + +#pragma omp parallel for schedule(dynamic) + for (int elmIdx = 0; elmIdx < static_cast(m_part->elementCount()); elmIdx++) + { + if (m_elmVisibility.isNull() || (*m_elmVisibility)[elmIdx]) + { + RigElementType eType = m_part->elementType(elmIdx); + int faceCount = RigFemTypes::elmentFaceCount(eType); + int elmQuadCount = 0; + + const int* elmNodeIndices = m_part->connectivities(elmIdx); + + for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx) + { + int elmNeighbor = m_part->elementNeighbor(elmIdx, lfIdx); + + if (elmNeighbor != -1 && (m_elmVisibility.isNull() || (*m_elmVisibility)[elmNeighbor])) + { + continue; // Invisible face + } + + int faceNodeCount = 0; + const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(eType, lfIdx, &faceNodeCount); + if (faceNodeCount == 4) + { + + // Todo: Needs to get rid of opposite faces + + const cvf::Vec3f* quadVxs[4]; + + quadVxs[0] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[0]] ]); + quadVxs[1] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[1]] ]); + quadVxs[2] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[2]] ]); + quadVxs[3] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[3]] ]); + + int qNodeIdx[4]; + qNodeIdx[0] = elmNodeIndices[localElmNodeIndicesForFace[0]]; + qNodeIdx[1] = elmNodeIndices[localElmNodeIndicesForFace[1]]; + qNodeIdx[2] = elmNodeIndices[localElmNodeIndicesForFace[2]]; + qNodeIdx[3] = elmNodeIndices[localElmNodeIndicesForFace[3]]; + + size_t qElmNodeResIdx[4]; + qElmNodeResIdx[0] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[0]); + qElmNodeResIdx[1] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[1]); + qElmNodeResIdx[2] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[2]); + qElmNodeResIdx[3] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[3]); + + #pragma omp critical + { + vertices.push_back(*quadVxs[0]); + vertices.push_back(*quadVxs[1]); + vertices.push_back(*quadVxs[2]); + vertices.push_back(*quadVxs[3]); + + m_quadVerticesToNodeIdx.push_back(qNodeIdx[0]); + m_quadVerticesToNodeIdx.push_back(qNodeIdx[1]); + m_quadVerticesToNodeIdx.push_back(qNodeIdx[2]); + m_quadVerticesToNodeIdx.push_back(qNodeIdx[3]); + + m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[0]); + m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[1]); + m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[2]); + m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[3]); + + trianglesToElements.push_back(elmIdx); + trianglesToElements.push_back(elmIdx); + trianglesToElementFaces.push_back(lfIdx); + trianglesToElementFaces.push_back(lfIdx); + } + } + else + { + // Handle triangles and 6 node and 8 node faces + } + + } + } + + } + + m_quadVertices = new cvf::Vec3fArray; + m_quadVertices->assign(vertices); +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemPartGeometryGenerator::setElementVisibility(const cvf::UByteArray* cellVisibility) +{ + m_elmVisibility = cellVisibility; +} + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h new file mode 100644 index 0000000000..464628bd43 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h @@ -0,0 +1,88 @@ + +#pragma once + +#include "cvfObject.h" +#include "cvfArray.h" + +#include "RigFemPart.h" +#include "cvfStructGrid.h" + +namespace cvf +{ + +class DrawableGeo; +class ScalarMapper; + +} + +class RigFemPartScalarDataAccess; + +class RivFemPartTriangleToElmMapper : public cvf::Object +{ +public: + size_t triangleCount() const { return m_trianglesToElementIndex.size();} + + int elementIndex(size_t triangleIdx) const { return m_trianglesToElementIndex[triangleIdx]; } + char elementFace(size_t triangleIdx) const { return m_trianglesToElmFace[triangleIdx]; } + + // Interface for building the mappings + std::vector& triangleToElmIndexMap() { return m_trianglesToElementIndex; } + std::vector& triangleToElmFaceMap() { return m_trianglesToElmFace; } + +private: + std::vector m_trianglesToElementIndex; + std::vector m_trianglesToElmFace; +}; + +//================================================================================================== +// +// +// +//================================================================================================== +class RivFemPartGeometryGenerator : public cvf::Object +{ +public: + RivFemPartGeometryGenerator(const RigFemPart* part); + ~RivFemPartGeometryGenerator(); + + // Setup methods + + void setElementVisibility(const cvf::UByteArray* cellVisibility); + + // Access, valid after generation is done + + const RigFemPart* activePart() { return m_part.p(); } + + // Generated geometry + + cvf::ref generateSurface(); + cvf::ref createMeshDrawable(); + cvf::ref createOutlineMeshDrawable(double creaseAngle); + + const std::vector& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;} + const std::vector& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx;} + + RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p();} + +private: + static cvf::ref + lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray); + void computeArrays(); + +private: + // Input + cvf::cref m_part; // The part being processed + cvf::cref m_elmVisibility; + + // Created arrays + cvf::ref m_quadVertices; + //cvf::ref m_triangleVertices; // If needed, we will do it like this, I think + std::vector m_quadVerticesToNodeIdx; + std::vector m_quadVerticesToGlobalElmNodeIdx; + + // Mappings + cvf::ref m_triangleMapper; + +}; + + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp new file mode 100644 index 0000000000..b3dd11a0c1 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -0,0 +1,304 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +#include "RivGeoMechPartMgr.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RimEclipseView.h" +#include "RimGeoMechCellColors.h" +#include "RimLegendConfig.h" +#include "RimGeoMechView.h" + +#include "RivResultToTextureMapper.h" +#include "RivScalarMapperUtils.h" +#include "RivSourceInfo.h" +#include "RivTextureCoordsCreator.h" + +#include "cafEffectGenerator.h" + +#include "cvfDrawableGeo.h" +#include "cvfMath.h" +#include "cvfModelBasicList.h" +#include "cvfPart.h" +#include "cvfRenderStateBlending.h" +#include "cvfRenderStatePolygonOffset.h" +#include "cvfRenderState_FF.h" +#include "cvfShaderProgram.h" +#include "cvfShaderProgramGenerator.h" +#include "cvfShaderSourceProvider.h" +#include "cvfShaderSourceRepository.h" +#include "cvfStructGrid.h" +#include "cvfUniform.h" +#include "RifGeoMechReaderInterface.h" +#include "RigGeoMechCaseData.h" +#include "RigFemScalarResultFrames.h" +#include "RigFemPartResultsCollection.h" +#include "RivFemPickSourceInfo.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivFemPartPartMgr::RivFemPartPartMgr(const RigFemPart* grid) +: m_surfaceGenerator(grid), + m_grid(grid), + m_opacityLevel(1.0f), + m_defaultColor(cvf::Color3::WHITE) +{ + CVF_ASSERT(grid); + m_gridIdx = grid->elementPartId(); + m_cellVisibility = new cvf::UByteArray; + m_surfaceFacesTextureCoords = new cvf::Vec2fArray; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemPartPartMgr::setTransform(cvf::Transform* scaleTransform) +{ + m_scaleTransform = scaleTransform; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemPartPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities) +{ + CVF_ASSERT(m_scaleTransform.notNull()); + CVF_ASSERT(cellVisibilities); + + m_cellVisibility = cellVisibilities; + + m_surfaceGenerator.setElementVisibility(cellVisibilities); + + generatePartGeometry(m_surfaceGenerator); +} + +void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder) +{ + bool useBufferObjects = true; + // Surface geometry + { + m_surfaceFaces = NULL; // To possibly free memory before adding the new stuff + + cvf::ref geo = geoBuilder.generateSurface(); + if (geo.notNull()) + { + geo->computeNormals(); + + if (useBufferObjects) + { + geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT); + } + + cvf::ref part = new cvf::Part; + part->setName("FemPart " + cvf::String(m_gridIdx)); + part->setId(m_gridIdx); // Use grid index as part ID + part->setDrawable(geo.p()); + part->setTransform(m_scaleTransform.p()); + + // Set mapping from triangle face index to element index + cvf::ref si = new RivFemPickSourceInfo(m_gridIdx, geoBuilder.triangleToElementMapper()); + part->setSourceInfo(si.p()); + + part->updateBoundingBox(); + + // Set default effect + caf::SurfaceEffectGenerator geometryEffgen(cvf::Color4f(cvf::Color3f::WHITE), caf::PO_1); + cvf::ref geometryOnlyEffect = geometryEffgen.generateEffect(); + part->setEffect(geometryOnlyEffect.p()); + part->setEnableMask(surfaceBit); + m_surfaceFaces = part; + } + } + + // Mesh geometry + { + m_surfaceGridLines = NULL; // To possibly free memory before adding the new stuff + + cvf::ref geoMesh = geoBuilder.createMeshDrawable(); + if (geoMesh.notNull()) + { + if (useBufferObjects) + { + geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT); + } + + cvf::ref part = new cvf::Part; + part->setName("Grid mesh " + m_gridIdx); + part->setDrawable(geoMesh.p()); + + part->setTransform(m_scaleTransform.p()); + part->updateBoundingBox(); + + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + + cvf::ref eff; + caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors()); + eff = effGen.generateEffect(); + + // Set priority to make sure fault lines are rendered first + part->setPriority(10); + + part->setEnableMask(meshSurfaceBit); + part->setEffect(eff.p()); + m_surfaceGridLines = part; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemPartPartMgr::appendPartsToModel(cvf::ModelBasicList* model) +{ + CVF_ASSERT(model != NULL); + + if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() ); + if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemPartPartMgr::updateCellColor(cvf::Color4f color) +{ + if (m_surfaceFaces.isNull()) return; + + // Set default effect + caf::SurfaceEffectGenerator geometryEffgen(color, caf::PO_1); + cvf::ref geometryOnlyEffect = geometryEffgen.generateEffect(); + + if (m_surfaceFaces.notNull()) m_surfaceFaces->setEffect(geometryOnlyEffect.p()); + + if (color.a() < 1.0f) + { + // Set priority to make sure this transparent geometry are rendered last + if (m_surfaceFaces.notNull()) m_surfaceFaces->setPriority(100); + } + + m_opacityLevel = color.a(); + m_defaultColor = color.toColor3f(); + + // Update mesh colors as well, in case of change + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + + cvf::ref eff; + if (m_surfaceFaces.notNull()) + { + caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors()); + eff = effGen.generateEffect(); + m_surfaceGridLines->setEffect(eff.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors) +{ + CVF_ASSERT(cellResultColors); + + // RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData(); + + cvf::ref surfaceFacesColorArray; + + // Outer surface + if (m_surfaceFaces.notNull()) + { + + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + + RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData(); + + if (!caseData) return; + + RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); + + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, (int)timeStepIndex); + + const std::vector* vxToResultMapping = NULL; + + if (cellResultColors->resultPositionType() == RIG_NODAL) + { + vxToResultMapping = &(m_surfaceGenerator.quadVerticesToNodeIdxMapping()); + } + else if ( cellResultColors->resultPositionType() == RIG_ELEMENT_NODAL + || cellResultColors->resultPositionType() == RIG_INTEGRATION_POINT) + { + vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx()); + } + + m_surfaceFacesTextureCoords->resize(vxToResultMapping->size()); + + if (resultValues.size() == 0) + { + m_surfaceFacesTextureCoords->setAll(cvf::Vec2f(0.0, 1.0f)); + } + else + { + cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr(); + + int vxCount = static_cast(vxToResultMapping->size()); + + #pragma omp parallel for schedule(dynamic) + for (int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4) + { + float resultValue1 = resultValues[(*vxToResultMapping)[quadStartIdx]]; + float resultValue2 = resultValues[(*vxToResultMapping)[quadStartIdx + 1]]; + float resultValue3 = resultValues[(*vxToResultMapping)[quadStartIdx + 2]]; + float resultValue4 = resultValues[(*vxToResultMapping)[quadStartIdx + 3]]; + + if ( resultValue1 == HUGE_VAL || resultValue1 != resultValue1 // a != a is true for NAN's + || resultValue2 == HUGE_VAL || resultValue2 != resultValue2 + || resultValue3 == HUGE_VAL || resultValue3 != resultValue3 + || resultValue4 == HUGE_VAL || resultValue4 != resultValue4) + { + rawPtr[quadStartIdx][1] = 1.0f; + rawPtr[quadStartIdx + 1][1] = 1.0f; + rawPtr[quadStartIdx + 2][1] = 1.0f; + rawPtr[quadStartIdx + 3][1] = 1.0f; + } + else + { + rawPtr[quadStartIdx] = mapper->mapToTextureCoord(resultValue1); + rawPtr[quadStartIdx + 1] = mapper->mapToTextureCoord(resultValue2); + rawPtr[quadStartIdx + 2] = mapper->mapToTextureCoord(resultValue3); + rawPtr[quadStartIdx + 3] = mapper->mapToTextureCoord(resultValue4); + } + } + } + + RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE, cellResultColors->reservoirView()->isLightingDisabled()); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivFemPartPartMgr::~RivFemPartPartMgr() +{ + +} + + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h new file mode 100644 index 0000000000..a1eb4d1d25 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cvfObject.h" + +#include "RivFemPartGeometryGenerator.h" + +namespace cvf +{ + class StructGridInterface; + class ModelBasicList; + class Transform; + class Part; + class Effect; +} + +class RimGeoMechCellColors; +class RigFemPart; + + +//================================================================================================== +/// +/// RivGridGeometry: Class to handle visualization structures that embodies a specific grid at a specific time step. +/// frame on a certain level +/// LGR's have their own instance and the parent grid as well +/// +//================================================================================================== + +class RivFemPartPartMgr: public cvf::Object +{ +public: + RivFemPartPartMgr(const RigFemPart* femPart); + ~RivFemPartPartMgr(); + void setTransform(cvf::Transform* scaleTransform); + void setCellVisibility(cvf::UByteArray* cellVisibilities ); + cvf::ref cellVisibility() { return m_cellVisibility;} + + void updateCellColor(cvf::Color4f color); + void updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors); + + void appendPartsToModel(cvf::ModelBasicList* model); + +private: + void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder); + +private: + int m_gridIdx; + cvf::cref m_grid; + + cvf::ref m_scaleTransform; + float m_opacityLevel; + cvf::Color3f m_defaultColor; + + // Surface visualization + RivFemPartGeometryGenerator m_surfaceGenerator; + + cvf::ref m_surfaceFaces; + cvf::ref m_surfaceFacesTextureCoords; + + cvf::ref m_surfaceGridLines; + + cvf::ref m_cellVisibility; +}; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPickSourceInfo.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPickSourceInfo.cpp new file mode 100644 index 0000000000..ccadff6054 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPickSourceInfo.cpp @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RivFemPickSourceInfo.h" + +#include "RivFemPartGeometryGenerator.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivFemPickSourceInfo::RivFemPickSourceInfo(int partIndex, RivFemPartTriangleToElmMapper * triangleToElmMapper) + : m_fempartIndex(partIndex), + m_triangleToElmMapper(triangleToElmMapper) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivFemPickSourceInfo::~RivFemPickSourceInfo() +{ + +} diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPickSourceInfo.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPickSourceInfo.h new file mode 100644 index 0000000000..b1d3a7a89e --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPickSourceInfo.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cvfObject.h" + +class RivFemPartTriangleToElmMapper; + + +class RivFemPickSourceInfo : public cvf::Object +{ +public: + RivFemPickSourceInfo(int partIndex, RivFemPartTriangleToElmMapper * triangleToElmMapper); + ~RivFemPickSourceInfo(); + + int femPartIndex() const { return m_fempartIndex; } + const RivFemPartTriangleToElmMapper* triangleToElmMapper() const { return m_triangleToElmMapper.p(); } + +private: + int m_fempartIndex; + cvf::cref m_triangleToElmMapper; +}; + + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp new file mode 100644 index 0000000000..25f3920c0a --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp @@ -0,0 +1,141 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +#include "RivGeoMechPartMgr.h" +#include "cvfPart.h" +#include "cvfModelBasicList.h" + +#include "RigGeoMechCaseData.h" +#include "RigFemPartCollection.h" + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechPartMgr::RivGeoMechPartMgr() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechPartMgr::~RivGeoMechPartMgr() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgr::clearAndSetReservoir(const RigGeoMechCaseData* geoMechCase) +{ + m_femPartPartMgrs.clear(); + + if (geoMechCase) + { + const RigFemPartCollection* femParts = geoMechCase->femParts(); + + for (int i = 0; i < femParts->partCount(); ++i) + { + m_femPartPartMgrs.push_back(new RivFemPartPartMgr(femParts->part(i))); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgr::setTransform(cvf::Transform* scaleTransform) +{ + for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i) + { + m_femPartPartMgrs[i]->setTransform(scaleTransform); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgr::setCellVisibility(size_t gridIndex, cvf::UByteArray* cellVisibilities) +{ + CVF_ASSERT(gridIndex < m_femPartPartMgrs.size()); + m_femPartPartMgrs[gridIndex]->setCellVisibility(cellVisibilities); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivGeoMechPartMgr::cellVisibility(size_t gridIdx) +{ + CVF_ASSERT(gridIdx < m_femPartPartMgrs.size()); + return m_femPartPartMgrs[gridIdx]->cellVisibility(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgr::updateCellColor(cvf::Color4f color) +{ + for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i) + { + m_femPartPartMgrs[i]->updateCellColor(color); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors) +{ + for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i) + { + m_femPartPartMgrs[i]->updateCellResultColor(timeStepIndex, cellResultColors); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model) +{ + for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i) + { + m_femPartPartMgrs[i]->appendPartsToModel(model); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector& gridIndices) +{ + for (size_t i = 0; i < gridIndices.size() ; ++i) + { + if (gridIndices[i] < m_femPartPartMgrs.size()) + { + m_femPartPartMgrs[gridIndices[i]]->appendPartsToModel(model); + } + } +} diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h new file mode 100644 index 0000000000..bfdcc552c0 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfArray.h" +#include "cvfCollection.h" + +#include "RivFemPartPartMgr.h" + +namespace cvf +{ + class ModelBasicList; + class Transform; +} + +class RimGeoMechCellColors; +class RigGeoMechCaseData; +class RimGeoMechView; + +//================================================================================================== +/// +/// Class to handle visualization structures that embodies a complete Geo-mech reservoir at a specific +/// time step. +/// +//================================================================================================== + +class RivGeoMechPartMgr: public cvf::Object +{ +public: + RivGeoMechPartMgr(); + ~RivGeoMechPartMgr(); + + int initializedFemPartCount() { return static_cast(m_femPartPartMgrs.size());} + void clearAndSetReservoir(const RigGeoMechCaseData* geoMechCase); + void setTransform(cvf::Transform* scaleTransform); + void setCellVisibility(size_t partIndex, cvf::UByteArray* cellVisibilities ); + + cvf::ref + cellVisibility(size_t partIndex); + + void updateCellColor(cvf::Color4f color); + void updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors); + + void appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector& partIndices); + void appendGridPartsToModel(cvf::ModelBasicList* model); + +private: + + cvf::Collection m_femPartPartMgrs; +}; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp new file mode 100644 index 0000000000..8306b2cc19 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp @@ -0,0 +1,100 @@ +#include "RivGeoMechPartMgrCache.h" +#include "RivGeoMechPartMgr.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechPartMgrCache::RivGeoMechPartMgrCache() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechPartMgrCache::~RivGeoMechPartMgrCache() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivGeoMechPartMgrCache::isNeedingRegeneration(const Key& key) const +{ + std::map::const_iterator ceIt = m_partMgrs.find(key); + if (ceIt != m_partMgrs.end()) + { + return ceIt->second.needsRegen; + } + else + { + return true; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgrCache::scheduleRegeneration(const Key& key) +{ + std::map::iterator ceIt = m_partMgrs.find(key); + if (ceIt != m_partMgrs.end()) + { + ceIt->second.needsRegen = true; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgrCache::setGenerationFinished(const Key& key) +{ + m_partMgrs[key].needsRegen = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechPartMgr* RivGeoMechPartMgrCache::partMgr(const Key& key) +{ + CacheEntry& ce = m_partMgrs[key]; + if (ce.partMgr.isNull()) + { + ce.partMgr = new RivGeoMechPartMgr; + } + + return ce.partMgr.p(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechPartMgrCache::Key::set(RivCellSetEnum aGeometryType, int aFrameIndex) +{ + m_frameIndex = aFrameIndex; + m_geometryType = aGeometryType; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivGeoMechPartMgrCache::Key::operator<(const Key& other) const +{ + if (m_frameIndex != other.m_frameIndex) + { + return (m_frameIndex < other.m_frameIndex); + } + return (m_geometryType < other.m_geometryType); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechPartMgrCache::Key::Key(RivCellSetEnum aGeometryType, int aFrameIndex) +: m_geometryType(aGeometryType), m_frameIndex(aFrameIndex) +{ + +} diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.h new file mode 100644 index 0000000000..2089a38640 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.h @@ -0,0 +1,52 @@ +#pragma once +#include +#include "cvfObject.h" +#include +#include "RivCellSetEnum.h" + +class RivGeoMechPartMgr; +class RivGeoMechPartMgrGeneratorInterface; + +class RivGeoMechPartMgrCache : public cvf::Object +{ +public: + RivGeoMechPartMgrCache(); + ~RivGeoMechPartMgrCache(); + + class Key + { + public: + Key() : m_geometryType(-1), m_frameIndex(-1) {} + + Key(RivCellSetEnum aGeometryType, int aFrameIndex); + + void set(RivCellSetEnum aGeometryType, int aFrameIndex); + + int frameIndex() const { return m_frameIndex;} + unsigned short geometryType() const { return m_geometryType; } + + bool operator< (const Key& other) const; + + private: + int m_frameIndex; + unsigned short m_geometryType; + }; + + bool isNeedingRegeneration(const Key& key) const; + void scheduleRegeneration (const Key& key); + void setGenerationFinished(const Key& key); + RivGeoMechPartMgr* partMgr (const Key& key); + +private: + class CacheEntry + { + public: + CacheEntry() : needsRegen(true) {} + + bool needsRegen; + cvf::ref partMgr; + }; + + std::map m_partMgrs; +}; + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp new file mode 100644 index 0000000000..4fef3878e9 --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -0,0 +1,223 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RivGeoMechVizLogic.h" + +#include "RimGeoMechView.h" +#include "cvfModelBasicList.h" +#include "RimGeoMechCellColors.h" +#include "RivGeoMechPartMgrCache.h" +#include "RivGeoMechPartMgr.h" +#include "RivReservoirViewPartMgr.h" +#include "RimGeoMechCase.h" +#include "RigFemPartCollection.h" +#include "RigGeoMechCaseData.h" +#include "RimCellRangeFilterCollection.h" + +#include "RivCellSetEnum.h" +#include "RivFemElmVisibilityCalculator.h" +#include "RigFemPartResultsCollection.h" +#include "RimGeoMechPropertyFilterCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechVizLogic::RivGeoMechVizLogic(RimGeoMechView * geomView) +{ + CVF_ASSERT(geomView); + m_geomechView = geomView; + m_partMgrCache = new RivGeoMechPartMgrCache; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechVizLogic::~RivGeoMechVizLogic() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechVizLogic::appendNoAnimPartsToModel(cvf::ModelBasicList* model) +{ + this->appendPartsToModel(-1, model); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechVizLogic::appendPartsToModel(int timeStepIndex, cvf::ModelBasicList* model) +{ + std::vector visiblePartMgrs = keysToVisiblePartMgrs(timeStepIndex); + for (size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx) + { + RivGeoMechPartMgr* partMgr = getUpdatedPartMgr(visiblePartMgrs[pmIdx]); + + partMgr->appendGridPartsToModel(model); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechVizLogic::updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors) +{ + std::vector visiblePartMgrs = keysToVisiblePartMgrs(timeStepIndex); + for (size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx) + { + RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr(visiblePartMgrs[pmIdx]); + partMgr->updateCellResultColor(timeStepIndex, cellResultColors); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechVizLogic::updateStaticCellColors(int timeStepIndex) +{ + std::vector visiblePartMgrs = keysToVisiblePartMgrs(timeStepIndex); + for (size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx) + { + RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr(visiblePartMgrs[pmIdx]); + partMgr->updateCellColor(cvf::Color4f(cvf::Color3f::ORANGE)); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGeoMechVizLogic::scheduleGeometryRegen(RivCellSetEnum geometryType) +{ + this->scheduleRegenOfDirectlyDependentGeometry(geometryType); + + int frameCount = m_geomechView->geoMechCase()->geoMechData()->femPartResults()->frameCount(); + + for (int fIdx = -1; fIdx < frameCount; ++fIdx) + { + RivGeoMechPartMgrCache::Key geomToRegen(geometryType, fIdx); + m_partMgrCache->scheduleRegeneration(geomToRegen); + } +} + +void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum geometryType) +{ + if (geometryType == RANGE_FILTERED) + { + this->scheduleGeometryRegen(PROPERTY_FILTERED); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RivGeoMechVizLogic::keysToVisiblePartMgrs(int timeStepIndex) +{ + std::vector visiblePartMgrs; + + if (timeStepIndex >= 0 && m_geomechView->propertyFilterCollection()->hasActiveFilters()) + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(PROPERTY_FILTERED, timeStepIndex)); + } + else if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); + } + else + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); + } + + return visiblePartMgrs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache::Key pMgrKey) +{ + if (!m_partMgrCache->isNeedingRegeneration(pMgrKey)) + { + return m_partMgrCache->partMgr(pMgrKey); + } + + RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr(pMgrKey); + RigGeoMechCaseData* caseData = m_geomechView->geoMechCase()->geoMechData(); + int partCount = caseData->femParts()->partCount(); + + if (partMgrToUpdate->initializedFemPartCount() != partCount) + { + partMgrToUpdate->clearAndSetReservoir(caseData); + } + + for (int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx) + { + cvf::ref elmVisibility = partMgrToUpdate->cellVisibility(femPartIdx); + partMgrToUpdate->setTransform(m_geomechView->scaleTransform()); + + if (pMgrKey.geometryType() == RANGE_FILTERED) + { + cvf::CellRangeFilter cellRangeFilter; + m_geomechView->rangeFilterCollection()->compoundCellRangeFilter(&cellRangeFilter, femPartIdx); + RivFemElmVisibilityCalculator::computeRangeVisibility( elmVisibility.p(), + caseData->femParts()->part(femPartIdx), + cellRangeFilter); + } + else if (pMgrKey.geometryType() == PROPERTY_FILTERED) + { + RivGeoMechPartMgr* rangefiltered = NULL; + if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) + { + rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); + } + else + { + rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); + } + cvf::ref rangeFiltVisibility = rangefiltered->cellVisibility(femPartIdx); + + RivFemElmVisibilityCalculator::computePropertyVisibility(elmVisibility.p(), + caseData->femParts()->part(femPartIdx), + pMgrKey.frameIndex(), + rangeFiltVisibility.p(), + m_geomechView->propertyFilterCollection() + ); + } + else if (pMgrKey.geometryType() == ALL_CELLS) + { + RivFemElmVisibilityCalculator::computeAllVisible(elmVisibility.p(), caseData->femParts()->part(femPartIdx)); + } + else + { + CVF_ASSERT(false); // Unsupported CellSet Enum + } + + partMgrToUpdate->setCellVisibility(femPartIdx, elmVisibility.p()); + } + + m_partMgrCache->setGenerationFinished(pMgrKey); + + return partMgrToUpdate; +} + + diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h new file mode 100644 index 0000000000..04786ae83e --- /dev/null +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +#include "cvfObject.h" +#include "cvfColor4.h" +#include "RivGeoMechPartMgrCache.h" +#include "RivCellSetEnum.h" + +#include + +class RimGeoMechView; +class RimGeoMechCellColors; + +namespace cvf +{ + class ModelBasicList; +} + +class RivGeoMechVizLogic : public cvf::Object +{ +public: + + RivGeoMechVizLogic(RimGeoMechView * geomView); + virtual ~RivGeoMechVizLogic(); + + void appendNoAnimPartsToModel(cvf::ModelBasicList* model); + void appendPartsToModel(int timeStepIndex, cvf::ModelBasicList* model); + void updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors); + void updateStaticCellColors(int timeStepIndex); + void scheduleGeometryRegen(RivCellSetEnum geometryType); +private: + + std::vector keysToVisiblePartMgrs(int timeStepIndex); + RivGeoMechPartMgr* getUpdatedPartMgr(RivGeoMechPartMgrCache::Key partMgrKey); + void scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum geometryType); + + cvf::ref m_partMgrCache; + RimGeoMechView* m_geomechView; +}; + diff --git a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt new file mode 100644 index 0000000000..d45957caa2 --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt @@ -0,0 +1,89 @@ +cmake_minimum_required (VERSION 2.8) + +project (RifOdbReader) + +if (MSVC) + add_definitions(-DHKS_NT) + add_definitions(-DABQ_WIN86_64) +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -c -fPIC -w -Wno-deprecated") + + add_definitions(-DTYPENAME=typename) + add_definitions(-D_LINUX_SOURCE) + add_definitions(-DABQ_LINUX) + add_definitions(-DABQ_LNX86_64) + add_definitions(-DSMA_GNUC) + add_definitions(-DFOR_TRAIL) + add_definitions(-DHAS_BOOL) + add_definitions(-DASSERT_ENABLED) + add_definitions(-D_BSD_TYPES) + add_definitions(-D_BSD_SOURCE) + add_definitions(-D_GNU_SOURCE) + add_definitions(-D_POSIX_SOURCE) + add_definitions(-D_XOPEN_SOURCE_EXTENDED) + add_definitions(-D_XOPEN_SOURCE) + add_definitions(-DHAVE_OPENGL) + add_definitions(-DHKS_OPEN_GL) + add_definitions(-DGL_GLEXT_PROTOTYPES) + add_definitions(-DMULTI_THREADING_ENABLED) + add_definitions(-D_REENTRANT) + add_definitions(-DABQ_MPI_SUPPORT) + add_definitions(-DBIT64) + add_definitions(-D_LARGEFILE64_SOURCE) + add_definitions(-D_FILE_OFFSET_BITS=64) + add_definitions(-DABQ_MPI_PMPI) +endif(MSVC) + +include_directories( + ${RESINSIGHT_ODB_API_DIR}/include + ${RigGeoMechDataModel_SOURCE_DIR} + ${LibCore_SOURCE_DIR} +) + +add_library( ${PROJECT_NAME} + RifOdbReader.h + RifOdbReader.cpp + RifGeoMechReaderInterface.h + RifGeoMechReaderInterface.cpp + OdbSetup.cmake +) + +if (MSVC) + list(APPEND RI_ODB_LIBS + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbDdbOdb.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbApi.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbCore.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbCoreGeom.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbAttrEO.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAAbuBasicUtils.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMABasShared.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMABasCoreUtils.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAStiCAE_StableTime.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMABasMem.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAAbuGeom.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMARomDiagEx.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMASspUmaCore.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMASimInterface.lib + ${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAMtxCoreModule.lib + ) +else() + list(APPEND RI_ODB_LIBS + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbDdbOdb.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbApi.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbCore.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbCoreGeom.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbAttrEO.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAAbuBasicUtils.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMABasShared.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMABasCoreUtils.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAStiCAE_StableTime.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMABasMem.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAAbuGeom.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMARomDiagEx.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMASspUmaCore.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMASimInterface.so + ${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAMtxCoreModule.so + ) +endif(MSVC) + +target_link_libraries(${PROJECT_NAME} ${RI_ODB_LIBS} RigGeoMechDataModel LibCore) diff --git a/ApplicationCode/GeoMech/OdbReader/OdbSetup.cmake b/ApplicationCode/GeoMech/OdbReader/OdbSetup.cmake new file mode 100644 index 0000000000..d66c7085d4 --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader/OdbSetup.cmake @@ -0,0 +1,27 @@ + +# Copy Odb Dlls +set(RESINSIGHT_ODB_API_DIR "" CACHE PATH "Path tho the ODB api from Simulia") + +if (MSVC) + # Find all the dlls + file (GLOB RI_ALL_ODB_DLLS ${RESINSIGHT_ODB_API_DIR}/lib/*.dll) + + # Strip off the path + foreach (aDLL ${RI_ALL_ODB_DLLS}) + get_filename_component(filenameWithExt ${aDLL} NAME) + list(APPEND RI_ODB_DLLS ${filenameWithExt} ) + endforeach(aDLL) + + # Copy to target directory + #foreach (aDLL ${RI_ODB_DLLS}) + # add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + # COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RI_ODB_API_DIR}/lib/${aDLL}" "$") + #endforeach() + foreach (aDLL ${RI_ODB_DLLS}) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${RESINSIGHT_ODB_API_DIR}/lib/${aDLL}" + "${CMAKE_CURRENT_BINARY_DIR}/$") + endforeach() + +endif(MSVC) diff --git a/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.cpp b/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.cpp new file mode 100644 index 0000000000..84c784f9fd --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.cpp @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "RifGeoMechReaderInterface.h" + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifGeoMechReaderInterface::RifGeoMechReaderInterface() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifGeoMechReaderInterface::~RifGeoMechReaderInterface() +{ + +} diff --git a/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h b/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h new file mode 100644 index 0000000000..ac3b2fadf0 --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include +#include +#include + +class RigFemPartCollection; + + +//================================================================================================== +// +// Data interface base class +// +//================================================================================================== +class RifGeoMechReaderInterface : public cvf::Object +{ +public: + RifGeoMechReaderInterface(); + virtual ~RifGeoMechReaderInterface(); + + virtual bool openFile(const std::string& fileName, std::string* errorMessage) = 0; + + virtual bool readFemParts(RigFemPartCollection* geoMechCase) = 0; + virtual std::vector stepNames() = 0; + virtual std::vector frameTimes(int stepIndex) = 0; + + virtual std::vector elementSetNames(int partIndex) = 0; + virtual std::vector elementSet(int partIndex, int setIndex) = 0; + + virtual std::map > scalarNodeFieldAndComponentNames() = 0; + virtual std::map > scalarElementNodeFieldAndComponentNames() = 0; + virtual std::map > scalarIntegrationPointFieldAndComponentNames() = 0; + + virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector* displacements) = 0; + + virtual void readNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) = 0; + virtual void readElementNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) = 0; + virtual void readIntegrationPointField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) = 0; + +private: +}; diff --git a/ApplicationCode/GeoMech/OdbReader/RifOdbReader.cpp b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.cpp new file mode 100644 index 0000000000..67384d4ba1 --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.cpp @@ -0,0 +1,948 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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. +// +///////////////////////////////////////////////////////////////////////////////// + +#ifdef _MSC_VER +// Get rid of warnings from compilation of ODB API +#pragma warning(push) +#pragma warning(disable: 4018) +#pragma warning(disable: 4482) +#pragma warning(disable: 4584) +#pragma warning(disable: 4800) +#endif +#include +#include +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#include "RifOdbReader.h" + +#include "RigFemPartCollection.h" +#include "RigFemPart.h" + +#include +#include +#include +#include +#include "cafProgressInfo.h" +#include + + +//================================================================================================== +// +// Helper class to ensure that ODB bulk data are returned as float. Converting if necessary. +// +//================================================================================================== +class RifOdbBulkDataGetter +{ +public: + RifOdbBulkDataGetter(const odb_FieldBulkData& bulkData) : m_bulkData(bulkData) {}; + virtual ~RifOdbBulkDataGetter() {}; + + float* data() + { + odb_Enum::odb_PrecisionEnum precision = m_bulkData.precision(); + if (precision == odb_Enum::SINGLE_PRECISION) + { + return m_bulkData.data(); + } + else if (precision == odb_Enum::DOUBLE_PRECISION) + { + if (m_data.size() < 1) + { + int dataSize = m_bulkData.length()*m_bulkData.width(); + m_data.resize(dataSize); + + double* doublePtr = m_bulkData.dataDouble(); + CVF_ASSERT(doublePtr); + + float* dataPtr = m_data.data(); + for (int i = 0; i < dataSize; i++) + { + dataPtr[i] = (float) doublePtr[i]; + } + } + + return m_data.data(); + } + + // Should never end up here + CVF_ASSERT(0); + return NULL; + } + +private: + const odb_FieldBulkData& m_bulkData; + std::vector m_data; +}; + + +size_t RifOdbReader::sm_instanceCount = 0; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- + +std::map initFemTypeMap() +{ + std::map typeMap; + typeMap["C3D8R"] = HEX8; + typeMap["C3D8"] = HEX8; + typeMap["C3D8P"] = HEX8; + typeMap["CAX4"] = CAX4; + + return typeMap; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigElementType toRigElementType(const odb_String& odbTypeName) +{ + static std::map odbElmTypeToRigElmTypeMap = initFemTypeMap(); + + std::map::iterator it = odbElmTypeToRigElmTypeMap.find(odbTypeName.cStr()); + + if (it == odbElmTypeToRigElmTypeMap.end()) + { +#if 0 + std::cout << "Unsupported element type :" << odbElm.type().cStr() << std::endl; +#endif + return UNKNOWN_ELM_TYPE; + } + + return it->second; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- + +const int* localElmNodeToIntegrationPointMapping(RigElementType elmType) +{ + static const int HEX8_Mapping[8] ={ 0, 1, 3, 2, 4, 5, 7, 6 }; + + switch (elmType) + { + case HEX8: + return HEX8_Mapping; + break; + case CAX4: + return HEX8_Mapping; // First four is identical to HEX8 + break; + default: + //assert(false); // Element type not supported + break; + } + return NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifOdbReader::RifOdbReader() +{ + if (++sm_instanceCount == 1) + { + odb_initializeAPI(); + } + + m_odb = NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifOdbReader::~RifOdbReader() +{ + close(); + + if (--sm_instanceCount == 0) + { + odb_finalizeAPI(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifOdbReader::close() +{ + if (m_odb) + { + m_odb->close(); + m_odb = NULL; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifOdbReader::openFile(const std::string& fileName, std::string* errorMessage) +{ + close(); + CVF_ASSERT(m_odb == NULL); + + odb_String path = fileName.c_str(); + + try + { + m_odb = &openOdb(path, true); + } + + catch (const nex_Exception& nex) + { + if (errorMessage) + { + *errorMessage = nex.UserReport().CStr(); + } + + return false; + } + + catch (...) + { + if (errorMessage) + { + std::stringstream errStr; + errStr << "Unable to open file '" << fileName << "'."; + + *errorMessage = errStr.str(); + } + + return false; + } + + return true; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifOdbReader::assertMetaDataLoaded() +{ + CVF_ASSERT(m_odb != NULL); + + if (m_resultsMetaData.empty()) + { + m_resultsMetaData = readResultsMetaData(m_odb); + } + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map< RifOdbReader::RifOdbResultKey, std::vector > RifOdbReader::readResultsMetaData(odb_Odb* odb) +{ + CVF_ASSERT(odb != NULL); + + std::map< RifOdbResultKey, std::vector > resultsMap; + + const odb_StepRepository& stepRepository = odb->steps(); + odb_StepRepositoryIT stepIt(stepRepository); + stepIt.first(); + + const odb_Step& step = stepRepository.constGet(stepIt.currentKey()); + const odb_SequenceFrame& stepFrames = step.frames(); + + if (stepFrames.size() > 1) + { + // Optimization: Get results metadata for the second frame of the first step only + const odb_Frame& frame = stepFrames.constGet(1); + + const odb_FieldOutputRepository& fieldCon = frame.fieldOutputs(); + odb_FieldOutputRepositoryIT fieldConIT(fieldCon); + + for (fieldConIT.first(); !fieldConIT.isDone(); fieldConIT.next()) + { + const odb_FieldOutput& field = fieldCon[fieldConIT.currentKey()]; + + const odb_SequenceFieldLocation& fieldLocations = field.locations(); + for (int loc = 0; loc < fieldLocations.size(); loc++) + { + const odb_FieldLocation& fieldLocation = fieldLocations.constGet(loc); + + std::string fieldName = field.name().CStr(); + odb_SequenceString components = field.componentLabels(); + + std::vector compVec; + + int numComp = components.size(); + for (int comp = 0; comp < numComp; comp++) + { + compVec.push_back(components[comp].CStr()); + } + + switch (fieldLocation.position()) + { + case odb_Enum::NODAL: + resultsMap[RifOdbResultKey(NODAL, fieldName)] = compVec; + break; + + case odb_Enum::ELEMENT_NODAL: + resultsMap[RifOdbResultKey(ELEMENT_NODAL, fieldName)] = compVec; + break; + + case odb_Enum::INTEGRATION_POINT: + resultsMap[RifOdbResultKey(INTEGRATION_POINT, fieldName)] = compVec; + resultsMap[RifOdbResultKey(ELEMENT_NODAL, fieldName)] = compVec; + break; + + default: + break; + } + } + } + } + + stepFrames.release(); + + return resultsMap; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifOdbReader::readFemParts(RigFemPartCollection* femParts) +{ + CVF_ASSERT(femParts); + CVF_ASSERT(m_odb != NULL); + + + odb_Assembly& rootAssembly = m_odb->rootAssembly(); + odb_InstanceRepository instanceRepository = m_odb->rootAssembly().instances(); + odb_InstanceRepositoryIT iter(instanceRepository); + + caf::ProgressInfo modelProgress(instanceRepository.size()*(2+4), "Reading Odb Parts"); + + int instanceCount = 0; + for (iter.first(); !iter.isDone(); iter.next(), instanceCount++) + { + modelProgress.setProgressDescription(QString (iter.currentKey().cStr()) + ": Reading Nodes"); + m_nodeIdToIdxMaps.push_back(std::map()); + + odb_Instance& inst = instanceRepository[iter.currentKey()]; + + RigFemPart* femPart = new RigFemPart; + + // Extract nodes + const odb_SequenceNode& odbNodes = inst.nodes(); + + std::map& nodeIdToIdxMap = m_nodeIdToIdxMaps.back(); + + int nodeCount = odbNodes.size(); + femPart->nodes().nodeIds.resize(nodeCount); + femPart->nodes().coordinates.resize(nodeCount); + + for (int nIdx = 0; nIdx < nodeCount; ++nIdx) + { + const odb_Node odbNode = odbNodes.node(nIdx); + femPart->nodes().nodeIds[nIdx] = odbNode.label(); + const float * pos = odbNode.coordinates(); + femPart->nodes().coordinates[nIdx].set(pos[0], pos[1], pos[2]); + nodeIdToIdxMap[odbNode.label()] = nIdx; + + // Progress reporting + if(nIdx == nodeCount/2) + { + modelProgress.incrementProgress(); + } + } + + modelProgress.incrementProgress(); + modelProgress.setProgressDescription(QString (iter.currentKey().cStr()) + ": Reading Elements"); + + // Extract elements + const odb_SequenceElement& elements = inst.elements(); + + int elmCount = elements.size(); + femPart->preAllocateElementStorage(elmCount); + std::map::const_iterator it; + std::vector indexBasedConnectivities; + + m_elementIdToIdxMaps.push_back(std::map()); + std::map& elementIdToIdxMap = m_elementIdToIdxMaps.back(); + + for (int elmIdx = 0; elmIdx < elmCount; ++elmIdx) + { + const odb_Element odbElm = elements.element(elmIdx); + + elementIdToIdxMap[odbElm.label()] = elmIdx; + + RigElementType elmType = toRigElementType(odbElm.type()); + if (elmType == UNKNOWN_ELM_TYPE) continue; + + int nodeCount = 0; + const int* idBasedConnectivities = odbElm.connectivity(nodeCount); + CVF_TIGHT_ASSERT(nodeCount == RigFemTypes::elmentNodeCount(elmType)); + + indexBasedConnectivities.resize(nodeCount); + for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx) + { + indexBasedConnectivities[lnIdx] = nodeIdToIdxMap[idBasedConnectivities[lnIdx]]; + } + + femPart->appendElement(elmType, odbElm.label(), indexBasedConnectivities.data()); + + // Progress reporting + if (elmIdx == elmCount/4 || elmIdx == elmCount/2 || elmIdx == 3*elmCount/4) + { + modelProgress.incrementProgress(); + } + } + + femPart->setElementPartId(femParts->partCount()); + femParts->addFemPart(femPart); + + modelProgress.incrementProgress(); + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifOdbReader::stepNames() +{ + CVF_ASSERT(m_odb != NULL); + + std::vector stepNames; + + odb_StepRepository stepRepository = m_odb->steps(); + odb_StepRepositoryIT sIter(stepRepository); + for (sIter.first(); !sIter.isDone(); sIter.next()) + { + stepNames.push_back(stepRepository[sIter.currentKey()].name().CStr()); + } + + return stepNames; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifOdbReader::frameTimes(int stepIndex) +{ + CVF_ASSERT(m_odb != NULL); + + odb_StepRepository& stepRepository = m_odb->steps(); + + odb_StepList stepList = stepRepository.stepList(); + odb_Step& step = stepList.Get(stepIndex); + + odb_SequenceFrame& stepFrames = step.frames(); + + std::vector frameValues; + + int numFrames = stepFrames.size(); + for (int f = 0; f < numFrames; f++) + { + odb_Frame frame = stepFrames.constGet(f); + frameValues.push_back(frame.frameValue()); + } + + return frameValues; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifOdbReader::elementSetNames(int partIndex) +{ + CVF_ASSERT(m_odb != NULL); + + std::map< int, std::vector >::const_iterator mapIt = m_partElementSetNames.find(partIndex); + if (mapIt == m_partElementSetNames.end()) + { + std::vector setNames; + + const odb_Assembly& rootAssembly = m_odb->constRootAssembly(); + const odb_InstanceRepository& instances = rootAssembly.instances(); + + int currentInstance = 0; + odb_InstanceRepositoryIT instIt(instances); + for (instIt.first(); !instIt.isDone(); instIt.next(), currentInstance++) + { + const odb_Instance& instance = instIt.currentValue(); + + if (currentInstance == partIndex) + { + const odb_SetRepository& sets = rootAssembly.elementSets(); + + odb_SetRepositoryIT setIt(sets); + for (setIt.first(); !setIt.isDone(); setIt.next()) + { + const odb_Set& set = setIt.currentValue(); + setNames.push_back(set.name().CStr()); + } + + break; + } + } + + m_partElementSetNames[partIndex] = setNames; + } + + return m_partElementSetNames.at(partIndex); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifOdbReader::elementSet(int partIndex, int setIndex) +{ + CVF_ASSERT(m_odb != NULL); + + std::vector setNames = elementSetNames(partIndex); + const odb_Assembly& rootAssembly = m_odb->constRootAssembly(); + + const odb_Set& set = rootAssembly.elementSets()[odb_String(setNames[setIndex].c_str())]; + odb_SequenceString instanceNames = set.instanceNames(); + + const odb_SequenceElement& setElements = set.elements(instanceNames[partIndex]); + int elementCount = setElements.size(); + + std::vector elementIndexes; + elementIndexes.resize(elementCount); + + for (int i = 0; i < elementCount; i++) + { + elementIndexes[i] = setElements.element(i).index(); + } + + return elementIndexes; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RifOdbReader::scalarNodeFieldAndComponentNames() +{ + return fieldAndComponentNames(NODAL); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RifOdbReader::scalarElementNodeFieldAndComponentNames() +{ + return fieldAndComponentNames(ELEMENT_NODAL); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RifOdbReader::scalarIntegrationPointFieldAndComponentNames() +{ + return fieldAndComponentNames(INTEGRATION_POINT); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const odb_Frame& RifOdbReader::stepFrame(int stepIndex, int frameIndex) const +{ + CVF_ASSERT(m_odb); + + const odb_StepRepository& stepRepository = m_odb->steps(); + const odb_StepList& stepList = stepRepository.stepList(); + const odb_Step& step = stepList.ConstGet(stepIndex); + const odb_SequenceFrame& stepFrames = step.frames(); + + return stepFrames.constGet(frameIndex); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +odb_Instance* RifOdbReader::instance(int instanceIndex) +{ + CVF_ASSERT(m_odb != NULL); + + odb_Assembly& rootAssembly = m_odb->rootAssembly(); + odb_InstanceRepository& instanceRepository = m_odb->rootAssembly().instances(); + odb_InstanceRepositoryIT iter(instanceRepository); + + int instanceCount = 0; + for (iter.first(); !iter.isDone(); iter.next(), instanceCount++) + { + odb_Instance& inst = instanceRepository[iter.currentKey()]; + + if (instanceCount == instanceIndex) + { + return &inst; + } + } + + return NULL; +} + + +//-------------------------------------------------------------------------------------------------- +/// Get the number of result items (== #nodes or #elements) +//-------------------------------------------------------------------------------------------------- +size_t RifOdbReader::resultItemCount(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex) +{ + odb_Instance* partInstance = instance(partIndex); + CVF_ASSERT(partInstance != NULL); + + const odb_Frame& frame = stepFrame(stepIndex, frameIndex); + const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance); + const odb_SequenceFieldBulkData& seqFieldBulkData = instanceFieldOutput.bulkDataBlocks(); + + size_t resultItemCount = 0; + int numBlocks = seqFieldBulkData.size(); + + for (int block = 0; block < numBlocks; block++) + { + const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; + resultItemCount += bulkData.length(); + } + + return resultItemCount; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RifOdbReader::componentsCount(const std::string& fieldName, ResultPosition position) +{ + std::vector compNames = componentNames(RifOdbResultKey(position, fieldName)); + return compNames.size() > 0 ? compNames.size() : 1; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifOdbReader::componentIndex(const RifOdbResultKey& result, const std::string& componentName) +{ + std::vector compNames = componentNames(result); + + // If there are no component names, we expect the field to be a pure scalar. + // Then an empty string is the valid component name + if (!compNames.size() && componentName == "") return 0; + + for (size_t i = 0; i < compNames.size(); i++) + { + if (compNames[i] == componentName) + { + return static_cast(i); + } + } + + return -1; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifOdbReader::componentNames(const RifOdbResultKey& result) +{ + assertMetaDataLoaded(); + + std::map< RifOdbResultKey, std::vector >::const_iterator resMapIt = m_resultsMetaData.find(result); + if (resMapIt != m_resultsMetaData.end()) + { + std::vector compNames; + compNames = resMapIt->second; + return compNames; + } + + CVF_ASSERT(false); + return std::vector(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RifOdbReader::fieldAndComponentNames(ResultPosition position) +{ + assertMetaDataLoaded(); + + std::map > fieldsAndComponents; + + std::map< RifOdbResultKey, std::vector >::const_iterator resMapIt; + for (resMapIt = m_resultsMetaData.begin(); resMapIt != m_resultsMetaData.end(); resMapIt++) + { + if (resMapIt->first.resultPostion == position) + { + fieldsAndComponents[resMapIt->first.fieldName] = resMapIt->second; + } + } + + return fieldsAndComponents; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifOdbReader::readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector* displacements) +{ + CVF_ASSERT(displacements); + + odb_Instance* partInstance = instance(partIndex); + CVF_ASSERT(partInstance != NULL); + + size_t dataSize = resultItemCount("U", partIndex, stepIndex, frameIndex); + if (dataSize > 0) + { + displacements->resize(dataSize); + } + + const odb_Frame& frame = stepFrame(stepIndex, frameIndex); + const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()["U"].getSubset(*partInstance); + const odb_SequenceFieldBulkData& seqFieldBulkData = instanceFieldOutput.bulkDataBlocks(); + + size_t dataIndex = 0; + int numBlocks = seqFieldBulkData.size(); + for (int block = 0; block < numBlocks; block++) + { + const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; + RifOdbBulkDataGetter bulkDataGetter(bulkData); + + if (bulkData.numberOfNodes() > 0) + { + int numNodes = bulkData.length(); + int numComp = bulkData.width(); + float* data = bulkDataGetter.data(); + + for (int i = 0; i < numNodes; i++) + { + (*displacements)[i + dataIndex].set(data[i*numComp], data[i*numComp + 1], data[i*numComp + 2]); + } + + dataIndex += numNodes*numComp; + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifOdbReader::readNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) +{ + CVF_ASSERT(resultValues); + + odb_Instance* partInstance = instance(partIndex); + CVF_ASSERT(partInstance != NULL); + + size_t compCount = componentsCount(fieldName, NODAL); + CVF_ASSERT(compCount == resultValues->size()); + + std::map& nodeIdToIdxMap = m_nodeIdToIdxMaps[partIndex]; + + size_t dataSize = nodeIdToIdxMap.size(); + + if (dataSize > 0) + { + for (int comp = 0; comp < compCount; comp++) + { + CVF_ASSERT((*resultValues)[comp]); + + (*resultValues)[comp]->resize(dataSize, std::numeric_limits::infinity()); + } + } + + const odb_Frame& frame = stepFrame(stepIndex, frameIndex); + const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance); + const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::NODAL); + const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks(); + + size_t dataIndex = 0; + int numBlocks = seqFieldBulkData.size(); + for (int block = 0; block < numBlocks; block++) + { + const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; + RifOdbBulkDataGetter bulkDataGetter(bulkData); + + int numNodes = bulkData.length(); + int numComp = bulkData.width(); + int* nodeLabels = bulkData.nodeLabels(); + float* data = bulkDataGetter.data(); + + for (int nIdx = 0; nIdx < numNodes; nIdx++) + { + for (int comp = 0; comp < numComp; comp++) + { + std::vector* singleComponentValues = (*resultValues)[comp]; + (*singleComponentValues)[nodeIdToIdxMap[nodeLabels[nIdx]]] = data[nIdx*numComp + comp]; + } + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifOdbReader::readElementNodeField(const std::string& fieldName, + int partIndex, int stepIndex, int frameIndex, + std::vector*>* resultValues) +{ + CVF_ASSERT(resultValues); + + odb_Instance* partInstance = instance(partIndex); + CVF_ASSERT(partInstance != NULL); + + size_t compCount = componentsCount(fieldName, ELEMENT_NODAL); + CVF_ASSERT(compCount == resultValues->size()); + + size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex); + if (dataSize > 0) + { + for (int comp = 0; comp < compCount; comp++) + { + CVF_ASSERT((*resultValues)[comp]); + + (*resultValues)[comp]->resize(dataSize, std::numeric_limits::infinity()); + } + } + + const odb_Frame& frame = stepFrame(stepIndex, frameIndex); + const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance); + const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::ELEMENT_NODAL); + const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks(); + + std::map& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex]; + CVF_ASSERT(elementIdToIdxMap.size() > 0); + + size_t dataIndex = 0; + int numBlocks = seqFieldBulkData.size(); + for (int block = 0; block < numBlocks; block++) + { + const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; + RifOdbBulkDataGetter bulkDataGetter(bulkData); + + int numValues = bulkData.length(); + int numComp = bulkData.width(); + int elemCount = bulkData.numberOfElements(); + int elemNodeCount = numValues/elemCount; + int* elementLabels = bulkData.elementLabels(); + float* data = bulkDataGetter.data(); + + for (int elem = 0; elem < elemCount; elem++) + { + int elementIdx = elementIdToIdxMap[elementLabels[elem*elemNodeCount]]; + int elementResultStartDestIdx = elementIdx*elemNodeCount; // Ikke generellt riktig ! + int elementResultStartSourceIdx = elem*elemNodeCount*numComp; + + for (int elemNode = 0; elemNode < elemNodeCount; elemNode++) + { + int destIdx = elementResultStartDestIdx + elemNode; + int srcIdx = elementResultStartSourceIdx + elemNode*numComp; + + for (int comp = 0; comp < numComp; comp++) + { + (*(*resultValues)[comp])[destIdx] = data[srcIdx + comp]; + } + } + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifOdbReader::readIntegrationPointField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues) +{ + CVF_ASSERT(resultValues); + + odb_Instance* partInstance = instance(partIndex); + CVF_ASSERT(partInstance != NULL); + + size_t compCount = componentsCount(fieldName, INTEGRATION_POINT); + CVF_ASSERT(compCount == resultValues->size()); + + size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex); + if (dataSize > 0) + { + for (int comp = 0; comp < compCount; comp++) + { + CVF_ASSERT((*resultValues)[comp]); + + (*resultValues)[comp]->resize(dataSize, std::numeric_limits::infinity()); + } + } + + const odb_Frame& frame = stepFrame(stepIndex, frameIndex); + const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance); + const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::INTEGRATION_POINT); + const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks(); + + std::map& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex]; + CVF_ASSERT(elementIdToIdxMap.size() > 0); + + size_t dataIndex = 0; + int numBlocks = seqFieldBulkData.size(); + for (int block = 0; block < numBlocks; block++) + { + const odb_FieldBulkData& bulkData = seqFieldBulkData[block]; + RifOdbBulkDataGetter bulkDataGetter(bulkData); + + int numValues = bulkData.length(); + int numComp = bulkData.width(); + int elemCount = bulkData.numberOfElements(); + int ipCount = numValues/elemCount; + int* elementLabels = bulkData.elementLabels(); + float* data = bulkDataGetter.data(); + + RigElementType eType = toRigElementType(bulkData.baseElementType()); + const int* elmNodeToIpResultMapping = localElmNodeToIntegrationPointMapping(eType); + if (!elmNodeToIpResultMapping) continue; + + for (int elem = 0; elem < elemCount; elem++) + { + int elementIdx = elementIdToIdxMap[elementLabels[elem*ipCount]]; + int elementResultStartDestIdx = elementIdx*ipCount; // Ikke generellt riktig ! + int elementResultStartSourceIdx = elem*ipCount*numComp; + + for (int ipIdx = 0; ipIdx < ipCount; ipIdx++) + { + int resultIpIdx = elmNodeToIpResultMapping[ipIdx]; + int destIdx = elementResultStartDestIdx + ipIdx; + int srcIdx = elementResultStartSourceIdx + resultIpIdx*numComp; + + for (int comp = 0; comp < numComp; comp++) + { + (*(*resultValues)[comp])[destIdx] = data[srcIdx + comp]; + } + } + } + } +} diff --git a/ApplicationCode/GeoMech/OdbReader/RifOdbReader.h b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.h new file mode 100644 index 0000000000..d0b777d4f3 --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader/RifOdbReader.h @@ -0,0 +1,112 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RifGeoMechReaderInterface.h" +#include +#include + +class RigFemPartCollection; + +class odb_Odb; +class odb_Frame; +class odb_Instance; +class odb_SequenceFieldBulkData; + +//================================================================================================== +// +// Data interface base class +// +//================================================================================================== +class RifOdbReader : public RifGeoMechReaderInterface +{ +public: + RifOdbReader(); + virtual ~RifOdbReader(); + + virtual bool openFile(const std::string& fileName, std::string* errorMessage); + + virtual bool readFemParts(RigFemPartCollection* geoMechCase); + virtual std::vector stepNames(); + virtual std::vector frameTimes(int stepIndex); + + virtual std::vector elementSetNames(int partIndex); + virtual std::vector elementSet(int partIndex, int setIndex); + + virtual std::map > scalarNodeFieldAndComponentNames(); + virtual std::map > scalarElementNodeFieldAndComponentNames(); + virtual std::map > scalarIntegrationPointFieldAndComponentNames(); + + virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector* displacements); + + virtual void readNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues); + virtual void readElementNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues); + virtual void readIntegrationPointField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector*>* resultValues); + +private: + enum ResultPosition + { + NODAL, + ELEMENT_NODAL, + INTEGRATION_POINT + }; + + class RifOdbResultKey + { + public: + RifOdbResultKey(ResultPosition aResultPostion, const std::string& aFieldName) + : resultPostion(aResultPostion), fieldName(aFieldName) {}; + + ResultPosition resultPostion; + std::string fieldName; + + bool operator< (const RifOdbResultKey& other) const + { + if (resultPostion != other.resultPostion) + { + return (resultPostion < other.resultPostion); + } + + return (fieldName < other.fieldName); + } + }; + + void assertMetaDataLoaded(); + void close(); + size_t resultItemCount(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex); + size_t componentsCount(const std::string& fieldName, ResultPosition position); + const odb_Frame& stepFrame(int stepIndex, int frameIndex) const; + odb_Instance* instance(int instanceIndex); + + int componentIndex(const RifOdbResultKey& result, const std::string& componentName); + std::vector componentNames(const RifOdbResultKey& result); + std::map< std::string, std::vector > fieldAndComponentNames(ResultPosition position); + std::map< RifOdbResultKey, std::vector > readResultsMetaData(odb_Odb* odb); + +private: + odb_Odb* m_odb; + + std::map< RifOdbResultKey, std::vector > m_resultsMetaData; + std::map< int, std::vector > m_partElementSetNames; + std::vector< std::map > m_nodeIdToIdxMaps; + std::vector< std::map > m_elementIdToIdxMaps; + + static size_t sm_instanceCount; +}; diff --git a/ApplicationCode/GeoMech/OdbReader_UnitTests/CMakeLists.txt b/ApplicationCode/GeoMech/OdbReader_UnitTests/CMakeLists.txt new file mode 100644 index 0000000000..0c8636176b --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader_UnitTests/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required (VERSION 2.8) + +project ( OdbReader_UnitTests ) + +set(RI_VIZ_FWK_ROOT ../../../Fwk/VizFwk CACHE PATH "Path to VizFwk") +set(RI_GTEST_ROOT ../../../ThirdParty CACHE PATH "Path to folder containing gtest folder") +set(RI_TEST_FILE "" CACHE FILEPATH "Path to test file") + +include(${RI_VIZ_FWK_ROOT}/CMake/Utils/ceeDetermineCompilerFlags.cmake) + +add_subdirectory(${RI_VIZ_FWK_ROOT}/LibCore buildVizFwk) +add_subdirectory(../../ResultStatisticsCache buildResultStatisticsCache) +add_subdirectory(../OdbReader buildOdbReader) +add_subdirectory(../GeoMechDataModel buildGeoMechDataModel) + +add_definitions( -DTEST_FILE="${RI_TEST_FILE}") + +include_directories(${RI_VIZ_FWK_ROOT}/LibCore) +include_directories(../../ResultStatisticsCache) +include_directories(../../ReservoirDataModel) +include_directories(../OdbReader) +include_directories(../GeoMechDataModel) +include_directories(${RI_GTEST_ROOT}) + +set( UNIT_TEST_CPP_SOURCES + main.cpp + RifOdbReader-Test.cpp + ${RI_GTEST_ROOT}/gtest/gtest-all.cc +) + +add_executable( ${PROJECT_NAME} ${UNIT_TEST_CPP_SOURCES} ) +target_link_libraries( ${PROJECT_NAME} RifOdbReader) + +include(../OdbReader/OdbSetup.cmake) \ No newline at end of file diff --git a/ApplicationCode/GeoMech/OdbReader_UnitTests/RifOdbReader-Test.cpp b/ApplicationCode/GeoMech/OdbReader_UnitTests/RifOdbReader-Test.cpp new file mode 100644 index 0000000000..5b345d7be2 --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader_UnitTests/RifOdbReader-Test.cpp @@ -0,0 +1,125 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "gtest/gtest.h" +#include "RifOdbReader.h" +#include "RigGeoMechCaseData.h" +#include "RigFemPartCollection.h" + +#include "cvfDebugTimer.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(OdbReaderTest, BasicTests) +{ + std::cout << TEST_FILE << std::endl; + std::cout << std::endl; + cvf::ref reader = new RifOdbReader; + cvf::ref femCase = new RigGeoMechCaseData(""); + cvf::ref femData = femCase->femParts(); + + cvf::DebugTimer timer("DebugTimer"); + timer.reportTime(); + + reader->openFile(TEST_FILE); + reader->readFemParts(femData.p()); + + EXPECT_EQ(1, femData->partCount()); + EXPECT_EQ(4320, femData->part(0)->elementCount()); + EXPECT_EQ(HEX8, femData->part(0)->elementType(0)); + + EXPECT_EQ(true, reader->stepNames().size() == 1); + + std::vector steps = reader->stepNames(); + EXPECT_EQ(true, steps.at(0).find("Date_20100930") >= 0); + EXPECT_EQ(2, reader->frameTimes(0).size()); + EXPECT_EQ(1.0, reader->frameTimes(0)[1]); + + std::map > scalarNodeFieldsMap = reader->scalarNodeFieldAndComponentNames(); + EXPECT_EQ(3, scalarNodeFieldsMap.size()); + + std::map > scalarElementNodeFieldsMap = reader->scalarElementNodeFieldAndComponentNames(); + EXPECT_EQ(0, scalarElementNodeFieldsMap.size()); + + std::map > scalarIntegrationPointFieldsMap = reader->scalarIntegrationPointFieldAndComponentNames(); + EXPECT_EQ(6, scalarIntegrationPointFieldsMap.size()); + + std::vector displacementValues; + reader->readScalarNodeField("U", "U2", 0, 0, 1, &displacementValues); + EXPECT_EQ(5168, displacementValues.size()); + + std::vector integrationPointS22; + timer.restart(); + reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22); + timer.reportLapTime("Read S/S22"); + timer.restart(); + reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22); + timer.reportLapTime("Read S/S22 2nd time"); + timer.restart(); + reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22); + timer.reportLapTime("Read S/S22 3rd time"); + EXPECT_EQ(34560, integrationPointS22.size()); + EXPECT_FLOAT_EQ(-1921117.3, integrationPointS22[0]); + EXPECT_FLOAT_EQ(-1408592.5, integrationPointS22[1]); + EXPECT_FLOAT_EQ(-1345666.9, integrationPointS22[2]); + + std::vector elementNodeS11; + reader->readScalarElementNodeField("S", "S11", 0, 0, 1, &elementNodeS11); + EXPECT_EQ(34560, elementNodeS11.size()); + EXPECT_FLOAT_EQ(-2074357.3, elementNodeS11[0]); + EXPECT_FLOAT_EQ(-1353137.5, elementNodeS11[1]); + EXPECT_FLOAT_EQ(-1144559.4, elementNodeS11[2]); + + std::vector integrationPointE33; + reader->readScalarIntegrationPointField("E", "E33", 0, 0, 1, &integrationPointE33); + EXPECT_EQ(34560, integrationPointE33.size()); + + std::vector integrationPointTEMP; + reader->readScalarIntegrationPointField("TEMP", "", 0, 0, 1, &integrationPointTEMP); + EXPECT_EQ(34560, integrationPointTEMP.size()); + + std::vector displacements; + reader->readDisplacements(0, 0, 1, &displacements); + EXPECT_EQ(5168, displacements.size()); + EXPECT_FLOAT_EQ(0.047638997, displacements[1].y()); + EXPECT_FLOAT_EQ(-0.0036307564, displacements[6].x()); + EXPECT_FLOAT_EQ(0.065709047, displacements[6].y()); + EXPECT_FLOAT_EQ(-0.059760433, displacements[6].z()); + + std::vector porValues; + reader->readScalarNodeField("POR", "", 0, 0, 1, &porValues); + EXPECT_EQ(5168, porValues.size()); + + std::vector voidrValues; + reader->readScalarIntegrationPointField("VOIDR", "", 0, 0, 0, &voidrValues); + EXPECT_EQ(34560, voidrValues.size()); + EXPECT_FLOAT_EQ(0.22864963, voidrValues[0]); + EXPECT_FLOAT_EQ(0.23406270, voidrValues[1]); + EXPECT_FLOAT_EQ(0.24549910, voidrValues[2]); + + timer.restart(); + reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22); + timer.reportLapTime("Read S/S22 final time"); +} + + diff --git a/ApplicationCode/GeoMech/OdbReader_UnitTests/main.cpp b/ApplicationCode/GeoMech/OdbReader_UnitTests/main.cpp new file mode 100644 index 0000000000..143593e6c0 --- /dev/null +++ b/ApplicationCode/GeoMech/OdbReader_UnitTests/main.cpp @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015 - Statoil ASA +// Copyright (C) 2015 - Ceetron Solutions AS +// +// 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 "cvfBase.h" + +#include "gtest/gtest.h" +#include + +#include "cvfTrace.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int main(int argc, char **argv) +{ + cvf::Assert::setReportMode(cvf::Assert::CONSOLE); + + testing::InitGoogleTest(&argc, argv); + + int result = RUN_ALL_TESTS(); + + std::cout << "Please press to close the window."; + std::cin.get(); + + return result; +} diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index fec6bd6869..97009bc04c 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -30,6 +30,8 @@ ${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.h ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.h ${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.h ${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h + + ) set (SOURCE_GROUP_SOURCE_FILES @@ -56,6 +58,7 @@ ${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.cpp ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.cpp ${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.cpp ${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp + ) list(APPEND CODE_HEADER_FILES @@ -66,4 +69,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ) +source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/CMakeLists.txt b/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/CMakeLists.txt index 97e839bfc1..3f8c05e07e 100644 --- a/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/CMakeLists.txt +++ b/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/CMakeLists.txt @@ -61,6 +61,10 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set( EXTERNAL_LINK_LIBRARIES pthread ) +ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set( CMAKE_CXX_FLAGS + "-DGTEST_USE_OWN_TR1_TUPLE=1" + ) ENDIF() target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES}) diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index 3171aad530..bcde980d5c 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -49,6 +49,7 @@ CellEdgeEffectGenerator::CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeSc m_cullBackfaces = caf::FC_NONE; m_opacityLevel = 1.0f; m_defaultCellColor = cvf::Color3f(cvf::Color3::WHITE); + m_disableLighting = false; } //-------------------------------------------------------------------------------------------------- @@ -82,6 +83,7 @@ bool CellEdgeEffectGenerator::isEqual(const EffectGenerator* other) const && m_opacityLevel == otherCellFaceEffectGenerator->m_opacityLevel && m_undefinedColor == otherCellFaceEffectGenerator->m_undefinedColor && m_defaultCellColor == otherCellFaceEffectGenerator->m_defaultCellColor + && m_disableLighting == otherCellFaceEffectGenerator->m_disableLighting ) { cvf::ref texImg2 = new cvf::TextureImage; @@ -121,6 +123,7 @@ caf::EffectGenerator* CellEdgeEffectGenerator::copy() const newEffect->setFaceCulling(m_cullBackfaces); newEffect->setUndefinedColor(m_undefinedColor); newEffect->setDefaultCellColor(m_defaultCellColor); + newEffect->disableLighting(m_disableLighting); return newEffect; } @@ -179,8 +182,16 @@ void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) } } - shaderGen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); - shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + if (m_disableLighting) + { + shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit); + } + else + { + shaderGen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); + shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + } + cvf::ref prog = shaderGen.generate(); eff->setShaderProgram(prog.p()); diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h index 967cc0de12..52f6b1d8e7 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h @@ -110,6 +110,7 @@ class CellEdgeEffectGenerator : public caf::EffectGenerator void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; } void setFaceCulling(caf::FaceCulling faceCulling) { m_cullBackfaces = faceCulling; } void setDefaultCellColor(cvf::Color3f color) { m_defaultCellColor = color; } + void disableLighting(bool disable) { m_disableLighting = disable; } protected: virtual bool isEqual( const EffectGenerator* other ) const; @@ -130,5 +131,6 @@ class CellEdgeEffectGenerator : public caf::EffectGenerator caf::FaceCulling m_cullBackfaces; cvf::Color3f m_undefinedColor; cvf::Color3f m_defaultCellColor; + bool m_disableLighting; }; diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp index c23b50c919..b32a9f8b1b 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp @@ -26,12 +26,12 @@ #include "RigGridBase.h" #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" -#include "RimCase.h" -#include "RimCellEdgeResultSlot.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseCase.h" +#include "RimCellEdgeColors.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" #include "RimTernaryLegendConfig.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "RivTernaryTextureCoordsCreator.h" #include "cvfDrawableGeo.h" @@ -43,20 +43,20 @@ //-------------------------------------------------------------------------------------------------- void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( size_t timeStepIndex, - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors, const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper, cvf::DrawableGeo* geo, size_t gridIndex, float opacityLevel) { - RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData(); CVF_ASSERT(eclipseCase != NULL); // Create result access objects - cvf::ref cellCenterDataAccessObject = createCellCenterResultAccessor(cellResultSlot, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); - cvf::ref cellEdgeResultAccessor = createCellEdgeCenterResultAccessor(cellResultSlot, cellEdgeResultSlot, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); + cvf::ref cellCenterDataAccessObject = createCellCenterResultAccessor(cellResultColors, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); + cvf::ref cellEdgeResultAccessor = createCellEdgeCenterResultAccessor(cellResultColors, cellEdgeResultColors, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); size_t vertexCount = geo->vertexArray()->size(); size_t quadCount = vertexCount / 4; @@ -80,17 +80,17 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( cellEdgeColorTextureCoordsArrays.push_back(colorArray.p()); } - cvf::ScalarMapper* cellResultScalarMapper = cellResultSlot->legendConfig()->scalarMapper(); - cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultSlot->legendConfig()->scalarMapper(); + cvf::ScalarMapper* cellResultScalarMapper = cellResultColors->legendConfig()->scalarMapper(); + cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultColors->legendConfig()->scalarMapper(); - double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue(); + double ignoredScalarValue = cellEdgeResultColors->ignoredScalarValue(); const std::vector* isWellPipeVisible = NULL; cvf::ref gridCellToWellindexMap; if (opacityLevel < 1.0f) { - isWellPipeVisible = &(cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex)); + isWellPipeVisible = &(cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex)); gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(gridIndex); } @@ -187,14 +187,14 @@ bool RivCellEdgeGeometryUtils::hideScalarValue(double scalarValue, double scalar //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot, +void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors, const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper, cvf::DrawableGeo* geo, size_t gridIndex, float opacityLevel) { - RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData(); CVF_ASSERT(eclipseCase != NULL); - cvf::ref cellEdgeResultAccessor = createCellEdgeCenterResultAccessor(cellResultSlot, cellEdgeResultSlot, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); + cvf::ref cellEdgeResultAccessor = createCellEdgeCenterResultAccessor(cellResultColors, cellEdgeResultColors, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); size_t vertexCount = geo->vertexArray()->size(); size_t quadCount = vertexCount / 4; @@ -218,12 +218,12 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t tim cellEdgeColorTextureCoordsArrays.push_back(colorArray.p()); } - RivTernaryScalarMapper* ternaryCellResultScalarMapper = cellResultSlot->ternaryLegendConfig()->scalarMapper(); - cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultSlot->legendConfig()->scalarMapper(); + RivTernaryScalarMapper* ternaryCellResultScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); + cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultColors->legendConfig()->scalarMapper(); - double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue(); + double ignoredScalarValue = cellEdgeResultColors->ignoredScalarValue(); - RivTernaryTextureCoordsCreator texturer(cellResultSlot, cellResultSlot->ternaryLegendConfig(), + RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex, gridIndex, quadToCellFaceMapper); @@ -285,8 +285,8 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t tim /// //-------------------------------------------------------------------------------------------------- cvf::ref RivCellEdgeGeometryUtils::createCellEdgeCenterResultAccessor( - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors, size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid) @@ -294,8 +294,8 @@ cvf::ref RivCellEdgeGeometryUtils::createCellEdgeCenterResult cvf::ref cellEdgeResultAccessor = new RigCellEdgeResultAccessor(); { size_t resultIndices[6]; - cellEdgeResultSlot->gridScalarIndices(resultIndices); - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); + cellEdgeResultColors->gridScalarIndices(resultIndices); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()); size_t cubeFaceIdx; for (cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++) @@ -312,20 +312,20 @@ cvf::ref RivCellEdgeGeometryUtils::createCellEdgeCenterResult //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivCellEdgeGeometryUtils::createCellCenterResultAccessor(RimResultSlot* cellResultSlot, size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid) +cvf::ref RivCellEdgeGeometryUtils::createCellCenterResultAccessor(RimEclipseCellColors* cellResultColors, size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid) { cvf::ref resultAccessor = NULL; - if (cellResultSlot->hasResult()) + if (cellResultColors->hasResult()) { - if (!cellResultSlot->hasDynamicResult()) + if (!cellResultColors->hasDynamicResult()) { // Static result values are located at time step 0 timeStepIndex = 0; } - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, timeStepIndex, cellResultSlot->resultVariable()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()); + resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, timeStepIndex, cellResultColors->resultVariable()); } if (resultAccessor.isNull()) diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h index ce11b19a18..2bfb42c840 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h +++ b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h @@ -28,8 +28,8 @@ namespace cvf class StructGridQuadToCellFaceMapper; } -class RimCellEdgeResultSlot; -class RimResultSlot; +class RimCellEdgeColors; +class RimEclipseCellColors; class RigGridBase; class RigResultAccessor; class RigCaseData; @@ -39,16 +39,16 @@ class RivCellEdgeGeometryUtils { public: static void addCellEdgeResultsToDrawableGeo(size_t timeStepIndex, - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors, const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper, cvf::DrawableGeo* geo, size_t gridIndex, float opacityLevel); static void addTernaryCellEdgeResultsToDrawableGeo(size_t timeStepIndex, - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors, const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper, cvf::DrawableGeo* geo, size_t gridIndex, @@ -57,14 +57,14 @@ class RivCellEdgeGeometryUtils private: static cvf::ref createCellCenterResultAccessor( - RimResultSlot* cellResultSlot, + RimEclipseCellColors* cellResultColors, size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid); static cvf::ref createCellEdgeCenterResultAccessor( - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors, size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid); diff --git a/ApplicationCode/ModelVisualization/RivCellSetEnum.h b/ApplicationCode/ModelVisualization/RivCellSetEnum.h new file mode 100644 index 0000000000..0382ddc23f --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivCellSetEnum.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 + +enum RivCellSetEnum +{ + ALL_CELLS, + ACTIVE, ///< All Active cells without ALL_WELL_CELLS + ALL_WELL_CELLS, ///< All cells ever having a connection to a well (Might be inactive cells as well. Wellhead cells typically) + VISIBLE_WELL_CELLS, ///< ALL_WELL_CELLS && visible well cells including Fence + VISIBLE_WELL_FENCE_CELLS, ///< (! ALL_WELL_CELLS) && visible well cells including Fence + INACTIVE, ///< All inactive cells, but invalid cells might or might not be included + RANGE_FILTERED, ///< ACTIVE Filtered by the set of range filters + RANGE_FILTERED_INACTIVE, ///< INACTIVE Filtered by the set of range filters + RANGE_FILTERED_WELL_CELLS, ///< ALL_WELL_CELLS Filtered by the set of range filters + VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER, ///< VISIBLE_WELL_CELLS && !RANGE_FILTERED_WELL_CELLS + VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER, ///< VISIBLE_WELL_FENCE_CELLS && !RANGE_FILTERED + PROPERTY_FILTERED, ///< (RANGE_FILTERED || VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER) && !ExcludedByPropFilter && IncludedByPropFilter + PROPERTY_FILTERED_WELL_CELLS ///< (!(hasActiveRangeFilters || visibleWellCells) && (*ALL_WELL_CELLS)) || RANGE_FILTERED_WELL_CELLS || VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER +}; + + diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 773a1314e6..9a068e907c 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -26,10 +26,10 @@ #include "RigCaseData.h" #include "RigResultAccessor.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimFaultCollection.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" #include "RimTernaryLegendConfig.h" #include "RivResultToTextureMapper.h" @@ -94,40 +94,40 @@ void RivFaultPartMgr::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot) +void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors) { - CVF_ASSERT(cellResultSlot); + CVF_ASSERT(cellResultColors); - updateNNCColors(cellResultSlot); + updateNNCColors(cellResultColors); - size_t scalarSetIndex = cellResultSlot->scalarResultIndex(); + size_t scalarSetIndex = cellResultColors->scalarResultIndex(); // If the result is static, only read that. size_t resTimeStepIdx = timeStepIndex; - if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0; + if (cellResultColors->hasStaticResult()) resTimeStepIdx = 0; - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - - RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()); + RimEclipseView* eclipseView = cellResultColors->reservoirView(); + RigCaseData* eclipseCase = eclipseView->eclipseCase()->reservoirData(); // Faults if (m_nativeFaultFaces.notNull()) { - if (cellResultSlot->isTernarySaturationSelected()) + if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultSlot, cellResultSlot->ternaryLegendConfig(), + RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex, m_grid->gridIndex(), m_nativeFaultGenerator->quadToCellFaceMapper()); texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p()); - const RivTernaryScalarMapper* mapper = cellResultSlot->ternaryLegendConfig()->scalarMapper(); - RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_nativeFaultFaces.p(), m_nativeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode()); + const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); + RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_nativeFaultFaces.p(), m_nativeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); } else { - RivTextureCoordsCreator texturer(cellResultSlot, + RivTextureCoordsCreator texturer(cellResultColors, timeStepIndex, m_grid->gridIndex(), m_nativeFaultGenerator->quadToCellFaceMapper()); @@ -139,28 +139,28 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p()); - const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper(); - RivScalarMapperUtils::applyTextureResultsToPart(m_nativeFaultFaces.p(), m_nativeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode()); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + RivScalarMapperUtils::applyTextureResultsToPart(m_nativeFaultFaces.p(), m_nativeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); } } if (m_oppositeFaultFaces.notNull()) { - if (cellResultSlot->isTernarySaturationSelected()) + if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultSlot, cellResultSlot->ternaryLegendConfig(), + RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex, m_grid->gridIndex(), m_oppositeFaultGenerator->quadToCellFaceMapper()); texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p()); - const RivTernaryScalarMapper* mapper = cellResultSlot->ternaryLegendConfig()->scalarMapper(); - RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_oppositeFaultFaces.p(), m_oppositeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode()); + const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); + RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_oppositeFaultFaces.p(), m_oppositeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); } else { - RivTextureCoordsCreator texturer(cellResultSlot, + RivTextureCoordsCreator texturer(cellResultColors, timeStepIndex, m_grid->gridIndex(), m_oppositeFaultGenerator->quadToCellFaceMapper()); @@ -172,8 +172,8 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p()); - const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper(); - RivScalarMapperUtils::applyTextureResultsToPart(m_oppositeFaultFaces.p(), m_oppositeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode()); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + RivScalarMapperUtils::applyTextureResultsToPart(m_oppositeFaultFaces.p(), m_oppositeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); } } } @@ -181,9 +181,9 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) +void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) { - updateNNCColors(cellResultSlot); + updateNNCColors(cellResultColors); if (m_nativeFaultFaces.notNull()) { @@ -192,7 +192,7 @@ void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultS { cvf::ref eff = RivScalarMapperUtils::createCellEdgeEffect(dg, m_nativeFaultGenerator->quadToCellFaceMapper(), m_grid->gridIndex(), - timeStepIndex, cellResultSlot, cellEdgeResultSlot, m_opacityLevel, m_defaultColor, this->faceCullingMode()); + timeStepIndex, cellResultColors, cellEdgeResultColors, m_opacityLevel, m_defaultColor, this->faceCullingMode(), cellResultColors->reservoirView()->isLightingDisabled()); m_nativeFaultFaces->setEffect(eff.p()); } @@ -204,7 +204,7 @@ void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultS if (dg) { cvf::ref eff = RivScalarMapperUtils::createCellEdgeEffect(dg, m_oppositeFaultGenerator->quadToCellFaceMapper(), m_grid->gridIndex(), - timeStepIndex, cellResultSlot, cellEdgeResultSlot, m_opacityLevel, m_defaultColor, this->faceCullingMode()); + timeStepIndex, cellResultColors, cellEdgeResultColors, m_opacityLevel, m_defaultColor, this->faceCullingMode(), cellResultColors->reservoirView()->isLightingDisabled()); m_oppositeFaultFaces->setEffect(eff.p()); } @@ -236,11 +236,10 @@ void RivFaultPartMgr::generatePartGeometry() cvf::ref part = new cvf::Part; part->setName("Grid " + cvf::String(static_cast(m_grid->gridIndex()))); - part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info) part->setDrawable(geo.p()); // Set mapping from triangle face index to cell index - cvf::ref si = new RivSourceInfo; + cvf::ref si = new RivSourceInfo(m_grid->gridIndex()); si->m_cellFaceFromTriangleMapper = m_nativeFaultGenerator->triangleToCellFaceMapper(); part->setSourceInfo(si.p()); @@ -289,11 +288,10 @@ void RivFaultPartMgr::generatePartGeometry() cvf::ref part = new cvf::Part; part->setName("Grid " + cvf::String(static_cast(m_grid->gridIndex()))); - part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info) part->setDrawable(geo.p()); // Set mapping from triangle face index to cell index - cvf::ref si = new RivSourceInfo; + cvf::ref si = new RivSourceInfo(m_grid->gridIndex()); si->m_cellFaceFromTriangleMapper = m_oppositeFaultGenerator->triangleToCellFaceMapper(); part->setSourceInfo(si.p()); @@ -340,11 +338,10 @@ void RivFaultPartMgr::generatePartGeometry() cvf::ref part = new cvf::Part; part->setName("NNC in Fault. Grid " + cvf::String(static_cast(m_grid->gridIndex()))); - part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info) part->setDrawable(geo.p()); // Set mapping from triangle face index to cell index - cvf::ref si = new RivSourceInfo; + cvf::ref si = new RivSourceInfo(m_grid->gridIndex());; si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p(); part->setSourceInfo(si.p()); @@ -447,6 +444,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part) labelPosition.z() += bb.extent().z() / 2; // Fault label + if (!m_rimFault->name().isEmpty()) { cvf::Font* standardFont = RiaApplication::instance()->standardFont(); @@ -646,15 +644,15 @@ caf::FaceCulling RivFaultPartMgr::faceCullingMode() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivFaultPartMgr::updateNNCColors(RimResultSlot* cellResultSlot) +void RivFaultPartMgr::updateNNCColors(RimEclipseCellColors* cellResultColors) { if (m_NNCFaces.isNull()) return; bool showNncsWithScalarMappedColor = false; - if (cellResultSlot) + if (cellResultColors) { - size_t scalarSetIndex = cellResultSlot->scalarResultIndex(); + size_t scalarSetIndex = cellResultColors->scalarResultIndex(); if (m_grid->mainGrid()->nncData()->hasScalarValues(scalarSetIndex)) { @@ -664,9 +662,9 @@ void RivFaultPartMgr::updateNNCColors(RimResultSlot* cellResultSlot) if (showNncsWithScalarMappedColor) { - size_t scalarSetIndex = cellResultSlot->scalarResultIndex(); + size_t scalarSetIndex = cellResultColors->scalarResultIndex(); - const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper(); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); m_NNCGenerator->textureCoordinates(m_NNCTextureCoords.p(), mapper, scalarSetIndex); diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h index 5f21cc6cb7..5d58f30f93 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h @@ -37,8 +37,8 @@ namespace cvf class Part; } -class RimResultSlot; -class RimCellEdgeResultSlot; +class RimEclipseCellColors; +class RimCellEdgeColors; class RimFaultCollection; //================================================================================================== @@ -55,8 +55,8 @@ class RivFaultPartMgr : public cvf::Object void applySingleColorEffect(); void setOpacityLevel(float opacity) { m_opacityLevel = opacity; } - void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot); - void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot); + void updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors); + void updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors); void appendNativeFaultFacesToModel(cvf::ModelBasicList* model); void appendOppositeFaultFacesToModel(cvf::ModelBasicList* model); @@ -68,7 +68,7 @@ class RivFaultPartMgr : public cvf::Object void generatePartGeometry(); void updatePartEffect(); - void updateNNCColors(RimResultSlot* cellResultSlot); + void updateNNCColors(RimEclipseCellColors* cellResultColors); caf::FaceCulling faceCullingMode() const; diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 1c2a3d0c47..8b4241cbe0 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -27,13 +27,13 @@ #include "RigCaseData.h" #include "RigResultAccessorFactory.h" -#include "RimCase.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseCase.h" +#include "RimCellEdgeColors.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" #include "RimTernaryLegendConfig.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "RivCellEdgeEffectGenerator.h" #include "RivResultToTextureMapper.h" @@ -120,12 +120,11 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB cvf::ref part = new cvf::Part; part->setName("Grid " + cvf::String(static_cast(m_gridIdx))); - part->setId(m_gridIdx); // !! For now, use grid index as part ID (needed for pick info) part->setDrawable(geo.p()); part->setTransform(m_scaleTransform.p()); // Set mapping from triangle face index to cell index - cvf::ref si = new RivSourceInfo; + cvf::ref si = new RivSourceInfo(m_gridIdx); si->m_cellFaceFromTriangleMapper = geoBuilder.triangleToCellFaceMapper(); part->setSourceInfo(si.p()); @@ -222,32 +221,32 @@ void RivGridPartMgr::updateCellColor(cvf::Color4f color) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot) +void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors) { - CVF_ASSERT(cellResultSlot); + CVF_ASSERT(cellResultColors); - RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData(); cvf::ref surfaceFacesColorArray; // Outer surface if (m_surfaceFaces.notNull()) { - if (cellResultSlot->isTernarySaturationSelected()) + if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultSlot, cellResultSlot->ternaryLegendConfig(), + RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex, m_grid->gridIndex(), m_surfaceGenerator.quadToCellFaceMapper()); texturer.createTextureCoords(m_surfaceFacesTextureCoords.p()); - const RivTernaryScalarMapper* mapper = cellResultSlot->ternaryLegendConfig()->scalarMapper(); - RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE); + const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); + RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE, cellResultColors->reservoirView()->isLightingDisabled()); } else { - RivTextureCoordsCreator texturer(cellResultSlot, + RivTextureCoordsCreator texturer(cellResultColors, timeStepIndex, m_grid->gridIndex(), m_surfaceGenerator.quadToCellFaceMapper()); @@ -258,8 +257,8 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* texturer.createTextureCoords(m_surfaceFacesTextureCoords.p()); - const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper(); - RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE, cellResultColors->reservoirView()->isLightingDisabled()); } } } @@ -267,7 +266,7 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) +void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) { if (m_surfaceFaces.notNull()) { @@ -275,7 +274,7 @@ void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSl if (dg) { cvf::ref eff = RivScalarMapperUtils::createCellEdgeEffect(dg, m_surfaceGenerator.quadToCellFaceMapper(), m_grid->gridIndex(), - timeStepIndex, cellResultSlot, cellEdgeResultSlot, m_opacityLevel, m_defaultColor, caf::FC_NONE); + timeStepIndex, cellResultColors, cellEdgeResultColors, m_opacityLevel, m_defaultColor, caf::FC_NONE, cellResultColors->reservoirView()->isLightingDisabled()); m_surfaceFaces->setEffect(eff.p()); } diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.h b/ApplicationCode/ModelVisualization/RivGridPartMgr.h index a1b29cdb37..22ddb00930 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.h @@ -34,8 +34,8 @@ namespace cvf class Effect; } -class RimResultSlot; -class RimCellEdgeResultSlot; +class RimEclipseCellColors; +class RimCellEdgeColors; @@ -57,10 +57,10 @@ class RivGridPartMgr: public cvf::Object cvf::ref cellVisibility() { return m_cellVisibility;} void updateCellColor(cvf::Color4f color); - void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot); + void updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors); - void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot); + void updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); void appendPartsToModel(cvf::ModelBasicList* model); diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp index 9f9887babc..0bdeea610f 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp @@ -336,7 +336,11 @@ cvf::ref RivPipeGeometryGenerator::generateExtrudedCylinder(do cvf::Vec3d intersectionPlaneNormal = candidateDir + nextDir; - // if (intersectionPlaneNormal.lengthSquared() < 1e-10) intersectionPlaneNormal = nextDir; // candidateDir == -nextDir => 180 deg turn + if (intersectionPlaneNormal.lengthSquared() < 1e-10) // candidateDir == -nextDir => 180 deg turn + { + CVF_ASSERT(false); // This is never supposed to happen due to what's done in updateFilteredPipeCenterCoords(). So look there for the bug... + intersectionPlaneNormal = nextDir; + } computeExtrudedCoordsAndNormals(secondCoord, intersectionPlaneNormal, candidateDir, crossSectionNodeCount, &extrudedNodes, &crossSectionVertices, &cylinderSegmentNormals); } @@ -521,11 +525,18 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords() if (dotProduct > cosMinBendAngle) { bool success = false; - cvf::Vec3d pipeIntermediateDirection = (lastValidDirectionAB + directionBC.getNormalized()).getNormalized(&success); - if (!success) + + cvf::Vec3d pipeIntermediateDirection = (lastValidDirectionAB + directionBC.getNormalized()); + pipeIntermediateDirection.getNormalized(&success); + + if (pipeIntermediateDirection.lengthSquared() < squareDistanceTolerance) { pipeIntermediateDirection = lastValidDirectionAB.perpendicularVector(); } + else + { + pipeIntermediateDirection.normalize(); + } double bendRadius = m_bendScalingFactor * m_radius + 1.0e-30; cvf::Vec3d firstIntermediate = coordB - pipeIntermediateDirection * bendRadius; diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index b6ec6a08d9..659de5d5b7 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -28,16 +28,16 @@ #include "RigMainGrid.h" #include "RimFaultCollection.h" -#include "RimFaultResultSlot.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimCase.h" +#include "RimEclipseFaultColors.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseCase.h" #include "RigCaseData.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivReservoirFaultsPartMgr::RivReservoirFaultsPartMgr(const RigMainGrid* grid, RimReservoirView* reservoirView) +RivReservoirFaultsPartMgr::RivReservoirFaultsPartMgr(const RigMainGrid* grid, RimEclipseView* reservoirView) : m_reservoirView(reservoirView) { CVF_ASSERT(grid); @@ -142,8 +142,8 @@ void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model) } // Parts that is not overridden by the grid settings - RimFaultResultSlot* faultResultSlot = m_reservoirView->faultResultSettings(); - RimResultSlot* cellResultSlot = m_reservoirView->cellResult(); + RimEclipseFaultColors* faultResultColors = m_reservoirView->faultResultSettings(); + RimEclipseCellColors* cellResultColors = m_reservoirView->cellResult(); if (rimFault->showFault() && faultCollection->showFaultCollection()) { @@ -153,13 +153,13 @@ void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model) if (faultCollection->hideNncsWhenNoResultIsAvailable()) { size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - if (faultResultSlot->showCustomFaultResult()) + if (faultResultColors->showCustomFaultResult()) { - scalarResultIndex = faultResultSlot->customFaultResult()->scalarResultIndex(); + scalarResultIndex = faultResultColors->customFaultResult()->scalarResultIndex(); } else { - scalarResultIndex = cellResultSlot->scalarResultIndex(); + scalarResultIndex = cellResultColors->scalarResultIndex(); } RigMainGrid* mainGrid = m_reservoirView->eclipseCase()->reservoirData()->mainGrid(); @@ -200,7 +200,7 @@ void RivReservoirFaultsPartMgr::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirFaultsPartMgr::updateColors(size_t timeStepIndex, RimResultSlot* cellResultSlot) +void RivReservoirFaultsPartMgr::updateColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors) { if (!m_reservoirView) return; @@ -211,9 +211,9 @@ void RivReservoirFaultsPartMgr::updateColors(size_t timeStepIndex, RimResultSlot { RimFault* rimFault = faultCollection->faults[i]; - if (cellResultSlot && (cellResultSlot->hasResult() || cellResultSlot->isTernarySaturationSelected()) ) + if (cellResultColors && (cellResultColors->hasResult() || cellResultColors->isTernarySaturationSelected()) ) { - m_faultParts[i]->updateCellResultColor(timeStepIndex, cellResultSlot); + m_faultParts[i]->updateCellResultColor(timeStepIndex, cellResultColors); } else { @@ -225,11 +225,11 @@ void RivReservoirFaultsPartMgr::updateColors(size_t timeStepIndex, RimResultSlot //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirFaultsPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) +void RivReservoirFaultsPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) { for (size_t i = 0; i < m_faultParts.size(); i++) { - m_faultParts[i]->updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot); + m_faultParts[i]->updateCellEdgeResultColor(timeStepIndex, cellResultColors, cellEdgeResultColors); } } diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.h index 7723319ce0..6ec47c92f6 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.h @@ -30,9 +30,9 @@ namespace cvf class Transform; } -class RimResultSlot; -class RimCellEdgeResultSlot; -class RimReservoirView; +class RimEclipseCellColors; +class RimCellEdgeColors; +class RimEclipseView; //================================================================================================== /// @@ -40,7 +40,7 @@ class RimReservoirView; class RivReservoirFaultsPartMgr : public cvf::Object { public: - RivReservoirFaultsPartMgr(const RigMainGrid* grid, RimReservoirView* reservoirView); + RivReservoirFaultsPartMgr(const RigMainGrid* grid, RimEclipseView* reservoirView); ~RivReservoirFaultsPartMgr(); void setTransform(cvf::Transform* scaleTransform); @@ -49,9 +49,9 @@ class RivReservoirFaultsPartMgr : public cvf::Object void setOpacityLevel(float opacity); void applySingleColorEffect(); - void updateColors(size_t timeStepIndex, RimResultSlot* cellResultSlot); - void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot); + void updateColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors); + void updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); void appendPartsToModel(cvf::ModelBasicList* model); @@ -60,7 +60,7 @@ class RivReservoirFaultsPartMgr : public cvf::Object private: cvf::ref m_scaleTransform; - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; cvf::Collection m_faultParts; bool m_forceVisibility; }; diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp index c11bdfaac3..3d5c18190e 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp @@ -30,7 +30,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPartMgr::clearAndSetReservoir(const RigCaseData* eclipseCase, RimReservoirView* reservoirView) +void RivReservoirPartMgr::clearAndSetReservoir(const RigCaseData* eclipseCase, RimEclipseView* reservoirView) { m_allGrids.clear(); @@ -111,22 +111,22 @@ void RivReservoirPartMgr::updateCellColor(cvf::Color4f color) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot) +void RivReservoirPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors) { for (size_t i = 0; i < m_allGrids.size() ; ++i) { - m_allGrids[i]->updateCellResultColor(timeStepIndex, cellResultSlot); + m_allGrids[i]->updateCellResultColor(timeStepIndex, cellResultColors); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) +void RivReservoirPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) { for (size_t i = 0; i < m_allGrids.size() ; ++i) { - m_allGrids[i]->updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot); + m_allGrids[i]->updateCellEdgeResultColor(timeStepIndex, cellResultColors, cellEdgeResultColors); } } @@ -158,11 +158,11 @@ void RivReservoirPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPartMgr::updateFaultColors(size_t timeStepIndex, RimResultSlot* cellResultSlot) +void RivReservoirPartMgr::updateFaultColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors) { if (m_faultsPartMgr.notNull()) { - m_faultsPartMgr->updateColors(timeStepIndex, cellResultSlot); + m_faultsPartMgr->updateColors(timeStepIndex, cellResultColors); } } @@ -202,11 +202,11 @@ void RivReservoirPartMgr::setFaultForceVisibility(bool isGeneratedByFilter) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPartMgr::updateFaultCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) +void RivReservoirPartMgr::updateFaultCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) { if (m_faultsPartMgr.notNull()) { - m_faultsPartMgr->updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot); + m_faultsPartMgr->updateCellEdgeResultColor(timeStepIndex, cellResultColors, cellEdgeResultColors); } } diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h index 1e9e2b894b..5616f7cd25 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h @@ -23,6 +23,7 @@ #include "cvfArray.h" #include "cvfCollection.h" +#include "RivGridPartMgr.h" #include "RivReservoirFaultsPartMgr.h" namespace cvf @@ -31,11 +32,10 @@ namespace cvf class Transform; } -class RimResultSlot; -class RimCellEdgeResultSlot; -class RivGridPartMgr; +class RimEclipseCellColors; +class RimCellEdgeColors; class RigCaseData; -class RimReservoirView; +class RimEclipseView; //================================================================================================== /// @@ -47,7 +47,7 @@ class RimReservoirView; class RivReservoirPartMgr: public cvf::Object { public: - void clearAndSetReservoir(const RigCaseData* eclipseCase, RimReservoirView* reservoirView); + void clearAndSetReservoir(const RigCaseData* eclipseCase, RimEclipseView* reservoirView); void setTransform(cvf::Transform* scaleTransform); void setCellVisibility(size_t gridIndex, cvf::UByteArray* cellVisibilities ); void setFaultForceVisibility(bool isGeneratedByFilter); @@ -57,17 +57,17 @@ class RivReservoirPartMgr: public cvf::Object cellVisibility(size_t gridIdx); void updateCellColor(cvf::Color4f color); - void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot); - void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot); + void updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors); + void updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); void appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector& gridIdxes); void appendGridPartsToModel(cvf::ModelBasicList* model); // Faults - void updateFaultColors(size_t timeStepIndex, RimResultSlot* cellResultSlot); - void updateFaultCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot); + void updateFaultColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors); + void updateFaultCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); void appendFaultPartsToModel(cvf::ModelBasicList* model); void appendFaultLabelPartsToModel(cvf::ModelBasicList* model); private: diff --git a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp index 0ac416a076..7b9d911897 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp @@ -21,24 +21,24 @@ #include "RiaStdInclude.h" #include "RivReservoirPipesPartMgr.h" -#include "RimReservoirView.h" -#include "RimWell.h" -#include "RimWellCollection.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" +#include "RimEclipseWellCollection.h" #include "RivWellPipesPartMgr.h" #include "RivWellHeadPartMgr.h" -#include "RimCellEdgeResultSlot.h" +#include "RimCellEdgeColors.h" #include "cafPdmFieldCvfMat4d.h" #include "cafPdmFieldCvfColor.h" -#include "RimResultSlot.h" +#include "RimEclipseCellColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" #include "Rim3dOverlayInfoConfig.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivReservoirPipesPartMgr::RivReservoirPipesPartMgr(RimReservoirView* reservoirView) +RivReservoirPipesPartMgr::RivReservoirPipesPartMgr(RimEclipseView* reservoirView) { m_reservoirView = reservoirView; @@ -103,7 +103,7 @@ void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic { if (!m_reservoirView->wellCollection()->isActive()) return; - if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF) return; + if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_FORCE_ALL_OFF) return; if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size()) { diff --git a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h index 466627174b..1ba2b7a310 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h @@ -18,19 +18,19 @@ #pragma once -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "cvfCollection.h" -class RimReservoirView; +class RimEclipseView; class RivWellPipesPartMgr; class RivWellHeadPartMgr; class RivReservoirPipesPartMgr : public cvf::Object { public: - RivReservoirPipesPartMgr(RimReservoirView* reservoirView); + RivReservoirPipesPartMgr(RimEclipseView* reservoirView); ~RivReservoirPipesPartMgr(); void clearGeometryCache(); @@ -42,7 +42,7 @@ class RivReservoirPipesPartMgr : public cvf::Object void updatePipeResultColor(size_t frameIndex); private: - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; cvf::ref m_scaleTransform; cvf::Collection< RivWellPipesPartMgr > m_wellPipesPartMgrs; diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index f094460efd..d49c06c592 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -28,23 +28,23 @@ #include "RigResultAccessorFactory.h" #include "Rim3dOverlayInfoConfig.h" -#include "RimCase.h" -#include "RimCellEdgeResultSlot.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimCellEdgeColors.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimCellRangeFilterCollection.h" #include "RimFaultCollection.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultDefinition.h" -#include "RimResultSlot.h" -#include "RimWellCollection.h" +#include "RimEclipseView.h" +#include "RimEclipseResultDefinition.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseWellCollection.h" #include "RivGridPartMgr.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivReservoirViewPartMgr::RivReservoirViewPartMgr(RimReservoirView * resv) : +RivReservoirViewPartMgr::RivReservoirViewPartMgr(RimEclipseView * resv) : m_reservoirView(resv) { m_scaleTransform = new cvf::Transform(); @@ -55,7 +55,7 @@ m_reservoirView(resv) //-------------------------------------------------------------------------------------------------- /// Clears the geometry cache for the given, and the dependent geometryTypes (from a visibility standpoint) //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::scheduleGeometryRegen(ReservoirGeometryCacheType geometryType) +void RivReservoirViewPartMgr::scheduleGeometryRegen(RivCellSetEnum geometryType) { switch (geometryType) { @@ -139,7 +139,7 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen(ReservoirGeometryCacheType g //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geomType) +void RivReservoirViewPartMgr::clearGeometryCache(RivCellSetEnum geomType) { RigCaseData* eclipseCase = NULL; if (m_reservoirView != NULL && m_reservoirView->eclipseCase()) @@ -201,7 +201,7 @@ void RivReservoirViewPartMgr::clearGeometryCache() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, +void RivReservoirViewPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, const std::vector& gridIndices) { if (m_geometriesNeedsRegen[geometryType]) @@ -214,7 +214,7 @@ void RivReservoirViewPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicLi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, +void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex, const std::vector& gridIndices) { if (geometryType == PROPERTY_FILTERED) @@ -238,7 +238,7 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometryType) +void RivReservoirViewPartMgr::createGeometry(RivCellSetEnum geometryType) { RigCaseData* res = m_reservoirView->eclipseCase()->reservoirData(); m_geometries[geometryType].clearAndSetReservoir(res, m_reservoirView); @@ -261,7 +261,7 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx) +void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, RivCellSetEnum geometryType, RigGridBase* grid, size_t gridIdx) { RigCaseData* eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); RigActiveCellInfo* activeCellInfo = m_reservoirView->currentActiveCellInfo(); @@ -608,8 +608,11 @@ void RivReservoirViewPartMgr::copyByteArray(cvf::UByteArray* destination, const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::computeRangeVisibility(ReservoirGeometryCacheType geometryType, cvf::UByteArray* cellVisibility, const RigGridBase* grid, - const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl) +void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType, + cvf::UByteArray* cellVisibility, + const RigGridBase* grid, + const cvf::UByteArray* nativeVisibility, + const RimCellRangeFilterCollection* rangeFilterColl) { CVF_ASSERT(cellVisibility != NULL); CVF_ASSERT(nativeVisibility != NULL); @@ -625,7 +628,7 @@ void RivReservoirViewPartMgr::computeRangeVisibility(ReservoirGeometryCacheType { // Build range filter for current grid cvf::CellRangeFilter gridCellRangeFilter; - rangeFilterColl->compoundCellRangeFilter(&gridCellRangeFilter, grid); + rangeFilterColl->compoundCellRangeFilter(&gridCellRangeFilter, grid->gridIndex()); const RigLocalGrid* lgr = NULL; cvf::ref parentGridVisibilities; @@ -693,7 +696,7 @@ void RivReservoirViewPartMgr::computeRangeVisibility(ReservoirGeometryCacheType /// //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex, - const cvf::UByteArray* rangeFilterVisibility, RimCellPropertyFilterCollection* propFilterColl) + const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl) { CVF_ASSERT(cellVisibility != NULL); CVF_ASSERT(rangeFilterVisibility != NULL); @@ -707,30 +710,31 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis if (propFilterColl->hasActiveFilters()) { - std::list< caf::PdmPointer< RimCellPropertyFilter > >::const_iterator pfIt; - for (pfIt = propFilterColl->propertyFilters().begin(); pfIt != propFilterColl->propertyFilters().end(); ++pfIt) + for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) { - if ((*pfIt)->isActive()&& (*pfIt)->resultDefinition->hasResult()) + RimEclipsePropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; + + if (propertyFilter->isActive()&& propertyFilter->resultDefinition->hasResult()) { - const double lowerBound = (*pfIt)->lowerBound(); - const double upperBound = (*pfIt)->upperBound(); + const double lowerBound = propertyFilter->lowerBound(); + const double upperBound = propertyFilter->upperBound(); - size_t scalarResultIndex = (*pfIt)->resultDefinition->scalarResultIndex(); + size_t scalarResultIndex = propertyFilter->resultDefinition->scalarResultIndex(); size_t adjustedTimeStepIndex = timeStepIndex; // Set time step to zero for static results - if ((*pfIt)->resultDefinition()->hasStaticResult()) + if (propertyFilter->resultDefinition()->hasStaticResult()) { adjustedTimeStepIndex = 0; } - const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode(); + const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(propertyFilter->resultDefinition()->porosityModel()); RigCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData(); - cvf::ref resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, adjustedTimeStepIndex, (*pfIt)->resultDefinition->resultVariable(), (*pfIt)->resultDefinition->resultType()); + cvf::ref resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, adjustedTimeStepIndex, propertyFilter->resultDefinition->resultVariable(), propertyFilter->resultDefinition->resultType()); CVF_ASSERT(resultAccessor.notNull()); //#pragma omp parallel for schedule(dynamic) @@ -765,7 +769,7 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, cvf::Color4f color) +void RivReservoirViewPartMgr::updateCellColor(RivCellSetEnum geometryType, size_t timeStepIndex, cvf::Color4f color) { RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex ); pmgr->updateCellColor(color); @@ -774,7 +778,7 @@ void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometryType, cvf::Color4f color) +void RivReservoirViewPartMgr::updateCellColor(RivCellSetEnum geometryType, cvf::Color4f color) { //CVF_ASSERT(geometryType != PROPERTY_FILTERED); //CVF_ASSERT(geometryType != PROPERTY_FILTERED_WELL_CELLS); @@ -785,40 +789,40 @@ void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::updateCellResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot) +void RivReservoirViewPartMgr::updateCellResultColor(RivCellSetEnum geometryType, size_t timeStepIndex, RimEclipseCellColors* cellResultColors) { RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex ); - pmgr->updateCellResultColor(timeStepIndex, cellResultSlot); + pmgr->updateCellResultColor(timeStepIndex, cellResultColors); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) +void RivReservoirViewPartMgr::updateCellEdgeResultColor(RivCellSetEnum geometryType, size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) { RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex ); - pmgr->updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot); + pmgr->updateCellEdgeResultColor(timeStepIndex, cellResultColors, cellEdgeResultColors); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::updateFaultCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) +void RivReservoirViewPartMgr::updateFaultCellEdgeResultColor(RivCellSetEnum geometryType, size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) { RivReservoirPartMgr * pmgr = reservoirPartManager(geometryType, timeStepIndex); - pmgr->updateFaultCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot); + pmgr->updateFaultCellEdgeResultColor(timeStepIndex, cellResultColors, cellEdgeResultColors); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::cref RivReservoirViewPartMgr::cellVisibility(ReservoirGeometryCacheType geometryType, size_t gridIndex, size_t timeStepIndex) const +cvf::cref RivReservoirViewPartMgr::cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t timeStepIndex) const { RivReservoirPartMgr * pmgr = (const_cast(this))->reservoirPartManager( geometryType, timeStepIndex ); return pmgr->cellVisibility(gridIndex).p(); } -RivReservoirPartMgr * RivReservoirViewPartMgr::reservoirPartManager(ReservoirGeometryCacheType geometryType, size_t timeStepIndex ) +RivReservoirPartMgr * RivReservoirViewPartMgr::reservoirPartManager(RivCellSetEnum geometryType, size_t timeStepIndex ) { if (geometryType == PROPERTY_FILTERED) { @@ -837,7 +841,7 @@ RivReservoirPartMgr * RivReservoirViewPartMgr::reservoirPartManager(ReservoirGeo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::updateFaultColors(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot) +void RivReservoirViewPartMgr::updateFaultColors(RivCellSetEnum geometryType, size_t timeStepIndex, RimEclipseCellColors* cellResultColors) { if (geometryType == PROPERTY_FILTERED && timeStepIndex >= m_propFilteredGeometryFrames.size()) { @@ -850,13 +854,13 @@ void RivReservoirViewPartMgr::updateFaultColors(ReservoirGeometryCacheType geome } RivReservoirPartMgr* pmgr = reservoirPartManager(geometryType, timeStepIndex); - pmgr->updateFaultColors(timeStepIndex, cellResultSlot); + pmgr->updateFaultColors(timeStepIndex, cellResultColors); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType) +void RivReservoirViewPartMgr::appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType) { if (m_geometriesNeedsRegen[geometryType]) { @@ -868,7 +872,7 @@ void RivReservoirViewPartMgr::appendFaultsStaticGeometryPartsToModel(cvf::ModelB //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, size_t frameIndex) +void RivReservoirViewPartMgr::appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex) { if (geometryType == PROPERTY_FILTERED) { @@ -883,7 +887,7 @@ void RivReservoirViewPartMgr::appendFaultsDynamicGeometryPartsToModel(cvf::Model //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivReservoirViewPartMgr::ReservoirGeometryCacheType RivReservoirViewPartMgr::geometryTypeForFaultLabels(const std::vector& geometryTypes) const +RivCellSetEnum RivReservoirViewPartMgr::geometryTypeForFaultLabels(const std::vector& geometryTypes) const { bool hasInactive = false; for (size_t i = 0; i < geometryTypes.size(); i++) @@ -915,7 +919,7 @@ RivReservoirViewPartMgr::ReservoirGeometryCacheType RivReservoirViewPartMgr::geo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType) +void RivReservoirViewPartMgr::appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType) { if (m_geometriesNeedsRegen[geometryType]) { @@ -927,7 +931,7 @@ void RivReservoirViewPartMgr::appendFaultLabelsStaticGeometryPartsToModel(cvf::M //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, size_t frameIndex) +void RivReservoirViewPartMgr::appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex) { m_propFilteredGeometryFrames[frameIndex]->appendFaultLabelPartsToModel(model); } @@ -935,7 +939,7 @@ void RivReservoirViewPartMgr::appendFaultLabelsDynamicGeometryPartsToModel(cvf:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::setFaultForceVisibilityForGeometryType(ReservoirGeometryCacheType geometryType, bool forceVisibility) +void RivReservoirViewPartMgr::setFaultForceVisibilityForGeometryType(RivCellSetEnum geometryType, bool forceVisibility) { if (m_geometriesNeedsRegen[geometryType]) { diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h index f5fce9e94e..737e42742e 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h @@ -24,84 +24,68 @@ #include "cafFixedArray.h" #include "cvfArray.h" #include "cafPdmObject.h" +#include "RivCellSetEnum.h" -class RimReservoirView; +class RimEclipseView; class RigGridBase; class RimCellRangeFilterCollection; -class RimCellPropertyFilterCollection; +class RimEclipsePropertyFilterCollection; class RigActiveCellInfo; class RivReservoirViewPartMgr: public cvf::Object { public: - RivReservoirViewPartMgr(RimReservoirView * resv); + RivReservoirViewPartMgr(RimEclipseView * resv); cvf::Transform* scaleTransform() { return m_scaleTransform.p();} - void setScaleTransform(cvf::Mat4d scale) { m_scaleTransform->setLocalTransform(scale);} - - enum ReservoirGeometryCacheType - { - ACTIVE, ///< All Active cells without ALL_WELL_CELLS - ALL_WELL_CELLS, ///< All cells ever having a connection to a well (Might be inactive cells as well. Wellhead cells typically) - VISIBLE_WELL_CELLS, ///< ALL_WELL_CELLS && visible well cells including Fence - VISIBLE_WELL_FENCE_CELLS, ///< (! ALL_WELL_CELLS) && visible well cells including Fence - INACTIVE, ///< All inactive cells, but invalid cells might or might not be included - RANGE_FILTERED, ///< ACTIVE Filtered by the set of range filters - RANGE_FILTERED_INACTIVE, ///< INACTIVE Filtered by the set of range filters - RANGE_FILTERED_WELL_CELLS, ///< ALL_WELL_CELLS Filtered by the set of range filters - VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER, ///< VISIBLE_WELL_CELLS && !RANGE_FILTERED_WELL_CELLS - VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER, ///< VISIBLE_WELL_FENCE_CELLS && !RANGE_FILTERED - PROPERTY_FILTERED, ///< (RANGE_FILTERED || VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER) && !ExcludedByPropFilter && IncludedByPropFilter - PROPERTY_FILTERED_WELL_CELLS ///< (!(hasActiveRangeFilters || visibleWellCells) && (*ALL_WELL_CELLS)) || RANGE_FILTERED_WELL_CELLS || VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER - }; void clearGeometryCache(); - void scheduleGeometryRegen(ReservoirGeometryCacheType geometryType); - cvf::cref cellVisibility(ReservoirGeometryCacheType geometryType, size_t gridIndex, size_t frameIndex) const; + void scheduleGeometryRegen(RivCellSetEnum geometryType); + cvf::cref cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t frameIndex) const; - void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, const std::vector& gridIndices); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, size_t frameIndex, const std::vector& gridIndices); + void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, RivCellSetEnum geometryType, const std::vector& gridIndices); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex, const std::vector& gridIndices); - void updateCellColor (ReservoirGeometryCacheType geometryType, cvf::Color4f color); - void updateCellColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex, + void updateCellColor (RivCellSetEnum geometryType, cvf::Color4f color); + void updateCellColor (RivCellSetEnum geometryType, size_t timeStepIndex, cvf::Color4f color); - void updateCellResultColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex, - RimResultSlot* cellResultSlot); - void updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot); + void updateCellResultColor (RivCellSetEnum geometryType, size_t timeStepIndex, + RimEclipseCellColors* cellResultColors); + void updateCellEdgeResultColor(RivCellSetEnum geometryType, size_t timeStepIndex, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); // Faults - void appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType); - void appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, size_t frameIndex); - void updateFaultColors(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot); - void updateFaultCellEdgeResultColor( ReservoirGeometryCacheType geometryType, size_t timeStepIndex, - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot); + void appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType); + void appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex); + void updateFaultColors(RivCellSetEnum geometryType, size_t timeStepIndex, RimEclipseCellColors* cellResultColors); + void updateFaultCellEdgeResultColor( RivCellSetEnum geometryType, size_t timeStepIndex, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); // Fault labels - ReservoirGeometryCacheType geometryTypeForFaultLabels(const std::vector& geometryTypes) const; - void appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType); - void appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, size_t frameIndex); + RivCellSetEnum geometryTypeForFaultLabels(const std::vector& geometryTypes) const; + void appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType); + void appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex); - void setFaultForceVisibilityForGeometryType(ReservoirGeometryCacheType geometryType, bool forceVisibility); + void setFaultForceVisibilityForGeometryType(RivCellSetEnum geometryType, bool forceVisibility); private: - void createGeometry(ReservoirGeometryCacheType geometryType); - void computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx); + void createGeometry(RivCellSetEnum geometryType); + void computeVisibility(cvf::UByteArray* cellVisibility, RivCellSetEnum geometryType, RigGridBase* grid, size_t gridIdx); void createPropertyFilteredNoneWellCellGeometry(size_t frameIndex); void createPropertyFilteredWellGeometry(size_t frameIndex); - void clearGeometryCache(ReservoirGeometryCacheType geomType); + void clearGeometryCache(RivCellSetEnum geomType); static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible); - void computeRangeVisibility (ReservoirGeometryCacheType geometryType, cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl); - static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimCellPropertyFilterCollection* propFilterColl); + void computeRangeVisibility (RivCellSetEnum geometryType, cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl); + static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl); static void copyByteArray(cvf::UByteArray* cellVisibilities, const cvf::UByteArray* cellIsWellStatuses ); - RivReservoirPartMgr * reservoirPartManager(ReservoirGeometryCacheType geometryType, size_t timeStepIndex ); + RivReservoirPartMgr * reservoirPartManager(RivCellSetEnum geometryType, size_t timeStepIndex ); private: @@ -115,6 +99,6 @@ class RivReservoirViewPartMgr: public cvf::Object std::vector m_propFilteredWellGeometryFramesNeedsRegen; cvf::ref m_scaleTransform; - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; }; diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp index cac3315d34..b66ee7b5c1 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp @@ -19,10 +19,10 @@ #include "RivScalarMapperUtils.h" -#include "RimCellEdgeResultSlot.h" +#include "RimCellEdgeColors.h" #include "RimLegendConfig.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" #include "RimTernaryLegendConfig.h" #include "RivCellEdgeEffectGenerator.h" @@ -39,28 +39,28 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivScalarMapperUtils::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +void RivScalarMapperUtils::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(part && textureCoords && mapper); cvf::DrawableGeo* dg = dynamic_cast(part->drawable()); if (dg) dg->setTextureCoordArray(textureCoords); - cvf::ref scalarEffect = RivScalarMapperUtils::createScalarMapperEffect(mapper, opacityLevel, faceCulling); + cvf::ref scalarEffect = RivScalarMapperUtils::createScalarMapperEffect(mapper, opacityLevel, faceCulling, disableLighting); part->setEffect(scalarEffect.p()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivScalarMapperUtils::applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +void RivScalarMapperUtils::applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(part && textureCoords && mapper); cvf::DrawableGeo* dg = dynamic_cast(part->drawable()); if (dg) dg->setTextureCoordArray(textureCoords); - cvf::ref scalarEffect = RivScalarMapperUtils::createTernaryScalarMapperEffect(mapper, opacityLevel, faceCulling); + cvf::ref scalarEffect = RivScalarMapperUtils::createTernaryScalarMapperEffect(mapper, opacityLevel, faceCulling, disableLighting); part->setEffect(scalarEffect.p()); } @@ -71,34 +71,36 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper, size_t gridIndex, size_t timeStepIndex, - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors, float opacityLevel, cvf::Color3f defaultColor, - caf::FaceCulling faceCulling) + caf::FaceCulling faceCulling, + bool disableLighting) { - CellEdgeEffectGenerator cellFaceEffectGen(cellEdgeResultSlot->legendConfig()->scalarMapper()); + CellEdgeEffectGenerator cellFaceEffectGen(cellEdgeResultColors->legendConfig()->scalarMapper()); - if (cellResultSlot->isTernarySaturationSelected()) + if (cellResultColors->isTernarySaturationSelected()) { - RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot, + RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultColors, cellEdgeResultColors, quadToCellFaceMapper, dg, gridIndex, opacityLevel); - RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultSlot->ternaryLegendConfig()->scalarMapper(); + RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); cellFaceEffectGen.setTernaryScalarMapper(ternaryCellScalarMapper); } else { - RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot, + RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultColors, cellEdgeResultColors, quadToCellFaceMapper, dg, gridIndex, opacityLevel); - cvf::ScalarMapper* cellScalarMapper = cellResultSlot->legendConfig()->scalarMapper(); + cvf::ScalarMapper* cellScalarMapper = cellResultColors->legendConfig()->scalarMapper(); cellFaceEffectGen.setScalarMapper(cellScalarMapper); } cellFaceEffectGen.setOpacityLevel(opacityLevel); cellFaceEffectGen.setDefaultCellColor(defaultColor); cellFaceEffectGen.setFaceCulling(faceCulling); + cellFaceEffectGen.disableLighting(disableLighting); cvf::ref eff = cellFaceEffectGen.generateEffect(); return eff; @@ -107,7 +109,7 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(mapper); @@ -115,6 +117,7 @@ cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf:: caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.disableLighting(disableLighting); cvf::ref scalarEffect = scalarEffgen.generateEffect(); @@ -124,7 +127,7 @@ cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(mapper); @@ -132,6 +135,7 @@ cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(cons RivTernaryScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.disableLighting(disableLighting); cvf::ref scalarEffect = scalarEffgen.generateEffect(); return scalarEffect; diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h index 64bd98dcee..7ce0585fab 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h @@ -34,8 +34,8 @@ namespace cvf } class RivTernaryScalarMapper; -class RimResultSlot; -class RimCellEdgeResultSlot; +class RimEclipseCellColors; +class RimCellEdgeColors; //================================================================================================== /// @@ -43,21 +43,22 @@ class RimCellEdgeResultSlot; class RivScalarMapperUtils { public: - static void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); - static void applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); + static void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); + static void applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); static cvf::ref createCellEdgeEffect(cvf::DrawableGeo* dg, const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper, size_t gridIndex, size_t timeStepIndex, - RimResultSlot* cellResultSlot, - RimCellEdgeResultSlot* cellEdgeResultSlot, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors, float opacityLevel, cvf::Color3f defaultColor, - caf::FaceCulling faceCulling); + caf::FaceCulling faceCulling, + bool disableLighting); private: - static cvf::ref createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); - static cvf::ref createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); + static cvf::ref createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); + static cvf::ref createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); }; diff --git a/ApplicationCode/ModelVisualization/RivSourceInfo.h b/ApplicationCode/ModelVisualization/RivSourceInfo.h index 5c53214770..a346307a84 100644 --- a/ApplicationCode/ModelVisualization/RivSourceInfo.h +++ b/ApplicationCode/ModelVisualization/RivSourceInfo.h @@ -27,10 +27,15 @@ class RivSourceInfo : public cvf::Object { public: + RivSourceInfo(size_t gridIndex) : m_gridIndex(gridIndex) {} + + size_t gridIndex() const { return m_gridIndex; } bool hasCellFaceMapping() const; bool hasNNCIndices() const; public: cvf::cref m_cellFaceFromTriangleMapper; cvf::ref > m_NNCIndices; +private: + size_t m_gridIndex; }; diff --git a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp index 60b7630413..d80e67bc5b 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp @@ -54,6 +54,7 @@ RivTernaryScalarMapperEffectGenerator::RivTernaryScalarMapperEffectGenerator(con m_opacityLevel = 1.0f; m_faceCulling = caf::FC_NONE; m_enableDepthWrite = true; + m_disableLighting = false; } //-------------------------------------------------------------------------------------------------- @@ -66,8 +67,16 @@ void RivTernaryScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::E cvf::ShaderProgramGenerator gen("ScalarMapperMeshEffectGenerator", cvf::ShaderSourceProvider::instance()); gen.addVertexCode(cvf::ShaderSourceRepository::vs_Standard); gen.addFragmentCode(cvf::ShaderSourceRepository::src_Texture); - gen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); - gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + + if (m_disableLighting) + { + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit); + } + else + { + gen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + } cvf::ref prog = gen.generate(); eff->setShaderProgram(prog.p()); @@ -104,6 +113,7 @@ void RivTernaryScalarMapperEffectGenerator::updateForFixedFunctionRendering(cvf: cvf::ref lighting = new cvf::RenderStateLighting_FF; lighting->enableTwoSided(true); + lighting->enable(!m_disableLighting); eff->setRenderState(lighting.p()); // Result mapping texture @@ -189,7 +199,8 @@ bool RivTernaryScalarMapperEffectGenerator::isEqual(const EffectGenerator* other && m_opacityLevel == otherTextureResultEffect->m_opacityLevel && m_undefinedColor == otherTextureResultEffect->m_undefinedColor && m_faceCulling == otherTextureResultEffect->m_faceCulling - && m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite) + && m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite + && m_disableLighting == otherTextureResultEffect->m_disableLighting) { cvf::ref texImg2 = new cvf::TextureImage; otherTextureResultEffect->m_scalarMapper->updateTexture(texImg2.p(), m_opacityLevel); @@ -212,6 +223,7 @@ caf::EffectGenerator* RivTernaryScalarMapperEffectGenerator::copy() const scEffGen->m_undefinedColor = m_undefinedColor; scEffGen->m_faceCulling = m_faceCulling; scEffGen->m_enableDepthWrite = m_enableDepthWrite; + scEffGen->m_disableLighting = m_disableLighting; return scEffGen; } diff --git a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h index d45121421b..0e00ea2973 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h +++ b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h @@ -42,6 +42,7 @@ class RivTernaryScalarMapperEffectGenerator : public caf::EffectGenerator void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; } void setFaceCulling(caf::FaceCulling faceCulling) { m_faceCulling = faceCulling; } void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; } + void disableLighting(bool disable) { m_disableLighting = disable; } public: @@ -65,5 +66,6 @@ class RivTernaryScalarMapperEffectGenerator : public caf::EffectGenerator cvf::Color3f m_undefinedColor; caf::FaceCulling m_faceCulling; bool m_enableDepthWrite; + bool m_disableLighting; }; diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp index edef41aca8..5bd2243efd 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp @@ -25,11 +25,11 @@ #include "RigResultAccessorFactory.h" #include "RigTernaryResultAccessor2d.h" -#include "RimCase.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" #include "RimTernaryLegendConfig.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "RivTernaryResultToTextureMapper.h" #include "RivTernaryScalarMapper.h" @@ -38,22 +38,22 @@ /// //-------------------------------------------------------------------------------------------------- RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( - RimResultSlot* cellResultSlot, + RimEclipseCellColors* cellResultColors, RimTernaryLegendConfig* ternaryLegendConfig, size_t timeStepIndex, size_t gridIndex, const cvf::StructGridQuadToCellFaceMapper* quadMapper) { - RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData(); m_quadMapper = quadMapper; CVF_ASSERT(quadMapper && eclipseCase ); size_t resTimeStepIdx = timeStepIndex; - if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0; + if (cellResultColors->hasStaticResult()) resTimeStepIdx = 0; - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()); cvf::ref soil = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SOIL"); cvf::ref sgas = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SGAS"); @@ -62,7 +62,7 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( m_resultAccessor = new RigTernaryResultAccessor(); m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p()); - cvf::ref pipeInCellEval = new RigPipeInCellEvaluator( cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex), + cvf::ref pipeInCellEval = new RigPipeInCellEvaluator( cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex), eclipseCase->gridCellToWellIndex(gridIndex)); const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper(); diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h index d209c018f0..d927cf1f9e 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h @@ -26,7 +26,7 @@ #include "cvfObject.h" #include "cvfArray.h" -class RimResultSlot; +class RimEclipseCellColors; class RimTernaryLegendConfig; namespace cvf @@ -41,7 +41,7 @@ namespace cvf class RivTernaryTextureCoordsCreator { public: - RivTernaryTextureCoordsCreator( RimResultSlot* cellResultSlot, + RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, RimTernaryLegendConfig* ternaryLegendConfig, size_t timeStepIndex, size_t gridIndex, diff --git a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp index 4b3b8e6301..2964ae8090 100644 --- a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp @@ -19,38 +19,38 @@ #include "RivTextureCoordsCreator.h" -#include "RimResultSlot.h" +#include "RimEclipseCellColors.h" #include "RigCaseData.h" -#include "RimReservoirView.h" -#include "RimCase.h" +#include "RimEclipseView.h" +#include "RimEclipseCase.h" #include "RigCaseCellResultsData.h" #include "RigResultAccessorFactory.h" #include "RigPipeInCellEvaluator.h" #include "RivResultToTextureMapper.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivTextureCoordsCreator::RivTextureCoordsCreator(RimResultSlot* cellResultSlot, size_t timeStepIndex, size_t gridIndex, const cvf::StructGridQuadToCellFaceMapper* quadMapper) +RivTextureCoordsCreator::RivTextureCoordsCreator(RimEclipseCellColors* cellResultColors, size_t timeStepIndex, size_t gridIndex, const cvf::StructGridQuadToCellFaceMapper* quadMapper) { - RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData(); m_quadMapper = quadMapper; CVF_ASSERT(quadMapper && eclipseCase ); size_t resTimeStepIdx = timeStepIndex; - if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0; + if (cellResultColors->hasStaticResult()) resTimeStepIdx = 0; - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()); - m_resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, cellResultSlot->resultVariable()); + m_resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, cellResultColors->resultVariable()); - cvf::ref pipeInCellEval = new RigPipeInCellEvaluator(cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex), + cvf::ref pipeInCellEval = new RigPipeInCellEvaluator(cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex), eclipseCase->gridCellToWellIndex(gridIndex)); - const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper(); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); m_texMapper = new RivResultToTextureMapper(mapper, pipeInCellEval.p()); CVF_ASSERT(m_texMapper.notNull()); diff --git a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h index 7c1a4f174d..98f5758df6 100644 --- a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h +++ b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h @@ -23,7 +23,7 @@ #include "cvfObject.h" #include "cvfArray.h" -class RimResultSlot; +class RimEclipseCellColors; class RigResultAccessor; class RivResultToTextureMapper; @@ -36,7 +36,7 @@ namespace cvf class RivTextureCoordsCreator { public: - RivTextureCoordsCreator(RimResultSlot* cellResultSlot, + RivTextureCoordsCreator(RimEclipseCellColors* cellResultColors, size_t timeStepIndex, size_t gridIndex, const cvf::StructGridQuadToCellFaceMapper* quadMapper); diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 7b64b4f8be..65f4b8d6c7 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -36,19 +36,19 @@ #include "cvfFixedAtlasFont.h" #include "cvfqtUtils.h" -#include "RimReservoirView.h" -#include "RimWellCollection.h" +#include "RimEclipseView.h" +#include "RimEclipseWellCollection.h" #include "cafPdmFieldCvfMat4d.h" -#include "RimCellEdgeResultSlot.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirCellResultsStorage.h" -#include "RimResultSlot.h" +#include "RimEclipseCellColors.h" #include "RimLegendConfig.h" -#include "RimCase.h" -#include "RimWell.h" +#include "RimEclipseCase.h" +#include "RimEclipseWell.h" #include "RigCaseData.h" #include "RigCell.h" @@ -61,7 +61,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellHeadPartMgr::RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well) +RivWellHeadPartMgr::RivWellHeadPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well) { m_rimReservoirView = reservoirView; m_rimWell = well; @@ -87,7 +87,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) RigCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); - RimWell* well = m_rimWell; + RimEclipseWell* well = m_rimWell; RigSingleWellResultsData* wellResults = well->wellResults(); @@ -113,7 +113,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) // Compute well head based on the z position of the top of the K column the well head is part of cvf::Vec3d whEndPos = whStartPos; - if (m_rimReservoirView->wellCollection()->wellHeadPosition() == RimWellCollection::WELLHEAD_POS_TOP_COLUMN) + if (m_rimReservoirView->wellCollection()->wellHeadPosition() == RimEclipseWellCollection::WELLHEAD_POS_TOP_COLUMN) { // Position well head at top active cell of IJ-column @@ -282,7 +282,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) m_wellHeadParts.push_back(part.p()); } - if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel()) + if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel() && !well->name().isEmpty()) { cvf::Font* standardFont = RiaApplication::instance()->standardFont(); diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h index b24b8b40e0..b1b1f991c2 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h @@ -32,13 +32,13 @@ namespace cvf class Font; } -class RimWell; -class RimReservoirView; +class RimEclipseWell; +class RimEclipseView; class RivWellHeadPartMgr : public cvf::Object { public: - RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well); + RivWellHeadPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well); ~RivWellHeadPartMgr(); void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform;} @@ -51,8 +51,8 @@ class RivWellHeadPartMgr : public cvf::Object private: - caf::PdmPointer m_rimReservoirView; - caf::PdmPointer m_rimWell; + caf::PdmPointer m_rimReservoirView; + caf::PdmPointer m_rimWell; cvf::ref m_scaleTransform; cvf::Collection< cvf::Part > m_wellHeadParts; diff --git a/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.cpp index f2f7714f77..c3f79c55a8 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.cpp @@ -66,7 +66,8 @@ void RivWellPathCollectionPartMgr::setScaleTransform(cvf::Transform * scaleTrans //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathCollectionPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, cvf::Transform* scaleTransform, double characteristicCellSize, cvf::BoundingBox boundingBox) +void RivWellPathCollectionPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, + cvf::Transform* scaleTransform, double characteristicCellSize, cvf::BoundingBox wellPathClipBoundingBox) { setScaleTransform(scaleTransform); @@ -77,7 +78,7 @@ void RivWellPathCollectionPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBa { RivWellPathPartMgr* partMgr = m_wellPathCollection->wellPaths[wIdx]->partMgr(); partMgr->setScaleTransform(scaleTransform); - partMgr->appendStaticGeometryPartsToModel(model, displayModelOffset, characteristicCellSize, boundingBox); + partMgr->appendStaticGeometryPartsToModel(model, displayModelOffset, characteristicCellSize, wellPathClipBoundingBox); } } diff --git a/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.h index 5f0171bc8c..386e83d8f6 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathCollectionPartMgr.h @@ -54,9 +54,8 @@ class RivWellPathCollectionPartMgr : public cvf::Object cvf::Vec3d displayModelOffset, cvf::Transform* scaleTransform, double characteristicCellSize, - cvf::BoundingBox boundingBox); + cvf::BoundingBox wellPathClipBoundingBox); private: caf::PdmPointer m_wellPathCollection; - cvf::ref m_scaleTransform; }; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 6bc354e569..1093a46780 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -22,20 +22,20 @@ #include "cvfLibCore.h" #include "RiaApplication.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimProject.h" #include "RimWellPathCollection.h" #include "RimReservoirCellResultsStorage.h" #include "RimIdenticalGridCaseGroup.h" #include "RimScriptCollection.h" #include "RimCaseCollection.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RigCaseData.h" #include "RigCell.h" #include "RivWellPathPartMgr.h" @@ -51,7 +51,7 @@ #include "cafEffectGenerator.h" #include "cvfqtUtils.h" #include "RimOilField.h" -#include "RimAnalysisModels.h" +#include "RimEclipseCaseCollection.h" //-------------------------------------------------------------------------------------------------- /// @@ -93,9 +93,10 @@ RivWellPathPartMgr::~RivWellPathPartMgr() } //-------------------------------------------------------------------------------------------------- -/// +/// The pipe geometry needs to be rebuilt on scale change to keep the pipes round //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox) +void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, double characteristicCellSize, + cvf::BoundingBox wellPathClipBoundingBox) { if (m_wellPathCollection.isNull()) return; @@ -107,13 +108,9 @@ void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, doubl m_wellBranches.clear(); double wellPathRadius = m_wellPathCollection->wellPathRadiusScaleFactor() * m_rimWellPath->wellPathRadiusScaleFactor() * characteristicCellSize; -// cvf::Vec3d firstPoint = wellPathGeometry->m_wellPathPoints[0]; -// firstPoint -= displayModelOffset; -// firstPoint.transformPoint(m_scaleTransform->worldTransform()); -// printf("Well path start pos = (%f, %f, %f)\n", firstPoint.x(), firstPoint.y(), firstPoint.z()); cvf::Vec3d textPosition = wellPathGeometry->m_wellPathPoints[0]; - // Generate well path as pipe structure + // Generate the well path geometry as a line and pipe structure { m_wellBranches.push_back(RivPipeBranchData()); RivPipeBranchData& pbd = m_wellBranches.back(); @@ -131,7 +128,7 @@ void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, doubl for (size_t idx = 0; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) { cvf::Vec3d point = wellPathGeometry->m_wellPathPoints[idx]; - if (point.z() < (boundingBox.max().z() + m_wellPathCollection->wellPathClipZDistance)) + if (point.z() < (wellPathClipBoundingBox.max().z() + m_wellPathCollection->wellPathClipZDistance)) clippedPoints.push_back(point); } if (clippedPoints.size() < 2) return; @@ -161,7 +158,6 @@ void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, doubl { pbd.m_surfacePart = new cvf::Part; pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); - //printf("Well Path triangleCount = %i (%i points in well path)\n", pbd.m_surfaceDrawable->triangleCount(), wellPathGeometry->m_wellPathPoints.size()); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); cvf::ref eff = surfaceGen.generateEffect(); @@ -173,7 +169,6 @@ void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, doubl { pbd.m_centerLinePart = new cvf::Part; pbd.m_centerLinePart->setDrawable(pbd.m_centerLineDrawable.p()); - //printf("Well Path vertexCount = %i\n", pbd.m_centerLineDrawable->vertexCount()); caf::MeshEffectGenerator gen(m_rimWellPath->wellPathColor()); cvf::ref eff = gen.generateEffect(); @@ -182,14 +177,15 @@ void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, doubl } } - // Generate label with well path name + // Generate label with well-path name + textPosition -= displayModelOffset; textPosition.transformPoint(m_scaleTransform->worldTransform()); textPosition.z() += characteristicCellSize; // * m_rimReservoirView->wellCollection()->wellHeadScaleFactor(); textPosition.z() += 1.2 * characteristicCellSize; m_wellLabelPart = NULL; - if (m_wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel()) + if (m_wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel() && !m_rimWellPath->name().isEmpty()) { cvf::Font* standardFont = RiaApplication::instance()->standardFont(); @@ -225,7 +221,8 @@ void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, doubl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox) +void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, + double characteristicCellSize, cvf::BoundingBox wellPathClipBoundingBox) { if (m_wellPathCollection.isNull()) return; if (m_rimWellPath.isNull()) return; @@ -238,25 +235,15 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m if (m_needsTransformUpdate) { - //printf("G"); - buildWellPathParts(displayModelOffset, characteristicCellSize, boundingBox); - } - else - { - //printf("s"); + // The pipe geometry needs to be rebuilt on scale change to keep the pipes round + buildWellPathParts(displayModelOffset, characteristicCellSize, wellPathClipBoundingBox); } - - if (m_wellBranches.size() < 1) - { - //printf("RivWellPathPartMgr::appendStaticGeometryPartsToModel: There are no well branches in well \"%s\"!!!\n", (const char*) m_rimWellPath->name().toLocal8Bit()); - } - + std::list::iterator it; for (it = m_wellBranches.begin(); it != m_wellBranches.end(); it++) { if (it->m_surfacePart.notNull()) { - //printf("a"); model->addPart(it->m_surfacePart.p()); } if (it->m_centerLinePart.notNull()) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index 0f01a673cd..911c816d19 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -49,7 +49,8 @@ class RivWellPathPartMgr : public cvf::Object void scheduleGeometryRegen() { m_needsTransformUpdate = true; }//printf("R"); } - void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox); + void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, + double characteristicCellSize, cvf::BoundingBox wellPathClipBoundingBox); private: caf::PdmPointer m_wellPathCollection; @@ -58,7 +59,7 @@ class RivWellPathPartMgr : public cvf::Object cvf::ref m_scaleTransform; bool m_needsTransformUpdate; - void buildWellPathParts(cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox); + void buildWellPathParts(cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox wellPathClipBoundingBox); struct RivPipeBranchData { diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index 546a57fd57..ea6713c99b 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -36,16 +36,16 @@ #include "RigCell.h" #include "RivPipeGeometryGenerator.h" -#include "RimCase.h" -#include "RimReservoirView.h" -#include "RimWell.h" -#include "RimWellCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" +#include "RimEclipseWellCollection.h" #include "RimReservoirCellResultsStorage.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" #include "Rim3dOverlayInfoConfig.h" @@ -53,7 +53,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPipesPartMgr::RivWellPipesPartMgr(RimReservoirView* reservoirView, RimWell* well) +RivWellPipesPartMgr::RivWellPipesPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well) { m_rimReservoirView = reservoirView; m_rimWell = well; diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h index 88a3cf0403..bad5f24be4 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h @@ -37,13 +37,13 @@ namespace cvf } class RivPipeGeometryGenerator; -class RimReservoirView; -class RimWell; +class RimEclipseView; +class RimEclipseWell; class RivWellPipesPartMgr : public cvf::Object { public: - RivWellPipesPartMgr(RimReservoirView* reservoirView, RimWell* well); + RivWellPipesPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well); ~RivWellPipesPartMgr(); void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; scheduleGeometryRegen();} @@ -55,8 +55,8 @@ class RivWellPipesPartMgr : public cvf::Object private: - caf::PdmPointer m_rimReservoirView; - caf::PdmPointer m_rimWell; + caf::PdmPointer m_rimReservoirView; + caf::PdmPointer m_rimWell; cvf::ref m_scaleTransform; bool m_needsTransformUpdate; diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index acfb39020e..8c5f2ef7c5 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -5,34 +5,34 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") endif() set (SOURCE_GROUP_HEADER_FILES -${CEE_CURRENT_LIST_DIR}RimAnalysisModels.h +${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.h ${CEE_CURRENT_LIST_DIR}RimCaseCollection.h ${CEE_CURRENT_LIST_DIR}RimCellFilter.h -${CEE_CURRENT_LIST_DIR}RimCellPropertyFilter.h -${CEE_CURRENT_LIST_DIR}RimCellPropertyFilterCollection.h +${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.h +${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.h ${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.h ${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.h ${CEE_CURRENT_LIST_DIR}RimDefines.h ${CEE_CURRENT_LIST_DIR}RimLegendConfig.h ${CEE_CURRENT_LIST_DIR}RimOilField.h ${CEE_CURRENT_LIST_DIR}RimProject.h -${CEE_CURRENT_LIST_DIR}RimCase.h +${CEE_CURRENT_LIST_DIR}RimEclipseCase.h ${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.h -${CEE_CURRENT_LIST_DIR}RimInputProperty.h -${CEE_CURRENT_LIST_DIR}RimInputPropertyCollection.h -${CEE_CURRENT_LIST_DIR}RimInputCase.h -${CEE_CURRENT_LIST_DIR}RimResultCase.h -${CEE_CURRENT_LIST_DIR}RimReservoirView.h -${CEE_CURRENT_LIST_DIR}RimResultDefinition.h -${CEE_CURRENT_LIST_DIR}RimResultSlot.h -${CEE_CURRENT_LIST_DIR}RimCellEdgeResultSlot.h -${CEE_CURRENT_LIST_DIR}RimWell.h -${CEE_CURRENT_LIST_DIR}RimWellCollection.h +${CEE_CURRENT_LIST_DIR}RimEclipseInputProperty.h +${CEE_CURRENT_LIST_DIR}RimEclipseInputPropertyCollection.h +${CEE_CURRENT_LIST_DIR}RimEclipseInputCase.h +${CEE_CURRENT_LIST_DIR}RimEclipseResultCase.h +${CEE_CURRENT_LIST_DIR}RimEclipseView.h +${CEE_CURRENT_LIST_DIR}RimEclipseResultDefinition.h +${CEE_CURRENT_LIST_DIR}RimEclipseCellColors.h +${CEE_CURRENT_LIST_DIR}RimCellEdgeColors.h +${CEE_CURRENT_LIST_DIR}RimEclipseWell.h +${CEE_CURRENT_LIST_DIR}RimEclipseWellCollection.h ${CEE_CURRENT_LIST_DIR}RimWellPath.h ${CEE_CURRENT_LIST_DIR}RimWellPathCollection.h ${CEE_CURRENT_LIST_DIR}RimScriptCollection.h -${CEE_CURRENT_LIST_DIR}RimStatisticsCase.h -${CEE_CURRENT_LIST_DIR}RimStatisticsCaseCollection.h +${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCase.h +${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseCollection.h ${CEE_CURRENT_LIST_DIR}RimCalcScript.h ${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.h ${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.h @@ -40,7 +40,7 @@ ${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.h ${CEE_CURRENT_LIST_DIR}RimUiTreeModelPdm.h ${CEE_CURRENT_LIST_DIR}RimUiTreeView.h ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.h -${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.h +${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.h ${CEE_CURRENT_LIST_DIR}RimMimeData.h ${CEE_CURRENT_LIST_DIR}RimCommandObject.h ${CEE_CURRENT_LIST_DIR}RimTools.h @@ -48,40 +48,49 @@ ${CEE_CURRENT_LIST_DIR}RimFault.h ${CEE_CURRENT_LIST_DIR}RimFaultCollection.h ${CEE_CURRENT_LIST_DIR}RimMockModelSettings.h ${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.h -${CEE_CURRENT_LIST_DIR}RimFaultResultSlot.h +${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.h ${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNNC.h ${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.h +${CEE_CURRENT_LIST_DIR}RimGeoMechModels.h +${CEE_CURRENT_LIST_DIR}RimGeoMechCase.h +${CEE_CURRENT_LIST_DIR}RimGeoMechView.h +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilter.h +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.h +${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.h +${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.h +${CEE_CURRENT_LIST_DIR}RimView.h +${CEE_CURRENT_LIST_DIR}RimCase.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimAnalysisModels.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.cpp ${CEE_CURRENT_LIST_DIR}RimCaseCollection.cpp ${CEE_CURRENT_LIST_DIR}RimCellFilter.cpp -${CEE_CURRENT_LIST_DIR}RimCellPropertyFilter.cpp -${CEE_CURRENT_LIST_DIR}RimCellPropertyFilterCollection.cpp +${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.cpp +${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.cpp ${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.cpp ${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.cpp ${CEE_CURRENT_LIST_DIR}RimDefines.cpp ${CEE_CURRENT_LIST_DIR}RimLegendConfig.cpp ${CEE_CURRENT_LIST_DIR}RimOilField.cpp ${CEE_CURRENT_LIST_DIR}RimProject.cpp -${CEE_CURRENT_LIST_DIR}RimCase.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseCase.cpp ${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.cpp -${CEE_CURRENT_LIST_DIR}RimInputProperty.cpp -${CEE_CURRENT_LIST_DIR}RimInputPropertyCollection.cpp -${CEE_CURRENT_LIST_DIR}RimInputCase.cpp -${CEE_CURRENT_LIST_DIR}RimResultCase.cpp -${CEE_CURRENT_LIST_DIR}RimReservoirView.cpp -${CEE_CURRENT_LIST_DIR}RimResultDefinition.cpp -${CEE_CURRENT_LIST_DIR}RimResultSlot.cpp -${CEE_CURRENT_LIST_DIR}RimCellEdgeResultSlot.cpp -${CEE_CURRENT_LIST_DIR}RimWell.cpp -${CEE_CURRENT_LIST_DIR}RimWellCollection.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseInputProperty.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseInputPropertyCollection.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseInputCase.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseResultCase.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseView.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseResultDefinition.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseCellColors.cpp +${CEE_CURRENT_LIST_DIR}RimCellEdgeColors.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseWell.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseWellCollection.cpp ${CEE_CURRENT_LIST_DIR}RimWellPath.cpp ${CEE_CURRENT_LIST_DIR}RimWellPathCollection.cpp ${CEE_CURRENT_LIST_DIR}RimScriptCollection.cpp -${CEE_CURRENT_LIST_DIR}RimStatisticsCase.cpp -${CEE_CURRENT_LIST_DIR}RimStatisticsCaseCollection.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCase.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseCollection.cpp ${CEE_CURRENT_LIST_DIR}RimCalcScript.cpp ${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.cpp ${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.cpp @@ -89,7 +98,7 @@ ${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.cpp ${CEE_CURRENT_LIST_DIR}RimUiTreeModelPdm.cpp ${CEE_CURRENT_LIST_DIR}RimUiTreeView.cpp ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.cpp -${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.cpp ${CEE_CURRENT_LIST_DIR}RimMimeData.cpp ${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp ${CEE_CURRENT_LIST_DIR}RimTools.cpp @@ -97,9 +106,18 @@ ${CEE_CURRENT_LIST_DIR}RimFault.cpp ${CEE_CURRENT_LIST_DIR}RimFaultCollection.cpp ${CEE_CURRENT_LIST_DIR}RimMockModelSettings.cpp ${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.cpp -${CEE_CURRENT_LIST_DIR}RimFaultResultSlot.cpp +${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.cpp ${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNNC.cpp ${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechModels.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechCase.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechView.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilter.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.cpp +${CEE_CURRENT_LIST_DIR}RimView.cpp +${CEE_CURRENT_LIST_DIR}RimCase.cpp ) list(APPEND CODE_HEADER_FILES @@ -110,4 +128,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ) +source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 9165ad92dc..78ebbeee4f 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -22,16 +22,24 @@ #include "RigCaseCellResultsData.h" #include "RigCaseData.h" -#include "RimCase.h" -#include "RimCellEdgeResultSlot.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimCellEdgeColors.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimFaultCollection.h" -#include "RimFaultResultSlot.h" +#include "RimEclipseFaultColors.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimWellCollection.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseWellCollection.h" #include "RiuViewer.h" +#include "RimGeoMechView.h" +#include "RimView.h" +#include "RimGeoMechCase.h" +#include "RigGeoMechCaseData.h" +#include "RigFemPartCollection.h" +#include "RimGeoMechCellColors.h" +#include "RigFemResultAddress.h" +#include "RigFemPartResultsCollection.h" CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig"); @@ -65,9 +73,9 @@ void Rim3dOverlayInfoConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed { this->update3DInfo(); - if (m_reservoirView && m_reservoirView->viewer()) + if (m_viewDef && m_viewDef->viewer()) { - m_reservoirView->viewer()->update(); + m_viewDef->viewer()->update(); } } @@ -86,22 +94,49 @@ void Rim3dOverlayInfoConfig::update3DInfo() { this->updateUiIconFromToggleField(); - if (!m_reservoirView) return; - if (!m_reservoirView->viewer()) return; + if (!m_viewDef) return; + if (!m_viewDef->viewer()) return; if (!this->active()) { - m_reservoirView->viewer()->showInfoText(false); - m_reservoirView->viewer()->showHistogram(false); - m_reservoirView->viewer()->showAnimationProgress(false); + m_viewDef->viewer()->showInfoText(false); + m_viewDef->viewer()->showHistogram(false); + m_viewDef->viewer()->showAnimationProgress(false); return; } - m_reservoirView->viewer()->showInfoText(showInfoText()); - m_reservoirView->viewer()->showHistogram(false); - m_reservoirView->viewer()->showAnimationProgress(showAnimProgress()); + m_viewDef->viewer()->showInfoText(showInfoText()); + m_viewDef->viewer()->showHistogram(false); + m_viewDef->viewer()->showAnimationProgress(showAnimProgress()); + RimEclipseView * reservoirView = dynamic_cast(m_viewDef.p()); + if (reservoirView) updateReservoir3DInfo(reservoirView); + RimGeoMechView * geoMechView = dynamic_cast(m_viewDef.p()); + if (geoMechView) updateGeoMech3DInfo(geoMechView); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dOverlayInfoConfig::objectToggleField() +{ + return &active; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dOverlayInfoConfig::setReservoirView(RimView* ownerReservoirView) +{ + m_viewDef = ownerReservoirView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dOverlayInfoConfig::updateReservoir3DInfo(RimEclipseView * reservoirView) +{ if (showInfoText()) { QString caseName; @@ -115,64 +150,64 @@ void Rim3dOverlayInfoConfig::update3DInfo() QString faultCellResultMapping; - if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->mainGrid()) + if (reservoirView->eclipseCase() && reservoirView->eclipseCase()->reservoirData() && reservoirView->eclipseCase()->reservoirData()->mainGrid()) { - caseName = m_reservoirView->eclipseCase()->caseUserDescription(); - totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); - size_t mxActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount(); - size_t frActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->reservoirActiveCellCount(); + caseName = reservoirView->eclipseCase()->caseUserDescription(); + totCellCount = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); + size_t mxActCellCount = reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount(); + size_t frActCellCount = reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->reservoirActiveCellCount(); if (frActCellCount > 0) activeCellCountText += "Matrix : "; activeCellCountText += QString::number(mxActCellCount); if (frActCellCount > 0) activeCellCountText += " Fracture : " + QString::number(frActCellCount); - iSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI()); - jSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ()); - kSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK()); + iSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI()); + jSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ()); + kSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK()); - zScale = QString::number(m_reservoirView->scaleZ()); + zScale = QString::number(reservoirView->scaleZ()); - propName = m_reservoirView->cellResult()->resultVariable(); - cellEdgeName = m_reservoirView->cellEdgeResult()->resultVariable(); + propName = reservoirView->cellResult()->resultVariable(); + cellEdgeName = reservoirView->cellEdgeResult()->resultVariable(); } QString infoText = QString( "

-- %1 --

" - "Cell count. Total: %2 Active: %3
" + "Cell count. Total: %2 Active: %3
" "Main Grid I,J,K: %4, %5, %6 Z-Scale: %7
").arg(caseName, totCellCount, activeCellCountText, iSize, jSize, kSize, zScale); - if (m_reservoirView->cellResult()->isTernarySaturationSelected()) + if (reservoirView->cellResult()->isTernarySaturationSelected()) { infoText += QString("Cell Property: %1 ").arg(propName); } - if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult()) + if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult()) { infoText += QString("Cell Property: %1 ").arg(propName); double min, max; double p10, p90; double mean; - size_t scalarIndex = m_reservoirView->cellResult()->scalarResultIndex(); - m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); - m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); + size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); + reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); + reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); //infoText += QString("

Min: %1 P10: %2 Mean: %3 P90: %4 Max: %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); //infoText += QString("
Min: %1   P10: %2   Mean: %3 \n  P90: %4   Max: %5 
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); - infoText += QString("" - "
MinP10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); + infoText += QString("" + "
MinP10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); - if (m_reservoirView->faultResultSettings()->hasValidCustomResult()) + if (reservoirView->faultResultSettings()->hasValidCustomResult()) { QString faultMapping; - bool isShowingGrid = m_reservoirView->faultCollection()->isGridVisualizationMode(); + bool isShowingGrid = reservoirView->faultCollection()->isGridVisualizationMode(); if (!isShowingGrid) { - if (m_reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING) + if (reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING) { faultMapping = "Cells behind fault"; } - else if (m_reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING) + else if (reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING) { faultMapping = "Cells in front of fault"; } @@ -188,7 +223,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() infoText += QString("Fault results: %1
").arg(faultMapping); - infoText += QString("Fault Property: %1
").arg(m_reservoirView->faultResultSettings()->customFaultResult()->resultVariable()); + infoText += QString("Fault Property: %1
").arg(reservoirView->faultResultSettings()->customFaultResult()->resultVariable()); } } else @@ -197,43 +232,43 @@ void Rim3dOverlayInfoConfig::update3DInfo() } - if (m_reservoirView->animationMode() && m_reservoirView->cellEdgeResult()->hasResult()) + if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellEdgeResult()->hasResult()) { double min, max; - m_reservoirView->cellEdgeResult()->minMaxCellEdgeValues(min, max); + reservoirView->cellEdgeResult()->minMaxCellEdgeValues(min, max); infoText += QString("Cell Edge Property: %1
Min: %2 Max: %3
").arg(cellEdgeName).arg(min).arg(max); } - if ( m_reservoirView->cellResult()->hasDynamicResult() - || m_reservoirView->propertyFilterCollection()->hasActiveDynamicFilters() - || m_reservoirView->wellCollection()->hasVisibleWellPipes() - || m_reservoirView->cellResult()->isTernarySaturationSelected()) + if (reservoirView->cellResult()->hasDynamicResult() + || reservoirView->propertyFilterCollection()->hasActiveDynamicFilters() + || reservoirView->wellCollection()->hasVisibleWellPipes() + || reservoirView->cellResult()->isTernarySaturationSelected()) { - int currentTimeStep = m_reservoirView->currentTimeStep(); - QDateTime date = m_reservoirView->currentGridCellResults()->cellResults()->timeStepDate(0, currentTimeStep); + int currentTimeStep = reservoirView->currentTimeStep(); + QDateTime date = reservoirView->currentGridCellResults()->cellResults()->timeStepDate(0, currentTimeStep); infoText += QString("Time Step: %1 Time: %2").arg(currentTimeStep).arg(date.toString("dd.MMM yyyy")); } - m_reservoirView->viewer()->setInfoText(infoText); + reservoirView->viewer()->setInfoText(infoText); } if (showHistogram()) { - if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult()) + if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult()) { double min, max; double p10, p90; double mean; - size_t scalarIndex = m_reservoirView->cellResult()->scalarResultIndex(); - m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); - m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); + size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); + reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); + reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); - m_reservoirView->viewer()->showHistogram(true); - m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); - m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); + reservoirView->viewer()->showHistogram(true); + reservoirView->viewer()->setHistogram(min, max, reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); + reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } } @@ -241,7 +276,108 @@ void Rim3dOverlayInfoConfig::update3DInfo() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* Rim3dOverlayInfoConfig::objectToggleField() +void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { - return &active; + if (showInfoText()) + { + QString infoText; + + RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); + RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; + RigFemPartCollection* femParts = caseData ? caseData->femParts() : NULL; + + if (femParts) + { + QString caseName = geoMechCase->caseUserDescription(); + QString cellCount = QString("%1").arg(femParts->totalElementCount()); + QString zScale = QString::number(geoMechView->scaleZ()); + + infoText = QString( + "

-- %1 --

" + "Cell count: %2 Z-Scale: %3
").arg(caseName, cellCount, zScale); + + if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult()) + { + QString resultPos; + QString fieldName = geoMechView->cellResult()->resultFieldUiName(); + QString compName = geoMechView->cellResult()->resultComponentUiName(); + + if (!fieldName.isEmpty()) + { + switch (geoMechView->cellResult()->resultPositionType()) + { + case RIG_NODAL: + resultPos = "Nodal"; + break; + + case RIG_ELEMENT_NODAL: + resultPos = "Element nodal"; + break; + + case RIG_INTEGRATION_POINT: + resultPos = "Integration point"; + break; + + default: + break; + } + + infoText += QString( + "Cell result: %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); + + double min = 0, max = 0; + double p10 = 0, p90 = 0; + double mean = 0; + + RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); + caseData->femPartResults()->meanScalarValue(resAddress, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max); + + // ToDo: Implement statistics for geomech data + + caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); + + infoText += QString("" + "
MinP10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); + } + else + { + infoText += QString("
"); + } + + int currentTimeStep = geoMechView->currentTimeStep(); + QString stepName = QString::fromStdString(caseData->femPartResults()->stepNames()[currentTimeStep]); + infoText += QString("Time Step: %1 Time: %2").arg(currentTimeStep).arg(stepName); + } + } + + geoMechView->viewer()->setInfoText(infoText); + } + + if (showHistogram()) + { + if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult()) + { + geoMechView->viewer()->showHistogram(true); + + // ToDo: Implement statistics for geomech data + + RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); + RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; + + if (caseData) + { + double min = 0, max = 0; + double p10 = 0, p90 = 0; + double mean = 0; + + RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); + caseData->femPartResults()->meanScalarValue(resAddress, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); + caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); + geoMechView->viewer()->setHistogram(min, max, caseData->femPartResults()->scalarValuesHistogram(resAddress)); + geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean); + } + } + } } diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h index 7f0c805144..463fb6b71b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h @@ -27,7 +27,10 @@ #include "cvfVector2.h" -class RimReservoirView; +class RimEclipseView; +class RimGeoMechView; +class RimView; + //================================================================================================== /// /// @@ -41,7 +44,7 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void update3DInfo(); - void setReservoirView(RimReservoirView* ownerReservoirView) {m_reservoirView = ownerReservoirView; } + void setReservoirView(RimView* ownerView); void setPosition(cvf::Vec2ui position); caf::PdmField active; @@ -53,7 +56,13 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual caf::PdmFieldHandle* objectToggleField(); private: - caf::PdmPointer m_reservoirView; + + void updateReservoir3DInfo(RimEclipseView * reservoirView); + void updateGeoMech3DInfo(RimGeoMechView * geoMechView); + + + + caf::PdmPointer m_viewDef; cvf::Vec2ui m_position; }; diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 371f5c8f6d..94c0fdfcbb 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -1,8 +1,7 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,64 +18,28 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimCase.h" +#include "cafPdmObjectFactory.h" -#include "RiaApplication.h" -#include "RiaPreferences.h" - -#include "RigCaseCellResultsData.h" -#include "RigCaseData.h" - -#include "RimCaseCollection.h" -#include "RimCellEdgeResultSlot.h" -#include "RimCellPropertyFilter.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" - -#include "cafPdmDocument.h" -#include "cafProgressInfo.h" +#include "cafPdmAbstractClassSourceInit.h" #include #include #include #include +CAF_PDM_ABSTRACT_SOURCE_INIT(RimCase, "RimCase"); -CAF_PDM_SOURCE_INIT(RimCase, "RimReservoir"); -//------------------------------------------------------------------------------------------------ +//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimCase::RimCase() { CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case name", "", "" ,""); - + CAF_PDM_InitField(&caseId, "CaseId", -1, "Case ID", "", "" ,""); caseId.setUiReadOnly(true); - CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", ""); - - CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", ""); - m_matrixModelResults.setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", ""); - m_fractureModelResults.setUiHidden(true); - - CAF_PDM_InitField(&flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", ""); - CAF_PDM_InitField(&flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", ""); - - CAF_PDM_InitFieldNoDefault(&filesContainingFaults, "FilesContainingFaults", "", "", "", ""); - filesContainingFaults.setUiHidden(true); - - // Obsolete field - CAF_PDM_InitField(&caseName, "CaseName", QString(), "Obsolete", "", "" ,""); - caseName.setIOWritable(false); - caseName.setUiHidden(true); - - m_matrixModelResults = new RimReservoirCellResultsStorage; - m_fractureModelResults = new RimReservoirCellResultsStorage; - - this->setReservoirData( NULL ); } //-------------------------------------------------------------------------------------------------- @@ -84,304 +47,10 @@ RimCase::RimCase() //-------------------------------------------------------------------------------------------------- RimCase::~RimCase() { - reservoirViews.deleteAllChildObjects(); - - delete m_matrixModelResults(); - delete m_fractureModelResults(); - - if (this->reservoirData()) - { - // At this point, we assume that memory should be released - CVF_ASSERT(this->reservoirData()->refCount() == 1); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigCaseData* RimCase::reservoirData() -{ - return m_rigEclipseCase.p(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RigCaseData* RimCase::reservoirData() const -{ - return m_rigEclipseCase.p(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCase::initAfterRead() -{ - size_t j; - for (j = 0; j < reservoirViews().size(); j++) - { - RimReservoirView* riv = reservoirViews()[j]; - CVF_ASSERT(riv); - - riv->setEclipseCase(this); - } - - if (caseUserDescription().isEmpty() && !caseName().isEmpty()) - { - caseUserDescription = caseName; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimReservoirView* RimCase::createAndAddReservoirView() -{ - RimReservoirView* riv = new RimReservoirView(); - riv->setEclipseCase(this); - - caf::PdmDocument::updateUiIconStateRecursively(riv); - - size_t i = reservoirViews().size(); - riv->name = QString("View %1").arg(i + 1); - - reservoirViews().push_back(riv); - - return riv; -} - -//-------------------------------------------------------------------------------------------------- -/// TODO: Move this functionality to PdmPointersField -//-------------------------------------------------------------------------------------------------- -void RimCase::removeReservoirView(RimReservoirView* reservoirView) -{ - std::vector indices; - - size_t i; - for (i = 0; i < reservoirViews().size(); i++) - { - if (reservoirViews()[i] == reservoirView) - { - indices.push_back(i); - } - } - - // NB! Make sure the ordering goes from large to low index - while (!indices.empty()) - { - reservoirViews().erase(indices.back()); - indices.pop_back(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCase::removeResult(const QString& resultName) -{ - size_t i; - for (i = 0; i < reservoirViews().size(); i++) - { - RimReservoirView* reservoirView = reservoirViews()[i]; - CVF_ASSERT(reservoirView); - - RimResultSlot* result = reservoirView->cellResult; - CVF_ASSERT(result); - - bool rebuildDisplayModel = false; - - // Set cell result variable to none if displaying - if (result->resultVariable() == resultName) - { - result->setResultVariable(RimDefines::undefinedResultName()); - result->loadResult(); - - rebuildDisplayModel = true; - } - - std::list< caf::PdmPointer< RimCellPropertyFilter > >::iterator it; - RimCellPropertyFilterCollection* propFilterCollection = reservoirView->propertyFilterCollection(); - for (it = propFilterCollection->propertyFilters.v().begin(); it != propFilterCollection->propertyFilters.v().end(); ++it) - { - RimCellPropertyFilter* propertyFilter = *it; - if (propertyFilter->resultDefinition->resultVariable() == resultName) - { - propertyFilter->resultDefinition->setResultVariable(RimDefines::undefinedResultName()); - propertyFilter->resultDefinition->loadResult(); - propertyFilter->setDefaultValues(); - - rebuildDisplayModel = true; - } - } - - if (rebuildDisplayModel) - { - reservoirViews()[i]->createDisplayModelAndRedraw(); - } - - - // TODO - // CellEdgeResults are not considered, as they do not support display of input properties yet - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - if (changedField == &releaseResultMemory) - { - if (this->reservoirData()) - { - for (size_t i = 0; i < reservoirViews().size(); i++) - { - RimReservoirView* reservoirView = reservoirViews()[i]; - CVF_ASSERT(reservoirView); - - RimResultSlot* result = reservoirView->cellResult; - CVF_ASSERT(result); - - result->setResultVariable(RimDefines::undefinedResultName()); - result->loadResult(); - - RimCellEdgeResultSlot* cellEdgeResult = reservoirView->cellEdgeResult; - CVF_ASSERT(cellEdgeResult); - - cellEdgeResult->resultVariable.v() = RimDefines::undefinedResultName(); - cellEdgeResult->loadResult(); - - reservoirView->createDisplayModelAndRedraw(); - } - - RigCaseCellResultsData* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); - if (matrixModelResults) - { - matrixModelResults->clearAllResults(); - } - - RigCaseCellResultsData* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS); - if (fractureModelResults) - { - fractureModelResults->clearAllResults(); - } - } - - releaseResultMemory = oldValue.toBool(); - } - else if (changedField == &flipXAxis || changedField == &flipYAxis) - { - RigCaseData* rigEclipseCase = reservoirData(); - if (rigEclipseCase) - { - rigEclipseCase->mainGrid()->setFlipAxis(flipXAxis, flipYAxis); - - computeCachedData(); - - for (size_t i = 0; i < reservoirViews().size(); i++) - { - RimReservoirView* reservoirView = reservoirViews()[i]; - - reservoirView->scheduleReservoirGridGeometryRegen(); - reservoirView->schedulePipeGeometryRegen(); - reservoirView->createDisplayModelAndRedraw(); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCase::computeCachedData() -{ - RigCaseData* rigEclipseCase = reservoirData(); - if (rigEclipseCase) - { - caf::ProgressInfo pInf(30, ""); - pInf.setNextProgressIncrement(1); - rigEclipseCase->computeActiveCellBoundingBoxes(); - pInf.incrementProgress(); - - pInf.setNextProgressIncrement(10); - rigEclipseCase->mainGrid()->computeCachedData(); - pInf.incrementProgress(); - - pInf.setProgressDescription("Calculating faults"); - rigEclipseCase->mainGrid()->calculateFaults(); - pInf.incrementProgress(); - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimCaseCollection* RimCase::parentCaseCollection() -{ - std::vector parentObjects; - this->parentObjectsOfType(parentObjects); - - if (parentObjects.size() > 0) - { - return parentObjects[0]; - } - return NULL; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimCase::parentGridCaseGroup() -{ - RimCaseCollection* caseColl = parentCaseCollection(); - if (caseColl) - { - return caseColl->parentCaseGroup(); - } - else - { - return NULL; - } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCase::setReservoirData(RigCaseData* eclipseCase) -{ - m_rigEclipseCase = eclipseCase; - if (this->reservoirData()) - { - m_fractureModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)); - m_matrixModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)); - m_fractureModelResults()->setMainGrid(this->reservoirData()->mainGrid()); - m_matrixModelResults()->setMainGrid(this->reservoirData()->mainGrid()); - } - else - { - m_fractureModelResults()->setCellResults(NULL); - m_matrixModelResults()->setCellResults(NULL); - m_fractureModelResults()->setMainGrid(NULL); - m_matrixModelResults()->setMainGrid(NULL); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityModelResultType porosityModel) -{ - if (porosityModel == RifReaderInterface::MATRIX_RESULTS) - { - return m_matrixModelResults(); - } - - return m_fractureModelResults(); -} - //-------------------------------------------------------------------------------------------------- /// Relocate the supplied file name, based on the search path as follows: @@ -536,41 +205,4 @@ QString RimCase::relocateFile(const QString& orgFileName, const QString& orgNew if (foundFile) *foundFile = false; return fileName; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimCase::openReserviorCase() -{ - // If read already, return - - if (this->reservoirData() != NULL) return true; - - if (!openEclipseGridFile()) - { - return false; - } - - { - RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::MATRIX_RESULTS); - if (results->cellResults()) - { - results->cellResults()->createPlaceholderResultEntries(); - // After the placeholder result for combined transmissibility is created, - // make sure the nnc transmissibilities can be addressed by this scalarResultIndex as well - size_t combinedTransResIdx = results->cellResults()->findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedTransmissibilityResultName()); - if (combinedTransResIdx != cvf::UNDEFINED_SIZE_T) - { - reservoirData()->mainGrid()->nncData()->setCombTransmisibilityScalarResultIndex(combinedTransResIdx); - } - } - - } - { - RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::FRACTURE_RESULTS); - if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries(); - } - - return true; -} +} \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index ccaee649f8..10fd3efc13 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -1,8 +1,7 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,90 +18,35 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once - -#include "cvfBase.h" -#include "cvfObject.h" #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RifReaderInterface.h" -class QString; +#include -class RigCaseData; -class RigGridBase; -class RimReservoirView; -class RimCaseCollection; -class RimIdenticalGridCaseGroup; -class RimReservoirCellResultsStorage; +class RimView; -//================================================================================================== -// -// Interface for reservoirs. -// -//================================================================================================== class RimCase : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: RimCase(); virtual ~RimCase(); - - - // Fields: - caf::PdmField caseUserDescription; - caf::PdmField caseId; - caf::PdmField releaseResultMemory; - caf::PdmPointersField reservoirViews; - caf::PdmField flipXAxis; - caf::PdmField flipYAxis; - caf::PdmField > filesContainingFaults; - - - bool openReserviorCase(); - virtual bool openEclipseGridFile() { return false; }; // Should be pure virtual but PDM does not allow that. - - RigCaseData* reservoirData(); - const RigCaseData* reservoirData() const; - - RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); - - RimReservoirView* createAndAddReservoirView(); - void removeReservoirView(RimReservoirView* reservoirView); - - void removeResult(const QString& resultName); + caf::PdmField caseUserDescription; - virtual QString locationOnDisc() const { return QString(); } - virtual QString gridFileName() const { return QString(); } + caf::PdmField caseId; + virtual std::vector views() = 0; - virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) { }; + virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0; - RimCaseCollection* parentCaseCollection(); - RimIdenticalGridCaseGroup* parentGridCaseGroup(); - - - // Overridden methods from PdmObject -public: virtual caf::PdmFieldHandle* userDescriptionField() { return &caseUserDescription; } protected: - virtual void initAfterRead(); - virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); - - // Internal methods -protected: - void computeCachedData(); - void setReservoirData(RigCaseData* eclipseCase); static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath, bool* foundFile, std::vector* searchedPaths); private: - cvf::ref m_rigEclipseCase; + +}; + -private: - caf::PdmField m_matrixModelResults; - caf::PdmField m_fractureModelResults; - // Obsolete fields -protected: - caf::PdmField caseName; -}; diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp index 2ab8bb64ad..b3122b9b94 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -20,7 +20,7 @@ #include "RimCaseCollection.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimIdenticalGridCaseGroup.h" @@ -63,7 +63,7 @@ RimIdenticalGridCaseGroup* RimCaseCollection::parentCaseGroup() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase* RimCaseCollection::findByDescription(const QString& caseDescription) const +RimEclipseCase* RimCaseCollection::findByDescription(const QString& caseDescription) const { for (size_t i = 0; i < reservoirs.size(); i++) { diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.h b/ApplicationCode/ProjectDataModel/RimCaseCollection.h index 9eb79e7c1a..9208554226 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.h @@ -21,7 +21,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -class RimCase; +class RimEclipseCase; class RimIdenticalGridCaseGroup; //================================================================================================== @@ -36,10 +36,10 @@ class RimCaseCollection : public caf::PdmObject public: RimCaseCollection(); virtual ~RimCaseCollection(); - caf::PdmPointersField reservoirs; + caf::PdmPointersField reservoirs; RimIdenticalGridCaseGroup* parentCaseGroup(); - RimCase* findByDescription(const QString& caseDescription) const; + RimEclipseCase* findByDescription(const QString& caseDescription) const; private: diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp similarity index 85% rename from ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp rename to ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp index 19926c6dee..d55ac2b40d 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp @@ -18,26 +18,29 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimCellEdgeResultSlot.h" +#include "RimCellEdgeColors.h" #include "RigCaseCellResultsData.h" #include "RimLegendConfig.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "cafPdmUiListEditor.h" #include "cvfMath.h" -CAF_PDM_SOURCE_INIT(RimCellEdgeResultSlot, "CellEdgeResultSlot"); +CAF_PDM_SOURCE_INIT(RimCellEdgeColors, "CellEdgeResultSlot"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellEdgeResultSlot::RimCellEdgeResultSlot() +RimCellEdgeColors::RimCellEdgeColors() { CAF_PDM_InitObject("Cell Edge Result", "", "", ""); + CAF_PDM_InitField(&enableCellEdgeColors, "EnableCellEdgeColors", true, "Enable cell edge results", "", "", ""); + enableCellEdgeColors.setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&resultVariable, "CellEdgeVariable", "Result property", "", "", ""); CAF_PDM_InitField(&useXVariable, "UseXVariable", true, "Use X values", "", "", ""); CAF_PDM_InitField(&useYVariable, "UseYVariable", true, "Use Y values", "", "", ""); @@ -56,7 +59,7 @@ RimCellEdgeResultSlot::RimCellEdgeResultSlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellEdgeResultSlot::~RimCellEdgeResultSlot() +RimCellEdgeColors::~RimCellEdgeColors() { delete legendConfig(); } @@ -64,7 +67,7 @@ RimCellEdgeResultSlot::~RimCellEdgeResultSlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::setReservoirView(RimReservoirView* ownerReservoirView) +void RimCellEdgeColors::setReservoirView(RimEclipseView* ownerReservoirView) { m_reservoirView = ownerReservoirView; this->legendConfig()->setReservoirView(ownerReservoirView); @@ -73,7 +76,7 @@ void RimCellEdgeResultSlot::setReservoirView(RimReservoirView* ownerReservoirVie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::loadResult() +void RimCellEdgeColors::loadResult() { CVF_ASSERT(m_reservoirView && m_reservoirView->currentGridCellResults()); @@ -106,7 +109,7 @@ void RimCellEdgeResultSlot::loadResult() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimCellEdgeColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { loadResult(); @@ -116,14 +119,14 @@ void RimCellEdgeResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF namespace caf { template<> - void RimCellEdgeResultSlot::EdgeFaceEnum::setUp() + void RimCellEdgeColors::EdgeFaceEnum::setUp() { - addItem(RimCellEdgeResultSlot::X, "X", ""); - addItem(RimCellEdgeResultSlot::NEG_X, "X-", ""); - addItem(RimCellEdgeResultSlot::Y, "Y", ""); - addItem(RimCellEdgeResultSlot::NEG_Y, "Y-", ""); - addItem(RimCellEdgeResultSlot::Z, "Z", ""); - addItem(RimCellEdgeResultSlot::NEG_Z, "Z-", ""); + addItem(RimCellEdgeColors::X, "X", ""); + addItem(RimCellEdgeColors::NEG_X, "X-", ""); + addItem(RimCellEdgeColors::Y, "Y", ""); + addItem(RimCellEdgeColors::NEG_Y, "Y-", ""); + addItem(RimCellEdgeColors::Z, "Z", ""); + addItem(RimCellEdgeColors::NEG_Z, "Z-", ""); } } @@ -132,7 +135,7 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- -QList RimCellEdgeResultSlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimCellEdgeColors::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { if (fieldNeedingOptions == &resultVariable) { @@ -209,7 +212,7 @@ QList RimCellEdgeResultSlot::calculateValueOptions(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RimCellEdgeResultSlot::findResultVariableNames() +QStringList RimCellEdgeColors::findResultVariableNames() { QStringList varNames; @@ -238,7 +241,7 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::gridScalarIndices(size_t resultIndices[6]) +void RimCellEdgeColors::gridScalarIndices(size_t resultIndices[6]) { int cubeFaceIndex; for (cubeFaceIndex = 0; cubeFaceIndex < 6; ++cubeFaceIndex) @@ -250,7 +253,7 @@ void RimCellEdgeResultSlot::gridScalarIndices(size_t resultIndices[6]) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::gridScalarResultNames(QStringList* resultNames) +void RimCellEdgeColors::gridScalarResultNames(QStringList* resultNames) { CVF_ASSERT(resultNames); @@ -265,7 +268,7 @@ void RimCellEdgeResultSlot::gridScalarResultNames(QStringList* resultNames) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::resetResultIndices() +void RimCellEdgeColors::resetResultIndices() { int cubeFaceIndex; for (cubeFaceIndex = 0; cubeFaceIndex < 6; ++cubeFaceIndex) @@ -277,8 +280,10 @@ void RimCellEdgeResultSlot::resetResultIndices() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimCellEdgeResultSlot::hasResult() const +bool RimCellEdgeColors::hasResult() const { + if (!enableCellEdgeColors()) return false; + bool hasResult = false; int cubeFaceIndex; for (cubeFaceIndex = 0; cubeFaceIndex < 6; ++cubeFaceIndex) @@ -292,7 +297,7 @@ bool RimCellEdgeResultSlot::hasResult() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::updateIgnoredScalarValue() +void RimCellEdgeColors::updateIgnoredScalarValue() { if (resultVariable == "MULT" || resultVariable == "riMULT") { @@ -307,7 +312,7 @@ void RimCellEdgeResultSlot::updateIgnoredScalarValue() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max) +void RimCellEdgeColors::minMaxCellEdgeValues(double& min, double& max) { double globalMin, globalMax; globalMin = HUGE_VAL; @@ -338,7 +343,7 @@ void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellEdgeResultSlot::posNegClosestToZero(double& pos, double& neg) +void RimCellEdgeColors::posNegClosestToZero(double& pos, double& neg) { pos = HUGE_VAL; neg = -HUGE_VAL; @@ -361,3 +366,11 @@ void RimCellEdgeResultSlot::posNegClosestToZero(double& pos, double& neg) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimCellEdgeColors::objectToggleField() +{ + return &enableCellEdgeColors; +} + diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.h b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h similarity index 85% rename from ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.h rename to ApplicationCode/ProjectDataModel/RimCellEdgeColors.h index 8be396dad6..46b5b73a82 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.h +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h @@ -28,19 +28,19 @@ class RigCaseCellResultsData; class RimLegendConfig; -class RimReservoirView; +class RimEclipseView; //================================================================================================== /// /// //================================================================================================== -class RimCellEdgeResultSlot : public caf::PdmObject +class RimCellEdgeColors : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimCellEdgeResultSlot(); - virtual ~RimCellEdgeResultSlot(); + RimCellEdgeColors(); + virtual ~RimCellEdgeColors(); enum EdgeFaceType { @@ -49,14 +49,12 @@ class RimCellEdgeResultSlot : public caf::PdmObject Z, NEG_Z }; - typedef caf::AppEnum EdgeFaceEnum; + typedef caf::AppEnum EdgeFaceEnum; - void setReservoirView(RimReservoirView* ownerReservoirView); + void setReservoirView(RimEclipseView* ownerReservoirView); caf::PdmField resultVariable; - caf::PdmField useXVariable; - caf::PdmField useYVariable; - caf::PdmField useZVariable; + caf::PdmField enableCellEdgeColors; caf::PdmField legendConfig; double ignoredScalarValue() { return m_ignoredResultScalar; } @@ -74,11 +72,19 @@ class RimCellEdgeResultSlot : public caf::PdmObject QStringList findResultVariableNames(); private: + + void resetResultIndices(); void updateIgnoredScalarValue(); -protected: + + virtual caf::PdmFieldHandle* objectToggleField(); + + caf::PdmField useXVariable; + caf::PdmField useYVariable; + caf::PdmField useZVariable; + caf::FixedArray, 6 > m_resultNameToIndexPairs; - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; double m_ignoredResultScalar; }; diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h deleted file mode 100644 index 7e92b29787..0000000000 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h +++ /dev/null @@ -1,74 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS -// -// 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 "RimCellFilter.h" - -class RimReservoirView; -class RimCellPropertyFilterCollection; -class RimResultDefinition; - -class RigGridBase; -class RigCaseCellResultsData; - - -//================================================================================================== -/// -/// -//================================================================================================== -class RimCellPropertyFilter : public RimCellFilter -{ - CAF_PDM_HEADER_INIT; - - enum EvaluationRegionType - { - RANGE_FILTER_REGION, - GLOBAL_REGION - }; - -public: - RimCellPropertyFilter(); - virtual ~RimCellPropertyFilter(); - - void setParentContainer(RimCellPropertyFilterCollection* parentContainer); - RimCellPropertyFilterCollection* parentContainer(); - void setDefaultValues(); - void computeResultValueRange(); - - caf::PdmField resultDefinition; - - caf::PdmField lowerBound; - caf::PdmField upperBound; - caf::PdmField< caf::AppEnum< EvaluationRegionType > > evaluationRegion; - - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - - virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); - -protected: - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) ; - virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); - -private: - RimCellPropertyFilterCollection* m_parentContainer; - double m_minimumResultValue, m_maximumResultValue; -}; - diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index 15fff47817..88f79f8a6c 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -25,9 +25,9 @@ #include "RigCaseData.h" #include "RigGridBase.h" #include "RigMainGrid.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimCellRangeFilterCollection.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "cafPdmUiSliderEditor.h" #include "cvfAssert.h" @@ -102,8 +102,8 @@ void RimCellRangeFilter::computeAndSetValidValues() { CVF_ASSERT(m_parentContainer); - RigGridBase* grid = selectedGrid(); - if (grid && grid->cellCount() > 0 ) + const cvf::StructGridInterface* grid = selectedGrid(); + if (grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0) { cellCountI = cvf::Math::clamp(cellCountI.v(), 1, static_cast(grid->cellCountI())); startIndexI = cvf::Math::clamp(startIndexI.v(), 1, static_cast(grid->cellCountI())); @@ -124,10 +124,10 @@ void RimCellRangeFilter::setDefaultValues() { CVF_ASSERT(m_parentContainer); - RigGridBase* grid = selectedGrid(); + const cvf::StructGridInterface* grid = selectedGrid(); RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo(); - if (grid == m_parentContainer->mainGrid() && actCellInfo) + if (grid == m_parentContainer->gridByIndex(0) && actCellInfo) { cvf::Vec3st min, max; actCellInfo->IJKBoundingBox(min, max); @@ -178,7 +178,7 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, return; } - RigGridBase* grid = selectedGrid(); + const cvf::StructGridInterface* grid = selectedGrid(); if (field == &startIndexI || field == &cellCountI) { @@ -197,7 +197,7 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, } RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo(); - if (grid == m_parentContainer->mainGrid() && actCellInfo) + if (grid == m_parentContainer->gridByIndex(0) && actCellInfo) { cvf::Vec3st min, max; actCellInfo->IJKBoundingBox(min, max); @@ -240,17 +240,11 @@ QList RimCellRangeFilter::calculateValueOptions(const ca if (&gridIndex == fieldNeedingOptions) { - RigMainGrid * mainGrid = NULL; - - if (parentContainer() && parentContainer()->reservoirView() && parentContainer()->reservoirView()->eclipseCase() && parentContainer()->reservoirView()->eclipseCase()->reservoirData()) - mainGrid = parentContainer()->reservoirView()->eclipseCase()->reservoirData()->mainGrid(); - - for (size_t gIdx = 0; gIdx < mainGrid->gridCount(); ++gIdx) + for (int gIdx = 0; gIdx < parentContainer()->gridCount(); ++gIdx) { - RigGridBase* grid = mainGrid->gridByIndex(gIdx); QString gridName; - gridName += grid->gridName().c_str(); + gridName += parentContainer()->gridName(gIdx); if (gIdx == 0) { if (gridName.isEmpty()) @@ -269,19 +263,17 @@ QList RimCellRangeFilter::calculateValueOptions(const ca //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigGridBase* RimCellRangeFilter::selectedGrid() +const cvf::StructGridInterface* RimCellRangeFilter::selectedGrid() { - RigMainGrid* mainGrid = m_parentContainer->mainGrid(); - CVF_ASSERT(mainGrid); - - RigGridBase* grid = NULL; - if (static_cast(gridIndex()) >= mainGrid->gridCount()) + if (gridIndex() >= m_parentContainer->gridCount()) { gridIndex = 0; } - grid = mainGrid->gridByIndex(gridIndex()); + const cvf::StructGridInterface* grid = m_parentContainer->gridByIndex(gridIndex()); + CVF_ASSERT(grid); + return grid; } diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.h b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.h index 78ee97f190..07164269cd 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.h +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.h @@ -25,11 +25,12 @@ class RigGridBase; class RigMainGrid; class RimCellRangeFilterCollection; -class RimReservoirView; +class RimEclipseView; namespace cvf { class CellRangeFilter; + class StructGridInterface; } //================================================================================================== @@ -67,7 +68,7 @@ class RimCellRangeFilter : public RimCellFilter virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); private: - RigGridBase* selectedGrid(); + const cvf::StructGridInterface* selectedGrid(); RimCellRangeFilterCollection* m_parentContainer; }; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index ff430c838e..64623f1f0c 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -20,11 +20,16 @@ #include "RimCellRangeFilterCollection.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RigGridBase.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RigCaseData.h" - +#include "RigFemPartCollection.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCase.h" +#include "RigGeoMechCaseData.h" +#include "RigFemPart.h" +#include "RigFemPartGrid.h" CAF_PDM_SOURCE_INIT(RimCellRangeFilterCollection, "CellRangeFilterCollection"); @@ -55,7 +60,7 @@ RimCellRangeFilterCollection::~RimCellRangeFilterCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellRangeFilterCollection::setReservoirView(RimReservoirView* reservoirView) +void RimCellRangeFilterCollection::setReservoirView(RimView* reservoirView) { m_reservoirView = reservoirView; } @@ -65,7 +70,7 @@ void RimCellRangeFilterCollection::setReservoirView(RimReservoirView* reservoirV /// RimCellRangeFilter is using Eclipse 1-based indexing, adjust filter values before // populating cvf::CellRangeFilter (which is 0-based) //-------------------------------------------------------------------------------------------------- -void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter, const RigGridBase* grid) const +void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex) const { CVF_ASSERT(cellRangeFilter); @@ -74,7 +79,7 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter* { RimCellRangeFilter* rangeFilter = *it; - if (rangeFilter && rangeFilter->isActive() && static_cast(rangeFilter->gridIndex()) == grid->gridIndex()) + if (rangeFilter && rangeFilter->isActive() && static_cast(rangeFilter->gridIndex()) == gridIndex) { if (rangeFilter->filterMode == RimCellFilter::INCLUDE) { @@ -108,13 +113,14 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter* //-------------------------------------------------------------------------------------------------- RigMainGrid* RimCellRangeFilterCollection::mainGrid() const { - if (m_reservoirView && - m_reservoirView->eclipseCase() && - m_reservoirView->eclipseCase()->reservoirData() && - m_reservoirView->eclipseCase()->reservoirData()->mainGrid()) + RimEclipseView* eclipseView = this->eclipseView(); + if (eclipseView && + eclipseView->eclipseCase() && + eclipseView->eclipseCase()->reservoirData() && + eclipseView->eclipseCase()->reservoirData()->mainGrid()) { - return m_reservoirView->eclipseCase()->reservoirData()->mainGrid(); + return eclipseView->eclipseCase()->reservoirData()->mainGrid(); } return NULL; @@ -126,9 +132,10 @@ RigMainGrid* RimCellRangeFilterCollection::mainGrid() const //-------------------------------------------------------------------------------------------------- RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const { - if (m_reservoirView ) + RimEclipseView* eclipseView = this->eclipseView(); + if (eclipseView ) { - return m_reservoirView->currentActiveCellInfo(); + return eclipseView->currentActiveCellInfo(); } return NULL; @@ -140,12 +147,13 @@ RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const //-------------------------------------------------------------------------------------------------- void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { + this->updateUiIconFromToggleField(); CVF_ASSERT(m_reservoirView); - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + m_reservoirView->scheduleGeometryRegen(RANGE_FILTERED); + m_reservoirView->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } @@ -166,15 +174,22 @@ RimCellRangeFilter* RimCellRangeFilterCollection::createAndAppendRangeFilter() return rangeFilter; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView* RimCellRangeFilterCollection::reservoirView() +RimView* RimCellRangeFilterCollection::reservoirView() { return m_reservoirView; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RimCellRangeFilterCollection::eclipseView() const +{ + return dynamic_cast(m_reservoirView); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -240,3 +255,90 @@ bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::StructGridInterface* RimCellRangeFilterCollection::gridByIndex(int gridIndex) const +{ + RigMainGrid* mnGrid = mainGrid(); + RigFemPartCollection* femPartColl = this->femPartColl(); + + if (mnGrid) + { + RigGridBase* grid = NULL; + + grid = mnGrid->gridByIndex(gridIndex); + + CVF_ASSERT(grid); + + return grid; + } + else if (femPartColl) + { + if (gridIndex < femPartColl->partCount()) + return femPartColl->part(gridIndex)->structGrid(); + else + return NULL; + } + + return NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimCellRangeFilterCollection::gridCount() const +{ + RigMainGrid* mnGrid = mainGrid(); + RigFemPartCollection* femPartColl = this->femPartColl(); + + if (mnGrid) + { + return (int)mnGrid->gridCount(); + } + else if (femPartColl) + { + return femPartColl->partCount(); + } + + return 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCellRangeFilterCollection::gridName(int gridIndex) const +{ + RigMainGrid* mnGrid = mainGrid(); + RigFemPartCollection* femPartColl = this->femPartColl(); + + if (mnGrid) + { + return mnGrid->gridByIndex(gridIndex)->gridName().c_str(); + } + else if (femPartColl) + { + return QString::number(gridIndex); + } + + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartCollection* RimCellRangeFilterCollection::femPartColl() const +{ + RimGeoMechView* eclipseView = dynamic_cast(m_reservoirView); + + if (eclipseView && + eclipseView->geoMechCase() && + eclipseView->geoMechCase()->geoMechData() ) + { + + return eclipseView->geoMechCase()->geoMechData()->femParts(); + } + + return NULL; +} + diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h index 211c410e8c..56c04cf9fa 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h @@ -22,6 +22,8 @@ class RigActiveCellInfo; class RigGridBase; +class RimView; +class RigFemPartCollection; //================================================================================================== /// @@ -39,17 +41,21 @@ class RimCellRangeFilterCollection : public caf::PdmObject caf::PdmField< std::list< caf::PdmPointer< RimCellRangeFilter > > > rangeFilters; // Methods - RimCellRangeFilter* createAndAppendRangeFilter(); - void remove(RimCellRangeFilter* rangeFilter); + RimCellRangeFilter* createAndAppendRangeFilter(); + void remove(RimCellRangeFilter* rangeFilter); - void compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter, const RigGridBase* grid) const; - bool hasActiveFilters() const; - bool hasActiveIncludeFilters() const; + void compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex) const; + bool hasActiveFilters() const; + bool hasActiveIncludeFilters() const; - void setReservoirView(RimReservoirView* reservoirView); - RimReservoirView* reservoirView(); - RigMainGrid* mainGrid() const; - RigActiveCellInfo* activeCellInfo() const; + void setReservoirView(RimView* reservoirView); + + RimView* reservoirView(); + const cvf::StructGridInterface* gridByIndex(int gridIndex) const; + int gridCount() const; + QString gridName(int gridIndex) const; + + RigActiveCellInfo* activeCellInfo() const; // Overridden methods virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); @@ -57,9 +63,13 @@ class RimCellRangeFilterCollection : public caf::PdmObject protected: // Overridden methods - virtual void initAfterRead(); + virtual void initAfterRead(); private: - RimReservoirView* m_reservoirView; + RimEclipseView* eclipseView() const; + RigMainGrid* mainGrid() const; + RigFemPartCollection* femPartColl() const; + + RimView* m_reservoirView; }; diff --git a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp index 56b934001d..de670e402b 100644 --- a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp +++ b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp @@ -23,7 +23,7 @@ #include "RiaApplication.h" #include "RimCalcScript.h" #include "RimProject.h" -#include "RimStatisticsCase.h" +#include "RimEclipseStatisticsCase.h" #include "cafPdmDocument.h" #include "cafPdmUiPushButtonEditor.h" @@ -178,9 +178,9 @@ void RimCommandFactory::createCommandObjects(const caf::PdmObjectGroup& selected commandObjects->push_back(command); } } - else if (dynamic_cast(pdmObject)) + else if (dynamic_cast(pdmObject)) { - RimStatisticsCase* statisticsCase = dynamic_cast(pdmObject); + RimEclipseStatisticsCase* statisticsCase = dynamic_cast(pdmObject); RimCommandIssueFieldChanged* command = new RimCommandIssueFieldChanged; command->objectName = statisticsCase->uiName(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp new file mode 100644 index 0000000000..fa53aa8f05 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -0,0 +1,413 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011- Statoil ASA +// Copyright (C) 2013- Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS +// +// 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 "RimEclipseCase.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RigCaseCellResultsData.h" +#include "RigCaseData.h" + +#include "RimCaseCollection.h" +#include "RimCellEdgeColors.h" +#include "RimEclipsePropertyFilter.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimReservoirCellResultsStorage.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" + +#include "cafPdmDocument.h" +#include "cafProgressInfo.h" + +#include +#include +#include +#include + + +#include "cafPdmAbstractClassSourceInit.h" + +CAF_PDM_ABSTRACT_SOURCE_INIT(RimEclipseCase, "RimReservoir"); + +//------------------------------------------------------------------------------------------------ +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase::RimEclipseCase() +{ + + + CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", ""); + m_matrixModelResults.setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", ""); + m_fractureModelResults.setUiHidden(true); + + CAF_PDM_InitField(&flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", ""); + CAF_PDM_InitField(&flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&filesContainingFaults, "FilesContainingFaults", "", "", "", ""); + filesContainingFaults.setUiHidden(true); + + // Obsolete field + CAF_PDM_InitField(&caseName, "CaseName", QString(), "Obsolete", "", "" ,""); + caseName.setIOWritable(false); + caseName.setUiHidden(true); + + m_matrixModelResults = new RimReservoirCellResultsStorage; + m_fractureModelResults = new RimReservoirCellResultsStorage; + + this->setReservoirData( NULL ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase::~RimEclipseCase() +{ + reservoirViews.deleteAllChildObjects(); + + delete m_matrixModelResults(); + delete m_fractureModelResults(); + + if (this->reservoirData()) + { + // At this point, we assume that memory should be released + CVF_ASSERT(this->reservoirData()->refCount() == 1); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseData* RimEclipseCase::reservoirData() +{ + return m_rigEclipseCase.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigCaseData* RimEclipseCase::reservoirData() const +{ + return m_rigEclipseCase.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::initAfterRead() +{ + size_t j; + for (j = 0; j < reservoirViews().size(); j++) + { + RimEclipseView* riv = reservoirViews()[j]; + CVF_ASSERT(riv); + + riv->setEclipseCase(this); + } + + if (caseUserDescription().isEmpty() && !caseName().isEmpty()) + { + caseUserDescription = caseName; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RimEclipseCase::createAndAddReservoirView() +{ + RimEclipseView* riv = new RimEclipseView(); + riv->setEclipseCase(this); + riv->cellEdgeResult()->resultVariable = "MULT"; + riv->cellEdgeResult()->enableCellEdgeColors = false; + + caf::PdmDocument::updateUiIconStateRecursively(riv); + + size_t i = reservoirViews().size(); + riv->name = QString("View %1").arg(i + 1); + + reservoirViews().push_back(riv); + + return riv; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::removeResult(const QString& resultName) +{ + size_t i; + for (i = 0; i < reservoirViews().size(); i++) + { + RimEclipseView* reservoirView = reservoirViews()[i]; + CVF_ASSERT(reservoirView); + + RimEclipseCellColors* result = reservoirView->cellResult; + CVF_ASSERT(result); + + bool rebuildDisplayModel = false; + + // Set cell result variable to none if displaying + if (result->resultVariable() == resultName) + { + result->setResultVariable(RimDefines::undefinedResultName()); + result->loadResult(); + + rebuildDisplayModel = true; + } + + std::list< caf::PdmPointer< RimEclipsePropertyFilter > >::iterator it; + RimEclipsePropertyFilterCollection* propFilterCollection = reservoirView->propertyFilterCollection(); + + for (size_t filter = 0; filter < propFilterCollection->propertyFilters().size(); filter++) + { + RimEclipsePropertyFilter* propertyFilter = propFilterCollection->propertyFilters()[filter]; + if (propertyFilter->resultDefinition->resultVariable() == resultName) + { + propertyFilter->resultDefinition->setResultVariable(RimDefines::undefinedResultName()); + propertyFilter->resultDefinition->loadResult(); + propertyFilter->setToDefaultValues(); + + rebuildDisplayModel = true; + } + } + + if (rebuildDisplayModel) + { + reservoirViews()[i]->createDisplayModelAndRedraw(); + } + + + // TODO + // CellEdgeResults are not considered, as they do not support display of input properties yet + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &releaseResultMemory) + { + if (this->reservoirData()) + { + for (size_t i = 0; i < reservoirViews().size(); i++) + { + RimEclipseView* reservoirView = reservoirViews()[i]; + CVF_ASSERT(reservoirView); + + RimEclipseCellColors* result = reservoirView->cellResult; + CVF_ASSERT(result); + + result->setResultVariable(RimDefines::undefinedResultName()); + result->loadResult(); + + RimCellEdgeColors* cellEdgeResult = reservoirView->cellEdgeResult; + CVF_ASSERT(cellEdgeResult); + + cellEdgeResult->resultVariable.v() = RimDefines::undefinedResultName(); + cellEdgeResult->loadResult(); + + reservoirView->createDisplayModelAndRedraw(); + } + + RigCaseCellResultsData* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); + if (matrixModelResults) + { + matrixModelResults->clearAllResults(); + } + + RigCaseCellResultsData* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS); + if (fractureModelResults) + { + fractureModelResults->clearAllResults(); + } + } + + releaseResultMemory = oldValue.toBool(); + } + else if (changedField == &flipXAxis || changedField == &flipYAxis) + { + RigCaseData* rigEclipseCase = reservoirData(); + if (rigEclipseCase) + { + rigEclipseCase->mainGrid()->setFlipAxis(flipXAxis, flipYAxis); + + computeCachedData(); + + for (size_t i = 0; i < reservoirViews().size(); i++) + { + RimEclipseView* reservoirView = reservoirViews()[i]; + + reservoirView->scheduleReservoirGridGeometryRegen(); + reservoirView->schedulePipeGeometryRegen(); + reservoirView->createDisplayModelAndRedraw(); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::computeCachedData() +{ + RigCaseData* rigEclipseCase = reservoirData(); + if (rigEclipseCase) + { + caf::ProgressInfo pInf(30, ""); + pInf.setNextProgressIncrement(1); + rigEclipseCase->computeActiveCellBoundingBoxes(); + pInf.incrementProgress(); + + pInf.setNextProgressIncrement(10); + rigEclipseCase->mainGrid()->computeCachedData(); + pInf.incrementProgress(); + + pInf.setProgressDescription("Calculating faults"); + rigEclipseCase->mainGrid()->calculateFaults(); + pInf.incrementProgress(); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCaseCollection* RimEclipseCase::parentCaseCollection() +{ + std::vector parentObjects; + this->parentObjectsOfType(parentObjects); + + if (parentObjects.size() > 0) + { + return parentObjects[0]; + } + + return NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimEclipseCase::parentGridCaseGroup() +{ + RimCaseCollection* caseColl = parentCaseCollection(); + if (caseColl) + { + return caseColl->parentCaseGroup(); + } + else + { + return NULL; + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::setReservoirData(RigCaseData* eclipseCase) +{ + m_rigEclipseCase = eclipseCase; + if (this->reservoirData()) + { + m_fractureModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)); + m_matrixModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)); + m_fractureModelResults()->setMainGrid(this->reservoirData()->mainGrid()); + m_matrixModelResults()->setMainGrid(this->reservoirData()->mainGrid()); + } + else + { + m_fractureModelResults()->setCellResults(NULL); + m_matrixModelResults()->setCellResults(NULL); + m_fractureModelResults()->setMainGrid(NULL); + m_matrixModelResults()->setMainGrid(NULL); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimReservoirCellResultsStorage* RimEclipseCase::results(RifReaderInterface::PorosityModelResultType porosityModel) +{ + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + return m_matrixModelResults(); + } + + return m_fractureModelResults(); +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseCase::openReserviorCase() +{ + // If read already, return + + if (this->reservoirData() != NULL) return true; + + if (!openEclipseGridFile()) + { + return false; + } + + { + RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::MATRIX_RESULTS); + if (results->cellResults()) + { + results->cellResults()->createPlaceholderResultEntries(); + // After the placeholder result for combined transmissibility is created, + // make sure the nnc transmissibilities can be addressed by this scalarResultIndex as well + size_t combinedTransResIdx = results->cellResults()->findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedTransmissibilityResultName()); + if (combinedTransResIdx != cvf::UNDEFINED_SIZE_T) + { + reservoirData()->mainGrid()->nncData()->setCombTransmisibilityScalarResultIndex(combinedTransResIdx); + } + } + + } + { + RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::FRACTURE_RESULTS); + if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries(); + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseCase::views() +{ + std::vector views; + for (size_t vIdx = 0; vIdx < reservoirViews.size(); ++vIdx) + { + views.push_back(reservoirViews[vIdx]); + } + return views; +} diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h new file mode 100644 index 0000000000..e1f42e5ea9 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -0,0 +1,106 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011- Statoil ASA +// Copyright (C) 2013- Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS +// +// 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 "RimCase.h" + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "RifReaderInterface.h" +class QString; + +class RigCaseData; +class RigGridBase; +class RimEclipseView; +class RimCaseCollection; +class RimIdenticalGridCaseGroup; +class RimReservoirCellResultsStorage; + + +//================================================================================================== +// +// Interface for reservoirs. +// +//================================================================================================== +class RimEclipseCase : public RimCase +{ + CAF_PDM_HEADER_INIT; +public: + RimEclipseCase(); + virtual ~RimEclipseCase(); + + + // Fields: + caf::PdmField releaseResultMemory; + caf::PdmPointersField reservoirViews; + caf::PdmField flipXAxis; + caf::PdmField flipYAxis; + + caf::PdmField > filesContainingFaults; + + + bool openReserviorCase(); + virtual bool openEclipseGridFile() = 0; + + RigCaseData* reservoirData(); + const RigCaseData* reservoirData() const; + + RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); + + RimEclipseView* createAndAddReservoirView(); + + void removeResult(const QString& resultName); + + virtual QString locationOnDisc() const { return QString(); } + virtual QString gridFileName() const { return QString(); } + + + RimCaseCollection* parentCaseCollection(); + RimIdenticalGridCaseGroup* parentGridCaseGroup(); + + virtual std::vector views(); + + // Overridden methods from PdmObject +public: + +protected: + virtual void initAfterRead(); + virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); + + // Internal methods +protected: + void computeCachedData(); + void setReservoirData(RigCaseData* eclipseCase); + + +private: + cvf::ref m_rigEclipseCase; + +private: + caf::PdmField m_matrixModelResults; + caf::PdmField m_fractureModelResults; + + // Obsolete fields +protected: + caf::PdmField caseName; +}; diff --git a/ApplicationCode/ProjectDataModel/RimAnalysisModels.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.cpp similarity index 85% rename from ApplicationCode/ProjectDataModel/RimAnalysisModels.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.cpp index 5a3f8f9408..faefd53074 100644 --- a/ApplicationCode/ProjectDataModel/RimAnalysisModels.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.cpp @@ -18,23 +18,23 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimAnalysisModels.h" +#include "RimEclipseCaseCollection.h" #include "RiaApplication.h" #include "RigCaseData.h" #include "RigGridManager.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" #include "RimProject.h" -#include "RimStatisticsCase.h" +#include "RimEclipseStatisticsCase.h" -CAF_PDM_SOURCE_INIT(RimAnalysisModels, "ResInsightAnalysisModels"); +CAF_PDM_SOURCE_INIT(RimEclipseCaseCollection, "ResInsightAnalysisModels"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimAnalysisModels::RimAnalysisModels(void) +RimEclipseCaseCollection::RimEclipseCaseCollection(void) { CAF_PDM_InitObject("Grid Models", ":/Cases16x16.png", "", ""); @@ -47,7 +47,7 @@ RimAnalysisModels::RimAnalysisModels(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimAnalysisModels::~RimAnalysisModels(void) +RimEclipseCaseCollection::~RimEclipseCaseCollection(void) { close(); } @@ -55,7 +55,7 @@ RimAnalysisModels::~RimAnalysisModels(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnalysisModels::close() +void RimEclipseCaseCollection::close() { m_gridCollection->clear(); @@ -66,7 +66,7 @@ void RimAnalysisModels::close() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCase(RimCase* mainCase) +RimIdenticalGridCaseGroup* RimEclipseCaseCollection::createIdenticalCaseGroupFromMainCase(RimEclipseCase* mainCase) { CVF_ASSERT(mainCase); @@ -78,7 +78,7 @@ RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCa assert(RiaApplication::instance()->project()); RiaApplication::instance()->project()->assignIdToCaseGroup(group); - RimCase* createdCase = group->createAndAppendStatisticsCase(); + RimEclipseCase* createdCase = group->createAndAppendStatisticsCase(); RiaApplication::instance()->project()->assignCaseIdToCase(createdCase); group->addCase(mainCase); @@ -90,7 +90,7 @@ RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnalysisModels::moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir) +void RimEclipseCaseCollection::moveEclipseCaseIntoCaseGroup(RimEclipseCase* rimReservoir) { CVF_ASSERT(rimReservoir); @@ -130,7 +130,7 @@ void RimAnalysisModels::moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnalysisModels::removeCaseFromAllGroups(RimCase* reservoir) +void RimEclipseCaseCollection::removeCaseFromAllGroups(RimEclipseCase* reservoir) { m_gridCollection->removeCase(reservoir->reservoirData()); @@ -148,7 +148,7 @@ void RimAnalysisModels::removeCaseFromAllGroups(RimCase* reservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigMainGrid* RimAnalysisModels::registerCaseInGridCollection(RigCaseData* rigEclipseCase) +RigMainGrid* RimEclipseCaseCollection::registerCaseInGridCollection(RigCaseData* rigEclipseCase) { CVF_ASSERT(rigEclipseCase); @@ -177,7 +177,7 @@ RigMainGrid* RimAnalysisModels::registerCaseInGridCollection(RigCaseData* rigEcl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnalysisModels::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir) +void RimEclipseCaseCollection::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimEclipseCase* rimReservoir) { CVF_ASSERT(rimReservoir); @@ -191,7 +191,7 @@ void RimAnalysisModels::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGro //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimAnalysisModels::recomputeStatisticsForAllCaseGroups() +void RimEclipseCaseCollection::recomputeStatisticsForAllCaseGroups() { const size_t numCaseGroups = caseGroups.size(); for (size_t caseGrpIdx = 0; caseGrpIdx < numCaseGroups; ++caseGrpIdx) @@ -201,7 +201,7 @@ void RimAnalysisModels::recomputeStatisticsForAllCaseGroups() const size_t numStatisticsCases = statisticsCaseCollection->reservoirs.size(); for (size_t caseIdx = 0; caseIdx < numStatisticsCases; caseIdx++) { - RimStatisticsCase* statisticsCase = dynamic_cast(statisticsCaseCollection->reservoirs[caseIdx]); + RimEclipseStatisticsCase* statisticsCase = dynamic_cast(statisticsCaseCollection->reservoirs[caseIdx]); if (statisticsCase) { statisticsCase->clearComputedStatistics(); diff --git a/ApplicationCode/ProjectDataModel/RimAnalysisModels.h b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.h similarity index 81% rename from ApplicationCode/ProjectDataModel/RimAnalysisModels.h rename to ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.h index 44673a9b8c..6e8f6e666e 100644 --- a/ApplicationCode/ProjectDataModel/RimAnalysisModels.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.h @@ -26,7 +26,7 @@ #include "cvfObject.h" -class RimCase; +class RimEclipseCase; class RigGridManager; class RimIdenticalGridCaseGroup; class RigMainGrid; @@ -37,23 +37,23 @@ class RimWellPathCollection; /// /// //================================================================================================== -class RimAnalysisModels : public caf::PdmObject +class RimEclipseCaseCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimAnalysisModels(void); - virtual ~RimAnalysisModels(void); + RimEclipseCaseCollection(void); + virtual ~RimEclipseCaseCollection(void); - caf::PdmPointersField cases; + caf::PdmPointersField cases; caf::PdmPointersField caseGroups; void close(); - RimIdenticalGridCaseGroup* createIdenticalCaseGroupFromMainCase(RimCase* mainCase); - void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir); - void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir); - void removeCaseFromAllGroups(RimCase* rimReservoir); + RimIdenticalGridCaseGroup* createIdenticalCaseGroupFromMainCase(RimEclipseCase* mainCase); + void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimEclipseCase* rimReservoir); + void moveEclipseCaseIntoCaseGroup(RimEclipseCase* rimReservoir); + void removeCaseFromAllGroups(RimEclipseCase* rimReservoir); void recomputeStatisticsForAllCaseGroups(); diff --git a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp similarity index 86% rename from ApplicationCode/ProjectDataModel/RimResultSlot.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index 01ea519c71..37b4226d90 100644 --- a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -18,19 +18,19 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimResultSlot.h" +#include "RimEclipseCellColors.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RimTernaryLegendConfig.h" #include "RimUiTreeModelPdm.h" #include "RiuMainWindow.h" -CAF_PDM_SOURCE_INIT(RimResultSlot, "ResultSlot"); +CAF_PDM_SOURCE_INIT(RimEclipseCellColors, "ResultSlot"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultSlot::RimResultSlot() +RimEclipseCellColors::RimEclipseCellColors() { CAF_PDM_InitObject("Result Slot", "", "", ""); @@ -52,7 +52,7 @@ RimResultSlot::RimResultSlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultSlot::~RimResultSlot() +RimEclipseCellColors::~RimEclipseCellColors() { delete legendConfig(); delete ternaryLegendConfig(); @@ -61,9 +61,9 @@ RimResultSlot::~RimResultSlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipseCellColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - RimResultDefinition::fieldChangedByUi(changedField, oldValue, newValue); + RimEclipseResultDefinition::fieldChangedByUi(changedField, oldValue, newValue); // Update of legend config must happen after RimResultDefinition::fieldChangedByUi(), as this function modifies this->resultVariable() if (changedField == &m_resultVariableUiField) @@ -75,7 +75,7 @@ void RimResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, co if (newValue != RimDefines::undefinedResultName()) { - if (m_reservoirView) m_reservoirView->animationMode = true; + if (m_reservoirView) m_reservoirView->hasUserRequestedAnimation = true; } RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(this); @@ -87,7 +87,7 @@ void RimResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend) +void RimEclipseCellColors::changeLegendConfig(QString resultVarNameOfNewLegend) { if (resultVarNameOfNewLegend == RimDefines::ternarySaturationResultName()) { @@ -139,9 +139,9 @@ void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultSlot::initAfterRead() +void RimEclipseCellColors::initAfterRead() { - RimResultDefinition::initAfterRead(); + RimEclipseResultDefinition::initAfterRead(); if (this->legendConfig()->resultVariableName == "") { @@ -154,9 +154,9 @@ void RimResultSlot::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultSlot::setReservoirView(RimReservoirView* ownerReservoirView) +void RimEclipseCellColors::setReservoirView(RimEclipseView* ownerReservoirView) { - RimResultDefinition::setReservoirView(ownerReservoirView); + RimEclipseResultDefinition::setReservoirView(ownerReservoirView); m_reservoirView = ownerReservoirView; this->legendConfig()->setReservoirView(ownerReservoirView); @@ -172,9 +172,9 @@ void RimResultSlot::setReservoirView(RimReservoirView* ownerReservoirView) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultSlot::setResultVariable(const QString& val) +void RimEclipseCellColors::setResultVariable(const QString& val) { - RimResultDefinition::setResultVariable(val); + RimEclipseResultDefinition::setResultVariable(val); this->changeLegendConfig(val); } diff --git a/ApplicationCode/ProjectDataModel/RimResultSlot.h b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h similarity index 86% rename from ApplicationCode/ProjectDataModel/RimResultSlot.h rename to ApplicationCode/ProjectDataModel/RimEclipseCellColors.h index c08ebc69d4..128afd39b8 100644 --- a/ApplicationCode/ProjectDataModel/RimResultSlot.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h @@ -22,7 +22,7 @@ #include "RimDefines.h" #include "RimLegendConfig.h" -#include "RimResultDefinition.h" +#include "RimEclipseResultDefinition.h" class RimTernaryLegendConfig; @@ -30,14 +30,14 @@ class RimTernaryLegendConfig; /// /// //================================================================================================== -class RimResultSlot : public RimResultDefinition +class RimEclipseCellColors : public RimEclipseResultDefinition { CAF_PDM_HEADER_INIT; public: - RimResultSlot(); - virtual ~RimResultSlot(); + RimEclipseCellColors(); + virtual ~RimEclipseCellColors(); - virtual void setReservoirView(RimReservoirView* ownerReservoirView); + virtual void setReservoirView(RimEclipseView* ownerReservoirView); caf::PdmField legendConfig; caf::PdmField ternaryLegendConfig; @@ -46,7 +46,7 @@ class RimResultSlot : public RimResultDefinition virtual void setResultVariable(const QString& resultName); protected: - friend class RimFaultResultSlot; + friend class RimEclipseFaultColors; virtual void initAfterRead(); private: diff --git a/ApplicationCode/ProjectDataModel/RimFaultResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp similarity index 63% rename from ApplicationCode/ProjectDataModel/RimFaultResultSlot.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp index f29f1408b4..824f468ab0 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp @@ -17,40 +17,40 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimFaultResultSlot.h" +#include "RimEclipseFaultColors.h" #include "RigCaseData.h" #include "RigMainGrid.h" -#include "RimCase.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" #include "RimUiTreeModelPdm.h" #include "RiuMainWindow.h" -CAF_PDM_SOURCE_INIT(RimFaultResultSlot, "RimFaultResultSlot"); +CAF_PDM_SOURCE_INIT(RimEclipseFaultColors, "RimFaultResultSlot"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFaultResultSlot::RimFaultResultSlot() +RimEclipseFaultColors::RimEclipseFaultColors() { CAF_PDM_InitObject("Fault Result Slot", ":/draw_style_faults_24x24.png", "", ""); CAF_PDM_InitField(&showCustomFaultResult, "ShowCustomFaultResult", false, "Show Custom Fault Result", "", "", ""); showCustomFaultResult.setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_customFaultResult, "CustomResultSlot", "Custom Fault Result", ":/CellResult.png", "", ""); - m_customFaultResult = new RimResultSlot(); - m_customFaultResult.setOwnerObject(this); - m_customFaultResult.setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_customFaultResultColors, "CustomResultSlot", "Custom Fault Result", ":/CellResult.png", "", ""); + m_customFaultResultColors = new RimEclipseCellColors(); + m_customFaultResultColors.setOwnerObject(this); + m_customFaultResultColors.setUiHidden(true); // Take ownership of the fields in RimResultDefinition to be able to trap fieldChangedByUi in this class - m_customFaultResult->m_resultTypeUiField.setOwnerObject(this); - m_customFaultResult->m_porosityModelUiField.setOwnerObject(this); - m_customFaultResult->m_resultVariableUiField.setOwnerObject(this); + m_customFaultResultColors->m_resultTypeUiField.setOwnerObject(this); + m_customFaultResultColors->m_porosityModelUiField.setOwnerObject(this); + m_customFaultResultColors->m_resultVariableUiField.setOwnerObject(this); updateFieldVisibility(); @@ -59,29 +59,29 @@ RimFaultResultSlot::RimFaultResultSlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFaultResultSlot::~RimFaultResultSlot() +RimEclipseFaultColors::~RimEclipseFaultColors() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFaultResultSlot::setReservoirView(RimReservoirView* ownerReservoirView) +void RimEclipseFaultColors::setReservoirView(RimEclipseView* ownerReservoirView) { m_reservoirView = ownerReservoirView; - m_customFaultResult->setReservoirView(ownerReservoirView); + m_customFaultResultColors->setReservoirView(ownerReservoirView); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFaultResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipseFaultColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { this->updateUiIconFromToggleField(); - m_customFaultResult->fieldChangedByUi(changedField, oldValue, newValue); + m_customFaultResultColors->fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &m_customFaultResult->m_resultVariableUiField) + if (changedField == &m_customFaultResultColors->m_resultVariableUiField) { RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(this); } @@ -92,9 +92,9 @@ void RimFaultResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFaultResultSlot::initAfterRead() +void RimEclipseFaultColors::initAfterRead() { - m_customFaultResult->initAfterRead(); + m_customFaultResultColors->initAfterRead(); updateFieldVisibility(); this->updateUiIconFromToggleField(); @@ -103,23 +103,23 @@ void RimFaultResultSlot::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFaultResultSlot::updateFieldVisibility() +void RimEclipseFaultColors::updateFieldVisibility() { - m_customFaultResult->updateFieldVisibility(); + m_customFaultResultColors->updateFieldVisibility(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultSlot* RimFaultResultSlot::customFaultResult() +RimEclipseCellColors* RimEclipseFaultColors::customFaultResult() { - return this->m_customFaultResult(); + return this->m_customFaultResultColors(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimFaultResultSlot::objectToggleField() +caf::PdmFieldHandle* RimEclipseFaultColors::objectToggleField() { return &showCustomFaultResult; } @@ -127,30 +127,30 @@ caf::PdmFieldHandle* RimFaultResultSlot::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFaultResultSlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEclipseFaultColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result"); - group1->add(&(m_customFaultResult->m_resultTypeUiField)); - group1->add(&(m_customFaultResult->m_porosityModelUiField)); - group1->add(&(m_customFaultResult->m_resultVariableUiField)); + group1->add(&(m_customFaultResultColors->m_resultTypeUiField)); + group1->add(&(m_customFaultResultColors->m_porosityModelUiField)); + group1->add(&(m_customFaultResultColors->m_resultVariableUiField)); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimFaultResultSlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimEclipseFaultColors::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { - return m_customFaultResult->calculateValueOptionsForSpecifiedDerivedListPosition(true, fieldNeedingOptions, useOptionsOnly); + return m_customFaultResultColors->calculateValueOptionsForSpecifiedDerivedListPosition(true, fieldNeedingOptions, useOptionsOnly); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimFaultResultSlot::hasValidCustomResult() +bool RimEclipseFaultColors::hasValidCustomResult() { if (this->showCustomFaultResult()) { - if (m_customFaultResult->hasResult() || m_customFaultResult->isTernarySaturationSelected()) + if (m_customFaultResultColors->hasResult() || m_customFaultResultColors->isTernarySaturationSelected()) { return true; } diff --git a/ApplicationCode/ProjectDataModel/RimFaultResultSlot.h b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h similarity index 81% rename from ApplicationCode/ProjectDataModel/RimFaultResultSlot.h rename to ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h index b123503faa..14826cb2ed 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultResultSlot.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h @@ -23,27 +23,27 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -class RimResultSlot; -class RimReservoirView; +class RimEclipseCellColors; +class RimEclipseView; //================================================================================================== /// /// //================================================================================================== -class RimFaultResultSlot : public caf::PdmObject +class RimEclipseFaultColors : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimFaultResultSlot(); - virtual ~RimFaultResultSlot(); + RimEclipseFaultColors(); + virtual ~RimEclipseFaultColors(); - void setReservoirView(RimReservoirView* ownerReservoirView); + void setReservoirView(RimEclipseView* ownerReservoirView); caf::PdmField showCustomFaultResult; bool hasValidCustomResult(); - RimResultSlot* customFaultResult(); + RimEclipseCellColors* customFaultResult(); void updateFieldVisibility(); @@ -56,7 +56,7 @@ class RimFaultResultSlot : public caf::PdmObject virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) ; private: - caf::PdmField m_customFaultResult; - caf::PdmPointer m_reservoirView; + caf::PdmField m_customFaultResultColors; + caf::PdmPointer m_reservoirView; }; diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp similarity index 89% rename from ApplicationCode/ProjectDataModel/RimInputCase.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp index 3c4b6847f2..d08c8b92ae 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimInputCase.h" +#include "RimEclipseInputCase.h" #include "RiaPreferences.h" #include "RifEclipseInputFileTools.h" @@ -29,20 +29,20 @@ #include "RigCaseCellResultsData.h" #include "RigCaseData.h" #include "RimDefines.h" -#include "RimInputProperty.h" -#include "RimInputPropertyCollection.h" +#include "RimEclipseInputProperty.h" +#include "RimEclipseInputPropertyCollection.h" #include "RimReservoirCellResultsStorage.h" #include "cafProgressInfo.h" #include -CAF_PDM_SOURCE_INIT(RimInputCase, "RimInputReservoir"); +CAF_PDM_SOURCE_INIT(RimEclipseInputCase, "RimInputReservoir"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputCase::RimInputCase() - : RimCase() +RimEclipseInputCase::RimEclipseInputCase() + : RimEclipseCase() { CAF_PDM_InitObject("RimInputCase", ":/EclipseInput48x48.png", "", ""); CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,""); @@ -51,14 +51,14 @@ RimInputCase::RimInputCase() m_additionalFileNames.setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_inputPropertyCollection, "InputPropertyCollection", "", "", "", ""); - m_inputPropertyCollection = new RimInputPropertyCollection; + m_inputPropertyCollection = new RimEclipseInputPropertyCollection; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputCase::~RimInputCase() +RimEclipseInputCase::~RimEclipseInputCase() { delete m_inputPropertyCollection; } @@ -67,7 +67,7 @@ RimInputCase::~RimInputCase() /// Open the supplied file set. If no grid data has been read, it will first find the possible /// grid data among the files then read all supported properties from the files matching the grid //-------------------------------------------------------------------------------------------------- -void RimInputCase::openDataFileSet(const QStringList& fileNames) +void RimEclipseInputCase::openDataFileSet(const QStringList& fileNames) { if (fileNames.contains(RimDefines::mockModelBasicInputCase())) { @@ -150,11 +150,11 @@ void RimInputCase::openDataFileSet(const QStringList& fileNames) std::map::iterator it; for (it = readProperties.begin(); it != readProperties.end(); ++it) { - RimInputProperty* inputProperty = new RimInputProperty; + RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty; inputProperty->resultName = it->first; inputProperty->eclipseKeyword = it->second; inputProperty->fileName = propertyFileName; - inputProperty->resolvedState = RimInputProperty::RESOLVED; + inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED; m_inputPropertyCollection->inputProperties.push_back(inputProperty); } @@ -169,7 +169,7 @@ void RimInputCase::openDataFileSet(const QStringList& fileNames) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimInputCase::openEclipseGridFile() +bool RimEclipseInputCase::openEclipseGridFile() { // Early exit if reservoir data is created if (this->reservoirData() == NULL) @@ -226,7 +226,7 @@ bool RimInputCase::openEclipseGridFile() /// Loads input property data from the gridFile and additional files /// Creates new InputProperties if necessary, and flags the unused ones as obsolete //-------------------------------------------------------------------------------------------------- -void RimInputCase::loadAndSyncronizeInputProperties() +void RimEclipseInputCase::loadAndSyncronizeInputProperties() { // Make sure we actually have reservoir data @@ -267,7 +267,7 @@ void RimInputCase::loadAndSyncronizeInputProperties() // Find the input property objects referring to the file - std::vector ipsUsingThisFile = this->m_inputPropertyCollection()->findInputProperties(filenames[i]); + std::vector ipsUsingThisFile = this->m_inputPropertyCollection()->findInputProperties(filenames[i]); // Read property data for each inputProperty @@ -275,17 +275,17 @@ void RimInputCase::loadAndSyncronizeInputProperties() { if (!isExistingFile) { - ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::FILE_MISSING; + ipsUsingThisFile[ipIdx]->resolvedState = RimEclipseInputProperty::FILE_MISSING; } else { QString kw = ipsUsingThisFile[ipIdx]->eclipseKeyword(); - ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::KEYWORD_NOT_IN_FILE; + ipsUsingThisFile[ipIdx]->resolvedState = RimEclipseInputProperty::KEYWORD_NOT_IN_FILE; if (fileKeywordSet.count(kw)) { if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), kw, ipsUsingThisFile[ipIdx]->resultName )) { - ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::RESOLVED; + ipsUsingThisFile[ipIdx]->resolvedState = RimEclipseInputProperty::RESOLVED; } } fileKeywordSet.erase(kw); @@ -309,11 +309,11 @@ void RimInputCase::loadAndSyncronizeInputProperties() QString resultName = this->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(knownKeywords[fkIt]); if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), knownKeywords[fkIt], resultName)) { - RimInputProperty* inputProperty = new RimInputProperty; + RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty; inputProperty->resultName = resultName; inputProperty->eclipseKeyword = knownKeywords[fkIt]; inputProperty->fileName = filenames[i]; - inputProperty->resolvedState = RimInputProperty::RESOLVED; + inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED; m_inputPropertyCollection->inputProperties.push_back(inputProperty); } } @@ -324,9 +324,9 @@ void RimInputCase::loadAndSyncronizeInputProperties() for_all(m_inputPropertyCollection->inputProperties, i) { - if (m_inputPropertyCollection->inputProperties[i]->resolvedState() == RimInputProperty::UNKNOWN) + if (m_inputPropertyCollection->inputProperties[i]->resolvedState() == RimEclipseInputProperty::UNKNOWN) { - m_inputPropertyCollection->inputProperties[i]->resolvedState = RimInputProperty::FILE_MISSING; + m_inputPropertyCollection->inputProperties[i]->resolvedState = RimEclipseInputProperty::FILE_MISSING; } } } @@ -334,7 +334,7 @@ void RimInputCase::loadAndSyncronizeInputProperties() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputCase::removeProperty(RimInputProperty* inputProperty) +void RimEclipseInputCase::removeProperty(RimEclipseInputProperty* inputProperty) { bool isPropertyFileReferencedByOthers = false; @@ -364,7 +364,7 @@ void RimInputCase::removeProperty(RimInputProperty* inputProperty) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimInputCase::createMockModel(QString modelName) +cvf::ref RimEclipseInputCase::createMockModel(QString modelName) { cvf::ref reservoir = new RigCaseData; cvf::ref mockFileInterface = new RifReaderMockModel; @@ -395,7 +395,7 @@ cvf::ref RimInputCase::createMockModel(QString modelName) } // Add a property - RimInputProperty* inputProperty = new RimInputProperty; + RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty; inputProperty->resultName = "PORO"; inputProperty->eclipseKeyword = "PORO"; inputProperty->fileName = "PORO.prop"; @@ -410,7 +410,7 @@ cvf::ref RimInputCase::createMockModel(QString modelName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimInputCase::locationOnDisc() const +QString RimEclipseInputCase::locationOnDisc() const { if (m_gridFileName().isEmpty()) return QString(); @@ -421,7 +421,7 @@ QString RimInputCase::locationOnDisc() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) +void RimEclipseInputCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { bool foundFile = false; std::vector searchedPaths; diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.h b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.h similarity index 84% rename from ApplicationCode/ProjectDataModel/RimInputCase.h rename to ApplicationCode/ProjectDataModel/RimEclipseInputCase.h index 7415796cdc..d9be00a185 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.h @@ -23,33 +23,33 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimCase.h" +#include "RimEclipseCase.h" class RifReaderInterface; -class RimInputPropertyCollection; -class RimInputProperty; +class RimEclipseInputPropertyCollection; +class RimEclipseInputProperty; //================================================================================================== // // // //================================================================================================== -class RimInputCase : public RimCase +class RimEclipseInputCase : public RimEclipseCase { CAF_PDM_HEADER_INIT; public: - RimInputCase(); - virtual ~RimInputCase(); + RimEclipseInputCase(); + virtual ~RimEclipseInputCase(); // Fields - caf::PdmField m_inputPropertyCollection; + caf::PdmField m_inputPropertyCollection; // File open methods void openDataFileSet(const QStringList& fileNames); void loadAndSyncronizeInputProperties(); - void removeProperty(RimInputProperty* inputProperty); + void removeProperty(RimEclipseInputProperty* inputProperty); // RimCase overrides virtual bool openEclipseGridFile(); // Find grid file among file set. Read, Find read and validate property date. Syncronize child property sets. diff --git a/ApplicationCode/ProjectDataModel/RimInputProperty.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp similarity index 71% rename from ApplicationCode/ProjectDataModel/RimInputProperty.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp index acbd17a801..11fcb0e71e 100644 --- a/ApplicationCode/ProjectDataModel/RimInputProperty.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimInputProperty.h" +#include "RimEclipseInputProperty.h" #include "cafPdmUiLineEditor.h" #include "cvfAssert.h" @@ -27,24 +27,24 @@ namespace caf { template<> -void RimInputProperty::ResolveStateEnum::setUp() +void RimEclipseInputProperty::ResolveStateEnum::setUp() { - addItem(RimInputProperty::UNKNOWN, "UNKNOWN", "Unknown"); - addItem(RimInputProperty::FILE_MISSING, "FILE_MISSING", "No data loaded, can't find the file"); - addItem(RimInputProperty::KEYWORD_NOT_IN_FILE, "KEYWORD_NOT_IN_FILE", "No data loaded, can't find the keyword"); - addItem(RimInputProperty::RESOLVED_NOT_SAVED, "RESOLVED_NOT_SAVED", "Ok, but not saved"); - addItem(RimInputProperty::RESOLVED, "RESOLVED", "Loaded, Ok"); - setDefault(RimInputProperty::UNKNOWN); + addItem(RimEclipseInputProperty::UNKNOWN, "UNKNOWN", "Unknown"); + addItem(RimEclipseInputProperty::FILE_MISSING, "FILE_MISSING", "No data loaded, can't find the file"); + addItem(RimEclipseInputProperty::KEYWORD_NOT_IN_FILE, "KEYWORD_NOT_IN_FILE", "No data loaded, can't find the keyword"); + addItem(RimEclipseInputProperty::RESOLVED_NOT_SAVED, "RESOLVED_NOT_SAVED", "Ok, but not saved"); + addItem(RimEclipseInputProperty::RESOLVED, "RESOLVED", "Loaded, Ok"); + setDefault(RimEclipseInputProperty::UNKNOWN); } } -CAF_PDM_SOURCE_INIT(RimInputProperty, "RimInputProperty"); +CAF_PDM_SOURCE_INIT(RimEclipseInputProperty, "RimInputProperty"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputProperty::RimInputProperty() +RimEclipseInputProperty::RimEclipseInputProperty() { CAF_PDM_InitObject("Input Property", ":/EclipseInput48x48.png", "", ""); @@ -64,7 +64,7 @@ RimInputProperty::RimInputProperty() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputProperty::~RimInputProperty() +RimEclipseInputProperty::~RimEclipseInputProperty() { } diff --git a/ApplicationCode/ProjectDataModel/RimInputProperty.h b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h similarity index 93% rename from ApplicationCode/ProjectDataModel/RimInputProperty.h rename to ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h index 7ee9e916a1..4a21500647 100644 --- a/ApplicationCode/ProjectDataModel/RimInputProperty.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h @@ -31,13 +31,13 @@ class QString; // // //================================================================================================== -class RimInputProperty : public caf::PdmObject +class RimEclipseInputProperty : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimInputProperty(); - virtual ~RimInputProperty(); + RimEclipseInputProperty(); + virtual ~RimEclipseInputProperty(); enum ResolveState { diff --git a/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp similarity index 82% rename from ApplicationCode/ProjectDataModel/RimInputPropertyCollection.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp index 0758a0576c..5be7a25714 100644 --- a/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp @@ -18,18 +18,18 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimInputPropertyCollection.h" +#include "RimEclipseInputPropertyCollection.h" -#include "RimInputProperty.h" +#include "RimEclipseInputProperty.h" #include -CAF_PDM_SOURCE_INIT(RimInputPropertyCollection, "RimInputPropertyCollection"); +CAF_PDM_SOURCE_INIT(RimEclipseInputPropertyCollection, "RimInputPropertyCollection"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputPropertyCollection::RimInputPropertyCollection() +RimEclipseInputPropertyCollection::RimEclipseInputPropertyCollection() { CAF_PDM_InitObject("Input Properties", ":/EclipseInput48x48.png", "", ""); @@ -39,7 +39,7 @@ RimInputPropertyCollection::RimInputPropertyCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputPropertyCollection::~RimInputPropertyCollection() +RimEclipseInputPropertyCollection::~RimEclipseInputPropertyCollection() { } @@ -47,10 +47,10 @@ RimInputPropertyCollection::~RimInputPropertyCollection() //-------------------------------------------------------------------------------------------------- /// Returns the InputProperties pointing to the same file as \a fileName //-------------------------------------------------------------------------------------------------- -std::vector RimInputPropertyCollection::findInputProperties(QString fileName) +std::vector RimEclipseInputPropertyCollection::findInputProperties(QString fileName) { QFileInfo fileInfo(fileName); - std::vector result; + std::vector result; for (size_t i = 0; i < this->inputProperties.size(); ++i) { if (!inputProperties[i]) continue; @@ -66,7 +66,7 @@ std::vector RimInputPropertyCollection::findInputProperties(Q /// Remove given input property from collection and checks if the associated file is referenced by other input /// properties //-------------------------------------------------------------------------------------------------- -void RimInputPropertyCollection::removeInputProperty(RimInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers) +void RimEclipseInputPropertyCollection::removeInputProperty(RimEclipseInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers) { CVF_ASSERT(inputProperty); @@ -85,7 +85,7 @@ void RimInputPropertyCollection::removeInputProperty(RimInputProperty* inputProp //-------------------------------------------------------------------------------------------------- /// Returns the InputProperty with resultName \a resultName //-------------------------------------------------------------------------------------------------- -RimInputProperty * RimInputPropertyCollection::findInputProperty(QString resultName) +RimEclipseInputProperty * RimEclipseInputPropertyCollection::findInputProperty(QString resultName) { for (size_t i = 0; i < this->inputProperties.size(); i++) { diff --git a/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.h similarity index 71% rename from ApplicationCode/ProjectDataModel/RimInputPropertyCollection.h rename to ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.h index 81828209cb..f4467b962f 100644 --- a/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.h @@ -25,7 +25,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -class RimInputProperty; +class RimEclipseInputProperty; //================================================================================================== @@ -33,20 +33,20 @@ class RimInputProperty; // // //================================================================================================== -class RimInputPropertyCollection : public caf::PdmObject +class RimEclipseInputPropertyCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimInputPropertyCollection(); - virtual ~RimInputPropertyCollection(); - std::vector findInputProperties(QString fileName); - RimInputProperty* findInputProperty(QString resultName); + RimEclipseInputPropertyCollection(); + virtual ~RimEclipseInputPropertyCollection(); + std::vector findInputProperties(QString fileName); + RimEclipseInputProperty* findInputProperty(QString resultName); - void removeInputProperty(RimInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers); + void removeInputProperty(RimEclipseInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers); // Fields: - caf::PdmPointersField inputProperties; + caf::PdmPointersField inputProperties; }; diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp similarity index 76% rename from ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp rename to ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp index e09bc9df37..68b929a572 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp @@ -18,46 +18,47 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimCellPropertyFilter.h" +#include "RimEclipsePropertyFilter.h" #include "RigCaseCellResultsData.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimReservoirCellResultsStorage.h" -#include "RimResultDefinition.h" +#include "RimEclipseResultDefinition.h" #include "cafPdmUiDoubleSliderEditor.h" #include "cvfAssert.h" #include "cvfMath.h" +#include "RiuMainWindow.h" namespace caf -{ +{ // Obsolete stuff template<> - void caf::AppEnum< RimCellPropertyFilter::EvaluationRegionType>::setUp() + void caf::AppEnum< RimEclipsePropertyFilter::EvaluationRegionType>::setUp() { - addItem(RimCellPropertyFilter::RANGE_FILTER_REGION, "RANGE_FILTER_REGION", "Range filter cells"); - addItem(RimCellPropertyFilter::GLOBAL_REGION, "GLOBAL_REGION", "All cells"); - setDefault(RimCellPropertyFilter::RANGE_FILTER_REGION); + addItem(RimEclipsePropertyFilter::RANGE_FILTER_REGION, "RANGE_FILTER_REGION", "Range filter cells"); + addItem(RimEclipsePropertyFilter::GLOBAL_REGION, "GLOBAL_REGION", "All cells"); + setDefault(RimEclipsePropertyFilter::RANGE_FILTER_REGION); } } -CAF_PDM_SOURCE_INIT(RimCellPropertyFilter, "CellPropertyFilter"); +CAF_PDM_SOURCE_INIT(RimEclipsePropertyFilter, "CellPropertyFilter"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellPropertyFilter::RimCellPropertyFilter() +RimEclipsePropertyFilter::RimEclipsePropertyFilter() : m_parentContainer(NULL) { CAF_PDM_InitObject("Cell Property Filter", ":/CellFilter_Values.png", "", ""); - CAF_PDM_InitFieldNoDefault(&evaluationRegion, "EvaluationRegion", "Evaluation region", "", "", ""); - evaluationRegion.setUiHidden(true); - evaluationRegion.setIOWritable(false); + CAF_PDM_InitFieldNoDefault(&obsoleteField_evaluationRegion, "EvaluationRegion", "Evaluation region", "", "", ""); + obsoleteField_evaluationRegion.setUiHidden(true); + obsoleteField_evaluationRegion.setIOWritable(false); CAF_PDM_InitFieldNoDefault(&resultDefinition, "ResultDefinition", "Result definition", "", "", ""); - resultDefinition = new RimResultDefinition(); + resultDefinition = new RimEclipseResultDefinition(); // Take ownership of the fields in RimResultDefinition to be able to trap fieldChangedByUi in this class resultDefinition->m_resultTypeUiField.setOwnerObject(this); @@ -86,14 +87,14 @@ RimCellPropertyFilter::RimCellPropertyFilter() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellPropertyFilter::~RimCellPropertyFilter() +RimEclipsePropertyFilter::~RimEclipsePropertyFilter() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipsePropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (&name == changedField) { @@ -108,17 +109,19 @@ void RimCellPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF if ( &(resultDefinition->m_resultVariableUiField) == changedField ) { resultDefinition->fieldChangedByUi(changedField, oldValue, newValue); - setDefaultValues(); + setToDefaultValues(); m_parentContainer->fieldChangedByUi(changedField, oldValue, newValue); + updateFilterName(); } if ( &lowerBound == changedField || &upperBound == changedField - || &evaluationRegion == changedField + || &obsoleteField_evaluationRegion == changedField || &isActive == changedField || &filterMode == changedField) { m_parentContainer->fieldChangedByUi(changedField, oldValue, newValue); + updateFilterName(); this->updateIconState(); } } @@ -126,7 +129,7 @@ void RimCellPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimCellPropertyFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimEclipsePropertyFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { QList optionItems = resultDefinition->calculateValueOptions(fieldNeedingOptions, useOptionsOnly); @@ -155,7 +158,7 @@ QList RimCellPropertyFilter::calculateValueOptions(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilter::setParentContainer(RimCellPropertyFilterCollection* parentContainer) +void RimEclipsePropertyFilter::setParentContainer(RimEclipsePropertyFilterCollection* parentContainer) { m_parentContainer = parentContainer; } @@ -163,7 +166,7 @@ void RimCellPropertyFilter::setParentContainer(RimCellPropertyFilterCollection* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellPropertyFilterCollection* RimCellPropertyFilter::parentContainer() +RimEclipsePropertyFilterCollection* RimEclipsePropertyFilter::parentContainer() { return m_parentContainer; } @@ -171,7 +174,7 @@ RimCellPropertyFilterCollection* RimCellPropertyFilter::parentContainer() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilter::setDefaultValues() +void RimEclipsePropertyFilter::setToDefaultValues() { CVF_ASSERT(m_parentContainer); @@ -184,7 +187,7 @@ void RimCellPropertyFilter::setDefaultValues() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEclipsePropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { // Fields declared in RimCellFilter uiOrdering.add(&name); @@ -208,7 +211,7 @@ void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RimEclipsePropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { if (m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE) { @@ -231,7 +234,7 @@ void RimCellPropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* fie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilter::computeResultValueRange() +void RimEclipsePropertyFilter::computeResultValueRange() { CVF_ASSERT(m_parentContainer); @@ -255,3 +258,15 @@ void RimCellPropertyFilter::computeResultValueRange() upperBound.setUiName(QString("Max (%1)").arg(max)); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipsePropertyFilter::updateFilterName() +{ + QString newFiltername; + newFiltername = resultDefinition->resultVariable() + " (" + + QString::number(lowerBound()) + " .. " + QString::number(upperBound) + ")"; + this->name = newFiltername; + RiuMainWindow::instance()->forceProjectTreeRepaint(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h new file mode 100644 index 0000000000..1398d03807 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011- Statoil ASA +// Copyright (C) 2013- Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS +// +// 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 "RimCellFilter.h" + +class RimEclipseView; +class RimEclipsePropertyFilterCollection; +class RimEclipseResultDefinition; + +class RigGridBase; +class RigCaseCellResultsData; + + +//================================================================================================== +/// +/// +//================================================================================================== +class RimEclipsePropertyFilter : public RimCellFilter +{ + CAF_PDM_HEADER_INIT; + +public: + RimEclipsePropertyFilter(); + virtual ~RimEclipsePropertyFilter(); + + caf::PdmField resultDefinition; + + caf::PdmField lowerBound; + caf::PdmField upperBound; + + void setParentContainer(RimEclipsePropertyFilterCollection* parentContainer); + RimEclipsePropertyFilterCollection* parentContainer(); + void setToDefaultValues(); + void updateFilterName(); + void computeResultValueRange(); + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); +protected: + virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) ; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + +private: + + RimEclipsePropertyFilterCollection* m_parentContainer; + double m_minimumResultValue; + double m_maximumResultValue; + +public: + // Obsolete stuff + enum EvaluationRegionType + { + RANGE_FILTER_REGION, + GLOBAL_REGION + }; +private: + caf::PdmField< caf::AppEnum< EvaluationRegionType > > obsoleteField_evaluationRegion; + +}; + diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp similarity index 68% rename from ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp rename to ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp index c4bac8aaac..48d7f8423e 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp @@ -18,19 +18,19 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" -#include "RimReservoirView.h" -#include "RimResultDefinition.h" -#include "RimResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseResultDefinition.h" +#include "RimEclipseCellColors.h" -CAF_PDM_SOURCE_INIT(RimCellPropertyFilterCollection, "CellPropertyFilters"); +CAF_PDM_SOURCE_INIT(RimEclipsePropertyFilterCollection, "CellPropertyFilters"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellPropertyFilterCollection::RimCellPropertyFilterCollection() +RimEclipsePropertyFilterCollection::RimEclipsePropertyFilterCollection() { CAF_PDM_InitObject("Cell Property Filters", ":/CellFilter_Values.png", "", ""); @@ -42,7 +42,7 @@ RimCellPropertyFilterCollection::RimCellPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellPropertyFilterCollection::~RimCellPropertyFilterCollection() +RimEclipsePropertyFilterCollection::~RimEclipsePropertyFilterCollection() { } @@ -51,14 +51,13 @@ RimCellPropertyFilterCollection::~RimCellPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilterCollection::setReservoirView(RimReservoirView* reservoirView) +void RimEclipsePropertyFilterCollection::setReservoirView(RimEclipseView* reservoirView) { m_reservoirView = reservoirView; - std::list< caf::PdmPointer< RimCellPropertyFilter > >::iterator it; - for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it) + for (size_t i = 0; i < propertyFilters.size(); i++) { - RimCellPropertyFilter* propertyFilter = *it; + RimEclipsePropertyFilter* propertyFilter = propertyFilters[i]; propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); } @@ -67,7 +66,7 @@ void RimCellPropertyFilterCollection::setReservoirView(RimReservoirView* reservo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView* RimCellPropertyFilterCollection::reservoirView() +RimEclipseView* RimEclipsePropertyFilterCollection::reservoirView() { CVF_ASSERT(!m_reservoirView.isNull()); return m_reservoirView; @@ -76,7 +75,7 @@ RimReservoirView* RimCellPropertyFilterCollection::reservoirView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipsePropertyFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { this->updateUiIconFromToggleField(); @@ -86,22 +85,21 @@ void RimCellPropertyFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellPropertyFilter* RimCellPropertyFilterCollection::createAndAppendPropertyFilter() +RimEclipsePropertyFilter* RimEclipsePropertyFilterCollection::createAndAppendPropertyFilter() { - RimCellPropertyFilter* propertyFilter = new RimCellPropertyFilter(); + RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter(); propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); propertyFilter->setParentContainer(this); - propertyFilters.v().push_back(propertyFilter); + propertyFilters.push_back(propertyFilter); propertyFilter->resultDefinition->setResultVariable(m_reservoirView->cellResult->resultVariable()); propertyFilter->resultDefinition->setPorosityModel(m_reservoirView->cellResult->porosityModel()); propertyFilter->resultDefinition->setResultType(m_reservoirView->cellResult->resultType()); propertyFilter->resultDefinition->loadResult(); - propertyFilter->setDefaultValues(); - - propertyFilter->name = QString("New Filter (%1)").arg(propertyFilters().size()); + propertyFilter->setToDefaultValues(); + propertyFilter->updateFilterName(); return propertyFilter; @@ -111,12 +109,11 @@ RimCellPropertyFilter* RimCellPropertyFilterCollection::createAndAppendPropertyF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilterCollection::loadAndInitializePropertyFilters() +void RimEclipsePropertyFilterCollection::loadAndInitializePropertyFilters() { - std::list< caf::PdmPointer< RimCellPropertyFilter > >::iterator it; - for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it) + for (size_t i = 0; i < propertyFilters.size(); i++) { - RimCellPropertyFilter* propertyFilter = *it; + RimEclipsePropertyFilter* propertyFilter = propertyFilters[i]; propertyFilter->setParentContainer(this); @@ -130,7 +127,7 @@ void RimCellPropertyFilterCollection::loadAndInitializePropertyFilters() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilterCollection::initAfterRead() +void RimEclipsePropertyFilterCollection::initAfterRead() { loadAndInitializePropertyFilters(); @@ -140,22 +137,22 @@ void RimCellPropertyFilterCollection::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilterCollection::remove(RimCellPropertyFilter* propertyFilter) +void RimEclipsePropertyFilterCollection::remove(RimEclipsePropertyFilter* propertyFilter) { - propertyFilters.v().remove(propertyFilter); + propertyFilters.removeChildObject(propertyFilter); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimCellPropertyFilterCollection::hasActiveFilters() const +bool RimEclipsePropertyFilterCollection::hasActiveFilters() const { if (!active) return false; - std::list< caf::PdmPointer< RimCellPropertyFilter > >::const_iterator it; - for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it) + for (size_t i = 0; i < propertyFilters.size(); i++) { - if ((*it)->isActive() && (*it)->resultDefinition->hasResult()) return true; + RimEclipsePropertyFilter* propertyFilter = propertyFilters[i]; + if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) return true; } return false; @@ -164,14 +161,14 @@ bool RimCellPropertyFilterCollection::hasActiveFilters() const //-------------------------------------------------------------------------------------------------- /// Returns whether any of the active property filters are based on a dynamic result //-------------------------------------------------------------------------------------------------- -bool RimCellPropertyFilterCollection::hasActiveDynamicFilters() const +bool RimEclipsePropertyFilterCollection::hasActiveDynamicFilters() const { if (!active) return false; - std::list< caf::PdmPointer< RimCellPropertyFilter > >::const_iterator it; - for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it) + for (size_t i = 0; i < propertyFilters.size(); i++) { - if ((*it)->isActive() && (*it)->resultDefinition->hasDynamicResult()) return true; + RimEclipsePropertyFilter* propertyFilter = propertyFilters[i]; + if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasDynamicResult()) return true; } return false; @@ -181,7 +178,7 @@ bool RimCellPropertyFilterCollection::hasActiveDynamicFilters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimCellPropertyFilterCollection::objectToggleField() +caf::PdmFieldHandle* RimEclipsePropertyFilterCollection::objectToggleField() { return &active; } diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.h b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.h similarity index 73% rename from ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.h rename to ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.h index 2032988fe1..fcaa65a817 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.h @@ -18,33 +18,33 @@ #pragma once -#include "RimCellPropertyFilter.h" +#include "RimEclipsePropertyFilter.h" //================================================================================================== /// /// //================================================================================================== -class RimCellPropertyFilterCollection : public caf::PdmObject +class RimEclipsePropertyFilterCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimCellPropertyFilterCollection(); - virtual ~RimCellPropertyFilterCollection(); + RimEclipsePropertyFilterCollection(); + virtual ~RimEclipsePropertyFilterCollection(); // Fields: caf::PdmField active; - caf::PdmField< std::list< caf::PdmPointer< RimCellPropertyFilter > > > propertyFilters; + caf::PdmPointersField propertyFilters; // Methods - RimCellPropertyFilter* createAndAppendPropertyFilter(); - void remove(RimCellPropertyFilter* propertyFilter); + RimEclipsePropertyFilter* createAndAppendPropertyFilter(); + void remove(RimEclipsePropertyFilter* propertyFilter); bool hasActiveFilters() const; bool hasActiveDynamicFilters() const; - void setReservoirView(RimReservoirView* reservoirView); - RimReservoirView* reservoirView(); + void setReservoirView(RimEclipseView* reservoirView); + RimEclipseView* reservoirView(); void loadAndInitializePropertyFilters(); @@ -58,5 +58,5 @@ class RimCellPropertyFilterCollection : public caf::PdmObject virtual void initAfterRead(); private: - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; }; diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp similarity index 92% rename from ApplicationCode/ProjectDataModel/RimResultCase.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index c83df1600a..81444bd5b6 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimResultCase.h" +#include "RimEclipseResultCase.h" #include "RiaPreferences.h" #include "RifEclipseOutputFileTools.h" @@ -39,12 +39,12 @@ #include #include -CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase"); +CAF_PDM_SOURCE_INIT(RimEclipseResultCase, "EclipseCase"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultCase::RimResultCase() - : RimCase() +RimEclipseResultCase::RimEclipseResultCase() + : RimEclipseCase() { CAF_PDM_InitObject("Eclipse Case", ":/Case48x48.png", "", ""); @@ -68,7 +68,7 @@ RimResultCase::RimResultCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimResultCase::openEclipseGridFile() +bool RimEclipseResultCase::openEclipseGridFile() { caf::ProgressInfo progInfo(50, "Reading Eclipse Grid File"); @@ -127,7 +127,7 @@ bool RimResultCase::openEclipseGridFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) +bool RimEclipseResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) { // Early exit if data is already read if (m_activeCellInfoIsReadFromFile) return true; @@ -187,7 +187,7 @@ bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimResultCase::createMockModel(QString modelName) +cvf::ref RimEclipseResultCase::createMockModel(QString modelName) { cvf::ref mockFileInterface = new RifReaderMockModel; cvf::ref reservoir = new RigCaseData; @@ -291,7 +291,7 @@ cvf::ref RimResultCase::createMockModel(QString modelName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultCase::~RimResultCase() +RimEclipseResultCase::~RimEclipseResultCase() { reservoirViews.deleteAllChildObjects(); } @@ -299,7 +299,7 @@ RimResultCase::~RimResultCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimResultCase::locationOnDisc() const +QString RimEclipseResultCase::locationOnDisc() const { QFileInfo fi(caseFileName()); return fi.absolutePath(); @@ -308,7 +308,7 @@ QString RimResultCase::locationOnDisc() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDimensions) +void RimEclipseResultCase::readGridDimensions(std::vector< std::vector >& gridDimensions) { RifEclipseOutputFileTools::readGridDimensions(caseFileName(), gridDimensions); } @@ -316,7 +316,7 @@ void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDime //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) +void RimEclipseResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { bool foundFile = false; std::vector searchedPaths; @@ -335,7 +335,7 @@ void RimResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::setGridFileName(const QString& caseFileName) +void RimEclipseResultCase::setGridFileName(const QString& caseFileName) { this->caseFileName = caseFileName; } @@ -344,7 +344,7 @@ void RimResultCase::setGridFileName(const QString& caseFileName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::setCaseInfo(const QString& userDescription, const QString& caseFileName) +void RimEclipseResultCase::setCaseInfo(const QString& userDescription, const QString& caseFileName) { this->caseUserDescription = userDescription; this->caseFileName = caseFileName; @@ -356,9 +356,9 @@ void RimResultCase::setCaseInfo(const QString& userDescription, const QString& c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::initAfterRead() +void RimEclipseResultCase::initAfterRead() { - RimCase::initAfterRead(); + RimEclipseCase::initAfterRead(); // Convert from old (9.0.2) way of storing the case file if (caseFileName().isEmpty()) @@ -373,7 +373,7 @@ void RimResultCase::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEclipseResultCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { uiOrdering.add(&caseUserDescription); uiOrdering.add(&caseId); diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h similarity index 94% rename from ApplicationCode/ProjectDataModel/RimResultCase.h rename to ApplicationCode/ProjectDataModel/RimEclipseResultCase.h index b373bb3ddb..f0f17ccebf 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h @@ -20,7 +20,7 @@ #pragma once -#include "RimCase.h" +#include "RimEclipseCase.h" class RifReaderInterface; class RigMainGrid; @@ -30,13 +30,13 @@ class RigMainGrid; // // //================================================================================================== -class RimResultCase : public RimCase +class RimEclipseResultCase : public RimEclipseCase { CAF_PDM_HEADER_INIT; public: - RimResultCase(); - virtual ~RimResultCase(); + RimEclipseResultCase(); + virtual ~RimEclipseResultCase(); void setGridFileName(const QString& caseFileName); void setCaseInfo(const QString& userDescription, const QString& caseFileName); diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp similarity index 88% rename from ApplicationCode/ProjectDataModel/RimResultDefinition.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 245489343e..c43468d765 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -18,22 +18,22 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimResultDefinition.h" +#include "RimEclipseResultDefinition.h" #include "RigCaseCellResultsData.h" #include "RigCaseData.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "cafPdmUiListEditor.h" -CAF_PDM_SOURCE_INIT(RimResultDefinition, "ResultDefinition"); +CAF_PDM_SOURCE_INIT(RimEclipseResultDefinition, "ResultDefinition"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultDefinition::RimResultDefinition() +RimEclipseResultDefinition::RimEclipseResultDefinition() //: m_gridScalarResultIndex(cvf::UNDEFINED_SIZE_T) { CAF_PDM_InitObject("Result Definition", "", "", ""); @@ -62,7 +62,7 @@ RimResultDefinition::RimResultDefinition() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultDefinition::~RimResultDefinition() +RimEclipseResultDefinition::~RimEclipseResultDefinition() { } @@ -70,14 +70,14 @@ RimResultDefinition::~RimResultDefinition() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::setReservoirView(RimReservoirView* ownerReservoirView) +void RimEclipseResultDefinition::setReservoirView(RimEclipseView* ownerReservoirView) { m_reservoirView = ownerReservoirView; updateFieldVisibility(); } -QStringList RimResultDefinition::getResultVariableListForCurrentUIFieldSettings() +QStringList RimEclipseResultDefinition::getResultVariableListForCurrentUIFieldSettings() { if (!m_reservoirView || !m_reservoirView->eclipseCase() ) return QStringList(); @@ -87,7 +87,7 @@ QStringList RimResultDefinition::getResultVariableListForCurrentUIFieldSettings( } -RimReservoirCellResultsStorage* RimResultDefinition::currentGridCellResults() const +RimReservoirCellResultsStorage* RimEclipseResultDefinition::currentGridCellResults() const { if (!m_reservoirView || !m_reservoirView->eclipseCase()) return NULL; @@ -99,7 +99,7 @@ RimReservoirCellResultsStorage* RimResultDefinition::currentGridCellResults() co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if ( &m_resultTypeUiField == changedField || &m_porosityModelUiField == changedField ) @@ -132,7 +132,7 @@ void RimResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimResultDefinition::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +QList RimEclipseResultDefinition::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) { return calculateValueOptionsForSpecifiedDerivedListPosition(false, fieldNeedingOptions, useOptionsOnly); } @@ -140,7 +140,7 @@ QList RimResultDefinition::calculateValueOptions(const c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimResultDefinition::calculateValueOptionsForSpecifiedDerivedListPosition(bool showDerivedResultsFirstInList, const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimEclipseResultDefinition::calculateValueOptionsForSpecifiedDerivedListPosition(bool showDerivedResultsFirstInList, const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { if (fieldNeedingOptions == &m_resultVariableUiField) { @@ -201,7 +201,7 @@ QList RimResultDefinition::calculateValueOptionsForSpeci //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimResultDefinition::scalarResultIndex() const +size_t RimEclipseResultDefinition::scalarResultIndex() const { size_t gridScalarResultIndex = cvf::UNDEFINED_SIZE_T; @@ -214,7 +214,7 @@ size_t RimResultDefinition::scalarResultIndex() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::loadResult() +void RimEclipseResultDefinition::loadResult() { RimReservoirCellResultsStorage* gridCellResults = this->currentGridCellResults(); if (gridCellResults) @@ -230,7 +230,7 @@ void RimResultDefinition::loadResult() /// Returns whether the result requested by the definition is a single frame result /// The result needs to be loaded before asking //-------------------------------------------------------------------------------------------------- -bool RimResultDefinition::hasStaticResult() const +bool RimEclipseResultDefinition::hasStaticResult() const { const RimReservoirCellResultsStorage* gridCellResults = this->currentGridCellResults(); size_t gridScalarResultIndex = this->scalarResultIndex(); @@ -248,7 +248,7 @@ bool RimResultDefinition::hasStaticResult() const //-------------------------------------------------------------------------------------------------- /// Returns whether the result requested by the definition is loaded or possible to load from the result file //-------------------------------------------------------------------------------------------------- -bool RimResultDefinition::hasResult() const +bool RimEclipseResultDefinition::hasResult() const { if (this->currentGridCellResults() && this->currentGridCellResults()->cellResults()) { @@ -264,7 +264,7 @@ bool RimResultDefinition::hasResult() const /// Returns whether the result requested by the definition is a multi frame result /// The result needs to be loaded before asking //-------------------------------------------------------------------------------------------------- -bool RimResultDefinition::hasDynamicResult() const +bool RimEclipseResultDefinition::hasDynamicResult() const { if (hasResult()) { @@ -290,7 +290,7 @@ bool RimResultDefinition::hasDynamicResult() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView* RimResultDefinition::reservoirView() +RimEclipseView* RimEclipseResultDefinition::reservoirView() { return m_reservoirView; } @@ -298,7 +298,7 @@ RimReservoirView* RimResultDefinition::reservoirView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::initAfterRead() +void RimEclipseResultDefinition::initAfterRead() { m_porosityModelUiField = m_porosityModel; m_resultTypeUiField = m_resultType; @@ -310,7 +310,7 @@ void RimResultDefinition::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::setResultType(RimDefines::ResultCatType val) +void RimEclipseResultDefinition::setResultType(RimDefines::ResultCatType val) { m_resultType = val; m_resultTypeUiField = val; @@ -319,7 +319,7 @@ void RimResultDefinition::setResultType(RimDefines::ResultCatType val) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::setPorosityModel(RimDefines::PorosityModelType val) +void RimEclipseResultDefinition::setPorosityModel(RimDefines::PorosityModelType val) { m_porosityModel = val; m_porosityModelUiField = val; @@ -328,7 +328,7 @@ void RimResultDefinition::setPorosityModel(RimDefines::PorosityModelType val) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::setResultVariable(const QString& val) +void RimEclipseResultDefinition::setResultVariable(const QString& val) { m_resultVariable = val; m_resultVariableUiField = val; @@ -337,7 +337,7 @@ void RimResultDefinition::setResultVariable(const QString& val) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimResultDefinition::isTernarySaturationSelected() const +bool RimEclipseResultDefinition::isTernarySaturationSelected() const { bool isTernary = (m_resultType() == RimDefines::DYNAMIC_NATIVE) && (m_resultVariable().compare(RimDefines::ternarySaturationResultName(), Qt::CaseInsensitive) == 0); @@ -348,7 +348,7 @@ bool RimResultDefinition::isTernarySaturationSelected() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultDefinition::updateFieldVisibility() +void RimEclipseResultDefinition::updateFieldVisibility() { if (m_reservoirView && m_reservoirView->eclipseCase() && diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.h b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h similarity index 88% rename from ApplicationCode/ProjectDataModel/RimResultDefinition.h rename to ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h index e3a6d3754a..905de6dd12 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -28,22 +28,22 @@ #include "cafPdmPointer.h" -class RimReservoirView; +class RimEclipseView; class RigCaseCellResultsData; class RimReservoirCellResultsStorage; //================================================================================================== /// /// //================================================================================================== -class RimResultDefinition : public caf::PdmObject +class RimEclipseResultDefinition : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimResultDefinition(); - virtual ~RimResultDefinition(); + RimEclipseResultDefinition(); + virtual ~RimEclipseResultDefinition(); - virtual void setReservoirView(RimReservoirView* ownerReservoirView); - RimReservoirView* reservoirView(); + virtual void setReservoirView(RimEclipseView* ownerReservoirView); + RimEclipseView* reservoirView(); RimDefines::ResultCatType resultType() const { return m_resultType(); } void setResultType(RimDefines::ResultCatType val); @@ -70,15 +70,15 @@ class RimResultDefinition : public caf::PdmObject caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; caf::PdmField m_resultVariable; - friend class RimCellPropertyFilter; - friend class RimFaultResultSlot; + friend class RimEclipsePropertyFilter; + friend class RimEclipseFaultColors; // User interface only fields, to support "filtering"-like behaviour etc. caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultTypeUiField; caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModelUiField; caf::PdmField m_resultVariableUiField; - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; protected: void updateFieldVisibility(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp similarity index 85% rename from ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index b2a0c39f85..fc6164060d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -18,18 +18,18 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimStatisticsCase.h" +#include "RimEclipseStatisticsCase.h" #include "RigCaseCellResultsData.h" #include "RigCaseData.h" #include "RimCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimStatisticsCaseEvaluator.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseStatisticsCaseEvaluator.h" #include "RimUiTreeModelPdm.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "RiuMainWindow.h" #include "cafPdmUiPushButtonEditor.h" @@ -38,23 +38,23 @@ namespace caf { template<> - void caf::AppEnum::setUp() + void caf::AppEnum::setUp() { - addItem(RimStatisticsCase::NEAREST_OBSERVATION, "NearestObservationPercentile", "Nearest Observation"); - addItem(RimStatisticsCase::HISTOGRAM_ESTIMATED, "HistogramEstimatedPercentile", "Histogram based estimate"); - addItem(RimStatisticsCase::INTERPOLATED_OBSERVATION, "InterpolatedObservationPercentile", "Interpolated Observation"); - setDefault(RimStatisticsCase::INTERPOLATED_OBSERVATION); + addItem(RimEclipseStatisticsCase::NEAREST_OBSERVATION, "NearestObservationPercentile", "Nearest Observation"); + addItem(RimEclipseStatisticsCase::HISTOGRAM_ESTIMATED, "HistogramEstimatedPercentile", "Histogram based estimate"); + addItem(RimEclipseStatisticsCase::INTERPOLATED_OBSERVATION, "InterpolatedObservationPercentile", "Interpolated Observation"); + setDefault(RimEclipseStatisticsCase::INTERPOLATED_OBSERVATION); } } -CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation"); +CAF_PDM_SOURCE_INIT(RimEclipseStatisticsCase, "RimStatisticalCalculation"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCase::RimStatisticsCase() - : RimCase() +RimEclipseStatisticsCase::RimEclipseStatisticsCase() + : RimEclipseCase() { CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); @@ -111,7 +111,7 @@ RimStatisticsCase::RimStatisticsCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCase::~RimStatisticsCase() +RimEclipseStatisticsCase::~RimEclipseStatisticsCase() { } @@ -120,7 +120,7 @@ RimStatisticsCase::~RimStatisticsCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::setMainGrid(RigMainGrid* mainGrid) +void RimEclipseStatisticsCase::setMainGrid(RigMainGrid* mainGrid) { CVF_ASSERT(mainGrid); CVF_ASSERT(this->reservoirData()); @@ -131,7 +131,7 @@ void RimStatisticsCase::setMainGrid(RigMainGrid* mainGrid) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimStatisticsCase::openEclipseGridFile() +bool RimEclipseStatisticsCase::openEclipseGridFile() { if (this->reservoirData()) return true; @@ -159,7 +159,7 @@ bool RimStatisticsCase::openEclipseGridFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCaseCollection* RimStatisticsCase::parentStatisticsCaseCollection() +RimCaseCollection* RimEclipseStatisticsCase::parentStatisticsCaseCollection() { std::vector parentObjects; this->parentObjectsOfType(parentObjects); @@ -175,7 +175,7 @@ RimCaseCollection* RimStatisticsCase::parentStatisticsCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::computeStatistics() +void RimEclipseStatisticsCase::computeStatistics() { if (this->reservoirData() == NULL) { @@ -186,7 +186,7 @@ void RimStatisticsCase::computeStatistics() CVF_ASSERT(gridCaseGroup); gridCaseGroup->computeUnionOfActiveCells(); - std::vector sourceCases; + std::vector sourceCases; getSourceCases(sourceCases); @@ -217,69 +217,69 @@ void RimStatisticsCase::computeStatistics() RigCaseData* resultCase = reservoirData(); - QList resultSpecification; + QList resultSpecification; for(size_t pIdx = 0; pIdx < m_selectedDynamicProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::DYNAMIC_NATIVE, m_selectedDynamicProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::DYNAMIC_NATIVE, m_selectedDynamicProperties()[pIdx])); } for(size_t pIdx = 0; pIdx < m_selectedStaticProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::STATIC_NATIVE, m_selectedStaticProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::STATIC_NATIVE, m_selectedStaticProperties()[pIdx])); } for(size_t pIdx = 0; pIdx < m_selectedGeneratedProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::GENERATED, m_selectedGeneratedProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::GENERATED, m_selectedGeneratedProperties()[pIdx])); } for(size_t pIdx = 0; pIdx < m_selectedInputProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::INPUT_PROPERTY, m_selectedInputProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::INPUT_PROPERTY, m_selectedInputProperties()[pIdx])); } for(size_t pIdx = 0; pIdx < m_selectedFractureDynamicProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::DYNAMIC_NATIVE, m_selectedFractureDynamicProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::DYNAMIC_NATIVE, m_selectedFractureDynamicProperties()[pIdx])); } for(size_t pIdx = 0; pIdx < m_selectedFractureStaticProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::STATIC_NATIVE, m_selectedFractureStaticProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::STATIC_NATIVE, m_selectedFractureStaticProperties()[pIdx])); } for(size_t pIdx = 0; pIdx < m_selectedFractureGeneratedProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::GENERATED, m_selectedFractureGeneratedProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::GENERATED, m_selectedFractureGeneratedProperties()[pIdx])); } for(size_t pIdx = 0; pIdx < m_selectedFractureInputProperties().size(); ++pIdx) { - resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::INPUT_PROPERTY, m_selectedFractureInputProperties()[pIdx])); + resultSpecification.append(RimEclipseStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::INPUT_PROPERTY, m_selectedFractureInputProperties()[pIdx])); } - RimStatisticsCaseEvaluator stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); + RimEclipseStatisticsCaseEvaluator stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); stat.evaluateForResults(resultSpecification); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::scheduleACTIVEGeometryRegenOnReservoirViews() +void RimEclipseStatisticsCase::scheduleACTIVEGeometryRegenOnReservoirViews() { for (size_t i = 0; i < reservoirViews().size(); i++) { - RimReservoirView* reservoirView = reservoirViews()[i]; + RimEclipseView* reservoirView = reservoirViews()[i]; CVF_ASSERT(reservoirView); - reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE); + reservoirView->scheduleGeometryRegen(ACTIVE); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::getSourceCases(std::vector& sourceCases) +void RimEclipseStatisticsCase::getSourceCases(std::vector& sourceCases) { RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup(); if (gridCaseGroup) @@ -290,7 +290,7 @@ void RimStatisticsCase::getSourceCases(std::vector& sourceCases) CVF_ASSERT(gridCaseGroup->caseCollection); CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]); - RimCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]; + RimEclipseCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]; sourceCases.push_back(sourceCase); } } @@ -299,7 +299,7 @@ void RimStatisticsCase::getSourceCases(std::vector& sourceCases) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() +RimIdenticalGridCaseGroup* RimEclipseStatisticsCase::caseGroup() { RimCaseCollection* parentCollection = parentStatisticsCaseCollection(); if (parentCollection) @@ -313,7 +313,7 @@ RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEclipseStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { updateSelectionSummaryLabel(); @@ -362,7 +362,7 @@ QList toOptionList(const QStringList& varList) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimStatisticsCase::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimEclipseStatisticsCase::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { QList options; if (useOptionsOnly) *useOptionsOnly = true; @@ -436,7 +436,7 @@ QList RimStatisticsCase::calculateValueOptions(const caf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipseStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (&m_resultType == changedField || &m_porosityModel == changedField) { @@ -462,7 +462,7 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); // Find or load well data for given case - RimCase* sourceResultCase = caseGroup()->caseCollection()->findByDescription(m_wellDataSourceCase); + RimEclipseCase* sourceResultCase = caseGroup()->caseCollection()->findByDescription(m_wellDataSourceCase); if (sourceResultCase) { sourceResultCase->openEclipseGridFile(); @@ -485,7 +485,7 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::setWellResultsAndUpdateViews(const cvf::Collection& sourceCaseWellResults) +void RimEclipseStatisticsCase::setWellResultsAndUpdateViews(const cvf::Collection& sourceCaseWellResults) { RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); @@ -496,7 +496,7 @@ void RimStatisticsCase::setWellResultsAndUpdateViews(const cvf::CollectionwellCollection()->wells.deleteAllChildObjects(); @@ -530,7 +530,7 @@ void addPropertySetToHtmlText(QString& html, const QString& heading, const std:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::updateSelectionSummaryLabel() +void RimEclipseStatisticsCase::updateSelectionSummaryLabel() { QString html; @@ -569,7 +569,7 @@ void RimStatisticsCase::updateSelectionSummaryLabel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) +void RimEclipseStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) { if (&m_selectionSummary == field) { @@ -587,7 +587,7 @@ void RimStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::updateSelectionListVisibilities() +void RimEclipseStatisticsCase::updateSelectionListVisibilities() { bool isLocked = hasComputedStatistics(); m_resultType.setUiHidden(isLocked); @@ -607,7 +607,7 @@ void RimStatisticsCase::updateSelectionListVisibilities() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::updatePercentileUiVisibility() +void RimEclipseStatisticsCase::updatePercentileUiVisibility() { bool isLocked = hasComputedStatistics(); m_calculatePercentiles.setUiHidden(isLocked); @@ -620,7 +620,7 @@ void RimStatisticsCase::updatePercentileUiVisibility() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimStatisticsCase::hasComputedStatistics() const +bool RimEclipseStatisticsCase::hasComputedStatistics() const { if ( reservoirData() && ( reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->resultCount() @@ -638,7 +638,7 @@ bool RimStatisticsCase::hasComputedStatistics() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::updateConnectedEditorsAndReservoirViews() +void RimEclipseStatisticsCase::updateConnectedEditorsAndReservoirViews() { for (size_t i = 0; i < reservoirViews.size(); ++i) { @@ -659,7 +659,7 @@ void RimStatisticsCase::updateConnectedEditorsAndReservoirViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::clearComputedStatistics() +void RimEclipseStatisticsCase::clearComputedStatistics() { reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->clearAllResults(); reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->clearAllResults(); @@ -670,7 +670,7 @@ void RimStatisticsCase::clearComputedStatistics() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::populateWithDefaultsIfNeeded() +void RimEclipseStatisticsCase::populateWithDefaultsIfNeeded() { RimIdenticalGridCaseGroup* idgcg = caseGroup(); if (!(caseGroup() && caseGroup()->mainCase() && caseGroup()->mainCase()->reservoirData())) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.h similarity index 91% rename from ApplicationCode/ProjectDataModel/RimStatisticsCase.h rename to ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.h index a225d50674..e9cdb4f180 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.h @@ -26,12 +26,12 @@ #include "cafPdmObject.h" #include "cafAppEnum.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimDefines.h" class RimIdenticalGridCaseGroup; -class RimResultDefinition; -class RimStatisticsCaseCollection; +class RimEclipseResultDefinition; +class RimEclipseStatisticsCaseCollection; class RigMainGrid; class RigSingleWellResultsData; @@ -41,13 +41,13 @@ class RigSingleWellResultsData; // // //================================================================================================== -class RimStatisticsCase : public RimCase +class RimEclipseStatisticsCase : public RimEclipseCase { CAF_PDM_HEADER_INIT; public: - RimStatisticsCase(); - virtual ~RimStatisticsCase(); + RimEclipseStatisticsCase(); + virtual ~RimEclipseStatisticsCase(); void setMainGrid(RigMainGrid* mainGrid); @@ -70,11 +70,12 @@ class RimStatisticsCase : public RimCase }; caf::PdmField< bool > m_calculateEditCommand; + virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath){} private: RimIdenticalGridCaseGroup* caseGroup(); - void getSourceCases(std::vector& sourceCases); + void getSourceCases(std::vector& sourceCases); void populateWithDefaultsIfNeeded(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp similarity index 84% rename from ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp index c4563c6fdd..545b4bcc20 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.cpp @@ -18,17 +18,17 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimStatisticsCaseCollection.h" +#include "RimEclipseStatisticsCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" -CAF_PDM_SOURCE_INIT(RimStatisticsCaseCollection, "RimStatisticalCollection"); +CAF_PDM_SOURCE_INIT(RimEclipseStatisticsCaseCollection, "RimStatisticalCollection"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCaseCollection::RimStatisticsCaseCollection() +RimEclipseStatisticsCaseCollection::RimEclipseStatisticsCaseCollection() : PdmObject() { CAF_PDM_InitObject("Derived Statistics", "", "", ""); @@ -39,7 +39,7 @@ RimStatisticsCaseCollection::RimStatisticsCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCaseCollection::~RimStatisticsCaseCollection() +RimEclipseStatisticsCaseCollection::~RimEclipseStatisticsCaseCollection() { cases.deleteAllChildObjects(); } @@ -47,7 +47,7 @@ RimStatisticsCaseCollection::~RimStatisticsCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimStatisticsCaseCollection::parentCaseGroup() +RimIdenticalGridCaseGroup* RimEclipseStatisticsCaseCollection::parentCaseGroup() { std::vector parentObjects; this->parentObjectsOfType(parentObjects); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.h similarity index 83% rename from ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.h rename to ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.h index 71f5bf5228..e1f18bfcc3 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseCollection.h @@ -25,7 +25,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -class RimStatisticsCase; +class RimEclipseStatisticsCase; class RimIdenticalGridCaseGroup; @@ -34,15 +34,15 @@ class RimIdenticalGridCaseGroup; // // //================================================================================================== -class RimStatisticsCaseCollection : public caf::PdmObject +class RimEclipseStatisticsCaseCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimStatisticsCaseCollection(); - virtual ~RimStatisticsCaseCollection(); + RimEclipseStatisticsCaseCollection(); + virtual ~RimEclipseStatisticsCaseCollection(); - caf::PdmPointersField cases; + caf::PdmPointersField cases; RimIdenticalGridCaseGroup* parentCaseGroup(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp similarity index 94% rename from ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp index 70524a840b..9ec9ac653f 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimStatisticsCaseEvaluator.h" +#include "RimEclipseStatisticsCaseEvaluator.h" #include "RigCaseCellResultsData.h" #include "RigCaseData.h" @@ -36,7 +36,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCaseEvaluator::addNamedResult(RigCaseCellResultsData* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount) +void RimEclipseStatisticsCaseEvaluator::addNamedResult(RigCaseCellResultsData* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount) { // Use time step dates from first result in first source case CVF_ASSERT(m_sourceCases.size() > 0); @@ -70,7 +70,7 @@ QString createResultNamePVal(const QString& resultName, double pValPos) { retur //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCaseEvaluator::evaluateForResults(const QList& resultSpecification) +void RimEclipseStatisticsCaseEvaluator::evaluateForResults(const QList& resultSpecification) { CVF_ASSERT(m_destinationCase); @@ -153,7 +153,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& result cvf::Collection sourceDataAccessList; for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { - RimCase* sourceCase = m_sourceCases.at(caseIdx); + RimEclipseCase* sourceCase = m_sourceCases.at(caseIdx); // Trigger loading of dataset sourceCase->results(poroModel)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex); @@ -224,7 +224,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& result // Calculate percentiles if (m_statisticsConfig.m_calculatePercentiles ) { - if (m_statisticsConfig.m_pValMethod == RimStatisticsCase::NEAREST_OBSERVATION) + if (m_statisticsConfig.m_pValMethod == RimEclipseStatisticsCase::NEAREST_OBSERVATION) { std::vector pValPoss; pValPoss.push_back(m_statisticsConfig.m_pMinPos); @@ -235,7 +235,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& result statParams[PMID] = pVals[1]; statParams[PMAX] = pVals[2]; } - else if (m_statisticsConfig.m_pValMethod == RimStatisticsCase::HISTOGRAM_ESTIMATED) + else if (m_statisticsConfig.m_pValMethod == RimEclipseStatisticsCase::HISTOGRAM_ESTIMATED) { std::vector histogram; RigHistogramCalculator histCalc(statParams[MIN], statParams[MAX], 100, &histogram); @@ -244,7 +244,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& result statParams[PMID] = histCalc.calculatePercentil(m_statisticsConfig.m_pMidPos); statParams[PMAX] = histCalc.calculatePercentil(m_statisticsConfig.m_pMaxPos); } - else if (m_statisticsConfig.m_pValMethod == RimStatisticsCase::INTERPOLATED_OBSERVATION) + else if (m_statisticsConfig.m_pValMethod == RimEclipseStatisticsCase::INTERPOLATED_OBSERVATION) { std::vector pValPoss; pValPoss.push_back(m_statisticsConfig.m_pMinPos); @@ -282,7 +282,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& result for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { - RimCase* eclipseCase = m_sourceCases.at(caseIdx); + RimEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); if (!eclipseCase->reservoirViews.size()) { @@ -303,7 +303,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& result //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCaseEvaluator::RimStatisticsCaseEvaluator(const std::vector& sourceCases, const std::vector& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase) +RimEclipseStatisticsCaseEvaluator::RimEclipseStatisticsCaseEvaluator(const std::vector& sourceCases, const std::vector& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase) : m_sourceCases(sourceCases), m_statisticsConfig(statisticsConfig), m_destinationCase(destinationCase), diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.h similarity index 88% rename from ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h rename to ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.h index 7dfad6eb7b..ca39be70cb 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.h @@ -21,13 +21,13 @@ #pragma once #include "RimDefines.h" -#include "RimStatisticsCase.h" +#include "RimEclipseStatisticsCase.h" #include #include -class RimCase; +class RimEclipseCase; class RigCaseData; class RigCaseCellResultsData; @@ -40,7 +40,7 @@ class RimStatisticsConfig m_pMinPos(10.0), m_pMidPos(50.0), m_pMaxPos(90.0), - m_pValMethod(RimStatisticsCase::INTERPOLATED_OBSERVATION) + m_pValMethod(RimEclipseStatisticsCase::INTERPOLATED_OBSERVATION) { } @@ -49,14 +49,14 @@ class RimStatisticsConfig double m_pMinPos; double m_pMidPos; double m_pMaxPos; - RimStatisticsCase::PercentileCalcType m_pValMethod; + RimEclipseStatisticsCase::PercentileCalcType m_pValMethod; }; -class RimStatisticsCaseEvaluator +class RimEclipseStatisticsCaseEvaluator { public: - RimStatisticsCaseEvaluator(const std::vector& sourceCases, + RimEclipseStatisticsCaseEvaluator(const std::vector& sourceCases, const std::vector& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase); @@ -82,7 +82,7 @@ class RimStatisticsCaseEvaluator enum StatisticsParamType { MIN, MAX, RANGE, MEAN, STDEV, PMIN, PMID, PMAX, STAT_PARAM_COUNT }; private: - std::vector m_sourceCases; + std::vector m_sourceCases; std::vector m_timeStepIndices; size_t m_reservoirCellCount; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp similarity index 56% rename from ApplicationCode/ProjectDataModel/RimReservoirView.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 76a37bda57..2871e287f3 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RiaApplication.h" #include "RiaPreferences.h" @@ -27,18 +27,18 @@ #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" #include "Rim3dOverlayInfoConfig.h" -#include "RimCase.h" -#include "RimCellEdgeResultSlot.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimCellEdgeColors.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimCellRangeFilterCollection.h" #include "RimFaultCollection.h" -#include "RimFaultResultSlot.h" +#include "RimEclipseFaultColors.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimResultSlot.h" +#include "RimEclipseCellColors.h" #include "RimTernaryLegendConfig.h" -#include "RimWell.h" -#include "RimWellCollection.h" +#include "RimEclipseWell.h" +#include "RimEclipseWellCollection.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -63,37 +63,13 @@ #include -namespace caf { - -template<> -void caf::AppEnum< RimReservoirView::MeshModeType >::setUp() -{ - addItem(RimReservoirView::FULL_MESH, "FULL_MESH", "All"); - addItem(RimReservoirView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); - addItem(RimReservoirView::NO_MESH, "NO_MESH", "None"); - setDefault(RimReservoirView::FULL_MESH); -} - -template<> -void caf::AppEnum< RimReservoirView::SurfaceModeType >::setUp() -{ - addItem(RimReservoirView::SURFACE, "SURFACE", "All"); - addItem(RimReservoirView::FAULTS, "FAULTS", "Faults only"); - addItem(RimReservoirView::NO_SURFACE, "NO_SURFACE", "None"); - setDefault(RimReservoirView::SURFACE); -} - -} // End namespace caf - - - -CAF_PDM_SOURCE_INIT(RimReservoirView, "ReservoirView"); +CAF_PDM_SOURCE_INIT(RimEclipseView, "ReservoirView"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView::RimReservoirView() +RimEclipseView::RimEclipseView() { RiaApplication* app = RiaApplication::instance(); RiaPreferences* preferences = app->preferences(); @@ -102,35 +78,17 @@ RimReservoirView::RimReservoirView() CAF_PDM_InitObject("Reservoir View", ":/ReservoirView.png", "", ""); CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); - cellResult = new RimResultSlot(); + cellResult = new RimEclipseCellColors(); CAF_PDM_InitFieldNoDefault(&cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png", "", ""); - cellEdgeResult = new RimCellEdgeResultSlot(); + cellEdgeResult = new RimCellEdgeColors(); CAF_PDM_InitFieldNoDefault(&faultResultSettings, "FaultResultSettings", "Separate Fault Result", "", "", ""); - faultResultSettings = new RimFaultResultSlot(); - - CAF_PDM_InitFieldNoDefault(&overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); - overlayInfoConfig = new Rim3dOverlayInfoConfig(); - overlayInfoConfig->setReservoirView(this); - - CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); - - double defaultScaleFactor = 1.0; - if (preferences) defaultScaleFactor = preferences->defaultScaleFactorZ; - CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); - - CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", ""); - showWindow.setUiHidden(true); - - CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step","", "", ""); - m_currentTimeStep.setUiHidden(true); - - CAF_PDM_InitField(&animationMode, "AnimationMode", false, "Animation Mode","", "", ""); - animationMode.setUiHidden(true); + faultResultSettings = new RimEclipseFaultColors(); + CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection", "Simulation Wells", "", "", ""); - wellCollection = new RimWellCollection; + wellCollection = new RimEclipseWellCollection; CAF_PDM_InitFieldNoDefault(&faultCollection, "FaultCollection", "Faults", "", "", ""); faultCollection = new RimFaultCollection; @@ -140,28 +98,14 @@ RimReservoirView::RimReservoirView() rangeFilterCollection->setReservoirView(this); CAF_PDM_InitFieldNoDefault(&propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", ""); - propertyFilterCollection = new RimCellPropertyFilterCollection(); + propertyFilterCollection = new RimEclipsePropertyFilterCollection(); propertyFilterCollection->setReservoirView(this); - caf::AppEnum defaultMeshType = NO_MESH; - if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; - CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", ""); - CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", ""); - - CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate","", "", ""); - maximumFrameRate.setUiHidden(true); - // Visualization fields CAF_PDM_InitField(&showMainGrid, "ShowMainGrid", true, "Show Main Grid", "", "", ""); CAF_PDM_InitField(&showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", ""); CAF_PDM_InitField(&showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", ""); - cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); - CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); - - - CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); - - + this->cellResult()->setReservoirView(this); this->cellResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 120)); @@ -177,106 +121,32 @@ RimReservoirView::RimReservoirView() m_pipesPartManager = new RivReservoirPipesPartMgr(this); m_reservoir = NULL; - m_previousGridModeMeshLinesWasFaults = false; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView::~RimReservoirView() +RimEclipseView::~RimEclipseView() { delete this->faultResultSettings(); delete this->cellResult(); delete this->cellEdgeResult(); - delete this->overlayInfoConfig(); delete rangeFilterCollection(); delete propertyFilterCollection(); delete wellCollection(); delete faultCollection(); - if (m_viewer) - { - RiuMainWindow::instance()->removeViewer(m_viewer); - } - m_reservoirGridPartManager->clearGeometryCache(); - delete m_viewer; - + m_reservoir = NULL; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateViewerWidget() -{ - if (showWindow()) - { - bool isViewerCreated = false; - if (!m_viewer) - { - QGLFormat glFormat; - glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); - - m_viewer = new RiuViewer(glFormat, NULL); - m_viewer->setOwnerReservoirView(this); - - RiuMainWindow::instance()->addViewer(m_viewer); - m_viewer->setMinNearPlaneDistance(10); - this->cellResult()->legendConfig->recreateLegend(); - this->cellResult()->ternaryLegendConfig->recreateLegend(); - this->cellEdgeResult()->legendConfig->recreateLegend(); - - m_viewer->removeAllColorLegends(); - m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend()); - - if (RiaApplication::instance()->navigationPolicy() == RiaApplication::NAVIGATION_POLICY_CEETRON) - { - m_viewer->setNavigationPolicy(new caf::CeetronPlusNavigation); - } - else - { - m_viewer->setNavigationPolicy(new caf::CadNavigation); - } - - m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); - - //m_viewer->layoutWidget()->showMaximized(); - - isViewerCreated = true; - } - - RiuMainWindow::instance()->setActiveViewer(m_viewer); - - if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition); - m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); - - m_viewer->update(); - } - else - { - if (m_viewer) - { - if (m_viewer->layoutWidget()->parentWidget()) - { - m_viewer->layoutWidget()->parentWidget()->hide(); - } - else - { - m_viewer->layoutWidget()->hide(); - } - } - } - - updateViewerWidgetWindowTitle(); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateViewerWidgetWindowTitle() +void RimEclipseView::updateViewerWidgetWindowTitle() { if (m_viewer) { @@ -295,11 +165,10 @@ void RimReservoirView::updateViewerWidgetWindowTitle() } //-------------------------------------------------------------------------------------------------- -/// +/// Clamp the current timestep to actual possibilities //-------------------------------------------------------------------------------------------------- -void RimReservoirView::clampCurrentTimestep() +void RimEclipseView::clampCurrentTimestep() { - // Clamp the current timestep to actual possibilities if (this->currentGridCellResults() && this->currentGridCellResults()->cellResults()) { if (m_currentTimeStep() >= static_cast(this->currentGridCellResults()->cellResults()->maxTimeStepCount())) @@ -311,94 +180,15 @@ void RimReservoirView::clampCurrentTimestep() if (m_currentTimeStep < 0 ) m_currentTimeStep = 0; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::scheduleCreateDisplayModelAndRedraw() -{ - RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::createDisplayModelAndRedraw() +void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - if (m_viewer) - { - m_viewer->animationControl()->slotStop(); - - this->clampCurrentTimestep(); - - createDisplayModel(); - updateDisplayModelVisibility(); + RimView::fieldChangedByUi(changedField, oldValue, newValue); - if (m_viewer->frameCount() > 0) - { - m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep); - } - } - - RiuMainWindow::instance()->refreshAnimationActions(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setDefaultView() -{ - if (m_viewer) - { - m_viewer->setDefaultView(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - if (changedField == &scaleZ ) - { - if (scaleZ < 1) scaleZ = 1; - - // Regenerate well paths - RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; - RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; - if (wellPathCollection) wellPathCollection->wellPathCollectionPartMgr()->scheduleGeometryRegen(); - - if (m_viewer) - { - cvf::Vec3d poi = m_viewer->pointOfInterest(); - cvf::Vec3d eye, dir, up; - eye = m_viewer->mainCamera()->position(); - dir = m_viewer->mainCamera()->direction(); - up = m_viewer->mainCamera()->up(); - - eye[2] = poi[2]*scaleZ()/m_reservoirGridPartManager->scaleTransform()->worldTransform()(2,2) + (eye[2] - poi[2]); - poi[2] = poi[2]*scaleZ()/m_reservoirGridPartManager->scaleTransform()->worldTransform()(2,2); - - m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up); - m_viewer->setPointOfInterest(poi); - - updateScaleTransform(); - createDisplayModelAndRedraw(); - m_viewer->update(); - } - - RiuMainWindow::instance()->updateScaleValue(); - } - else if (changedField == &maximumFrameRate) - { - // !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0? - // !! Should be able to specify legal range for number properties - if (m_viewer) - { - m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); - } - } - else if (changedField == &showWindow ) + if (changedField == &showWindow) { if (showWindow) { @@ -421,79 +211,49 @@ void RimReservoirView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, this->updateUiIconFromToggleField(); } - else if (changedField == &backgroundColor ) - { - if (viewer() != NULL) - { - updateViewerWidget(); - } - } - else if (changedField == &m_currentTimeStep) - { - if (m_viewer) - { - m_viewer->update(); - } - } - else if (changedField == &showInvalidCells ) + + else if (changedField == &showInvalidCells) { - m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::INACTIVE); - m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + m_reservoirGridPartManager->scheduleGeometryRegen(INACTIVE); + m_reservoirGridPartManager->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); createDisplayModelAndRedraw(); - } - else if ( changedField == &showInactiveCells ) + } + else if (changedField == &showInactiveCells) { - m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::INACTIVE); - m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + m_reservoirGridPartManager->scheduleGeometryRegen(INACTIVE); + m_reservoirGridPartManager->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); createDisplayModelAndRedraw(); - } - else if ( changedField == &showMainGrid ) + } + else if (changedField == &showMainGrid) { createDisplayModelAndRedraw(); - } - else if ( changedField == &rangeFilterCollection ) + } + else if (changedField == &rangeFilterCollection) { - m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + m_reservoirGridPartManager->scheduleGeometryRegen(RANGE_FILTERED); + m_reservoirGridPartManager->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); scheduleCreateDisplayModelAndRedraw(); - } - else if ( changedField == &propertyFilterCollection) + } + else if (changedField == &propertyFilterCollection) { - m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::PROPERTY_FILTERED); + m_reservoirGridPartManager->scheduleGeometryRegen(PROPERTY_FILTERED); scheduleCreateDisplayModelAndRedraw(); - } - else if (changedField == &meshMode) - { - createDisplayModel(); - updateDisplayModelVisibility(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - } - else if (changedField == &surfaceMode) - { - createDisplayModel(); - updateDisplayModelVisibility(); - RiuMainWindow::instance()->refreshDrawStyleActions(); - } - else if (changedField == &name) - { - updateViewerWidgetWindowTitle(); } + + } -void RimReservoirView::updateScaleTransform() +void RimEclipseView::updateScaleTransform() { - CVF_ASSERT(m_reservoirGridPartManager.notNull()); - CVF_ASSERT(m_pipesPartManager.notNull()); - cvf::Mat4d scale = cvf::Mat4d::IDENTITY; scale(2, 2) = scaleZ(); - m_reservoirGridPartManager->setScaleTransform(scale); - m_pipesPartManager->setScaleTransform(m_reservoirGridPartManager->scaleTransform()); + this->scaleTransform()->setLocalTransform(scale); + m_pipesPartManager->setScaleTransform(this->scaleTransform()); if (m_viewer) m_viewer->updateCachedValuesInScene(); } @@ -505,7 +265,7 @@ void RimReservoirView::updateScaleTransform() /// or at least empty scenes as frames that is delivered to the viewer /// The real geometry generation is done inside RivReservoirViewGeometry and friends //-------------------------------------------------------------------------------------------------- -void RimReservoirView::createDisplayModel() +void RimEclipseView::createDisplayModel() { if (m_viewer.isNull()) return; @@ -571,41 +331,41 @@ void RimReservoirView::createDisplayModel() if (!this->propertyFilterCollection()->hasActiveFilters()) { - std::vector geometryTypesToAdd; + std::vector geometryTypesToAdd; if (this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + geometryTypesToAdd.push_back(RANGE_FILTERED); + geometryTypesToAdd.push_back(RANGE_FILTERED_WELL_CELLS); + geometryTypesToAdd.push_back(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + geometryTypesToAdd.push_back(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); if (this->showInactiveCells()) { - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + geometryTypesToAdd.push_back(RANGE_FILTERED_INACTIVE); } } else if (!this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS); + geometryTypesToAdd.push_back(VISIBLE_WELL_CELLS); + geometryTypesToAdd.push_back(VISIBLE_WELL_FENCE_CELLS); } else if (this->rangeFilterCollection()->hasActiveFilters() && !this->wellCollection()->hasVisibleWellCells()) { - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); + geometryTypesToAdd.push_back(RANGE_FILTERED); + geometryTypesToAdd.push_back(RANGE_FILTERED_WELL_CELLS); if (this->showInactiveCells()) { - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + geometryTypesToAdd.push_back(RANGE_FILTERED_INACTIVE); } } else { - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); // Should be all well cells - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::ACTIVE); + geometryTypesToAdd.push_back(ALL_WELL_CELLS); // Should be all well cells + geometryTypesToAdd.push_back(ACTIVE); if (this->showInactiveCells()) { - geometryTypesToAdd.push_back(RivReservoirViewPartMgr::INACTIVE); + geometryTypesToAdd.push_back(INACTIVE); } } @@ -628,9 +388,9 @@ void RimReservoirView::createDisplayModel() { updateFaultForcedVisibility(); - std::vector faultGeometryTypesToAppend = visibleFaultGeometryTypes(); + std::vector faultGeometryTypesToAppend = visibleFaultGeometryTypes(); - RivReservoirViewPartMgr::ReservoirGeometryCacheType faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend); + RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend); for (size_t frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx) { @@ -671,6 +431,11 @@ void RimReservoirView::createDisplayModel() // Create Scenes from the frameModels // Animation frames for results display, starts from frame 1 + RimEclipseCase* eclCase = eclipseCase(); + RigCaseData* caseData = eclCase ? eclCase->reservoirData() : NULL; + RigMainGrid* mainGrid = caseData ? caseData->mainGrid() : NULL; + CVF_ASSERT(mainGrid); + size_t frameIndex; for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++) { @@ -680,6 +445,12 @@ void RimReservoirView::createDisplayModel() cvf::ref scene = new cvf::Scene; scene->addModel(model); + // Add well paths, if any + addWellPathsToScene(scene.p(), mainGrid->displayModelOffset(), + mainGrid->characteristicIJCellSize(), + currentActiveCellInfo()->geometryBoundingBox(), + m_reservoirGridPartManager->scaleTransform()); + if (frameIndex == 0) m_viewer->setMainScene(scene.p()); else @@ -688,22 +459,26 @@ void RimReservoirView::createDisplayModel() // If the animation was active before recreating everything, make viewer view current frame - if (isAnimationActive || cellResult->hasResult()) + if (frameModels.size() > 1 && this->hasUserRequestedAnimation()) { - m_viewer->slotSetCurrentFrame(m_currentTimeStep); + m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep); + } + else + { + overlayInfoConfig()->update3DInfo(); + updateLegends(); } - - overlayInfoConfig()->update3DInfo(); - updateLegends(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateCurrentTimeStep() +void RimEclipseView::updateCurrentTimeStep() { - std::vector geometriesToRecolor; + updateLegends(); // To make sure the scalar mappers are set up correctly + + std::vector geometriesToRecolor; if (this->propertyFilterCollection()->hasActiveFilters()) { @@ -712,35 +487,35 @@ void RimReservoirView::updateCurrentTimeStep() std::vector gridIndices; this->indicesToVisibleGrids(&gridIndices); - geometriesToRecolor.push_back( RivReservoirViewPartMgr::PROPERTY_FILTERED); - m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::PROPERTY_FILTERED, m_currentTimeStep, gridIndices); + geometriesToRecolor.push_back( PROPERTY_FILTERED); + m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED, m_currentTimeStep, gridIndices); - geometriesToRecolor.push_back( RivReservoirViewPartMgr::PROPERTY_FILTERED_WELL_CELLS); - m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, gridIndices); + geometriesToRecolor.push_back( PROPERTY_FILTERED_WELL_CELLS); + m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, gridIndices); if (faultCollection()->showFaultsOutsideFilters()) { - std::vector faultGeometryTypesToAppend = visibleFaultGeometryTypes(); + std::vector faultGeometryTypesToAppend = visibleFaultGeometryTypes(); for (size_t i = 0; i < faultGeometryTypesToAppend.size(); i++) { m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), faultGeometryTypesToAppend[i]); } - RivReservoirViewPartMgr::ReservoirGeometryCacheType faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend); + RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend); m_reservoirGridPartManager->appendFaultLabelsStaticGeometryPartsToModel(frameParts.p(), faultLabelType); } else { - m_reservoirGridPartManager->appendFaultsDynamicGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::PROPERTY_FILTERED, m_currentTimeStep); - m_reservoirGridPartManager->appendFaultLabelsDynamicGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::PROPERTY_FILTERED, m_currentTimeStep); + m_reservoirGridPartManager->appendFaultsDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED, m_currentTimeStep); + m_reservoirGridPartManager->appendFaultLabelsDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED, m_currentTimeStep); - m_reservoirGridPartManager->appendFaultsDynamicGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep); + m_reservoirGridPartManager->appendFaultsDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep); } // Set the transparency on all the Wellcell parts before setting the result color float opacity = static_cast< float> (1 - cvf::Math::clamp(this->wellCollection()->wellCellTransparencyLevel(), 0.0, 1.0)); - m_reservoirGridPartManager->updateCellColor(RivReservoirViewPartMgr::PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, cvf::Color4f(cvf::Color3f(cvf::Color3::WHITE), opacity)); + m_reservoirGridPartManager->updateCellColor(PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, cvf::Color4f(cvf::Color3f(cvf::Color3::WHITE), opacity)); if (this->showInactiveCells()) @@ -750,20 +525,20 @@ void RimReservoirView::updateCurrentTimeStep() if (this->rangeFilterCollection()->hasActiveFilters() ) // Wells not considered, because we do not have a INACTIVE_WELL_CELLS group yet. { - m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE, gridIndices); + m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), RANGE_FILTERED_INACTIVE, gridIndices); if (!faultCollection()->showFaultsOutsideFilters()) { - m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), RANGE_FILTERED_INACTIVE); } } else { - m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::INACTIVE, gridIndices); + m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), INACTIVE, gridIndices); if (!faultCollection()->showFaultsOutsideFilters()) { - m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), RivReservoirViewPartMgr::INACTIVE); + m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), INACTIVE); } } } @@ -783,34 +558,34 @@ void RimReservoirView::updateCurrentTimeStep() } else if (this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { - geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); - geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); - geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); - geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + geometriesToRecolor.push_back(RANGE_FILTERED); + geometriesToRecolor.push_back(RANGE_FILTERED_WELL_CELLS); + geometriesToRecolor.push_back(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + geometriesToRecolor.push_back(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); } else if (!this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { - geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); - geometriesToRecolor.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS); + geometriesToRecolor.push_back(VISIBLE_WELL_CELLS); + geometriesToRecolor.push_back(VISIBLE_WELL_FENCE_CELLS); } else if (this->rangeFilterCollection()->hasActiveFilters() && !this->wellCollection()->hasVisibleWellCells()) { - geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); - geometriesToRecolor.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); + geometriesToRecolor.push_back(RANGE_FILTERED); + geometriesToRecolor.push_back(RANGE_FILTERED_WELL_CELLS); } else { - geometriesToRecolor.push_back(RivReservoirViewPartMgr::ACTIVE); - geometriesToRecolor.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); + geometriesToRecolor.push_back(ACTIVE); + geometriesToRecolor.push_back(ALL_WELL_CELLS); } for (size_t i = 0; i < geometriesToRecolor.size(); ++i) { - if (this->animationMode() && this->cellEdgeResult()->hasResult()) + if (this->hasUserRequestedAnimation() && this->cellEdgeResult()->hasResult()) { m_reservoirGridPartManager->updateCellEdgeResultColor(geometriesToRecolor[i], m_currentTimeStep, this->cellResult(), this->cellEdgeResult()); } - else if ((this->animationMode() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected()) + else if ((this->hasUserRequestedAnimation() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected()) { m_reservoirGridPartManager->updateCellResultColor(geometriesToRecolor[i], m_currentTimeStep, this->cellResult()); } @@ -822,7 +597,7 @@ void RimReservoirView::updateCurrentTimeStep() this->updateFaultColors(); - // Well pipes and well paths + // Well pipes if (m_viewer) { cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); @@ -855,53 +630,28 @@ void RimReservoirView::updateCurrentTimeStep() wellPipeModelBasicList->updateBoundingBoxesRecursive(); //printf("updateCurrentTimeStep: Add WellPipeModel to frameScene\n"); frameScene->addModel(wellPipeModelBasicList.p()); - - // Well paths - // ---------- - cvf::String wellPathModelName = "WellPathModel"; - std::vector wellPathModels; - for (cvf::uint i = 0; i < frameScene->modelCount(); i++) - { - if (frameScene->model(i)->name() == wellPathModelName) - { - wellPathModels.push_back(frameScene->model(i)); - } - } - - for (size_t i = 0; i < wellPathModels.size(); i++) - { - //printf("updateCurrentTimeStep: Remove WellPathModel %i from frameScene, for frame %i\n", i, m_currentTimeStep.v()); - frameScene->removeModel(wellPathModels[i]); - } - // Append static Well Paths to model - cvf::ref wellPathModelBasicList = new cvf::ModelBasicList; - wellPathModelBasicList->setName(wellPathModelName); - RimOilField* oilFields = (RiaApplication::instance()->project()) ? RiaApplication::instance()->project()->activeOilField() : NULL; - RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; - RivWellPathCollectionPartMgr* wellPathCollectionPartMgr = (wellPathCollection) ? wellPathCollection->wellPathCollectionPartMgr() : NULL; - if (wellPathCollectionPartMgr) - { - //printf("updateCurrentTimeStep: Append well paths for frame %i: ", m_currentTimeStep.v()); - cvf::Vec3d displayModelOffset = eclipseCase()->reservoirData()->mainGrid()->displayModelOffset(); - double characteristicCellSize = eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize(); - cvf::BoundingBox boundingBox = currentActiveCellInfo()->geometryBoundingBox(); - wellPathCollectionPartMgr->appendStaticGeometryPartsToModel(wellPathModelBasicList.p(), displayModelOffset, m_reservoirGridPartManager->scaleTransform(), characteristicCellSize, boundingBox); - //printf("\n"); - } - wellPathModelBasicList->updateBoundingBoxesRecursive(); - frameScene->addModel(wellPathModelBasicList.p()); + // Add well paths, if any + RimEclipseCase* eclCase = eclipseCase(); + RigCaseData* caseData = eclCase ? eclCase->reservoirData() : NULL; + RigMainGrid* mainGrid = caseData ? caseData->mainGrid() : NULL; + CVF_ASSERT(mainGrid); + + addWellPathsToScene(frameScene, + mainGrid->displayModelOffset(), + mainGrid->characteristicIJCellSize(), + currentActiveCellInfo()->geometryBoundingBox(), + m_reservoirGridPartManager->scaleTransform()); } } overlayInfoConfig()->update3DInfo(); - updateLegends(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::loadDataAndUpdate() +void RimEclipseView::loadDataAndUpdate() { updateScaleTransform(); @@ -943,7 +693,6 @@ void RimReservoirView::loadDataAndUpdate() { setDefaultView(); } - } @@ -951,7 +700,7 @@ void RimReservoirView::loadDataAndUpdate() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::initAfterRead() +void RimEclipseView::initAfterRead() { this->faultResultSettings()->setReservoirView(this); this->cellResult()->setReservoirView(this); @@ -962,81 +711,55 @@ void RimReservoirView::initAfterRead() this->updateUiIconFromToggleField(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setCurrentTimeStep(int frameIndex) -{ - m_currentTimeStep = frameIndex; - this->animationMode = true; - this->updateCurrentTimeStep(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::endAnimation() -{ - this->animationMode = false; - this->updateStaticCellColors(); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateStaticCellColors() +void RimEclipseView::updateStaticCellColors() { - updateStaticCellColors( RivReservoirViewPartMgr::ACTIVE); - updateStaticCellColors( RivReservoirViewPartMgr::ALL_WELL_CELLS); - updateStaticCellColors( RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); - updateStaticCellColors( RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS); - updateStaticCellColors( RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); - updateStaticCellColors( RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); - updateStaticCellColors( RivReservoirViewPartMgr::INACTIVE); - updateStaticCellColors( RivReservoirViewPartMgr::RANGE_FILTERED); - updateStaticCellColors( RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); - updateStaticCellColors( RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + updateStaticCellColors( ACTIVE); + updateStaticCellColors( ALL_WELL_CELLS); + updateStaticCellColors( VISIBLE_WELL_CELLS); + updateStaticCellColors( VISIBLE_WELL_FENCE_CELLS); + updateStaticCellColors( VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + updateStaticCellColors( VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + updateStaticCellColors( INACTIVE); + updateStaticCellColors( RANGE_FILTERED); + updateStaticCellColors( RANGE_FILTERED_WELL_CELLS); + updateStaticCellColors( RANGE_FILTERED_INACTIVE); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateStaticCellColors(unsigned short geometryType) +void RimEclipseView::updateStaticCellColors(RivCellSetEnum geometryType) { float opacity = static_cast< float> (1 - cvf::Math::clamp(this->wellCollection()->wellCellTransparencyLevel(), 0.0, 1.0)); cvf::Color4f color(cvf::Color3::ORANGE); switch (geometryType) { - case RivReservoirViewPartMgr::ACTIVE: color = cvf::Color4f(cvf::Color3::ORANGE); break; - case RivReservoirViewPartMgr::ALL_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; - case RivReservoirViewPartMgr::VISIBLE_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; - case RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS: color = cvf::Color4f(cvf::Color3::ORANGE); break; - case RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER: + case ACTIVE: color = cvf::Color4f(cvf::Color3::ORANGE); break; + case ALL_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; + case VISIBLE_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; + case VISIBLE_WELL_FENCE_CELLS: color = cvf::Color4f(cvf::Color3::ORANGE); break; + case VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; - case RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER: + case VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER: color = cvf::Color4f(cvf::Color3::ORANGE); break; - case RivReservoirViewPartMgr::INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; - case RivReservoirViewPartMgr::RANGE_FILTERED: color = cvf::Color4f(cvf::Color3::ORANGE); break; - case RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; - case RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; + case INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; + case RANGE_FILTERED: color = cvf::Color4f(cvf::Color3::ORANGE); break; + case RANGE_FILTERED_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; + case RANGE_FILTERED_INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; } - m_reservoirGridPartManager->updateCellColor(static_cast(geometryType), color); + m_reservoirGridPartManager->updateCellColor(geometryType, color); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuViewer* RimReservoirView::viewer() -{ - return m_viewer; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateDisplayModelVisibility() +void RimEclipseView::updateDisplayModelVisibility() { if (m_viewer.isNull()) return; @@ -1076,22 +799,10 @@ void RimReservoirView::updateDisplayModelVisibility() faultCollection->updateConnectedEditors(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setupBeforeSave() -{ - if (m_viewer) - { - animationMode = m_viewer->isAnimationActive(); - cameraPosition = m_viewer->mainCamera()->viewMatrix(); - } -} - //-------------------------------------------------------------------------------------------------- /// Convenience for quick access to results //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsStorage* RimReservoirView::currentGridCellResults() +RimReservoirCellResultsStorage* RimEclipseView::currentGridCellResults() { if (m_reservoir) { @@ -1106,7 +817,7 @@ RimReservoirCellResultsStorage* RimReservoirView::currentGridCellResults() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigActiveCellInfo* RimReservoirView::currentActiveCellInfo() +RigActiveCellInfo* RimEclipseView::currentActiveCellInfo() { if (m_reservoir && m_reservoir->reservoirData() @@ -1124,15 +835,15 @@ RigActiveCellInfo* RimReservoirView::currentActiveCellInfo() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::scheduleGeometryRegen(unsigned short geometryType) +void RimEclipseView::scheduleGeometryRegen(RivCellSetEnum geometryType) { - m_reservoirGridPartManager->scheduleGeometryRegen(static_cast(geometryType)); + m_reservoirGridPartManager->scheduleGeometryRegen(static_cast(geometryType)); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::scheduleReservoirGridGeometryRegen() +void RimEclipseView::scheduleReservoirGridGeometryRegen() { m_reservoirGridPartManager->clearGeometryCache(); } @@ -1140,25 +851,16 @@ void RimReservoirView::scheduleReservoirGridGeometryRegen() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::schedulePipeGeometryRegen() +void RimEclipseView::schedulePipeGeometryRegen() { m_pipesPartManager->scheduleGeometryRegen(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateCurrentTimeStepAndRedraw() -{ - this->updateCurrentTimeStep(); - - if (m_viewer) m_viewer->update(); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::indicesToVisibleGrids(std::vector* gridIndices) +void RimEclipseView::indicesToVisibleGrids(std::vector* gridIndices) { CVF_ASSERT(gridIndices != NULL); @@ -1182,7 +884,7 @@ void RimReservoirView::indicesToVisibleGrids(std::vector* gridIndices) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateLegends() +void RimEclipseView::updateLegends() { if (m_viewer) { @@ -1204,7 +906,7 @@ void RimReservoirView::updateLegends() updateMinMaxValuesAndAddLegendToView(QString("Cell Results: \n"), this->cellResult(), results); if (this->faultResultSettings()->showCustomFaultResult() && this->faultResultSettings()->hasValidCustomResult()) { - updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultSlot(), results); + updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results); } if (this->cellEdgeResult()->hasResult()) @@ -1230,21 +932,21 @@ void RimReservoirView::updateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimResultSlot* resultSlot, RigCaseCellResultsData* cellResultsData) +void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData) { - if (resultSlot->hasResult()) + if (resultColors->hasResult()) { double globalMin, globalMax; double globalPosClosestToZero, globalNegClosestToZero; - cellResultsData->minMaxCellScalarValues(resultSlot->scalarResultIndex(), globalMin, globalMax); - cellResultsData->posNegClosestToZero(resultSlot->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); + cellResultsData->minMaxCellScalarValues(resultColors->scalarResultIndex(), globalMin, globalMax); + cellResultsData->posNegClosestToZero(resultColors->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); double localMin, localMax; double localPosClosestToZero, localNegClosestToZero; - if (resultSlot->hasDynamicResult()) + if (resultColors->hasDynamicResult()) { - cellResultsData->minMaxCellScalarValues(resultSlot->scalarResultIndex(), m_currentTimeStep, localMin, localMax); - cellResultsData->posNegClosestToZero(resultSlot->scalarResultIndex(), m_currentTimeStep, localPosClosestToZero, localNegClosestToZero); + cellResultsData->minMaxCellScalarValues(resultColors->scalarResultIndex(), m_currentTimeStep, localMin, localMax); + cellResultsData->posNegClosestToZero(resultColors->scalarResultIndex(), m_currentTimeStep, localPosClosestToZero, localNegClosestToZero); } else { @@ -1255,22 +957,22 @@ void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, localNegClosestToZero = globalNegClosestToZero; } - resultSlot->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - resultSlot->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + resultColors->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + resultColors->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - m_viewer->addColorLegendToBottomLeftCorner(resultSlot->legendConfig->legend()); - resultSlot->legendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel + resultSlot->resultVariable())); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig->legend()); + resultColors->legendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel + resultColors->resultVariable())); } else { - resultSlot->legendConfig->setClosestToZeroValues(0, 0, 0, 0); - resultSlot->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE); + resultColors->legendConfig->setClosestToZeroValues(0, 0, 0, 0); + resultColors->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE); } size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); - if (resultSlot->isTernarySaturationSelected() && maxTimeStepCount > 1) + if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - RimReservoirCellResultsStorage* gridCellResults = resultSlot->currentGridCellResults(); + RimReservoirCellResultsStorage* gridCellResults = resultColors->currentGridCellResults(); { double globalMin = 0.0; double globalMax = 1.0; @@ -1283,7 +985,7 @@ void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - resultSlot->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); + resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); } } @@ -1299,7 +1001,7 @@ void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - resultSlot->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); + resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); } } @@ -1315,14 +1017,14 @@ void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - resultSlot->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); + resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); } } - if (resultSlot->ternaryLegendConfig->legend()) + if (resultColors->ternaryLegendConfig->legend()) { - resultSlot->ternaryLegendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel)); - m_viewer->addColorLegendToBottomLeftCorner(resultSlot->ternaryLegendConfig->legend()); + resultColors->ternaryLegendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel)); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); } } } @@ -1330,7 +1032,7 @@ void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::setEclipseCase(RimCase* reservoir) +void RimEclipseView::setEclipseCase(RimEclipseCase* reservoir) { m_reservoir = reservoir; } @@ -1338,7 +1040,7 @@ void RimReservoirView::setEclipseCase(RimCase* reservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase* RimReservoirView::eclipseCase() +RimEclipseCase* RimEclipseView::eclipseCase() { return m_reservoir; } @@ -1356,19 +1058,19 @@ RimCase* RimReservoirView::eclipseCase() */ //-------------------------------------------------------------------------------------------------- -void RimReservoirView::syncronizeWellsWithResults() +void RimEclipseView::syncronizeWellsWithResults() { if (!(m_reservoir && m_reservoir->reservoirData()) ) return; cvf::Collection wellResults = m_reservoir->reservoirData()->wellResults(); - std::vector > newWells; + std::vector > newWells; // Clear the possible well results data present for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { - RimWell* well = this->wellCollection()->wells()[wIdx]; + RimEclipseWell* well = this->wellCollection()->wells()[wIdx]; well->setWellResults(NULL); } @@ -1376,11 +1078,11 @@ void RimReservoirView::syncronizeWellsWithResults() for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx) { - RimWell* well = this->wellCollection()->findWell(wellResults[wIdx]->m_wellName); + RimEclipseWell* well = this->wellCollection()->findWell(wellResults[wIdx]->m_wellName); if (!well) { - well = new RimWell; + well = new RimEclipseWell; well->name = wellResults[wIdx]->m_wellName; } @@ -1393,7 +1095,7 @@ void RimReservoirView::syncronizeWellsWithResults() for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { - RimWell* well = this->wellCollection()->wells()[wIdx]; + RimEclipseWell* well = this->wellCollection()->wells()[wIdx]; RigSingleWellResultsData* wellRes = well->wellResults(); if (wellRes == NULL) { @@ -1417,7 +1119,7 @@ void RimReservoirView::syncronizeWellsWithResults() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid) +void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid) { CVF_ASSERT(visibleCells != NULL); @@ -1429,7 +1131,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl visibleCells->setAll(false); // If all wells are forced off, return - if (this->wellCollection()->wellCellsToRangeFilterMode() == RimWellCollection::RANGE_ADD_NONE) return; + if (this->wellCollection()->wellCellsToRangeFilterMode() == RimEclipseWellCollection::RANGE_ADD_NONE) return; RigActiveCellInfo* activeCellInfo = this->currentActiveCellInfo(); @@ -1438,8 +1140,8 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl // Loop over the wells and find their contribution for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { - RimWell* well = this->wellCollection()->wells()[wIdx]; - if (this->wellCollection()->wellCellsToRangeFilterMode() == RimWellCollection::RANGE_ADD_ALL || (well->showWell() && well->showWellCells()) ) + RimEclipseWell* well = this->wellCollection()->wells()[wIdx]; + if (this->wellCollection()->wellCellsToRangeFilterMode() == RimEclipseWellCollection::RANGE_ADD_ALL || (well->showWell() && well->showWellCells()) ) { RigSingleWellResultsData* wres = well->wellResults(); if (!wres) continue; @@ -1489,17 +1191,17 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl size_t cellCountFenceDirection = 0; size_t fIdx = 0; - if (this->wellCollection()->wellCellFenceType == RimWellCollection::K_DIRECTION) + if (this->wellCollection()->wellCellFenceType == RimEclipseWellCollection::K_DIRECTION) { cellCountFenceDirection = grid->cellCountK(); pK = &fIdx; } - else if (this->wellCollection()->wellCellFenceType == RimWellCollection::J_DIRECTION) + else if (this->wellCollection()->wellCellFenceType == RimEclipseWellCollection::J_DIRECTION) { cellCountFenceDirection = grid->cellCountJ(); pJ = &fIdx; } - else if (this->wellCollection()->wellCellFenceType == RimWellCollection::I_DIRECTION) + else if (this->wellCollection()->wellCellFenceType == RimEclipseWellCollection::I_DIRECTION) { cellCountFenceDirection = grid->cellCountI(); pI = &fIdx; @@ -1527,7 +1229,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateDisplayModelForWellResults() +void RimEclipseView::updateDisplayModelForWellResults() { m_reservoirGridPartManager->clearGeometryCache(); m_pipesPartManager->clearGeometryCache(); @@ -1537,141 +1239,20 @@ void RimReservoirView::updateDisplayModelForWellResults() createDisplayModel(); updateDisplayModelVisibility(); - if (animationMode && m_viewer) + if (hasUserRequestedAnimation() && m_viewer) { - m_viewer->slotSetCurrentFrame(m_currentTimeStep); + m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep); } RiuMainWindow::instance()->refreshAnimationActions(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setMeshOnlyDrawstyle() -{ - if (isGridVisualizationMode()) - { - meshMode.setValueFromUi(FULL_MESH); - } - else - { - meshMode.setValueFromUi(FAULTS_MESH); - } - - surfaceMode.setValueFromUi(NO_SURFACE); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setMeshSurfDrawstyle() -{ - if (isGridVisualizationMode()) - { - surfaceMode.setValueFromUi(SURFACE); - meshMode.setValueFromUi(FULL_MESH); - } - else - { - surfaceMode.setValueFromUi(FAULTS); - meshMode.setValueFromUi(FAULTS_MESH); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setFaultMeshSurfDrawstyle() -{ - // Surf: No Fault Surf - // Mesh ------------- - // No FF FF SF - // Fault FF FF SF - // Mesh SF SF SF - if (this->isGridVisualizationMode()) - { - surfaceMode.setValueFromUi(SURFACE); - } - else - { - surfaceMode.setValueFromUi(FAULTS); - } - - meshMode.setValueFromUi(FAULTS_MESH); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::setSurfOnlyDrawstyle() -{ - if (isGridVisualizationMode()) - { - surfaceMode.setValueFromUi(SURFACE); - } - else - { - surfaceMode.setValueFromUi(FAULTS); - } - meshMode.setValueFromUi(NO_MESH); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setShowFaultsOnly(bool showFaults) -{ - if (showFaults) - { - m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(FAULTS); - if (meshMode() != NO_MESH) meshMode.setValueFromUi(FAULTS_MESH); - } - else - { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE); - if (meshMode() != NO_MESH) meshMode.setValueFromUi(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH: FULL_MESH); - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::setSurfaceDrawstyle() -{ - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE); -} - -//-------------------------------------------------------------------------------------------------- -/// -// Surf: No Fault Surf -// Mesh ------------- -// No F F G -// Fault F F G -// Mesh G G G -// -//-------------------------------------------------------------------------------------------------- -bool RimReservoirView::isGridVisualizationMode() const -{ - return ( this->surfaceMode() == SURFACE - || this->meshMode() == FULL_MESH); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimReservoirView::objectToggleField() -{ - return &showWindow; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEclipseView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); viewGroup->add(&name); @@ -1691,7 +1272,7 @@ void RimReservoirView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateFaultForcedVisibility() +void RimEclipseView::updateFaultForcedVisibility() { // Force visibility of faults based on application state // As fault geometry is visible in grid visualization mode, fault geometry must be forced visible @@ -1699,83 +1280,83 @@ void RimReservoirView::updateFaultForcedVisibility() if (!faultCollection->showFaultCollection) { - m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(RivReservoirViewPartMgr::ALL_WELL_CELLS, true); + m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(ALL_WELL_CELLS, true); } - m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(RivReservoirViewPartMgr::RANGE_FILTERED, true); - m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS, true); - m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER, true); + m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(RANGE_FILTERED, true); + m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(VISIBLE_WELL_FENCE_CELLS, true); + m_reservoirGridPartManager->setFaultForceVisibilityForGeometryType(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER, true); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimReservoirView::visibleFaultGeometryTypes() const +std::vector RimEclipseView::visibleFaultGeometryTypes() const { - std::vector faultParts; + std::vector faultParts; if (this->propertyFilterCollection()->hasActiveFilters() && !faultCollection()->showFaultsOutsideFilters()) { - faultParts.push_back(RivReservoirViewPartMgr::PROPERTY_FILTERED); - faultParts.push_back(RivReservoirViewPartMgr::PROPERTY_FILTERED_WELL_CELLS); + faultParts.push_back(PROPERTY_FILTERED); + faultParts.push_back(PROPERTY_FILTERED_WELL_CELLS); if (this->showInactiveCells()) { - faultParts.push_back(RivReservoirViewPartMgr::INACTIVE); - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + faultParts.push_back(INACTIVE); + faultParts.push_back(RANGE_FILTERED_INACTIVE); } } else if (this->faultCollection()->showFaultsOutsideFilters()) { - faultParts.push_back(RivReservoirViewPartMgr::ACTIVE); - faultParts.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); - faultParts.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); - faultParts.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + faultParts.push_back(ACTIVE); + faultParts.push_back(ALL_WELL_CELLS); + faultParts.push_back(RANGE_FILTERED); + faultParts.push_back(RANGE_FILTERED_WELL_CELLS); + faultParts.push_back(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + faultParts.push_back(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); if (this->showInactiveCells()) { - faultParts.push_back(RivReservoirViewPartMgr::INACTIVE); - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + faultParts.push_back(INACTIVE); + faultParts.push_back(RANGE_FILTERED_INACTIVE); } } else if (this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); - faultParts.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); - faultParts.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + faultParts.push_back(RANGE_FILTERED); + faultParts.push_back(RANGE_FILTERED_WELL_CELLS); + faultParts.push_back(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + faultParts.push_back(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); if (this->showInactiveCells()) { - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + faultParts.push_back(RANGE_FILTERED_INACTIVE); } } else if (!this->rangeFilterCollection()->hasActiveFilters() && this->wellCollection()->hasVisibleWellCells()) { - faultParts.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); - faultParts.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS); + faultParts.push_back(VISIBLE_WELL_CELLS); + faultParts.push_back(VISIBLE_WELL_FENCE_CELLS); } else if (this->rangeFilterCollection()->hasActiveFilters() && !this->wellCollection()->hasVisibleWellCells()) { - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED); - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS); + faultParts.push_back(RANGE_FILTERED); + faultParts.push_back(RANGE_FILTERED_WELL_CELLS); if (this->showInactiveCells()) { - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + faultParts.push_back(RANGE_FILTERED_INACTIVE); } } else { - faultParts.push_back(RivReservoirViewPartMgr::ACTIVE); - faultParts.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); + faultParts.push_back(ACTIVE); + faultParts.push_back(ALL_WELL_CELLS); if (this->showInactiveCells()) { - faultParts.push_back(RivReservoirViewPartMgr::INACTIVE); - faultParts.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + faultParts.push_back(INACTIVE); + faultParts.push_back(RANGE_FILTERED_INACTIVE); } } @@ -1785,22 +1366,22 @@ std::vector RimReservoirVie //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::updateFaultColors() +void RimEclipseView::updateFaultColors() { // Update all fault geometry - std::vector faultGeometriesToRecolor = visibleFaultGeometryTypes(); + std::vector faultGeometriesToRecolor = visibleFaultGeometryTypes(); - RimResultSlot* faultResultSlot = currentFaultResultSlot(); + RimEclipseCellColors* faultResultColors = currentFaultResultColors(); for (size_t i = 0; i < faultGeometriesToRecolor.size(); ++i) { - if (this->animationMode() && this->cellEdgeResult()->hasResult()) + if (this->hasUserRequestedAnimation() && this->cellEdgeResult()->hasResult()) { - m_reservoirGridPartManager->updateFaultCellEdgeResultColor(faultGeometriesToRecolor[i], m_currentTimeStep, faultResultSlot, this->cellEdgeResult()); + m_reservoirGridPartManager->updateFaultCellEdgeResultColor(faultGeometriesToRecolor[i], m_currentTimeStep, faultResultColors, this->cellEdgeResult()); } else { - m_reservoirGridPartManager->updateFaultColors(faultGeometriesToRecolor[i], m_currentTimeStep, faultResultSlot); + m_reservoirGridPartManager->updateFaultColors(faultGeometriesToRecolor[i], m_currentTimeStep, faultResultColors); } } } @@ -1809,7 +1390,7 @@ void RimReservoirView::updateFaultColors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimReservoirView::isTimeStepDependentDataVisible() const +bool RimEclipseView::isTimeStepDependentDataVisible() const { if (this->cellResult()->hasDynamicResult()) return true; @@ -1833,15 +1414,85 @@ bool RimReservoirView::isTimeStepDependentDataVisible() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultSlot* RimReservoirView::currentFaultResultSlot() +RimEclipseCellColors* RimEclipseView::currentFaultResultColors() { - RimResultSlot* faultResultSlot = this->cellResult(); + RimEclipseCellColors* faultResultColors = this->cellResult(); if (this->faultResultSettings()->showCustomFaultResult()) { - faultResultSlot = this->faultResultSettings()->customFaultResult(); + faultResultColors = this->faultResultSettings()->customFaultResult(); } - return faultResultSlot; + return faultResultColors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::resetLegendsInViewer() +{ + this->cellResult()->legendConfig->recreateLegend(); + this->cellResult()->ternaryLegendConfig->recreateLegend(); + this->cellEdgeResult()->legendConfig->recreateLegend(); + + m_viewer->removeAllColorLegends(); + m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Transform* RimEclipseView::scaleTransform() +{ + return m_reservoirGridPartManager->scaleTransform(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* RimEclipseView::ownerCase() +{ + return eclipseCase(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::addWellPathsToScene(cvf::Scene* scene, + const cvf::Vec3d& displayModelOffset, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + cvf::Transform* scaleTransform) +{ + CVF_ASSERT(scene); + CVF_ASSERT(scaleTransform); + + cvf::String wellPathModelName = "WellPathModel"; + std::vector wellPathModels; + for (cvf::uint i = 0; i < scene->modelCount(); i++) + { + if (scene->model(i)->name() == wellPathModelName) + { + wellPathModels.push_back(scene->model(i)); + } + } + + for (size_t i = 0; i < wellPathModels.size(); i++) + { + scene->removeModel(wellPathModels[i]); + } + + // Append static Well Paths to model + cvf::ref wellPathModelBasicList = new cvf::ModelBasicList; + wellPathModelBasicList->setName(wellPathModelName); + + addWellPathsToModel(wellPathModelBasicList.p(), + displayModelOffset, + characteristicCellSize, + wellPathClipBoundingBox, + scaleTransform); + + scene->addModel(wellPathModelBasicList.p()); +} diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h new file mode 100644 index 0000000000..ec6c17bf1d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -0,0 +1,171 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011- Statoil ASA +// Copyright (C) 2013- Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS +// +// 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 "cafAppEnum.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "cvfArray.h" +#include "cvfBase.h" +#include "cvfObject.h" + +// Includes to make Pdm work for cvf::Color and cvf:Mat +#include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" + +#include "RivReservoirViewPartMgr.h" +#include "RimView.h" + +class RigActiveCellInfo; +class RigCaseCellResultsData; +class RigGridBase; +class RigGridCellFaceVisibilityFilter; +class Rim3dOverlayInfoConfig; +class RimEclipseCase; +class RimCellEdgeColors; +class RimEclipsePropertyFilter; +class RimEclipsePropertyFilterCollection; +class RimCellRangeFilter; +class RimCellRangeFilterCollection; +class RimFaultCollection; +class RimEclipseFaultColors; +class RimReservoirCellResultsStorage; +class RimReservoirCellResultsStorage; +class RimEclipseCellColors; +class RimEclipseWellCollection; +class RiuViewer; +class RivReservoirPipesPartMgr; + +namespace cvf +{ + class Transform; + class ScalarMapperUniformLevels; + class ModelBasicList; + class OverlayItem; +} + +enum PartRenderMaskEnum +{ + surfaceBit = 0x00000001, + meshSurfaceBit = 0x00000002, + faultBit = 0x00000004, + meshFaultBit = 0x00000008, +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimEclipseView : public RimView +{ + CAF_PDM_HEADER_INIT; +public: + RimEclipseView(void); + virtual ~RimEclipseView(void); + + // Fields containing child objects : + + caf::PdmField cellResult; + caf::PdmField cellEdgeResult; + caf::PdmField faultResultSettings; + + caf::PdmField propertyFilterCollection; + + caf::PdmField wellCollection; + caf::PdmField faultCollection; + + // Fields + + caf::PdmField showInvalidCells; + caf::PdmField showInactiveCells; + caf::PdmField showMainGrid; + + // Access internal objects + + RimReservoirCellResultsStorage* currentGridCellResults(); + RigActiveCellInfo* currentActiveCellInfo(); + RimEclipseCellColors* currentFaultResultColors(); + + void setEclipseCase(RimEclipseCase* reservoir); + RimEclipseCase* eclipseCase(); + + // Display model generation + + virtual void loadDataAndUpdate(); + bool isTimeStepDependentDataVisible() const; + + virtual void scheduleGeometryRegen(RivCellSetEnum geometryType); + void scheduleReservoirGridGeometryRegen(); + void schedulePipeGeometryRegen(); + void updateDisplayModelForWellResults(); + + const std::vector& visibleGridParts() const { return m_visibleGridParts;} + cvf::cref reservoirGridPartManager() const { return m_reservoirGridPartManager.p(); } + + // Does this belong here, really ? + void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid); + + // Overridden PDM methods: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); +protected: + virtual void initAfterRead(); + virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + +private: + void createDisplayModel(); + void updateDisplayModelVisibility(); + virtual void updateCurrentTimeStep(); + + void indicesToVisibleGrids(std::vector* gridIndices); + virtual void updateScaleTransform(); + virtual cvf::Transform* scaleTransform(); + + virtual void updateStaticCellColors(); + void updateStaticCellColors(RivCellSetEnum geometryType); + void updateLegends(); + void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData); + virtual void resetLegendsInViewer(); + virtual void updateViewerWidgetWindowTitle(); + + std::vector visibleFaultGeometryTypes() const; + void updateFaultForcedVisibility(); + void updateFaultColors(); + + void syncronizeWellsWithResults(); + void addWellPathsToScene(cvf::Scene* scene, + const cvf::Vec3d& displayModelOffset, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + cvf::Transform* scaleTransform); + + void clampCurrentTimestep(); + + virtual RimCase* ownerCase(); + + caf::PdmPointer m_reservoir; + + cvf::ref m_reservoirGridPartManager; + cvf::ref m_pipesPartManager; + + std::vector m_visibleGridParts; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp similarity index 87% rename from ApplicationCode/ProjectDataModel/RimWell.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index cd85659e14..b16ef133f0 100644 --- a/ApplicationCode/ProjectDataModel/RimWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -18,20 +18,20 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimWell.h" +#include "RimEclipseWell.h" #include "RigSingleWellResultsData.h" -#include "RimReservoirView.h" -#include "RimWellCollection.h" +#include "RimEclipseView.h" +#include "RimEclipseWellCollection.h" #include "cvfMath.h" -CAF_PDM_SOURCE_INIT(RimWell, "Well"); +CAF_PDM_SOURCE_INIT(RimEclipseWell, "Well"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWell::RimWell() +RimEclipseWell::RimEclipseWell() { CAF_PDM_InitObject("Well", ":/Well.png", "", ""); @@ -59,14 +59,14 @@ RimWell::RimWell() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWell::~RimWell() +RimEclipseWell::~RimEclipseWell() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimWell::userDescriptionField() +caf::PdmFieldHandle* RimEclipseWell::userDescriptionField() { return &name; } @@ -74,7 +74,7 @@ caf::PdmFieldHandle* RimWell::userDescriptionField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWell::setReservoirView(RimReservoirView* ownerReservoirView) +void RimEclipseWell::setReservoirView(RimEclipseView* ownerReservoirView) { m_reservoirView = ownerReservoirView; } @@ -82,7 +82,7 @@ void RimWell::setReservoirView(RimReservoirView* ownerReservoirView) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipseWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (&showWellLabel == changedField) { @@ -95,7 +95,7 @@ void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV { if (m_reservoirView) { - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } @@ -103,7 +103,7 @@ void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV { if (m_reservoirView) { - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } @@ -112,7 +112,7 @@ void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV { if (m_reservoirView) { - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } @@ -138,7 +138,7 @@ void RimWell::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimWell::objectToggleField() +caf::PdmFieldHandle* RimEclipseWell::objectToggleField() { return &showWell; } @@ -146,7 +146,7 @@ caf::PdmFieldHandle* RimWell::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWell::calculateWellPipeVisibility(size_t frameIndex) +bool RimEclipseWell::calculateWellPipeVisibility(size_t frameIndex) { if (m_reservoirView == NULL) return false; if (this->wellResults() == NULL) return false; @@ -165,10 +165,10 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex) if (!m_reservoirView->wellCollection()->isActive()) return false; - if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_ON) + if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_FORCE_ALL_ON) return true; - if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF) + if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_FORCE_ALL_OFF) return false; if ( this->showWell() == false ) @@ -177,12 +177,12 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex) if ( this->showWellPipes() == false ) return false; - if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_INDIVIDUALLY) + if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_INDIVIDUALLY) return true; - if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS) + if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS) { - const std::vector& visGridParts = m_reservoirView->visibleGridParts(); + const std::vector& visGridParts = m_reservoirView->visibleGridParts(); cvf::cref rvMan = m_reservoirView->reservoirGridPartManager(); for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx) @@ -237,7 +237,7 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEclipseWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* pipeGroup = uiOrdering.addNewGroup("Appearance"); pipeGroup->add(&showWellPipes); @@ -253,7 +253,7 @@ void RimWell::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrder //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWell::isWellPipeVisible(size_t frameIndex) +bool RimEclipseWell::isWellPipeVisible(size_t frameIndex) { CVF_ASSERT(m_wellIndex != cvf::UNDEFINED_SIZE_T); diff --git a/ApplicationCode/ProjectDataModel/RimWell.h b/ApplicationCode/ProjectDataModel/RimEclipseWell.h similarity index 91% rename from ApplicationCode/ProjectDataModel/RimWell.h rename to ApplicationCode/ProjectDataModel/RimEclipseWell.h index fae8c997c7..fc8ec77433 100644 --- a/ApplicationCode/ProjectDataModel/RimWell.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.h @@ -31,21 +31,21 @@ #include "cafPdmFieldCvfColor.h" class RigSingleWellResultsData; -class RimReservoirView; +class RimEclipseView; //================================================================================================== /// /// //================================================================================================== -class RimWell : public caf::PdmObject +class RimEclipseWell : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimWell(); - virtual ~RimWell(); + RimEclipseWell(); + virtual ~RimEclipseWell(); - void setReservoirView(RimReservoirView* ownerReservoirView); + void setReservoirView(RimEclipseView* ownerReservoirView); void setWellIndex(size_t val) { m_wellIndex = val; } void setWellResults(RigSingleWellResultsData* wellResults) { m_wellResults = wellResults;} @@ -77,5 +77,5 @@ class RimWell : public caf::PdmObject cvf::ref m_wellResults; size_t m_wellIndex; - RimReservoirView* m_reservoirView; + RimEclipseView* m_reservoirView; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp similarity index 78% rename from ApplicationCode/ProjectDataModel/RimWellCollection.cpp rename to ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index 2888f6d3ea..297ef704fc 100644 --- a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -18,25 +18,25 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "RiaApplication.h" #include "RiaPreferences.h" #include "RigSingleWellResultsData.h" -#include "RimReservoirView.h" -#include "RimWell.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" #include "RivReservoirViewPartMgr.h" namespace caf { template<> - void RimWellCollection::WellVisibilityEnum::setUp() + void RimEclipseWellCollection::WellVisibilityEnum::setUp() { - addItem(RimWellCollection::PIPES_FORCE_ALL_OFF, "FORCE_ALL_OFF", "All Off"); - addItem(RimWellCollection::PIPES_INDIVIDUALLY, "ALL_ON", "Individual"); - addItem(RimWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS,"OPEN_IN_VISIBLE_CELLS", "Visible cells filtered"); - addItem(RimWellCollection::PIPES_FORCE_ALL_ON, "FORCE_ALL_ON", "All On"); + addItem(RimEclipseWellCollection::PIPES_FORCE_ALL_OFF, "FORCE_ALL_OFF", "All Off"); + addItem(RimEclipseWellCollection::PIPES_INDIVIDUALLY, "ALL_ON", "Individual"); + addItem(RimEclipseWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS,"OPEN_IN_VISIBLE_CELLS", "Visible cells filtered"); + addItem(RimEclipseWellCollection::PIPES_FORCE_ALL_ON, "FORCE_ALL_ON", "All On"); } } @@ -44,43 +44,43 @@ namespace caf namespace caf { template<> - void RimWellCollection::WellCellsRangeFilterEnum::setUp() + void RimEclipseWellCollection::WellCellsRangeFilterEnum::setUp() { - addItem(RimWellCollection::RANGE_ADD_NONE, "FORCE_ALL_OFF", "All Off"); - addItem(RimWellCollection::RANGE_ADD_INDIVIDUAL, "ALL_ON", "Individually"); - addItem(RimWellCollection::RANGE_ADD_ALL, "FORCE_ALL_ON", "All On"); + addItem(RimEclipseWellCollection::RANGE_ADD_NONE, "FORCE_ALL_OFF", "All Off"); + addItem(RimEclipseWellCollection::RANGE_ADD_INDIVIDUAL, "ALL_ON", "Individually"); + addItem(RimEclipseWellCollection::RANGE_ADD_ALL, "FORCE_ALL_ON", "All On"); } } namespace caf { template<> - void RimWellCollection::WellFenceEnum::setUp() + void RimEclipseWellCollection::WellFenceEnum::setUp() { - addItem(RimWellCollection::K_DIRECTION, "K_DIRECTION", "K - Direction"); - addItem(RimWellCollection::J_DIRECTION, "J_DIRECTION", "J - Direction"); - addItem(RimWellCollection::I_DIRECTION, "I_DIRECTION", "I - Direction"); - setDefault(RimWellCollection::K_DIRECTION); + addItem(RimEclipseWellCollection::K_DIRECTION, "K_DIRECTION", "K - Direction"); + addItem(RimEclipseWellCollection::J_DIRECTION, "J_DIRECTION", "J - Direction"); + addItem(RimEclipseWellCollection::I_DIRECTION, "I_DIRECTION", "I - Direction"); + setDefault(RimEclipseWellCollection::K_DIRECTION); } } namespace caf { template<> - void RimWellCollection::WellHeadPositionEnum::setUp() + void RimEclipseWellCollection::WellHeadPositionEnum::setUp() { - addItem(RimWellCollection::WELLHEAD_POS_ACTIVE_CELLS_BB, "WELLHEAD_POS_ACTIVE_CELLS_BB", "Top of active cells BB"); - addItem(RimWellCollection::WELLHEAD_POS_TOP_COLUMN, "WELLHEAD_POS_TOP_COLUMN", "Top of active cells IJ-column"); - setDefault(RimWellCollection::WELLHEAD_POS_TOP_COLUMN); + addItem(RimEclipseWellCollection::WELLHEAD_POS_ACTIVE_CELLS_BB, "WELLHEAD_POS_ACTIVE_CELLS_BB", "Top of active cells BB"); + addItem(RimEclipseWellCollection::WELLHEAD_POS_TOP_COLUMN, "WELLHEAD_POS_TOP_COLUMN", "Top of active cells IJ-column"); + setDefault(RimEclipseWellCollection::WELLHEAD_POS_TOP_COLUMN); } } -CAF_PDM_SOURCE_INIT(RimWellCollection, "Wells"); +CAF_PDM_SOURCE_INIT(RimEclipseWellCollection, "Wells"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellCollection::RimWellCollection() +RimEclipseWellCollection::RimEclipseWellCollection() { CAF_PDM_InitObject("Wells", ":/WellCollection.png", "", ""); @@ -116,7 +116,7 @@ RimWellCollection::RimWellCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellCollection::~RimWellCollection() +RimEclipseWellCollection::~RimEclipseWellCollection() { wells.deleteAllChildObjects(); } @@ -124,7 +124,7 @@ RimWellCollection::~RimWellCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWell* RimWellCollection::findWell(QString name) +RimEclipseWell* RimEclipseWellCollection::findWell(QString name) { for (size_t i = 0; i < this->wells().size(); ++i) { @@ -139,7 +139,7 @@ RimWell* RimWellCollection::findWell(QString name) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellCollection::hasVisibleWellCells() +bool RimEclipseWellCollection::hasVisibleWellCells() { if (!this->isActive()) return false; if (this->wellCellsToRangeFilterMode() == RANGE_ADD_NONE) return false; @@ -148,7 +148,7 @@ bool RimWellCollection::hasVisibleWellCells() bool hasCells = false; for (size_t i = 0 ; !hasCells && i < this->wells().size(); ++i) { - RimWell* well = this->wells()[i]; + RimEclipseWell* well = this->wells()[i]; if ( well && well->wellResults() && ((well->showWell() && well->showWellCells()) || this->wellCellsToRangeFilterMode() == RANGE_ADD_ALL) ) { for (size_t tIdx = 0; !hasCells && tIdx < well->wellResults()->m_wellCellsTimeSteps.size(); ++tIdx ) @@ -174,7 +174,7 @@ bool RimWellCollection::hasVisibleWellCells() //-------------------------------------------------------------------------------------------------- /// Used to know if we need animation of timesteps due to the wells //-------------------------------------------------------------------------------------------------- -bool RimWellCollection::hasVisibleWellPipes() +bool RimEclipseWellCollection::hasVisibleWellPipes() { if (!this->isActive()) return false; if (this->wellPipeVisibility() == PIPES_FORCE_ALL_OFF) return false; @@ -188,7 +188,7 @@ bool RimWellCollection::hasVisibleWellPipes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (&showWellLabel == changedField || &isActive == changedField) { @@ -196,7 +196,7 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField if (m_reservoirView) { - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } @@ -204,7 +204,7 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (m_reservoirView) { - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } @@ -212,7 +212,7 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (m_reservoirView) { - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } @@ -227,7 +227,7 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (m_reservoirView) { - m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS); + m_reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } @@ -257,7 +257,7 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellCollection::setReservoirView(RimReservoirView* ownerReservoirView) +void RimEclipseWellCollection::setReservoirView(RimEclipseView* ownerReservoirView) { m_reservoirView = ownerReservoirView; } @@ -265,7 +265,7 @@ void RimWellCollection::setReservoirView(RimReservoirView* ownerReservoirView) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* filterGroup = uiOrdering.addNewGroup("Well range filter"); filterGroup->add(&wellCellsToRangeFilterMode); @@ -291,7 +291,7 @@ void RimWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimWellCollection::objectToggleField() +caf::PdmFieldHandle* RimEclipseWellCollection::objectToggleField() { return &isActive; } @@ -300,7 +300,7 @@ caf::PdmFieldHandle* RimWellCollection::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RimWellCollection::isWellPipesVisible(size_t frameIndex) +const std::vector& RimEclipseWellCollection::isWellPipesVisible(size_t frameIndex) { calculateIsWellPipesVisible(frameIndex); return m_isWellPipesVisible[frameIndex]; @@ -309,7 +309,7 @@ const std::vector& RimWellCollection::isWellPipesVisible(size_t fram //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellCollection::scheduleIsWellPipesVisibleRecalculation() +void RimEclipseWellCollection::scheduleIsWellPipesVisibleRecalculation() { m_isWellPipesVisible.clear(); } @@ -317,7 +317,7 @@ void RimWellCollection::scheduleIsWellPipesVisibleRecalculation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellCollection::calculateIsWellPipesVisible(size_t frameIndex) +void RimEclipseWellCollection::calculateIsWellPipesVisible(size_t frameIndex) { if (m_isWellPipesVisible.size() > frameIndex && m_isWellPipesVisible[frameIndex].size()) return; diff --git a/ApplicationCode/ProjectDataModel/RimWellCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h similarity index 81% rename from ApplicationCode/ProjectDataModel/RimWellCollection.h rename to ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h index 0bf9e7ad6e..a9e8a1e29e 100644 --- a/ApplicationCode/ProjectDataModel/RimWellCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.h @@ -30,22 +30,22 @@ #include -class RimReservoirView; -class RimWell; +class RimEclipseView; +class RimEclipseWell; //================================================================================================== /// /// //================================================================================================== -class RimWellCollection : public caf::PdmObject +class RimEclipseWellCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimWellCollection(); - virtual ~RimWellCollection(); + RimEclipseWellCollection(); + virtual ~RimEclipseWellCollection(); - void setReservoirView(RimReservoirView* ownerReservoirView); + void setReservoirView(RimEclipseView* ownerReservoirView); enum WellVisibilityType { @@ -54,7 +54,7 @@ class RimWellCollection : public caf::PdmObject PIPES_OPEN_IN_VISIBLE_CELLS, PIPES_FORCE_ALL_ON }; - typedef caf::AppEnum WellVisibilityEnum; + typedef caf::AppEnum WellVisibilityEnum; enum WellCellsRangeFilterType { @@ -62,7 +62,7 @@ class RimWellCollection : public caf::PdmObject RANGE_ADD_INDIVIDUAL, RANGE_ADD_NONE }; - typedef caf::AppEnum WellCellsRangeFilterEnum; + typedef caf::AppEnum WellCellsRangeFilterEnum; enum WellFenceType { @@ -70,14 +70,14 @@ class RimWellCollection : public caf::PdmObject J_DIRECTION, I_DIRECTION }; - typedef caf::AppEnum WellFenceEnum; + typedef caf::AppEnum WellFenceEnum; enum WellHeadPositionType { WELLHEAD_POS_ACTIVE_CELLS_BB, WELLHEAD_POS_TOP_COLUMN }; - typedef caf::AppEnum WellHeadPositionEnum; + typedef caf::AppEnum WellHeadPositionEnum; caf::PdmField showWellLabel; @@ -101,9 +101,9 @@ class RimWellCollection : public caf::PdmObject caf::PdmField isAutoDetectingBranches; - caf::PdmPointersField wells; + caf::PdmPointersField wells; - RimWell* findWell(QString name); + RimEclipseWell* findWell(QString name); bool hasVisibleWellCells(); bool hasVisibleWellPipes(); @@ -117,7 +117,7 @@ class RimWellCollection : public caf::PdmObject void calculateIsWellPipesVisible(size_t frameIndex); - RimReservoirView* m_reservoirView; + RimEclipseView* m_reservoirView; std::vector< std::vector< cvf::ubyte > > m_isWellPipesVisible; }; diff --git a/ApplicationCode/ProjectDataModel/RimFault.cpp b/ApplicationCode/ProjectDataModel/RimFault.cpp index ab499fea80..63f01fc646 100644 --- a/ApplicationCode/ProjectDataModel/RimFault.cpp +++ b/ApplicationCode/ProjectDataModel/RimFault.cpp @@ -21,7 +21,7 @@ #include "RigFault.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" CAF_PDM_SOURCE_INIT(RimFault, "Fault"); @@ -68,7 +68,7 @@ void RimFault::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const Q if (&faultColor == changedField || &showFault == changedField) { - RimReservoirView* reservoirView = NULL; + RimEclipseView* reservoirView = NULL; this->firstAncestorOfType(reservoirView); if (reservoirView) diff --git a/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp index e16532c68e..cdaeecc9a7 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp @@ -22,10 +22,10 @@ #include "RiaApplication.h" #include "RiaPreferences.h" #include "RigCaseData.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimNoCommonAreaNNC.h" #include "RimNoCommonAreaNncCollection.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RiuMainWindow.h" #include "RivColorTableArray.h" @@ -132,7 +132,7 @@ void RimFaultCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFaultCollection::setReservoirView(RimReservoirView* ownerReservoirView) +void RimFaultCollection::setReservoirView(RimEclipseView* ownerReservoirView) { m_reservoirView = ownerReservoirView; } diff --git a/ApplicationCode/ProjectDataModel/RimFaultCollection.h b/ApplicationCode/ProjectDataModel/RimFaultCollection.h index 54c93b908b..843882ba66 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultCollection.h +++ b/ApplicationCode/ProjectDataModel/RimFaultCollection.h @@ -33,7 +33,7 @@ #include class RimFault; -class RimReservoirView; +class RimEclipseView; class RimNoCommonAreaNncCollection; //================================================================================================== @@ -55,7 +55,7 @@ class RimFaultCollection : public caf::PdmObject RimFaultCollection(); virtual ~RimFaultCollection(); - void setReservoirView(RimReservoirView* ownerReservoirView); + void setReservoirView(RimEclipseView* ownerReservoirView); void syncronizeFaults(); void addMockData(); @@ -91,6 +91,6 @@ class RimFaultCollection : public caf::PdmObject private: caf::PdmField m_showFaultsOutsideFilters; - RimReservoirView* m_reservoirView; + RimEclipseView* m_reservoirView; }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp new file mode 100644 index 0000000000..d8cf7a4680 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechCase.h" +#include "RimGeoMechView.h" +#include "RiaApplication.h" +#include "RiaPreferences.h" +#include "RifOdbReader.h" +#include "RigGeoMechCaseData.h" +#include + +CAF_PDM_SOURCE_INIT(RimGeoMechCase, "ResInsightGeoMechCase"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCase::RimGeoMechCase(void) +{ + CAF_PDM_InitObject("Geomechanical Case", ":/GeoMechCase48x48.png", "", ""); + + CAF_PDM_InitField(&m_caseFileName, "CaseFileName", QString(), "Case file name", "", "", ""); + m_caseFileName.setUiReadOnly(true); + CAF_PDM_InitFieldNoDefault(&geoMechViews, "GeoMechViews", "", "", "", ""); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCase::~RimGeoMechCase(void) +{ + geoMechViews.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechView* RimGeoMechCase::createAndAddReservoirView() +{ + RimGeoMechView* gmv = new RimGeoMechView(); + size_t i = geoMechViews().size(); + gmv->name = QString("View %1").arg(i + 1); + + gmv->setGeoMechCase(this); + + geoMechViews.push_back(gmv); + return gmv; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage) +{ + // If read already, return + + if (this->m_geoMechCaseData.notNull()) return true; + + + if (!QFile::exists(m_caseFileName())) + { + return false; + } + + m_geoMechCaseData = new RigGeoMechCaseData(m_caseFileName().toStdString()); + + return m_geoMechCaseData->openAndReadFemParts(errorMessage); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) +{ + bool foundFile = false; + std::vector searchedPaths; + + // Update filename and folder paths when opening project from a different file location + m_caseFileName = relocateFile(m_caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); + +#if 0 // Output the search path for debugging + for (size_t i = 0; i < searchedPaths.size(); ++i) + qDebug() << searchedPaths[i]; +#endif + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimGeoMechCase::views() +{ + std::vector views; + for (size_t vIdx = 0; vIdx < geoMechViews.size(); ++vIdx) + { + views.push_back(geoMechViews[vIdx]); + } + return views; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::initAfterRead() +{ + size_t j; + for (j = 0; j < geoMechViews().size(); j++) + { + RimGeoMechView* riv = geoMechViews()[j]; + CVF_ASSERT(riv); + + riv->setGeoMechCase(this); + } + +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h new file mode 100644 index 0000000000..0f6a39bfed --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimCase.h" + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPointer.h" +#include "cvfObject.h" + +class RimGeoMechView; +class RigGeoMechCaseData; +class RifGeoMechReaderInterface; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechCase : public RimCase +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechCase(void); + virtual ~RimGeoMechCase(void); + + void setFileName(const QString& fileName) {m_caseFileName = fileName;} + QString caseFileName() const {return m_caseFileName();} + bool openGeoMechCase(std::string* errorMessage); + + RigGeoMechCaseData* geoMechData() { return m_geoMechCaseData.p(); } + const RigGeoMechCaseData* geoMechData() const { return m_geoMechCaseData.p(); } + + RimGeoMechView* createAndAddReservoirView(); + + virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath); + virtual std::vector views(); + + // Fields: + caf::PdmPointersField geoMechViews; + +private: + virtual void initAfterRead(); +private: + cvf::ref m_geoMechCaseData; + caf::PdmField m_caseFileName; +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp new file mode 100644 index 0000000000..f4c3fba9f6 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechCellColors.h" +#include "RimLegendConfig.h" +#include "RimView.h" + + +CAF_PDM_SOURCE_INIT(RimGeoMechCellColors, "GeoMechResultSlot"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCellColors::RimGeoMechCellColors(void) +{ + CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + this->legendConfig = new RimLegendConfig(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCellColors::~RimGeoMechCellColors(void) +{ +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h new file mode 100644 index 0000000000..99d57fa6de --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechResultDefinition.h" +#include "cafPdmField.h" + +class RimLegendConfig; + + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechCellColors : public RimGeoMechResultDefinition +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechCellColors(void); + virtual ~RimGeoMechCellColors(void); + + caf::PdmField legendConfig; +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechModels.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechModels.cpp new file mode 100644 index 0000000000..a24570d0f3 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechModels.cpp @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechModels.h" + +#include "RimGeoMechCase.h" + + +CAF_PDM_SOURCE_INIT(RimGeoMechModels, "ResInsightGeoMechModels"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechModels::RimGeoMechModels(void) +{ + CAF_PDM_InitObject("Geomechanical Models", ":/GeoMechCases48x48.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&cases, "Cases", "", "", "", ""); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechModels::~RimGeoMechModels(void) +{ + cases.deleteAllChildObjects(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechModels.h b/ApplicationCode/ProjectDataModel/RimGeoMechModels.h new file mode 100644 index 0000000000..aa81ca5b0c --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechModels.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPointer.h" + +class RimGeoMechCase; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechModels : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechModels(void); + virtual ~RimGeoMechModels(void); + + caf::PdmPointersField cases; + +private: +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp new file mode 100644 index 0000000000..f0f63c4655 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp @@ -0,0 +1,206 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechResultDefinition.h" + +#include "cvfMath.h" + +#include "cafPdmUiDoubleSliderEditor.h" +#include "cvfAssert.h" +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" +#include "RimGeoMechView.h" +#include "RiuMainWindow.h" + + +CAF_PDM_SOURCE_INIT(RimGeoMechPropertyFilter, "GeoMechPropertyFilter"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() + : m_parentContainer(NULL) +{ + CAF_PDM_InitObject("GeoMech Property Filter", ":/CellFilter_Values.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&resultDefinition, "ResultDefinition", "Result definition", "", "", ""); + resultDefinition = new RimGeoMechResultDefinition(); + resultDefinition->setOwnerPropertyFilter(this); + + // Set to hidden to avoid this item to been displayed as a child item + // Fields in this object are displayed using defineUiOrdering() + resultDefinition.setUiHidden(true); + + CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", ""); + lowerBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", ""); + upperBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + + updateIconState(); + + m_minimumResultValue = cvf::UNDEFINED_DOUBLE; + m_maximumResultValue = cvf::UNDEFINED_DOUBLE; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter::~RimGeoMechPropertyFilter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if ( &lowerBound == changedField + || &upperBound == changedField + || &isActive == changedField + || &filterMode == changedField) + { + this->updateIconState(); + this->updateFilterName(); + ((RimView*)resultDefinition->reservoirView())->scheduleGeometryRegen(PROPERTY_FILTERED); + resultDefinition->reservoirView()->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::setParentContainer(RimGeoMechPropertyFilterCollection* parentContainer) +{ + m_parentContainer = parentContainer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilterCollection* RimGeoMechPropertyFilter::parentContainer() +{ + return m_parentContainer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::setToDefaultValues() +{ + CVF_ASSERT(m_parentContainer); + + computeResultValueRange(); + + lowerBound = m_minimumResultValue; + upperBound = m_maximumResultValue; + this->updateFilterName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&name); + + caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result"); + group1->add(&(resultDefinition->m_resultPositionTypeUiField)); + group1->add(&(resultDefinition->m_resultVariableUiField)); + + uiOrdering.add(&isActive); + uiOrdering.add(&filterMode); + + uiOrdering.add(&lowerBound); + uiOrdering.add(&upperBound); + uiOrdering.add(&filterMode); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE) + { + return; + } + + if (field == &lowerBound || field == &upperBound) + { + caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); + if (!myAttr) + { + return; + } + + myAttr->m_minimum = m_minimumResultValue; + myAttr->m_maximum = m_maximumResultValue; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::computeResultValueRange() +{ + CVF_ASSERT(m_parentContainer); + + double min = 0.0; + double max = 0.0; + + RigFemResultAddress resultAddress = resultDefinition->resultAddress(); + if (resultAddress.isValid() && resultDefinition->ownerCaseData()) + { + resultDefinition->ownerCaseData()->femPartResults()->minMaxScalarValues(resultAddress, &min, &max); + } + + m_maximumResultValue = max; + m_minimumResultValue = min; + + lowerBound.setUiName(QString("Min (%1)").arg(min)); + upperBound.setUiName(QString("Max (%1)").arg(max)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::updateFilterName() +{ + RigFemResultAddress resultAddress = resultDefinition->resultAddress(); + QString newFiltername; + QString posName; + + switch (resultAddress.resultPosType) + { + case RIG_NODAL: posName = "N"; break; + case RIG_ELEMENT_NODAL: posName = "EN"; break; + case RIG_INTEGRATION_POINT: posName = "IP"; break; + } + + newFiltername = posName + ", " + QString::fromStdString(resultAddress.fieldName + ", " + resultAddress.componentName) + " (" + + QString::number(lowerBound()) + " .. " + QString::number(upperBound) + ")"; + this->name = newFiltername; + + RiuMainWindow::instance()->forceProjectTreeRepaint(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h new file mode 100644 index 0000000000..fe55e097ce --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimCellFilter.h" + + +class RimGeoMechResultDefinition; +class RimGeoMechPropertyFilterCollection; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechPropertyFilter : public RimCellFilter +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechPropertyFilter(); + virtual ~RimGeoMechPropertyFilter(); + + caf::PdmField resultDefinition; + + caf::PdmField lowerBound; + caf::PdmField upperBound; + + void setParentContainer(RimGeoMechPropertyFilterCollection* parentContainer); + RimGeoMechPropertyFilterCollection* parentContainer(); + void setToDefaultValues(); + void updateFilterName(); + void computeResultValueRange(); + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); +protected: + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) ; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + +private: + RimGeoMechPropertyFilterCollection* m_parentContainer; + double m_minimumResultValue; + double m_maximumResultValue; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp new file mode 100644 index 0000000000..23ef62f21b --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp @@ -0,0 +1,177 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCellColors.h" + +#include "cvfAssert.h" + + +CAF_PDM_SOURCE_INIT(RimGeoMechPropertyFilterCollection, "GeoMechPropertyFilters"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilterCollection::RimGeoMechPropertyFilterCollection() +{ + CAF_PDM_InitObject("GeoMech Property Filters", ":/CellFilter_Values.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&propertyFilters, "PropertyFilters", "Property Filters", "", "", ""); + CAF_PDM_InitField(&active, "Active", true, "Active", "", "", ""); + active.setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::setReservoirView(RimGeoMechView* reservoirView) +{ + m_reservoirView = reservoirView; + + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); + + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechView* RimGeoMechPropertyFilterCollection::reservoirView() +{ + CVF_ASSERT(!m_reservoirView.isNull()); + return m_reservoirView; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + this->updateUiIconFromToggleField(); + + ((RimView*)m_reservoirView)->scheduleGeometryRegen(PROPERTY_FILTERED); + m_reservoirView->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter* RimGeoMechPropertyFilterCollection::createAndAppendPropertyFilter() +{ + RimGeoMechPropertyFilter* propertyFilter = new RimGeoMechPropertyFilter(); + + propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); + + propertyFilter->setParentContainer(this); + propertyFilters.push_back(propertyFilter); + + propertyFilter->resultDefinition->setResultAddress(m_reservoirView->cellResult()->resultAddress()); + propertyFilter->resultDefinition->loadResult(); + propertyFilter->setToDefaultValues(); + propertyFilter->updateFilterName(); + + return propertyFilter; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::loadAndInitializePropertyFilters() +{ + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + + propertyFilter->resultDefinition->loadResult(); + propertyFilter->computeResultValueRange(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::initAfterRead() +{ + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + + propertyFilter->setParentContainer(this); + propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); + propertyFilter->updateIconState(); + } + + this->updateUiIconFromToggleField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::remove(RimGeoMechPropertyFilter* propertyFilter) +{ + propertyFilters.removeChildObject(propertyFilter); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechPropertyFilterCollection::hasActiveFilters() const +{ + if (!active) return false; + + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// Returns whether any of the active property filters are based on a dynamic result +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechPropertyFilterCollection::hasActiveDynamicFilters() const +{ + return hasActiveFilters(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimGeoMechPropertyFilterCollection::objectToggleField() +{ + return &active; +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h new file mode 100644 index 0000000000..521dee9570 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cafPdmObject.h" +#include "cafPdmField.h" +#include "cafPdmPointer.h" + +class RimGeoMechPropertyFilter; +class RimGeoMechView; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechPropertyFilterCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimGeoMechPropertyFilterCollection(); + virtual ~RimGeoMechPropertyFilterCollection(); + + void setReservoirView(RimGeoMechView* reservoirView); + RimGeoMechView* reservoirView(); + + + // Fields: + caf::PdmField active; + caf::PdmPointersField propertyFilters; + + // Methods + RimGeoMechPropertyFilter* createAndAppendPropertyFilter(); + void remove(RimGeoMechPropertyFilter* propertyFilter); + + bool hasActiveFilters() const; + bool hasActiveDynamicFilters() const; + + + void loadAndInitializePropertyFilters(); + + + // Overridden methods + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual caf::PdmFieldHandle* objectToggleField(); + +protected: + // Overridden methods + virtual void initAfterRead(); + +private: + caf::PdmPointer m_reservoirView; +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp new file mode 100644 index 0000000000..bb9f76ac52 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -0,0 +1,348 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" +#include "RimDefines.h" +#include "RimGeoMechCase.h" +#include "RifGeoMechReaderInterface.h" +#include "cafPdmUiListEditor.h" +#include "RigGeoMechCaseData.h" +#include "RigFemPartResultsCollection.h" +#include "RiuMainWindow.h" +#include "RimGeoMechPropertyFilter.h" +#include "RigFemResultAddress.h" + +namespace caf { + +template<> +void caf::AppEnum< RigFemResultPosEnum >::setUp() +{ + addItem(RIG_NODAL, "NODAL", "Nodal"); + addItem(RIG_ELEMENT_NODAL, "ELEMENT_NODAL", "Element Nodal"); + addItem(RIG_INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point"); + setDefault(RIG_NODAL); +} +} + + +CAF_PDM_SOURCE_INIT(RimGeoMechResultDefinition, "GeoMechResultDefinition"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) +{ + CAF_PDM_InitObject("Color Result", ":/CellResult.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", ""); + m_resultPositionType.setUiHidden(true); + CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", QString(""), "Field Name", "", "", ""); + m_resultFieldName.setUiHidden(true); + CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", ""); + m_resultComponentName.setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); + m_resultPositionTypeUiField.setIOWritable(false); + m_resultPositionTypeUiField.setIOReadable(false); + + CAF_PDM_InitField(&m_resultVariableUiField, "ResultVariableUI", QString(""), "Value", "", "", ""); + m_resultVariableUiField.setIOWritable(false); + m_resultVariableUiField.setIOReadable(false); + + m_resultVariableUiField.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + m_resultVariableUiField.setUiLabelPosition(caf::PdmUiItemInfo::TOP); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechResultDefinition::~RimGeoMechResultDefinition(void) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimGeoMechResultDefinition::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + *useOptionsOnly = true; + + if (m_reservoirView) + { + + + + if (&m_resultVariableUiField == fieldNeedingOptions) + { + std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); + QStringList uiVarNames; + QStringList varNames; + getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames); + + for (int oIdx = 0; oIdx < uiVarNames.size(); ++oIdx) + { + options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx])); + } + +#if 0 + + for (auto fieldIt = fieldCompNames.begin(); fieldIt != fieldCompNames.end(); ++fieldIt) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldIt->first), QString::fromStdString(fieldIt->first))); + + for (auto compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(" " + *compIt), QString::fromStdString(fieldIt->first + " " + *compIt))); + } + } +#endif + } + } + + return options; +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::setReservoirView(RimGeoMechView* ownerReservoirView) +{ + m_reservoirView = ownerReservoirView; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechView* RimGeoMechResultDefinition::reservoirView() +{ + return m_reservoirView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if(&m_resultPositionTypeUiField == changedField) + { + std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); + QStringList uiVarNames; + QStringList varNames; + getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames); + + if (m_resultPositionTypeUiField() == m_resultPositionType() + && varNames.contains(composeUiVarString(m_resultFieldName(), m_resultComponentName()))) + { + m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); + } + else + { + m_resultVariableUiField = ""; + } + + } + + if (&m_resultVariableUiField == changedField) + { + QStringList fieldComponentNames = m_resultVariableUiField().split(QRegExp("\\s+")); + if (fieldComponentNames.size() > 0) + { + m_resultPositionType = m_resultPositionTypeUiField; + m_resultFieldName = fieldComponentNames[0]; + if (fieldComponentNames.size() > 1) + { + m_resultComponentName = fieldComponentNames[1]; + } + else + { + m_resultComponentName = ""; + } + + if (m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) + { + m_reservoirView->hasUserRequestedAnimation = true; + } + + if (m_propertyFilter) + { + m_propertyFilter->setToDefaultValues(); + + ((RimView*)reservoirView())->scheduleGeometryRegen(PROPERTY_FILTERED); + } + + reservoirView()->scheduleCreateDisplayModelAndRedraw(); + } + } + + if (m_propertyFilter) + { + m_propertyFilter->updateConnectedEditors(); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RimGeoMechResultDefinition::getResultMetaDataForUIFieldSetting() +{ + RimGeoMechCase* gmCase = m_reservoirView->geoMechCase(); + if (gmCase && gmCase->geoMechData()) + { + return gmCase->geoMechData()->femPartResults()->scalarFieldAndComponentNames(m_resultPositionTypeUiField()); + } + else + { + return std::map >() ; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, + const std::map >& fieldCompNames) +{ + CVF_ASSERT(uiNames && variableNames); + + std::map >::const_iterator fieldIt; + for (fieldIt = fieldCompNames.begin(); fieldIt != fieldCompNames.end(); ++fieldIt) + { + QString resultFieldName = QString::fromStdString(fieldIt->first); + + if (resultFieldName == "E" || resultFieldName == "S") continue; // We will not show the native Stress and Strain + + QString resultFieldUiName = convertToUiResultFieldName(resultFieldName); + + uiNames->push_back(resultFieldUiName); + variableNames->push_back(resultFieldName); + + std::vector::const_iterator compIt; + for (compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt) + { + QString resultCompName = QString::fromStdString(*compIt); + uiNames->push_back(" " + resultCompName); + variableNames->push_back(composeUiVarString(resultFieldName, resultCompName)); + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGeoMechResultDefinition::composeUiVarString(const QString& resultFieldName, const QString& resultComponentName) +{ + return resultFieldName + " " + resultComponentName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::initAfterRead() +{ + m_resultPositionTypeUiField = m_resultPositionType; + m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::loadResult() +{ + if (m_reservoirView->geoMechCase()) + { + m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGeoMechCaseData* RimGeoMechResultDefinition::ownerCaseData() +{ + return m_reservoirView->geoMechCase()->geoMechData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechResultDefinition::hasResult() +{ + return ownerCaseData()->femPartResults()->assertResultsLoaded(this->resultAddress()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGeoMechResultDefinition::resultFieldUiName() +{ + return convertToUiResultFieldName(m_resultFieldName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGeoMechResultDefinition::resultComponentUiName() +{ + return m_resultComponentName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGeoMechResultDefinition::convertToUiResultFieldName(QString resultFieldName) +{ + if (resultFieldName == "E") return "NativeAbaqus Strain"; + if (resultFieldName == "S") return "NativeAbaqus Stress"; + if (resultFieldName == "NE") return "E"; // Make NE and NS appear as E and SE + + return resultFieldName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::setOwnerPropertyFilter( RimGeoMechPropertyFilter* propertyFilter ) +{ + m_propertyFilter = propertyFilter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& resultAddress ) +{ + m_resultPositionType = resultAddress.resultPosType; + m_resultFieldName = QString::fromStdString(resultAddress.fieldName); + m_resultComponentName = QString::fromStdString(resultAddress.componentName); + + m_resultPositionTypeUiField = m_resultPositionType; + m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h new file mode 100644 index 0000000000..d1d58674ad --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPointer.h" +#include "cafAppEnum.h" +#include "RigFemResultPosEnum.h" +#include "RigFemResultAddress.h" + +class RimGeoMechView; +class RimGeoMechPropertyFilter; +class RifGeoMechReaderInterface; +class RigGeoMechCaseData; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechResultDefinition : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechResultDefinition(void); + virtual ~RimGeoMechResultDefinition(void); + + void setReservoirView(RimGeoMechView* ownerReservoirView); + RimGeoMechView* reservoirView(); + + RigGeoMechCaseData* ownerCaseData(); + bool hasResult(); + void loadResult(); + + RigFemResultAddress resultAddress() { return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());} + + RigFemResultPosEnum resultPositionType() { return m_resultPositionType();} + QString resultFieldName() { return m_resultFieldName();} + QString resultComponentName() { return m_resultComponentName();} + void setResultAddress(const RigFemResultAddress& resultAddress); + + void setOwnerPropertyFilter(RimGeoMechPropertyFilter* propertyFilter); + + QString resultFieldUiName(); + QString resultComponentUiName(); + +protected: + friend class RimGeoMechPropertyFilter; // Property filter needs the ui fields + +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool * useOptionsOnly); + std::map > getResultMetaDataForUIFieldSetting(); + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + static void getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, + const std::map >& fieldCompNames); + static QString composeUiVarString(const QString& resultFieldName, const QString& resultComponentName); + + virtual void initAfterRead(); + + caf::PdmField > m_resultPositionType; + caf::PdmField m_resultFieldName; + caf::PdmField m_resultComponentName; + + caf::PdmField > m_resultPositionTypeUiField; + caf::PdmField m_resultVariableUiField; + + caf::PdmPointer m_reservoirView; + caf::PdmPointer m_propertyFilter; + + static QString convertToUiResultFieldName(QString resultFieldName); +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp new file mode 100644 index 0000000000..1d19853924 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -0,0 +1,515 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimGeoMechView.h" + +#include "Rim3dOverlayInfoConfig.h" +#include "RiaApplication.h" +#include "RiaPreferences.h" +#include "RimGeoMechCellColors.h" + +#include "RiuMainWindow.h" +#include "cafCeetronPlusNavigation.h" +#include "cafCadNavigation.h" +#include "RimLegendConfig.h" +#include "cvfOverlayScalarMapperLegend.h" + +#include "RimGeoMechCase.h" +#include "cvfPart.h" +#include "cvfViewport.h" +#include "cvfModelBasicList.h" +#include "cvfScene.h" +#include "RimEclipseView.h" +#include "RiuViewer.h" +#include "RivGeoMechPartMgr.h" +#include "RigGeoMechCaseData.h" +#include "cvfqtUtils.h" +#include "RigFemPartCollection.h" +#include "cafFrameAnimationControl.h" +#include +#include "cafProgressInfo.h" +#include "RimCellRangeFilterCollection.h" +#include "RivGeoMechPartMgrCache.h" +#include "RivGeoMechVizLogic.h" +#include "RigFemPartGrid.h" +#include "RigFemPartResultsCollection.h" +#include "RimGeoMechPropertyFilterCollection.h" + + + + +CAF_PDM_SOURCE_INIT(RimGeoMechView, "GeoMechView"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechView::RimGeoMechView(void) +{ + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + CVF_ASSERT(preferences); + + CAF_PDM_InitObject("Geomechanical View", ":/ReservoirView.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", ""); + cellResult = new RimGeoMechCellColors(); + + CAF_PDM_InitFieldNoDefault(&rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); + rangeFilterCollection = new RimCellRangeFilterCollection(); + rangeFilterCollection->setReservoirView(this); + + CAF_PDM_InitFieldNoDefault(&propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", ""); + propertyFilterCollection = new RimGeoMechPropertyFilterCollection(); + propertyFilterCollection->setReservoirView(this); + + this->cellResult()->setReservoirView(this); + this->cellResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 120)); + this->cellResult()->legendConfig()->setReservoirView(this); + + m_scaleTransform = new cvf::Transform(); + m_vizLogic = new RivGeoMechVizLogic(this); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechView::~RimGeoMechView(void) +{ + m_geomechCase = NULL; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateViewerWidgetWindowTitle() +{ + if (m_viewer) + { + QString windowTitle; + if (m_geomechCase.notNull()) + { + windowTitle = QString("%1 - %2").arg(m_geomechCase->caseUserDescription()).arg(name); + } + else + { + windowTitle = name; + } + + m_viewer->layoutWidget()->setWindowTitle(windowTitle); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::loadDataAndUpdate() +{ + caf::ProgressInfo progress(7, ""); + progress.setNextProgressIncrement(5); + updateScaleTransform(); + + if (m_geomechCase) + { + std::string errorMessage; + if (!m_geomechCase->openGeoMechCase(&errorMessage)) + { + QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + m_geomechCase->caseFileName() : QString::fromStdString(errorMessage); + + QMessageBox::warning(RiuMainWindow::instance(), + "File open error", + displayMessage); + m_geomechCase = NULL; + return; + } + } + progress.incrementProgress(); + + progress.setProgressDescription("Reading Current Result"); + + CVF_ASSERT(this->cellResult() != NULL); + if (this->hasUserRequestedAnimation()) + { + m_geomechCase->geoMechData()->femPartResults()->assertResultsLoaded(this->cellResult()->resultAddress()); + } + progress.incrementProgress(); + progress.setProgressDescription("Create Display model"); + + updateViewerWidget(); + this->propertyFilterCollection()->loadAndInitializePropertyFilters(); + + createDisplayModelAndRedraw(); + + if (cameraPosition().isIdentity()) + { + setDefaultView(); + } + + progress.incrementProgress(); +} + +//-------------------------------------------------------------------------------------------------- +/// +/// Todo: Work in progress +/// +//-------------------------------------------------------------------------------------------------- + +void RimGeoMechView::updateScaleTransform() +{ + cvf::Mat4d scale = cvf::Mat4d::IDENTITY; + scale(2, 2) = scaleZ(); + + this->scaleTransform()->setLocalTransform(scale); + + if (m_viewer) m_viewer->updateCachedValuesInScene(); +} + +//-------------------------------------------------------------------------------------------------- +/// Create display model, +/// or at least empty scenes as frames that is delivered to the viewer +/// The real geometry generation is done inside RivReservoirViewGeometry and friends +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::createDisplayModel() +{ + if (m_viewer.isNull()) return; + + if (!(m_geomechCase + && m_geomechCase->geoMechData() + && m_geomechCase->geoMechData()->femParts())) + return; + + int partCount = m_geomechCase->geoMechData()->femParts()->partCount(); + + if (partCount <= 0) return; + + // Remove all existing animation frames from the viewer. + // The parts are still cached in the RivReservoir geometry and friends + + m_viewer->removeAllFrames(); + + if (isTimeStepDependentDataVisible()) + { + // Create empty frames in the viewer + + int frameCount = geoMechCase()->geoMechData()->femPartResults()->frameCount(); + for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) + { + cvf::ref scene = new cvf::Scene; + scene->addModel(new cvf::ModelBasicList); + m_viewer->addFrame(scene.p()); + } + } + + // Set the Main scene in the viewer. Used when the animation is in "Stopped" state + + cvf::ref mainScene = new cvf::Scene; + m_viewer->setMainScene(mainScene.p()); + + // Grid model + cvf::ref mainSceneModel = new cvf::ModelBasicList; + m_vizLogic->appendNoAnimPartsToModel(mainSceneModel.p()); + mainSceneModel->updateBoundingBoxesRecursive(); + mainScene->addModel(mainSceneModel.p()); + + // Well path model + + double characteristicCellSize = geoMechCase()->geoMechData()->femParts()->characteristicElementSize(); + cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox(); + cvf::ref wellPathModel = new cvf::ModelBasicList; + addWellPathsToModel(wellPathModel.p(), + cvf::Vec3d(0, 0, 0), + characteristicCellSize, + femBBox, + scaleTransform()); + mainScene->addModel(wellPathModel.p()); + + + // If the animation was active before recreating everything, make viewer view current frame + + if (isTimeStepDependentDataVisible()) + { + m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep); + } + else + { + updateLegends(); + m_vizLogic->updateStaticCellColors(-1); + overlayInfoConfig()->update3DInfo(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateCurrentTimeStep() +{ + updateLegends(); + + if (this->isTimeStepDependentDataVisible()) + { + if (m_viewer) + { + cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); + if (frameScene) + { + frameScene->removeAllModels(); + + // Grid model + cvf::ref frameParts = new cvf::ModelBasicList; + m_vizLogic->appendPartsToModel(m_currentTimeStep, frameParts.p()); + frameParts->updateBoundingBoxesRecursive(); + frameScene->addModel(frameParts.p()); + + // Well Path model + double characteristicCellSize = geoMechCase()->geoMechData()->femParts()->characteristicElementSize(); + cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox(); + cvf::ref wellPathModel = new cvf::ModelBasicList; + addWellPathsToModel(wellPathModel.p(), + cvf::Vec3d(0, 0, 0), + characteristicCellSize, + femBBox, + scaleTransform()); + frameScene->addModel(wellPathModel.p()); + } + } + + if (this->cellResult()->hasResult()) + m_vizLogic->updateCellResultColor(m_currentTimeStep(), this->cellResult()); + else + m_vizLogic->updateStaticCellColors(m_currentTimeStep()); + + } + else + { + m_vizLogic->updateStaticCellColors(-1); + m_viewer->animationControl()->slotPause(); // To avoid animation timer spinning in the background + } + + overlayInfoConfig()->update3DInfo(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateStaticCellColors() +{ + m_vizLogic->updateStaticCellColors(-1); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateDisplayModelVisibility() +{ + if (m_viewer.isNull()) return; + + const cvf::uint uintSurfaceBit = surfaceBit; + const cvf::uint uintMeshSurfaceBit = meshSurfaceBit; + const cvf::uint uintFaultBit = faultBit; + const cvf::uint uintMeshFaultBit = meshFaultBit; + + // Initialize the mask to show everything except the the bits controlled here + unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ; + + // Then turn the appropriate bits on according to the user settings + + if (surfaceMode == SURFACE) + { + mask |= uintSurfaceBit; + mask |= uintFaultBit; + } + else if (surfaceMode == FAULTS) + { + mask |= uintFaultBit; + } + + if (meshMode == FULL_MESH) + { + mask |= uintMeshSurfaceBit; + mask |= uintMeshFaultBit; + } + else if (meshMode == FAULTS_MESH) + { + mask |= uintMeshFaultBit; + } + + m_viewer->setEnableMask(mask); + m_viewer->update(); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::setGeoMechCase(RimGeoMechCase* gmCase) +{ + m_geomechCase = gmCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::resetLegendsInViewer() +{ + this->cellResult()->legendConfig->recreateLegend(); + + m_viewer->removeAllColorLegends(); + m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateLegends() +{ + if (m_viewer) + { + m_viewer->removeAllColorLegends(); + } + + if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() + || !this->isTimeStepDependentDataVisible() ) + { + return; + } + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + + RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData(); + CVF_ASSERT(gmCase); + + RigFemResultAddress resVarAddress = cellResult()->resultAddress(); + + gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax); + gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero); + + gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax); + gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); + + + cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); + + cellResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString( + caf::AppEnum(cellResult->resultPositionType()).uiText() + "\n" + + cellResult->resultFieldUiName() + ", " + cellResult->resultComponentUiName())); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCase* RimGeoMechView::geoMechCase() +{ + return m_geomechCase; +} + +//-------------------------------------------------------------------------------------------------- +/// Clamp the current timestep to actual possibilities +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::clampCurrentTimestep() +{ + int maxFrameCount = 0; + + if (m_geomechCase){ + maxFrameCount = m_geomechCase->geoMechData()->femPartResults()->frameCount(); + } + + if (m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = maxFrameCount -1; + if (m_currentTimeStep < 0 ) m_currentTimeStep = 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechView::isTimeStepDependentDataVisible() +{ + return this->hasUserRequestedAnimation() && (this->cellResult()->hasResult() || this->propertyFilterCollection()->hasActiveFilters()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Transform* RimGeoMechView::scaleTransform() +{ + return m_scaleTransform.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimView::fieldChangedByUi(changedField, oldValue, newValue); + + if (changedField == &showWindow) + { + if (showWindow) + { + bool generateDisplayModel = (viewer() == NULL); + updateViewerWidget(); + if (generateDisplayModel) + { + scheduleCreateDisplayModelAndRedraw(); + } + } + else + { + if (m_viewer) + { + RiuMainWindow::instance()->removeViewer(m_viewer); + delete m_viewer; + m_viewer = NULL; + } + } + + this->updateUiIconFromToggleField(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::initAfterRead() +{ + this->cellResult()->setReservoirView(this); + + this->updateUiIconFromToggleField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* RimGeoMechView::ownerCase() +{ + return m_geomechCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::scheduleGeometryRegen(RivCellSetEnum geometryType) +{ + m_vizLogic->scheduleGeometryRegen(geometryType); +} + diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h new file mode 100644 index 0000000000..a40e5647df --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPointer.h" +#include "cafAppEnum.h" +#include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" + +#include "cvfObject.h" +#include "RimView.h" + +class RimGeoMechCellColors; +class Rim3dOverlayInfoConfig; +class RiuViewer; +class RimGeoMechCase; +class RivGeoMechPartMgr; +class RimCellRangeFilterCollection; +class RivGeoMechVizLogic; +class RimGeoMechPropertyFilterCollection; +class RigFemPart; + +namespace cvf { + class Transform; + class CellRangeFilter; +} + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechView : public RimView +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechView(void); + virtual ~RimGeoMechView(void); + + void setGeoMechCase(RimGeoMechCase* gmCase); + RimGeoMechCase* geoMechCase(); + + virtual void loadDataAndUpdate(); + + caf::PdmField cellResult; + caf::PdmField propertyFilterCollection; + + bool isTimeStepDependentDataVisible(); + + virtual cvf::Transform* scaleTransform(); + virtual void scheduleGeometryRegen(RivCellSetEnum geometryType); + +private: + virtual void createDisplayModel(); + virtual void updateDisplayModelVisibility(); + virtual void updateScaleTransform(); + + virtual void clampCurrentTimestep(); + + virtual void updateCurrentTimeStep(); + virtual void updateStaticCellColors(); + + virtual void updateViewerWidgetWindowTitle(); + virtual void resetLegendsInViewer(); + + void updateLegends(); + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual void initAfterRead(); + + virtual RimCase* ownerCase(); + + caf::PdmPointer m_geomechCase; + cvf::ref m_vizLogic; + cvf::ref m_scaleTransform; + +}; + +#include "cvfArray.h" + +namespace cvf { + class CellRangeFilter; +} + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 7e4a325b50..8a15d0c822 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -24,17 +24,20 @@ #include "RigCaseCellResultsData.h" #include "RigCaseData.h" #include "RigGridManager.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimCaseCollection.h" -#include "RimCellEdgeResultSlot.h" +#include "RimCellEdgeColors.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultCase.h" -#include "RimResultSlot.h" -#include "RimStatisticsCase.h" +#include "RimEclipseView.h" +#include "RimEclipseResultCase.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseStatisticsCase.h" #include "RigCaseCellResultsData.h" #include "cafProgressInfo.h" +#include "RiuMainWindow.h" +#include +#include CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); @@ -79,7 +82,7 @@ RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir) +void RimIdenticalGridCaseGroup::addCase(RimEclipseCase* reservoir) { CVF_ASSERT(reservoir); @@ -104,7 +107,7 @@ void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIdenticalGridCaseGroup::removeCase(RimCase* reservoir) +void RimIdenticalGridCaseGroup::removeCase(RimEclipseCase* reservoir) { if (caseCollection()->reservoirs().count(reservoir) == 0) { @@ -155,22 +158,19 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() // The mainGrid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RimCase* mainCase = caseCollection()->reservoirs[0]; - mainCase->openEclipseGridFile(); - RigCaseData* rigCaseData = mainCase->reservoirData(); - if (rigCaseData) + RimEclipseCase* mainCase = caseCollection()->reservoirs[0]; + if (!mainCase->openReserviorCase()) { - RifReaderInterface::PorosityModelResultType poroModel = RifReaderInterface::MATRIX_RESULTS; - RimReservoirCellResultsStorage* cellResultsStorage = mainCase->results(poroModel); - - cellResultsStorage->cellResults()->createPlaceholderResultEntries(); - } - else - { - // Error message + QMessageBox::warning(RiuMainWindow::instance(), + "Error when opening project file", + "Could not open the Eclipse Grid file: \n"+ mainCase->gridFileName() + "\n"+ + "Current working directory is: \n" + + QDir::currentPath()); return; } + RigCaseData* rigCaseData = mainCase->reservoirData(); + CVF_ASSERT(rigCaseData); // Action A : Read active cell info // Read active cell info from all source cases. The file access is optimized for this purpose, and result meta data @@ -179,7 +179,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() caf::ProgressInfo info(caseCollection()->reservoirs.size(), "Case group - Reading Active Cell data"); for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++) { - RimResultCase* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); + RimEclipseResultCase* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); if(!rimReservoir) continue; // Input reservoir if (!rimReservoir->openAndReadActiveCellData(rigCaseData)) @@ -198,7 +198,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() bool foundResultsInCache = false; for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++) { - RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i]; + RimEclipseCase* rimReservoir = statisticsCaseCollection()->reservoirs[i]; // Check if any results are stored in cache if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 || @@ -227,7 +227,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++) { - RimResultCase* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); + RimEclipseResultCase* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); if (!rimReservoir) continue; // Input reservoir RimReservoirCellResultsStorage* cellResultsStorage = rimReservoir->results(poroModel); @@ -257,7 +257,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++) { - RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i]; + RimEclipseCase* rimReservoir = statisticsCaseCollection()->reservoirs[i]; rimReservoir->openEclipseGridFile(); @@ -356,9 +356,9 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase() +RimEclipseStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase() { - RimStatisticsCase* newStatisticsCase = new RimStatisticsCase; + RimEclipseStatisticsCase* newStatisticsCase = new RimEclipseStatisticsCase; newStatisticsCase->caseUserDescription = QString("Statistics ") + QString::number(statisticsCaseCollection()->reservoirs.size()+1); statisticsCaseCollection()->reservoirs.push_back(newStatisticsCase); @@ -375,7 +375,7 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() { for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++) { - RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; + RimEclipseCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid()); @@ -393,7 +393,7 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults() { for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++) { - RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; + RimEclipseCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; if (!rimStaticsCase) continue; rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults(); @@ -401,7 +401,7 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults() for (size_t j = 0; j < rimStaticsCase->reservoirViews.size(); j++) { - RimReservoirView* rimReservoirView = rimStaticsCase->reservoirViews[j]; + RimEclipseView* rimReservoirView = rimStaticsCase->reservoirViews[j]; rimReservoirView->cellResult()->setResultVariable(RimDefines::undefinedResultName()); rimReservoirView->cellEdgeResult()->resultVariable = RimDefines::undefinedResultName(); rimReservoirView->loadDataAndUpdate(); @@ -421,13 +421,13 @@ void RimIdenticalGridCaseGroup::clearActiveCellUnions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimIdenticalGridCaseGroup::contains(RimCase* reservoir) const +bool RimIdenticalGridCaseGroup::contains(RimEclipseCase* reservoir) const { CVF_ASSERT(reservoir); for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++) { - RimCase* rimReservoir = caseCollection()->reservoirs()[i]; + RimEclipseCase* rimReservoir = caseCollection()->reservoirs()[i]; if (reservoir->gridFileName() == rimReservoir->gridFileName()) { return true; @@ -473,7 +473,7 @@ bool RimIdenticalGridCaseGroup::isStatisticsCaseCollection(RimCaseCollection* ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase* RimIdenticalGridCaseGroup::mainCase() +RimEclipseCase* RimIdenticalGridCaseGroup::mainCase() { if(caseCollection()->reservoirs().size()) { @@ -488,7 +488,7 @@ RimCase* RimIdenticalGridCaseGroup::mainCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimIdenticalGridCaseGroup::canCaseBeAdded(RimCase* reservoir) const +bool RimIdenticalGridCaseGroup::canCaseBeAdded(RimEclipseCase* reservoir) const { CVF_ASSERT(reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid()); diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 6a033e1ede..9e31ef3de6 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -28,9 +28,9 @@ #include "RifReaderInterface.h" class RimCaseCollection; -class RimStatisticsCase; +class RimEclipseStatisticsCase; -class RimCase; +class RimEclipseCase; class RigMainGrid; class RigActiveCellInfo; @@ -52,16 +52,16 @@ class RimIdenticalGridCaseGroup : public caf::PdmObject caf::PdmField caseCollection; caf::PdmField statisticsCaseCollection; - void addCase(RimCase* reservoir); - void removeCase(RimCase* reservoir); + void addCase(RimEclipseCase* reservoir); + void removeCase(RimEclipseCase* reservoir); - bool contains(RimCase* reservoir) const; - bool canCaseBeAdded(RimCase* reservoir) const; + bool contains(RimEclipseCase* reservoir) const; + bool canCaseBeAdded(RimEclipseCase* reservoir) const; - RimStatisticsCase* createAndAppendStatisticsCase(); + RimEclipseStatisticsCase* createAndAppendStatisticsCase(); - RimCase* mainCase(); + RimEclipseCase* mainCase(); void loadMainCaseAndActiveCellInfo(); RigMainGrid* mainGrid(); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 72c1312e3f..15c28fac82 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -35,7 +35,7 @@ #include #include "RiaApplication.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); @@ -44,9 +44,9 @@ namespace caf { template<> void AppEnum::setUp() { - addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Global range"); - addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Local range"); - addItem(RimLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User defined range"); + addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "All Timesteps"); + addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Current Timestep"); + addItem(RimLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); setDefault(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS); } } diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 6d8704d29a..5de9b90be0 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -39,7 +39,7 @@ namespace cvf class ScalarMapper; } -class RimReservoirView; +class RimView; //================================================================================================== /// @@ -52,7 +52,7 @@ class RimLegendConfig: public caf::PdmObject RimLegendConfig(); virtual ~RimLegendConfig(); - void setReservoirView(RimReservoirView* ownerReservoirView) {m_reservoirView = ownerReservoirView; } + void setReservoirView(RimView* ownerReservoirView) {m_reservoirView = ownerReservoirView; } caf::PdmField resultVariableName; // Used internally to describe the variable this legend setup is used for @@ -111,7 +111,7 @@ class RimLegendConfig: public caf::PdmObject private: - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; cvf::ref m_linDiscreteScalarMapper; cvf::ref m_logDiscreteScalarMapper; diff --git a/ApplicationCode/ProjectDataModel/RimOilField.cpp b/ApplicationCode/ProjectDataModel/RimOilField.cpp index f56e5bc456..69d2345dc9 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationCode/ProjectDataModel/RimOilField.cpp @@ -20,8 +20,9 @@ #include "RimOilField.h" -#include "RimAnalysisModels.h" +#include "RimEclipseCaseCollection.h" #include "RimWellPathCollection.h" +#include "RimGeoMechModels.h" CAF_PDM_SOURCE_INIT(RimOilField, "ResInsightOilField"); //-------------------------------------------------------------------------------------------------- @@ -32,9 +33,10 @@ RimOilField::RimOilField(void) CAF_PDM_InitObject("Oil Field", "", "", ""); 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", "", ""); - analysisModels = new RimAnalysisModels(); + analysisModels = new RimEclipseCaseCollection(); } //-------------------------------------------------------------------------------------------------- @@ -43,6 +45,7 @@ RimOilField::RimOilField(void) RimOilField::~RimOilField(void) { if (wellPathCollection()) delete wellPathCollection(); + if (geoMechModels()) delete geoMechModels(); if (analysisModels()) delete analysisModels(); } diff --git a/ApplicationCode/ProjectDataModel/RimOilField.h b/ApplicationCode/ProjectDataModel/RimOilField.h index 0a26e32d40..f2704939ff 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.h +++ b/ApplicationCode/ProjectDataModel/RimOilField.h @@ -25,7 +25,8 @@ #include "cafPdmPointer.h" class RimWellPathCollection; -class RimAnalysisModels; +class RimEclipseCaseCollection; +class RimGeoMechModels; //================================================================================================== /// @@ -39,6 +40,7 @@ class RimOilField : public caf::PdmObject RimOilField(void); virtual ~RimOilField(void); - caf::PdmField analysisModels; + caf::PdmField analysisModels; + caf::PdmField geoMechModels; caf::PdmField wellPathCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 3fea5fd02a..01683a007d 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -23,17 +23,19 @@ #include "RiaApplication.h" #include "RiaVersionInfo.h" #include "RigCaseData.h" -#include "RimAnalysisModels.h" -#include "RimCase.h" +#include "RimEclipseCaseCollection.h" +#include "RimEclipseCase.h" #include "RimCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" #include "RimOilField.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RimScriptCollection.h" #include "RimWellPathCollection.h" #include "RimWellPathImport.h" #include +#include "RimGeoMechModels.h" +#include "RimGeoMechCase.h" CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); //-------------------------------------------------------------------------------------------------- @@ -164,7 +166,7 @@ void RimProject::initScriptDirectories() } // Find largest used groupId read from file and make sure all groups have a valid groupId - RimAnalysisModels* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; if (analysisModels) { int largestGroupId = -1; @@ -213,7 +215,7 @@ void RimProject::initAfterRead() // Handle old project files with obsolete structure. // Move caseGroupsObsolete and casesObsolete to oilFields()[idx]->analysisModels() - RimAnalysisModels* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; bool movedOneRimIdenticalGridCaseGroup = false; for (size_t cgIdx = 0; cgIdx < caseGroupsObsolete.size(); ++cgIdx) { @@ -234,7 +236,7 @@ void RimProject::initAfterRead() bool movedOneRimCase = false; for (size_t cIdx = 0; cIdx < casesObsolete().size(); ++cIdx) { - RimCase* sourceCase = casesObsolete[cIdx]; + RimEclipseCase* sourceCase = casesObsolete[cIdx]; if (analysisModels) { analysisModels->cases.push_back(sourceCase); @@ -376,27 +378,44 @@ void RimProject::allCases(std::vector& cases) for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++) { RimOilField* oilField = oilFields[oilFieldIdx]; - RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL; - if (analysisModels == NULL) continue; + if (!oilField) continue; - for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++) + RimEclipseCaseCollection* analysisModels = oilField->analysisModels(); + if (analysisModels ) { - cases.push_back(analysisModels->cases[caseIdx]); - } - for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++) - { - // Load the Main case of each IdenticalGridCaseGroup - RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx]; - if (cg == NULL) continue; - - for (size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++) + for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++) + { + cases.push_back(analysisModels->cases[caseIdx]); + } + for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++) { - cases.push_back(cg->statisticsCaseCollection()->reservoirs[caseIdx]); + // Load the Main case of each IdenticalGridCaseGroup + RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx]; + if (cg == NULL) continue; + + if (cg->statisticsCaseCollection()) + { + for (size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++) + { + cases.push_back(cg->statisticsCaseCollection()->reservoirs[caseIdx]); + } + } + if (cg->caseCollection()) + { + for (size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++) + { + cases.push_back(cg->caseCollection()->reservoirs[caseIdx]); + } + } } + } - for (size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++) + RimGeoMechModels* geomModels = oilField->geoMechModels(); + if (geomModels) + { + for (size_t caseIdx = 0; caseIdx < geomModels->cases.size(); caseIdx++) { - cases.push_back(cg->caseCollection()->reservoirs[caseIdx]); + cases.push_back(geomModels->cases[caseIdx]); } } } @@ -414,11 +433,11 @@ void RimProject::createDisplayModelAndRedrawAllViews() { RimCase* rimCase = cases[caseIdx]; if (rimCase == NULL) continue; + std::vector views = rimCase->views(); - for (size_t viewIdx = 0; viewIdx < rimCase->reservoirViews.size(); viewIdx++) + for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++) { - RimReservoirView* reservoirView = rimCase->reservoirViews[viewIdx]; - reservoirView->scheduleCreateDisplayModelAndRedraw(); + views[viewIdx]->scheduleCreateDisplayModelAndRedraw(); } } } @@ -446,7 +465,7 @@ void RimProject::computeUtmAreaOfInterest() for (size_t i = 0; i < cases.size(); i++) { - RimCase* rimCase = cases[i]; + RimEclipseCase* rimCase = dynamic_cast(cases[i]); if (rimCase && rimCase->reservoirData()) { @@ -457,6 +476,10 @@ void RimProject::computeUtmAreaOfInterest() projectBB.add(rigGrid->boundingBox()); } } + else + { + // Todo : calculate BBox of GeoMechCase + } } if (projectBB.isValid()) diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 214706e7a7..33cfa8906d 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -23,6 +23,7 @@ #include "cafPdmDocument.h" class RimOilField; +class RimEclipseCase; class RimCase; class RigGridManager; class RimScriptCollection; @@ -50,10 +51,6 @@ class RimProject : public caf::PdmDocument caf::PdmPointersField commandObjects; caf::PdmField treeViewState; caf::PdmField currentModelIndexPath; - caf::PdmField nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts - caf::PdmField nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts - caf::PdmPointersField casesObsolete; // obsolete - caf::PdmPointersField caseGroupsObsolete; // obsolete void setScriptDirectories(const QString& scriptDirectories); QString projectFileVersionString() const; @@ -64,8 +61,8 @@ class RimProject : public caf::PdmDocument void assignCaseIdToCase(RimCase* reservoirCase); void assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup); - void allCases(std::vector& cases); // VL endre impl - void createDisplayModelAndRedrawAllViews(); // VL endre impl + void allCases(std::vector& cases); + void createDisplayModelAndRedrawAllViews(); void computeUtmAreaOfInterest(); @@ -79,4 +76,11 @@ class RimProject : public caf::PdmDocument private: caf::PdmField m_projectFileVersionString; + + caf::PdmField nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts + caf::PdmField nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts + + caf::PdmPointersField casesObsolete; // obsolete + caf::PdmPointersField caseGroupsObsolete; // obsolete + }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index d533ccb702..1be966dc4b 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -25,7 +25,7 @@ #include "RigCell.h" #include "RigMainGrid.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimTools.h" #include "cafProgressInfo.h" @@ -780,7 +780,7 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr // Set up which component to compute - cvf::StructGridInterface::FaceType faceId; + cvf::StructGridInterface::FaceType faceId = cvf::StructGridInterface::NO_FACE; QString permCompName; if (riTransComponentResultName == RimDefines::riTranXResultName()) @@ -810,6 +810,8 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr size_t permResultIdx = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, permCompName); size_t ntgResultIdx = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "NTG"); + bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T; + // Get the result index of the output size_t riTransResultIdx = m_cellResults->findScalarResultIndex(RimDefines::STATIC_NATIVE, riTransComponentResultName); @@ -818,32 +820,49 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr // Get the result count, to handle that one of them might be globally defined size_t permxResultValueCount = m_cellResults->cellScalarResults(permResultIdx)[0].size(); - size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); - - size_t resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + size_t resultValueCount = permxResultValueCount; + if (hasNTGResults) + { + size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); + resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + } // Get all the actual result values - std::vector & permResults = m_cellResults->cellScalarResults(permResultIdx)[0]; - std::vector & ntgResults = m_cellResults->cellScalarResults(ntgResultIdx)[0]; + std::vector & permResults = m_cellResults->cellScalarResults(permResultIdx)[0]; std::vector & riTransResults = m_cellResults->cellScalarResults(riTransResultIdx)[0]; + std::vector * ntgResults = NULL; + if (hasNTGResults) + { + ntgResults = &(m_cellResults->cellScalarResults(ntgResultIdx)[0]); + } // Set up output container to correct number of results riTransResults.resize(resultValueCount); // Prepare how to index the result values: + ResultIndexFunction riTranIdxFunc = NULL; + ResultIndexFunction permIdxFunc = NULL; + ResultIndexFunction ntgIdxFunc = NULL; + { + bool isPermUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permResultIdx); + bool isTransUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(riTransResultIdx); + bool isNtgUsingResIdx = false; + if (hasNTGResults) + { + isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); + } - bool isPermUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permResultIdx); - bool isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); - bool isTransUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(riTransResultIdx); - - // Set up result index function pointers - - ResultIndexFunction riTranIdxFunc = isTransUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction permIdxFunc = isPermUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + // Set up result index function pointers + riTranIdxFunc = isTransUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + permIdxFunc = isPermUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + if (hasNTGResults) + { + ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + } + } const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); const std::vector& nodes = m_ownerMainGrid->nodes(); @@ -906,10 +925,10 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr double perm = permResults[permResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, nativeResvCellIndex); - ntg = ntgResults[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } halfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, faceAreaVec); @@ -922,10 +941,10 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr double perm = permResults[neighborCellPermResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, neighborResvCellIdx); - ntg = ntgResults[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } neighborHalfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, -faceAreaVec); @@ -957,37 +976,56 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() size_t ntgResultIdx = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "NTG"); + bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T; + // Get the result count, to handle that one of them might be globally defined size_t permxResultValueCount = m_cellResults->cellScalarResults(permXResultIdx)[0].size(); - size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); - - size_t resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + size_t resultValueCount = permxResultValueCount; + if (hasNTGResults) + { + size_t ntgResultValueCount = m_cellResults->cellScalarResults(ntgResultIdx)[0].size(); + resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount); + } // Get all the actual result values std::vector & permXResults = m_cellResults->cellScalarResults(permXResultIdx)[0]; std::vector & permYResults = m_cellResults->cellScalarResults(permYResultIdx)[0]; std::vector & permZResults = m_cellResults->cellScalarResults(permZResultIdx)[0]; - std::vector & ntgResults = m_cellResults->cellScalarResults(ntgResultIdx)[0]; std::vector & riCombTransResults = m_ownerMainGrid->nncData()->makeConnectionScalarResult(riCombTransScalarResultIndex); + std::vector * ntgResults = NULL; + if (hasNTGResults) + { + ntgResults = &(m_cellResults->cellScalarResults(ntgResultIdx)[0]); + } // Prepare how to index the result values: + ResultIndexFunction permXIdxFunc = NULL; + ResultIndexFunction permYIdxFunc = NULL; + ResultIndexFunction permZIdxFunc = NULL; + ResultIndexFunction ntgIdxFunc = NULL; + { + bool isPermXUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permXResultIdx); + bool isPermYUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permYResultIdx); + bool isPermZUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permZResultIdx); + bool isNtgUsingResIdx = false; + if (hasNTGResults) + { + isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); + } - bool isPermXUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permXResultIdx); - bool isPermYUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permYResultIdx); - bool isPermZUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(permZResultIdx); - bool isNtgUsingResIdx = m_cellResults->isUsingGlobalActiveIndex(ntgResultIdx); - - - // Set up result index function pointers - - ResultIndexFunction permXIdxFunc = isPermXUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction permYIdxFunc = isPermYUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction permZIdxFunc = isPermZUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; - ResultIndexFunction ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + // Set up result index function pointers + permXIdxFunc = isPermXUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + permYIdxFunc = isPermYUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + permZIdxFunc = isPermZUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + if (hasNTGResults) + { + ntgIdxFunc = isNtgUsingResIdx ? &reservoirActiveCellIndex : &directReservoirCellIndex; + } + } const RigActiveCellInfo* activeCellInfo = m_cellResults->activeCellInfo(); const std::vector& nodes = m_ownerMainGrid->nodes(); @@ -1068,10 +1106,10 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() double perm = (*permResults)[nativeCellPermResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, nativeResvCellIndex); - ntg = ntgResults[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } halfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, faceAreaVec); @@ -1084,10 +1122,10 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() double perm = (*permResults)[neighborCellPermResIdx]; double ntg = 1.0; - if (faceId != cvf::StructGridInterface::POS_K) + if (hasNTGResults && faceId != cvf::StructGridInterface::POS_K) { size_t ntgResIdx = (*ntgIdxFunc)(activeCellInfo, neighborResvCellIdx); - ntg = ntgResults[ntgResIdx]; + ntg = (*ntgResults)[ntgResIdx]; } neighborHalfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, -faceAreaVec); @@ -1220,7 +1258,7 @@ void RimReservoirCellResultsStorage::computeRiTRANSbyAreaComponent(const QString // Set up which component to compute - cvf::StructGridInterface::FaceType faceId; + cvf::StructGridInterface::FaceType faceId = cvf::StructGridInterface::NO_FACE; QString transCompName; if (riTransByAreaCompResultName == RimDefines::riAreaNormTranXResultName()) @@ -1489,7 +1527,7 @@ double RimReservoirCellResultsStorage::darchysValue() double darchy = 0.008527; // (ECLIPSE 100) (METRIC) - RimCase* rimCase = NULL; + RimEclipseCase* rimCase = NULL; this->firstAncestorOfType(rimCase); if (rimCase && rimCase->reservoirData()) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h deleted file mode 100644 index 8b82ba0296..0000000000 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ /dev/null @@ -1,227 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS -// -// 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 "cafAppEnum.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" - -#include "cvfArray.h" -#include "cvfBase.h" -#include "cvfObject.h" - -// Includes to make Pdm work for cvf::Color and cvf:Mat -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" - -#include "RivReservoirViewPartMgr.h" - -class RigActiveCellInfo; -class RigCaseCellResultsData; -class RigGridBase; -class RigGridCellFaceVisibilityFilter; -class Rim3dOverlayInfoConfig; -class RimCase; -class RimCellEdgeResultSlot; -class RimCellPropertyFilter; -class RimCellPropertyFilterCollection; -class RimCellRangeFilter; -class RimCellRangeFilterCollection; -class RimFaultCollection; -class RimFaultResultSlot; -class RimReservoirCellResultsStorage; -class RimReservoirCellResultsStorage; -class RimResultSlot; -class RimWellCollection; -class RiuViewer; -class RivReservoirPipesPartMgr; - -namespace cvf -{ - class Transform; - class ScalarMapperUniformLevels; - class ModelBasicList; - class OverlayItem; -} - -enum PartRenderMaskEnum -{ - surfaceBit = 0x00000001, - meshSurfaceBit = 0x00000002, - faultBit = 0x00000004, - meshFaultBit = 0x00000008, -}; - - -//================================================================================================== -/// -/// -//================================================================================================== -class RimReservoirView : public caf::PdmObject -{ - CAF_PDM_HEADER_INIT; -public: - RimReservoirView(void); - virtual ~RimReservoirView(void); - - enum MeshModeType - { - FULL_MESH, - FAULTS_MESH, - NO_MESH - }; - - enum SurfaceModeType - { - SURFACE, - FAULTS, - NO_SURFACE - }; - - // Fields containing child objects : - - caf::PdmField cellResult; - caf::PdmField cellEdgeResult; - caf::PdmField faultResultSettings; - - caf::PdmField rangeFilterCollection; - caf::PdmField propertyFilterCollection; - - caf::PdmField wellCollection; - - caf::PdmField faultCollection; - - caf::PdmField overlayInfoConfig; - - // Visualization setup fields - - caf::PdmField name; - caf::PdmField scaleZ; - caf::PdmField showWindow; - - caf::PdmField showInvalidCells; - caf::PdmField showInactiveCells; - caf::PdmField showMainGrid; - - caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; - caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; - - caf::PdmField< cvf::Color3f > backgroundColor; - - caf::PdmField cameraPosition; - - caf::PdmField maximumFrameRate; - caf::PdmField animationMode; - - - // Access internal objects - RimReservoirCellResultsStorage* currentGridCellResults(); - RigActiveCellInfo* currentActiveCellInfo(); - RimResultSlot* currentFaultResultSlot(); - - - void setEclipseCase(RimCase* reservoir); - RimCase* eclipseCase(); - - // Animation - int currentTimeStep() { return m_currentTimeStep;} - void setCurrentTimeStep(int frameIdx); - void updateCurrentTimeStepAndRedraw(); - void endAnimation(); - - // 3D Viewer - RiuViewer* viewer(); - void updateViewerWidget(); - void updateViewerWidgetWindowTitle(); - void setDefaultView(); - - void setMeshOnlyDrawstyle(); - void setMeshSurfDrawstyle(); - void setSurfOnlyDrawstyle(); - void setFaultMeshSurfDrawstyle(); - void setSurfaceDrawstyle(); - - void setShowFaultsOnly(bool showFaults); - bool isGridVisualizationMode() const; - - // Does this belong here, really ? - void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid); - - // Display model generation -public: - void loadDataAndUpdate(); - void createDisplayModelAndRedraw(); - void scheduleCreateDisplayModelAndRedraw(); - bool isTimeStepDependentDataVisible() const; - - void scheduleGeometryRegen(unsigned short geometryType); - void scheduleReservoirGridGeometryRegen(); - void schedulePipeGeometryRegen(); - void updateDisplayModelForWellResults(); - - const std::vector& - visibleGridParts() const { return m_visibleGridParts;} - cvf::cref reservoirGridPartManager() const { return m_reservoirGridPartManager.p(); } - - // Display model generation -private: - void createDisplayModel(); - void updateDisplayModelVisibility(); - void updateCurrentTimeStep(); - void indicesToVisibleGrids(std::vector* gridIndices); - void updateScaleTransform(); - void updateStaticCellColors(); - void updateStaticCellColors(unsigned short geometryType); - void updateLegends(); - void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimResultSlot* resultSlot, RigCaseCellResultsData* cellResultsData); - - std::vector visibleFaultGeometryTypes() const; - void updateFaultForcedVisibility(); - void updateFaultColors(); - - cvf::ref m_reservoirGridPartManager; - cvf::ref m_pipesPartManager; - - // Overridden PDM methods: -public: - virtual caf::PdmFieldHandle* userDescriptionField() { return &name; } - virtual caf::PdmFieldHandle* objectToggleField(); - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); -protected: - virtual void initAfterRead(); - virtual void setupBeforeSave(); - virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); - - // Really private -private: - void syncronizeWellsWithResults(); - void clampCurrentTimestep(); - -private: - caf::PdmField m_currentTimeStep; - QPointer m_viewer; - caf::PdmPointer m_reservoir; - - bool m_previousGridModeMeshLinesWasFaults; - - std::vector m_visibleGridParts; -}; - diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 12565042a8..8dea112676 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -23,7 +23,7 @@ #include "cafPdmUiTextEditor.h" #include "RiaApplication.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RivTernarySaturationOverlayItem.h" #include "RivTernaryScalarMapper.h" diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 12fe8f1e89..4e781bf388 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -26,7 +26,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -class RimReservoirView; +class RimEclipseView; class RivTernarySaturationOverlayItem; class RivTernaryScalarMapper; @@ -65,7 +65,7 @@ class RimTernaryLegendConfig : public caf::PdmObject RimTernaryLegendConfig(); virtual ~RimTernaryLegendConfig(); - void setReservoirView(RimReservoirView* ownerReservoirView) {m_reservoirView = ownerReservoirView; } + void setReservoirView(RimEclipseView* ownerReservoirView) {m_reservoirView = ownerReservoirView; } void setAutomaticRanges(TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax); void ternaryRanges(double& soilLower, double& soilUpper, double& sgasLower, double& sgasUpper, double& swatLower, double& swatUpper) const; @@ -107,7 +107,7 @@ class RimTernaryLegendConfig : public caf::PdmObject std::vector m_localAutoMax; std::vector m_localAutoMin; - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; cvf::ref m_legend; cvf::ref m_scalarMapper; }; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 7b638e7d51..ccb645ba4a 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -22,30 +22,35 @@ #include "RiaApplication.h" #include "RigGridManager.h" -#include "RimAnalysisModels.h" -#include "RimCase.h" +#include "RimEclipseCaseCollection.h" +#include "RimEclipseCase.h" #include "RimCaseCollection.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimCellRangeFilterCollection.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechPropertyFilter.h" #include "RimIdenticalGridCaseGroup.h" -#include "RimInputCase.h" -#include "RimInputProperty.h" -#include "RimInputPropertyCollection.h" +#include "RimEclipseInputCase.h" +#include "RimEclipseInputProperty.h" +#include "RimEclipseInputPropertyCollection.h" #include "RimMimeData.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimReservoirView.h" -#include "RimResultCase.h" +#include "RimEclipseView.h" +#include "RimEclipseResultCase.h" #include "RimScriptCollection.h" -#include "RimStatisticsCase.h" +#include "RimEclipseStatisticsCase.h" #include "RimUiTreeView.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "RimWellPathCollection.h" +#include "RimGeoMechView.h" #include "cvfAssert.h" #include #include +#include "RimGeoMechCase.h" + //-------------------------------------------------------------------------------------------------- @@ -60,76 +65,64 @@ RimUiTreeModelPdm::RimUiTreeModelPdm(QObject* parent) connect(m_scriptChangeDetector, SIGNAL(fileChanged(QString)), this, SLOT(slotRefreshScriptTree(QString))); } + + //-------------------------------------------------------------------------------------------------- -/// TO BE DELETED +/// //-------------------------------------------------------------------------------------------------- -bool RimUiTreeModelPdm::insertRows_special(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/) +bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex) { - caf::PdmUiTreeItem* parentItem = getTreeItemFromIndex(parent); - - bool canCreateChildren = false; - QModelIndex parentIndex = parent; + CVF_ASSERT(itemIndex.isValid()); - if (dynamic_cast(parentItem->dataObject().p()) || - dynamic_cast(parentItem->dataObject().p())) - { - canCreateChildren = true; - } - else if (dynamic_cast(parentItem->dataObject().p())) - { - parentItem = parentItem->parent(); - parentIndex = parent.parent(); + caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex); + CVF_ASSERT(uiItem); - canCreateChildren = true; - } + RimEclipsePropertyFilter* propertyFilter = dynamic_cast(uiItem->dataObject().p()); + CVF_ASSERT(propertyFilter); - if (canCreateChildren) - { - beginInsertRows(parent, position, position + rows - 1); - - int i; - for (i = 0; i < rows; i++) - { - if (dynamic_cast(parentItem->dataObject().p())) - { - RimCellRangeFilterCollection* rangeFilterCollection = dynamic_cast(parentItem->dataObject().p()); - - RimCellRangeFilter* rangeFilter = rangeFilterCollection->createAndAppendRangeFilter(); + RimEclipsePropertyFilterCollection* propertyFilterCollection = propertyFilter->parentContainer(); + CVF_ASSERT(propertyFilterCollection); - caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentItem, position + i, rangeFilter); - } - else if (dynamic_cast(parentItem->dataObject().p())) - { - RimCellPropertyFilterCollection* propertyFilterCollection = dynamic_cast(parentItem->dataObject().p()); + bool wasFilterActive = propertyFilter->isActive(); + bool wasSomeFilterActive = propertyFilterCollection->hasActiveFilters(); - RimCellPropertyFilter* propertyFilter = propertyFilterCollection->createAndAppendPropertyFilter(); + // Remove Ui items pointing at the pdm object to delete + removeRows_special(itemIndex.row(), 1, itemIndex.parent()); // To be deleted - caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentItem, position + i, propertyFilter); - } + propertyFilterCollection->remove(propertyFilter); + delete propertyFilter; - } - endInsertRows(); + // updateUiSubTree(propertyFilterCollection); // To be enabled + + if (wasFilterActive) + { + propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED); } - return canCreateChildren; -} + if (wasSomeFilterActive) + { + propertyFilterCollection->reservoirView()->createDisplayModelAndRedraw(); + } + clearClipboard(); + return true; +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex) +bool RimUiTreeModelPdm::deleteGeoMechPropertyFilter(const QModelIndex& itemIndex) { CVF_ASSERT(itemIndex.isValid()); caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex); CVF_ASSERT(uiItem); - RimCellPropertyFilter* propertyFilter = dynamic_cast(uiItem->dataObject().p()); + RimGeoMechPropertyFilter* propertyFilter = dynamic_cast(uiItem->dataObject().p()); CVF_ASSERT(propertyFilter); - RimCellPropertyFilterCollection* propertyFilterCollection = propertyFilter->parentContainer(); + RimGeoMechPropertyFilterCollection* propertyFilterCollection = propertyFilter->parentContainer(); CVF_ASSERT(propertyFilterCollection); bool wasFilterActive = propertyFilter->isActive(); @@ -145,7 +138,7 @@ bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex) if (wasFilterActive) { - propertyFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::PROPERTY_FILTERED); + propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED); } if (wasSomeFilterActive) @@ -187,7 +180,7 @@ bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex) if (wasFilterActive) { - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::PROPERTY_FILTERED); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED); } if (wasSomeFilterActive) @@ -203,32 +196,63 @@ bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex) +void RimUiTreeModelPdm::deleteReservoirViews(const std::vector& treeSelection) { - CVF_ASSERT(itemIndex.isValid()); + std::set ownerCases; - caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex); - CVF_ASSERT(uiItem); - - RimReservoirView* reservoirView = dynamic_cast(uiItem->dataObject().p()); - CVF_ASSERT(reservoirView); + for (size_t sIdx = 0; sIdx < treeSelection.size(); ++sIdx) + { + RimView* reservoirView = dynamic_cast(treeSelection[sIdx]); + ownerCases.insert(reservoirView->ownerCase()); - // Remove Ui items pointing at the pdm object to delete - removeRows_special(itemIndex.row(), 1, itemIndex.parent()); // To be deleted + reservoirView->removeFromParentFields(); + delete reservoirView; + + } - reservoirView->eclipseCase()->removeReservoirView(reservoirView); - delete reservoirView; + for (std::set::iterator it = ownerCases.begin(); it != ownerCases.end(); ++it) + { + updateUiSubTree(*it); + } - // updateUiSubTree(reservoirView->eclipseCase()); // To be enabled clearClipboard(); +} - return true; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeModelPdm::deleteGeoMechCases(const std::vector& treeSelection) +{ + std::set allParents; + + for (size_t sIdx = 0; sIdx < treeSelection.size(); ++sIdx) + { + RimGeoMechCase* geomCase = dynamic_cast(treeSelection[sIdx]); + if (!geomCase) continue; + + std::vector parents; + geomCase->parentObjects(parents); + for (size_t pIdx = 0; pIdx < treeSelection.size(); ++pIdx) + { + allParents.insert(parents[pIdx]); + } + + geomCase->removeFromParentFields(); + delete geomCase; + } + + for (std::set::iterator it = allParents.begin(); it != allParents.end(); ++it) + { + updateUiSubTree(*it); + } + + clearClipboard(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) +void RimUiTreeModelPdm::deleteReservoir(RimEclipseCase* reservoir) { if (reservoir->parentCaseCollection()) { @@ -257,7 +281,7 @@ void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) { RimProject* proj = RiaApplication::instance()->project(); RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimAnalysisModels* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; if (analysisModels) analysisModels->removeCaseFromAllGroups(reservoir); } } @@ -275,7 +299,7 @@ void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) } RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimAnalysisModels* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; if (analysisModels) analysisModels->removeCaseFromAllGroups(reservoir); } @@ -284,29 +308,30 @@ void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) clearClipboard(); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellPropertyFilter* RimUiTreeModelPdm::addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +RimEclipsePropertyFilter* RimUiTreeModelPdm::addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) { caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); QModelIndex collectionIndex; - RimCellPropertyFilterCollection* propertyFilterCollection = NULL; + RimEclipsePropertyFilterCollection* propertyFilterCollection = NULL; caf::PdmUiTreeItem* propertyFilterCollectionItem = NULL; int position = 0; - if (dynamic_cast(currentItem->dataObject().p())) + if (dynamic_cast(currentItem->dataObject().p())) { - RimCellPropertyFilter* propertyFilter = dynamic_cast(currentItem->dataObject().p()); + RimEclipsePropertyFilter* propertyFilter = dynamic_cast(currentItem->dataObject().p()); propertyFilterCollection = propertyFilter->parentContainer(); propertyFilterCollectionItem = currentItem->parent(); position = itemIndex.row(); collectionIndex = itemIndex.parent(); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { - propertyFilterCollection = dynamic_cast(currentItem->dataObject().p()); + propertyFilterCollection = dynamic_cast(currentItem->dataObject().p()); propertyFilterCollectionItem = currentItem; position = propertyFilterCollectionItem->childCount(); collectionIndex = itemIndex; @@ -314,7 +339,7 @@ RimCellPropertyFilter* RimUiTreeModelPdm::addPropertyFilter(const QModelIndex& i beginInsertRows(collectionIndex, position, position); - RimCellPropertyFilter* propertyFilter = propertyFilterCollection->createAndAppendPropertyFilter(); + RimEclipsePropertyFilter* propertyFilter = propertyFilterCollection->createAndAppendPropertyFilter(); caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(propertyFilterCollectionItem, position, propertyFilter); endInsertRows(); @@ -323,12 +348,58 @@ RimCellPropertyFilter* RimUiTreeModelPdm::addPropertyFilter(const QModelIndex& i if (propertyFilterCollection) { - propertyFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::PROPERTY_FILTERED); + propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED); } return propertyFilter; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter* RimUiTreeModelPdm::addGeoMechPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +{ + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); + + QModelIndex collectionIndex; + RimGeoMechPropertyFilterCollection* propertyFilterCollection = NULL; + caf::PdmUiTreeItem* propertyFilterCollectionItem = NULL; + int position = 0; + + if (dynamic_cast(currentItem->dataObject().p())) + { + RimGeoMechPropertyFilter* propertyFilter = dynamic_cast(currentItem->dataObject().p()); + propertyFilterCollection = propertyFilter->parentContainer(); + propertyFilterCollectionItem = currentItem->parent(); + position = itemIndex.row(); + collectionIndex = itemIndex.parent(); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + propertyFilterCollection = dynamic_cast(currentItem->dataObject().p()); + propertyFilterCollectionItem = currentItem; + position = propertyFilterCollectionItem->childCount(); + collectionIndex = itemIndex; + } + + beginInsertRows(collectionIndex, position, position); + + RimGeoMechPropertyFilter* propertyFilter = propertyFilterCollection->createAndAppendPropertyFilter(); + caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(propertyFilterCollectionItem, position, propertyFilter); + + endInsertRows(); + + insertedModelIndex = index(position, 0, collectionIndex); + + if (propertyFilterCollection) + { + static_cast(propertyFilterCollection->reservoirView())->scheduleGeometryRegen(PROPERTY_FILTERED); + } + + return propertyFilter; +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -367,8 +438,8 @@ RimCellRangeFilter* RimUiTreeModelPdm::addRangeFilter(const QModelIndex& itemInd insertedModelIndex = index(position, 0, collectionIndex); if (rangeFilterCollection) { - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); } return rangeFilter; @@ -378,51 +449,43 @@ RimCellRangeFilter* RimUiTreeModelPdm::addRangeFilter(const QModelIndex& itemInd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +RimView* RimUiTreeModelPdm::addReservoirView(const std::vector& treeSelection) { - caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); - if (!currentItem) return NULL; + if (!treeSelection.size() || treeSelection[0] == NULL) return NULL; - caf::PdmUiTreeItem* collectionItem = NULL; + caf::PdmUiItem* currentItem = treeSelection[0]; - bool itemIndexIsCollection = false; - QModelIndex collectionIndex; - int position = 0; - if (dynamic_cast(currentItem->dataObject().p())) - { - collectionItem = currentItem->parent(); - collectionIndex = itemIndex.parent(); - position = itemIndex.row(); - } - else if (dynamic_cast(currentItem->dataObject().p())) - { - collectionItem = currentItem; - collectionIndex = itemIndex; - position = collectionItem->childCount(); - } - - if (collectionItem) - { - RimCase* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); - RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); - - // Must be run before buildViewItems, as wells are created in this function - insertedView->loadDataAndUpdate(); + // Establish type of selected object + RimEclipseCase* eclipseCase = dynamic_cast(currentItem); + RimGeoMechCase* geomCase = dynamic_cast(currentItem); + RimGeoMechView* geoMechView = dynamic_cast(currentItem); + RimEclipseView* reservoirView = dynamic_cast(currentItem); - beginInsertRows(collectionIndex, position, position); + // Find case to insert into - // NOTE: -1 as second argument indicates append - caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(collectionItem, position, insertedView); - - endInsertRows(); + if (geoMechView) geomCase = geoMechView->geoMechCase(); + if (reservoirView) eclipseCase = reservoirView->eclipseCase(); - insertedModelIndex = index(position, 0, collectionIndex); + RimView* insertedView = NULL; - return insertedView; + if (eclipseCase) + { + insertedView = eclipseCase->createAndAddReservoirView(); + } + else if (geomCase) + { + insertedView = geomCase->createAndAddReservoirView(); } - return NULL; -} + // Must be run before buildViewItems, as wells are created in this function + + insertedView->loadDataAndUpdate(); + + if (eclipseCase ) this->updateUiSubTree(eclipseCase); + if (geomCase ) this->updateUiSubTree(geomCase); + + return insertedView; +} //-------------------------------------------------------------------------------------------------- @@ -469,14 +532,14 @@ void RimUiTreeModelPdm::addInputProperty(const QModelIndex& itemIndex, const QSt { caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); - RimInputPropertyCollection* inputPropertyCollection = dynamic_cast(currentItem->dataObject().p()); + RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast(currentItem->dataObject().p()); CVF_ASSERT(inputPropertyCollection); - std::vector parentObjects; + std::vector parentObjects; inputPropertyCollection->parentObjectsOfType(parentObjects); CVF_ASSERT(parentObjects.size() == 1); - RimInputCase* inputReservoir = parentObjects[0]; + RimEclipseInputCase* inputReservoir = parentObjects[0]; CVF_ASSERT(inputReservoir); if (inputReservoir) { @@ -497,24 +560,24 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) if (!uiItem) return; caf::PdmObject* object = uiItem->dataObject().p(); - RimInputProperty* inputProperty = dynamic_cast(object); + RimEclipseInputProperty* inputProperty = dynamic_cast(object); if (!inputProperty) return; // Remove item from UI tree model before delete of project data structure removeRows_special(itemIndex.row(), 1, itemIndex.parent()); - std::vector parentObjects; + std::vector parentObjects; object->parentObjectsOfType(parentObjects); CVF_ASSERT(parentObjects.size() == 1); - RimInputPropertyCollection* inputPropertyCollection = parentObjects[0]; + RimEclipseInputPropertyCollection* inputPropertyCollection = parentObjects[0]; if (!inputPropertyCollection) return; - std::vector parentObjects2; + std::vector parentObjects2; inputPropertyCollection->parentObjectsOfType(parentObjects2); CVF_ASSERT(parentObjects2.size() == 1); - RimInputCase* inputReservoir = parentObjects2[0]; + RimEclipseInputCase* inputReservoir = parentObjects2[0]; if (!inputReservoir) return; inputReservoir->removeProperty(inputProperty); @@ -527,7 +590,7 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +RimEclipseStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) { caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); @@ -536,9 +599,9 @@ RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelInde caf::PdmUiTreeItem* parentCollectionItem = NULL; int position = 0; - if (dynamic_cast(currentItem->dataObject().p())) + if (dynamic_cast(currentItem->dataObject().p())) { - RimStatisticsCase* currentObject = dynamic_cast(currentItem->dataObject().p()); + RimEclipseStatisticsCase* currentObject = dynamic_cast(currentItem->dataObject().p()); caseGroup = currentObject->parentStatisticsCaseCollection()->parentCaseGroup(); parentCollectionItem = currentItem->parent(); position = itemIndex.row(); @@ -558,7 +621,7 @@ RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelInde beginInsertRows(collectionIndex, position, position); RimProject* proj = RiaApplication::instance()->project(); - RimStatisticsCase* createdObject = caseGroup->createAndAppendStatisticsCase(); + RimEclipseStatisticsCase* createdObject = caseGroup->createAndAppendStatisticsCase(); proj->assignCaseIdToCase(createdObject); caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject); @@ -583,14 +646,14 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& inserted RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); - RimAnalysisModels* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL; if (analysisModels) { RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; proj->assignIdToCaseGroup(createdObject); - RimCase* createdReservoir = createdObject->createAndAppendStatisticsCase(); + RimEclipseCase* createdReservoir = createdObject->createAndAppendStatisticsCase(); proj->assignCaseIdToCase(createdReservoir); createdObject->name = QString("Grid Case Group %1").arg(analysisModels->caseGroups().size() + 1); @@ -618,7 +681,7 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO RimIdenticalGridCaseGroup* gridCaseGroup = gridCaseGroupFromItemIndex(itemIndex); if (gridCaseGroup) { - std::vector > typedObjects; + std::vector > typedObjects; pdmObjects.createCopyByType(&typedObjects); if (typedObjects.size() == 0) @@ -626,24 +689,24 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO return; } - RimResultCase* mainResultCase = NULL; + RimEclipseResultCase* mainResultCase = NULL; std::vector< std::vector > mainCaseGridDimensions; // Read out main grid and main grid dimensions if present in case group if (gridCaseGroup->mainCase()) { - mainResultCase = dynamic_cast(gridCaseGroup->mainCase()); + mainResultCase = dynamic_cast(gridCaseGroup->mainCase()); CVF_ASSERT(mainResultCase); mainResultCase->readGridDimensions(mainCaseGridDimensions); } - std::vector insertedCases; + std::vector insertedCases; // Add cases to case group for (size_t i = 0; i < typedObjects.size(); i++) { - RimResultCase* rimResultReservoir = typedObjects[i]; + RimEclipseResultCase* rimResultReservoir = typedObjects[i]; proj->assignCaseIdToCase(rimResultReservoir); @@ -658,14 +721,14 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO // Initialize the new objects for (size_t i = 0; i < insertedCases.size(); i++) { - RimResultCase* rimResultReservoir = insertedCases[i]; + RimEclipseResultCase* rimResultReservoir = insertedCases[i]; caf::PdmDocument::initAfterReadTraversal(rimResultReservoir); } // Load stuff for (size_t i = 0; i < insertedCases.size(); i++) { - RimResultCase* rimResultReservoir = insertedCases[i]; + RimEclipseResultCase* rimResultReservoir = insertedCases[i]; if (!mainResultCase) @@ -693,7 +756,7 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO } RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimAnalysisModels* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir); caf::PdmDocument::updateUiIconStateRecursively(rimResultReservoir); @@ -710,33 +773,30 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO for (size_t rvIdx = 0; rvIdx < rimResultReservoir->reservoirViews.size(); rvIdx++) { - RimReservoirView* riv = rimResultReservoir->reservoirViews()[rvIdx]; + RimEclipseView* riv = rimResultReservoir->reservoirViews()[rvIdx]; riv->loadDataAndUpdate(); } } } else if (caseFromItemIndex(itemIndex)) { - std::vector > typedObjects; - pdmObjects.createCopyByType(&typedObjects); + std::vector > eclipseViews; + pdmObjects.createCopyByType(&eclipseViews); - if (typedObjects.size() == 0) + if (eclipseViews.size() != 0) { - return; - } - - RimCase* rimCase = caseFromItemIndex(itemIndex); + RimEclipseCase* rimCase = caseFromItemIndex(itemIndex); QModelIndex collectionIndex = getModelIndexFromPdmObject(rimCase); caf::PdmUiTreeItem* collectionItem = getTreeItemFromIndex(collectionIndex); // Add cases to case group - for (size_t i = 0; i < typedObjects.size(); i++) + for (size_t i = 0; i < eclipseViews.size(); i++) { - RimReservoirView* rimReservoirView = typedObjects[i]; + RimEclipseView* rimReservoirView = eclipseViews[i]; QString nameOfCopy = QString("Copy of ") + rimReservoirView->name; rimReservoirView->name = nameOfCopy; rimCase->reservoirViews().push_back(rimReservoirView); - + // Delete all wells to be able to copy/paste between cases, as the wells differ between cases rimReservoirView->wellCollection()->wells().deleteAllChildObjects(); @@ -745,7 +805,7 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView); - rimReservoirView->loadDataAndUpdate(); + rimReservoirView->loadDataAndUpdate(); int position = static_cast(rimCase->reservoirViews().size()); beginInsertRows(collectionIndex, position, position); @@ -754,6 +814,42 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO endInsertRows(); } + } + } + + caf::PdmObject* selectedObject = getTreeItemFromIndex(itemIndex)->dataObject().p(); + RimGeoMechCase* geomCase = dynamic_cast(selectedObject); + if (!geomCase && selectedObject) + { + RimGeoMechView* geomView = dynamic_cast(selectedObject); + if (geomView) geomCase = geomView->geoMechCase(); + } + + if (geomCase) + { + std::vector > geomViews; + pdmObjects.createCopyByType(&geomViews); + + if (geomViews.size() != 0) + { + // Add cases to case group + for (size_t i = 0; i < geomViews.size(); i++) + { + RimGeoMechView* rimReservoirView = geomViews[i]; + QString nameOfCopy = QString("Copy of ") + rimReservoirView->name; + rimReservoirView->name = nameOfCopy; + geomCase->geoMechViews().push_back(rimReservoirView); + + caf::PdmDocument::initAfterReadTraversal(rimReservoirView); + rimReservoirView->setGeoMechCase(geomCase); + + caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView); + + rimReservoirView->loadDataAndUpdate(); + + this->updateUiSubTree(geomCase); + } + } } } @@ -765,12 +861,12 @@ void RimUiTreeModelPdm::moveObjects(const QModelIndex& itemIndex, caf::PdmObject addObjects(itemIndex, pdmObjects); // Delete objects from original container - std::vector > typedObjects; + std::vector > typedObjects; pdmObjects.objectsByType(&typedObjects); for (size_t i = 0; i < typedObjects.size(); i++) { - RimCase* rimReservoir = typedObjects[i]; + RimEclipseCase* rimReservoir = typedObjects[i]; deleteReservoir(rimReservoir); } } @@ -859,7 +955,7 @@ Qt::ItemFlags RimUiTreeModelPdm::flags(const QModelIndex &index) const { return Qt::ItemIsDropEnabled | defaultFlags; } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { // TODO: Remember to handle reservoir holding the main grid return Qt::ItemIsDragEnabled | defaultFlags; @@ -943,9 +1039,9 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::gridCaseGroupFromItemIndex(const Q gridCaseGroup = caseCollection->parentCaseGroup(); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { - RimCase* rimReservoir = dynamic_cast(currentItem->dataObject().p()); + RimEclipseCase* rimReservoir = dynamic_cast(currentItem->dataObject().p()); CVF_ASSERT(rimReservoir); RimCaseCollection* caseCollection = rimReservoir->parentCaseCollection(); @@ -980,19 +1076,19 @@ void RimUiTreeModelPdm::addToParentAndBuildUiItems(caf::PdmUiTreeItem* parentTre //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase* RimUiTreeModelPdm::caseFromItemIndex(const QModelIndex& itemIndex) +RimEclipseCase* RimUiTreeModelPdm::caseFromItemIndex(const QModelIndex& itemIndex) { caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); - RimCase* rimCase = NULL; + RimEclipseCase* rimCase = NULL; - if (dynamic_cast(currentItem->dataObject().p())) + if (dynamic_cast(currentItem->dataObject().p())) { - rimCase = dynamic_cast(currentItem->dataObject().p()); + rimCase = dynamic_cast(currentItem->dataObject().p()); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { - RimReservoirView* reservoirView = dynamic_cast(currentItem->dataObject().p()); + RimEclipseView* reservoirView = dynamic_cast(currentItem->dataObject().p()); CVF_ASSERT(reservoirView); rimCase = reservoirView->eclipseCase(); @@ -1008,7 +1104,7 @@ void RimUiTreeModelPdm::setObjectToggleStateForSelection(QModelIndexList selecte { bool toggleOn = (state == Qt::Checked); - std::set resViewsToUpdate; + std::set resViewsToUpdate; foreach (QModelIndex index, selectedIndexes) { diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index a5a1a07730..40ebdfec28 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -27,14 +27,17 @@ class QFileSystemWatcher; -class RimCellPropertyFilter; +class RimEclipsePropertyFilter; class RimCellRangeFilter; -class RimCase; -class RimReservoirView; -class RimInputProperty; -class RimStatisticsCase; +class RimGeoMechPropertyFilter; +class RimEclipseCase; +class RimEclipseView; +class RimEclipseInputProperty; +class RimEclipseStatisticsCase; class RimIdenticalGridCaseGroup; +class RimView; + //================================================================================================== /// @@ -47,21 +50,23 @@ class RimUiTreeModelPdm : public caf::UiTreeModelPdm public: RimUiTreeModelPdm(QObject* parent); - - // TO BE DELETED, NOT USED - virtual bool insertRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); - // Special edit methods bool deleteRangeFilter(const QModelIndex& itemIndex); bool deletePropertyFilter(const QModelIndex& itemIndex); - bool deleteReservoirView(const QModelIndex& itemIndex); + bool deleteGeoMechPropertyFilter(const QModelIndex& itemIndex); + void deleteInputProperty(const QModelIndex& itemIndex); - void deleteReservoir(RimCase* reservoir); + void deleteReservoir(RimEclipseCase* reservoir); void deleteAllWellPaths(const QModelIndex& itemIndex); - RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimEclipsePropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimGeoMechPropertyFilter* addGeoMechPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); - RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + + RimView* addReservoirView(const std::vector& treeSelection); + void deleteReservoirViews(const std::vector& treeSelection); + void deleteGeoMechCases(const std::vector& treeSelection); + void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); void addToParentAndBuildUiItems(caf::PdmUiTreeItem* parentTreeItem, int position, caf::PdmObject* pdmObject); @@ -70,7 +75,7 @@ class RimUiTreeModelPdm : public caf::UiTreeModelPdm void addObjects(const QModelIndex& itemIndex, const caf::PdmObjectGroup& pdmObjects); void moveObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); - RimStatisticsCase* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimEclipseStatisticsCase* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimIdenticalGridCaseGroup* addCaseGroup(QModelIndex& insertedModelIndex); bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex); @@ -91,7 +96,7 @@ private slots: private: void clearClipboard(); - RimCase* caseFromItemIndex(const QModelIndex& itemIndex); + RimEclipseCase* caseFromItemIndex(const QModelIndex& itemIndex); private: QFileSystemWatcher* m_scriptChangeDetector; }; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index a8a4e1dd3f..68a0e411e7 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -35,39 +35,44 @@ #include "RimUiTreeView.h" #include "RimUiTreeModelPdm.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RimCalcScript.h" #include "RiaApplication.h" #include "RiuMainWindow.h" -#include "RimInputPropertyCollection.h" +#include "RimEclipseInputPropertyCollection.h" #include "RimExportInputPropertySettings.h" #include "RiaPreferences.h" #include "RifEclipseInputFileTools.h" -#include "RimInputCase.h" +#include "RimEclipseInputCase.h" #include "RimBinaryExportSettings.h" #include "RigCaseCellResultsData.h" -#include "RimStatisticsCase.h" -#include "RimResultCase.h" +#include "RimEclipseStatisticsCase.h" +#include "RimEclipseResultCase.h" #include "RimMimeData.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimResultSlot.h" -#include "RimStatisticsCaseCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimCellRangeFilterCollection.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseStatisticsCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" #include "RimCaseCollection.h" #include "RimScriptCollection.h" -#include "RimWell.h" -#include "RimCellEdgeResultSlot.h" -#include "RimWellCollection.h" +#include "RimEclipseWell.h" +#include "RimCellEdgeColors.h" +#include "RimEclipseWellCollection.h" #include "RimWellPathCollection.h" #include "RimReservoirCellResultsStorage.h" #include "Rim3dOverlayInfoConfig.h" #include "RimProject.h" #include "RimOilField.h" -#include "RimAnalysisModels.h" -#include "RimInputProperty.h" +#include "RimEclipseCaseCollection.h" +#include "RimEclipseInputProperty.h" #include "RigSingleWellResultsData.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCase.h" //-------------------------------------------------------------------------------------------------- @@ -114,8 +119,14 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; - // Range filters - if (dynamic_cast(uiItem->dataObject().p())) + if (dynamic_cast(uiItem->dataObject().p())) + { + menu.addAction(QString("New View"), this, SLOT(slotAddView())); + menu.addAction(QString("Copy View"), this, SLOT(slotCopyPdmObjectToClipboard())); + menu.addAction(m_pasteAction); + menu.addAction(QString("Delete"), this, SLOT(slotDeleteView())); + } + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.addAction(QString("Copy View"), this, SLOT(slotCopyPdmObjectToClipboard())); @@ -138,16 +149,26 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addSeparator(); menu.addAction(QString("Delete"), this, SLOT(slotDeleteRangeFilter())); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("New Property Filter"), this, SLOT(slotAddPropertyFilter())); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("Insert Property Filter"), this, SLOT(slotAddPropertyFilter())); menu.addSeparator(); menu.addAction(QString("Delete"), this, SLOT(slotDeletePropertyFilter())); } + else if (dynamic_cast(uiItem->dataObject().p())) + { + menu.addAction(QString("New Property Filter"), this, SLOT(slotAddGeoMechPropertyFilter())); + } + else if (dynamic_cast(uiItem->dataObject().p())) + { + menu.addAction(QString("Insert Property Filter"), this, SLOT(slotAddGeoMechPropertyFilter())); + menu.addSeparator(); + menu.addAction(QString("Delete"), this, SLOT(slotDeleteGeoMechPropertyFilter())); + } else if (dynamic_cast(uiItem->dataObject().p())) { RiaApplication* app = RiaApplication::instance(); @@ -170,30 +191,36 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) } } } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("Add Input Property"), this, SLOT(slotAddInputProperty())); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("Delete"), this, SLOT(slotDeleteObjectFromContainer())); menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteInputProperty())); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty())); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("New Statistics Case"), this, SLOT(slotNewStatisticsCase())); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.addAction(QString("Compute"), this, SLOT(slotComputeStatistics())); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) + { + menu.addAction(QString("New View"), this, SLOT(slotAddView())); + menu.addAction(QString("Close"), this, SLOT(slotCloseGeomechCase())); + menu.addAction(m_pasteAction); + } + else if (dynamic_cast(uiItem->dataObject().p())) { menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard())); menu.addAction(m_pasteAction); @@ -230,7 +257,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) RiuMainWindow* ruiMainWindow = RiuMainWindow::instance(); ruiMainWindow->appendActionsContextMenuForPdmObject(uiItem->dataObject().p(), &menu); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { RiuMainWindow* ruiMainWindow = RiuMainWindow::instance(); ruiMainWindow->appendActionsContextMenuForPdmObject(uiItem->dataObject().p(), &menu); @@ -339,7 +366,7 @@ void RimUiTreeView::slotAddPropertyFilter() if (myModel) { QModelIndex insertedIndex; - RimCellPropertyFilter* propFilter = myModel->addPropertyFilter(currentIndex(), insertedIndex); + RimEclipsePropertyFilter* propFilter = myModel->addPropertyFilter(currentIndex(), insertedIndex); setCurrentIndex(insertedIndex); if (propFilter) { @@ -348,6 +375,37 @@ void RimUiTreeView::slotAddPropertyFilter() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotAddGeoMechPropertyFilter() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + QModelIndex insertedIndex; + RimGeoMechPropertyFilter* propFilter = myModel->addGeoMechPropertyFilter(currentIndex(), insertedIndex); + setCurrentIndex(insertedIndex); + if (propFilter) + { + propFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotDeleteGeoMechPropertyFilter() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + myModel->deleteGeoMechPropertyFilter(currentIndex()); + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -382,8 +440,8 @@ void RimUiTreeView::slotAddSliceFilterI() rangeFilter->name = QString("Slice I (%1)").arg(rangeFilterCollection->rangeFilters().size()); rangeFilter->cellCountI = 1; - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); @@ -406,8 +464,8 @@ void RimUiTreeView::slotAddSliceFilterJ() rangeFilter->name = QString("Slice J (%1)").arg(rangeFilterCollection->rangeFilters().size()); rangeFilter->cellCountJ = 1; - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); @@ -430,8 +488,8 @@ void RimUiTreeView::slotAddSliceFilterK() rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size()); rangeFilter->cellCountK = 1; - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); @@ -604,12 +662,12 @@ void RimUiTreeView::slotExecuteScriptForSelectedCases() myModel->populateObjectGroupFromModelIndexList(mil, &group); - std::vector > typedObjects; + std::vector > typedObjects; group.objectsByType(&typedObjects); for (size_t i = 0; i < typedObjects.size(); i++) { - RimCase* rimReservoir = typedObjects[i]; + RimEclipseCase* rimReservoir = typedObjects[i]; caseIdsInSelection.push_back(rimReservoir->caseId); } } @@ -628,13 +686,13 @@ void RimUiTreeView::slotExecuteScriptForSelectedCases() //-------------------------------------------------------------------------------------------------- void RimUiTreeView::slotAddView() { - QModelIndex index = currentIndex(); RimUiTreeModelPdm* myModel = dynamic_cast(model()); - caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - - QModelIndex insertedIndex; - myModel->addReservoirView(index, insertedIndex); - + std::vector selection; + this->selectedUiItems(selection); + + RimView* newView = myModel->addReservoirView(selection); + QModelIndex insertedIndex = myModel->getModelIndexFromPdmObject(newView); + // Expand parent collection and inserted view item setExpandedUpToRoot(insertedIndex); @@ -647,13 +705,12 @@ void RimUiTreeView::slotAddView() void RimUiTreeView::slotDeleteView() { RimUiTreeModelPdm* myModel = dynamic_cast(model()); - if (myModel) - { - myModel->deleteReservoirView(currentIndex()); + std::vector selection; + this->selectedUiItems(selection); + myModel->deleteReservoirViews(selection); - RiaApplication* app = RiaApplication::instance(); - app->setActiveReservoirView(NULL); - } + RiaApplication* app = RiaApplication::instance(); + app->setActiveReservoirView(NULL); } //-------------------------------------------------------------------------------------------------- @@ -716,7 +773,7 @@ void RimUiTreeView::slotAddInputProperty() RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - RimInputPropertyCollection* inputPropertyCollection = dynamic_cast(uiItem->dataObject().p()); + RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast(uiItem->dataObject().p()); if (inputPropertyCollection) { myModel->addInputProperty(index, fileNames); @@ -747,12 +804,12 @@ void RimUiTreeView::slotWriteInputProperty() RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - RimInputProperty* inputProperty = dynamic_cast(uiItem->dataObject().p()); + RimEclipseInputProperty* inputProperty = dynamic_cast(uiItem->dataObject().p()); if (!inputProperty) return; { bool isResolved = false; - if (inputProperty->resolvedState == RimInputProperty::RESOLVED || inputProperty->resolvedState == RimInputProperty::RESOLVED_NOT_SAVED) + if (inputProperty->resolvedState == RimEclipseInputProperty::RESOLVED || inputProperty->resolvedState == RimEclipseInputProperty::RESOLVED_NOT_SAVED) { isResolved = true; } @@ -769,16 +826,16 @@ void RimUiTreeView::slotWriteInputProperty() exportSettings.eclipseKeyword = inputProperty->eclipseKeyword; // Find input reservoir for this property - RimInputCase* inputReservoir = NULL; + RimEclipseInputCase* inputReservoir = NULL; { - std::vector parentObjects; + std::vector parentObjects; inputProperty->parentObjectsOfType(parentObjects); CVF_ASSERT(parentObjects.size() == 1); - RimInputPropertyCollection* inputPropertyCollection = parentObjects[0]; + RimEclipseInputPropertyCollection* inputPropertyCollection = parentObjects[0]; if (!inputPropertyCollection) return; - std::vector parentObjects2; + std::vector parentObjects2; inputPropertyCollection->parentObjectsOfType(parentObjects2); CVF_ASSERT(parentObjects2.size() == 1); @@ -815,7 +872,7 @@ void RimUiTreeView::slotWriteInputProperty() { inputProperty->fileName = exportSettings.fileName; inputProperty->eclipseKeyword = exportSettings.eclipseKeyword; - inputProperty->resolvedState = RimInputProperty::RESOLVED; + inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED; inputProperty->updateConnectedEditors(); } @@ -831,14 +888,14 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - RimResultSlot* resultSlot = dynamic_cast(uiItem->dataObject().p()); - if (!resultSlot) return; - if (!resultSlot->reservoirView()) return; - if (!resultSlot->reservoirView()->eclipseCase()) return; - if (!resultSlot->reservoirView()->eclipseCase()->reservoirData()) return; + RimEclipseCellColors* resultColors = dynamic_cast(uiItem->dataObject().p()); + if (!resultColors) return; + if (!resultColors->reservoirView()) return; + if (!resultColors->reservoirView()->eclipseCase()) return; + if (!resultColors->reservoirView()->eclipseCase()->reservoirData()) return; RimBinaryExportSettings exportSettings; - exportSettings.eclipseKeyword = resultSlot->resultVariable(); + exportSettings.eclipseKeyword = resultColors->resultVariable(); { QString projectFolder; @@ -852,10 +909,10 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() } else { - projectFolder = resultSlot->reservoirView()->eclipseCase()->locationOnDisc(); + projectFolder = resultColors->reservoirView()->eclipseCase()->locationOnDisc(); } - QString outputFileName = projectFolder + "/" + resultSlot->resultVariable(); + QString outputFileName = projectFolder + "/" + resultColors->resultVariable(); exportSettings.fileName = outputFileName; } @@ -863,10 +920,10 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() caf::PdmUiPropertyDialog propertyDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File"); if (propertyDialog.exec() == QDialog::Accepted) { - size_t timeStep = resultSlot->reservoirView()->currentTimeStep(); - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel()); + size_t timeStep = resultColors->reservoirView()->currentTimeStep(); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultColors->porosityModel()); - bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultSlot->reservoirView()->eclipseCase()->reservoirData(), porosityModel, timeStep, resultSlot->resultVariable(), exportSettings.eclipseKeyword, exportSettings.undefinedValue); + bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultColors->reservoirView()->eclipseCase()->reservoirData(), porosityModel, timeStep, resultColors->resultVariable(), exportSettings.eclipseKeyword, exportSettings.undefinedValue); if (!isOk) { QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName); @@ -895,12 +952,12 @@ void RimUiTreeView::slotCloseCase() QModelIndexList mil = m->selectedRows(); myModel->populateObjectGroupFromModelIndexList(mil, &group); - std::vector > typedObjects; + std::vector > typedObjects; group.objectsByType(&typedObjects); for (size_t i = 0; i < typedObjects.size(); i++) { - RimCase* rimReservoir = typedObjects[i]; + RimEclipseCase* rimReservoir = typedObjects[i]; myModel->deleteReservoir(rimReservoir); } } @@ -916,7 +973,7 @@ void RimUiTreeView::slotNewStatisticsCase() if (myModel) { QModelIndex insertedIndex; - RimStatisticsCase* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex); + RimEclipseStatisticsCase* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex); setCurrentIndex(insertedIndex); setExpanded(insertedIndex, true); @@ -932,7 +989,7 @@ void RimUiTreeView::slotComputeStatistics() RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - RimStatisticsCase* statisticsCase = dynamic_cast(uiItem->dataObject().p()); + RimEclipseStatisticsCase* statisticsCase = dynamic_cast(uiItem->dataObject().p()); if (!statisticsCase) return; statisticsCase->computeStatistics(); @@ -1050,8 +1107,8 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); if (uiItem) { - if (dynamic_cast(uiItem->dataObject().p()) - || dynamic_cast(uiItem->dataObject().p())) + if (dynamic_cast(uiItem->dataObject().p()) + || dynamic_cast(uiItem->dataObject().p())) { if (keyEvent->matches(QKeySequence::Copy)) { @@ -1064,8 +1121,8 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) if (dynamic_cast(uiItem->dataObject().p()) || dynamic_cast(uiItem->dataObject().p()) - || dynamic_cast(uiItem->dataObject().p()) - || dynamic_cast(uiItem->dataObject().p())) + || dynamic_cast(uiItem->dataObject().p()) + || dynamic_cast(uiItem->dataObject().p())) { if (keyEvent->matches(QKeySequence::Paste)) { @@ -1221,7 +1278,7 @@ bool RimUiTreeView::hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gridCaseG for (size_t i = 0; i < gridCaseGroup->statisticsCaseCollection()->reservoirs().size(); i++) { - RimStatisticsCase* rimStaticsCase = dynamic_cast(gridCaseGroup->statisticsCaseCollection()->reservoirs[i]); + RimEclipseStatisticsCase* rimStaticsCase = dynamic_cast(gridCaseGroup->statisticsCaseCollection()->reservoirs[i]); if (rimStaticsCase) { if (rimStaticsCase->hasComputedStatistics()) @@ -1587,3 +1644,33 @@ void RimUiTreeView::slotDeleteAllWellPaths() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::selectedUiItems(std::vector& objects) +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + QModelIndexList idxList = this->selectionModel()->selectedIndexes(); + + for (int i = 0; i < idxList.size(); i++) + { + caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(idxList[i]); + if (uiItem) + { + caf::PdmUiItem* item = uiItem->dataObject(); + objects.push_back(item); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotCloseGeomechCase() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + std::vector selection; + this->selectedUiItems(selection); + myModel->deleteGeoMechCases(selection); + +} diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 204e961d26..8475748e70 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -44,6 +44,9 @@ class RimUiTreeView : public QTreeView virtual void setModel(QAbstractItemModel* model); + void selectedUiItems(std::vector& objects); + + void applyTreeViewStateFromString(const QString& treeViewState); void storeTreeViewStateToString(QString& treeViewState); @@ -65,6 +68,8 @@ private slots: void slotAddPropertyFilter(); void slotDeletePropertyFilter(); + void slotAddGeoMechPropertyFilter(); + void slotDeleteGeoMechPropertyFilter(); void slotEditScript(); void slotNewScript(); @@ -80,6 +85,7 @@ private slots: void slotWriteBinaryResultAsInputProperty(); void slotCloseCase(); + void slotCloseGeomechCase(); void slotNewStatisticsCase(); void slotComputeStatistics(); diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/RimView.cpp new file mode 100644 index 0000000000..1620ce362e --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimView.cpp @@ -0,0 +1,486 @@ +#include "RimView.h" +#include "cafPdmObjectFactory.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" +#include "Rim3dOverlayInfoConfig.h" +#include "RiuViewer.h" +#include "RiuMainWindow.h" +#include "cvfCamera.h" +#include "cvfModel.h" +#include "cvfModelBasicList.h" +#include "cvfPart.h" +#include "cvfScene.h" +#include "cvfViewport.h" +#include "cafFrameAnimationControl.h" + +#include +#include "RimOilField.h" +#include "RimWellPathCollection.h" +#include "RimProject.h" +#include "RivWellPathCollectionPartMgr.h" + + +namespace caf { + +template<> +void caf::AppEnum< RimView::MeshModeType >::setUp() +{ + addItem(RimView::FULL_MESH, "FULL_MESH", "All"); + addItem(RimView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); + addItem(RimView::NO_MESH, "NO_MESH", "None"); + setDefault(RimView::FULL_MESH); +} + +template<> +void caf::AppEnum< RimView::SurfaceModeType >::setUp() +{ + addItem(RimView::SURFACE, "SURFACE", "All"); + addItem(RimView::FAULTS, "FAULTS", "Faults only"); + addItem(RimView::NO_SURFACE, "NO_SURFACE", "None"); + setDefault(RimView::SURFACE); +} + +} // End namespace caf + + +#include "cafPdmAbstractClassSourceInit.h" + +CAF_PDM_ABSTRACT_SOURCE_INIT(RimView, "GenericView"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimView::RimView(void) +{ + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + CVF_ASSERT(preferences); + + + CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); + + CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", ""); + showWindow.setUiHidden(true); + CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); + + double defaultScaleFactor = 1.0; + if (preferences) defaultScaleFactor = preferences->defaultScaleFactorZ; + CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); + + cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); + CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); + + CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate", "", "", ""); + maximumFrameRate.setUiHidden(true); + CAF_PDM_InitField(&hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", ""); + hasUserRequestedAnimation.setUiHidden(true); + + CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", ""); + m_currentTimeStep.setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); + overlayInfoConfig = new Rim3dOverlayInfoConfig(); + overlayInfoConfig->setReservoirView(this); + + caf::AppEnum defaultMeshType = NO_MESH; + if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; + CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", ""); + CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", ""); + + CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); + + m_previousGridModeMeshLinesWasFaults = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimView::~RimView(void) +{ + delete this->overlayInfoConfig(); + + if (m_viewer) + { + RiuMainWindow::instance()->removeViewer(m_viewer); + } + + delete m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuViewer* RimView::viewer() +{ + return m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::updateViewerWidget() +{ + if (showWindow()) + { + bool isViewerCreated = false; + if (!m_viewer) + { + QGLFormat glFormat; + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + + m_viewer = new RiuViewer(glFormat, NULL); + m_viewer->setOwnerReservoirView(this); + + RiuMainWindow::instance()->addViewer(m_viewer); + m_viewer->setMinNearPlaneDistance(10); + + this->resetLegendsInViewer(); + + m_viewer->updateNavigationPolicy(); + m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); + + isViewerCreated = true; + } + + RiuMainWindow::instance()->setActiveViewer(m_viewer); + + if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition); + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + + m_viewer->update(); + } + else + { + if (m_viewer) + { + if (m_viewer->layoutWidget()->parentWidget()) + { + m_viewer->layoutWidget()->parentWidget()->hide(); + } + else + { + m_viewer->layoutWidget()->hide(); + } + } + } + + updateViewerWidgetWindowTitle(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::scheduleCreateDisplayModelAndRedraw() +{ + RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setCurrentTimeStep(int frameIndex) +{ + m_currentTimeStep = frameIndex; + this->hasUserRequestedAnimation = true; + this->updateCurrentTimeStep(); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::updateCurrentTimeStepAndRedraw() +{ + this->updateCurrentTimeStep(); + + if (m_viewer) m_viewer->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::createDisplayModelAndRedraw() +{ + if (m_viewer) + { + this->clampCurrentTimestep(); + + createDisplayModel(); + updateDisplayModelVisibility(); + } + + RiuMainWindow::instance()->refreshAnimationActions(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setDefaultView() +{ + if (m_viewer) + { + m_viewer->setDefaultView(); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::endAnimation() +{ + this->hasUserRequestedAnimation = false; + this->updateStaticCellColors(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setupBeforeSave() +{ + if (m_viewer) + { + hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice... + cameraPosition = m_viewer->mainCamera()->viewMatrix(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +// Surf: No Fault Surf +// Mesh ------------- +// No F F G +// Fault F F G +// Mesh G G G +// +//-------------------------------------------------------------------------------------------------- +bool RimView::isGridVisualizationMode() const +{ + return ( this->surfaceMode() == SURFACE + || this->meshMode() == FULL_MESH); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setMeshOnlyDrawstyle() +{ + if (isGridVisualizationMode()) + { + meshMode.setValueFromUi(FULL_MESH); + } + else + { + meshMode.setValueFromUi(FAULTS_MESH); + } + + surfaceMode.setValueFromUi(NO_SURFACE); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setMeshSurfDrawstyle() +{ + if (isGridVisualizationMode()) + { + surfaceMode.setValueFromUi(SURFACE); + meshMode.setValueFromUi(FULL_MESH); + } + else + { + surfaceMode.setValueFromUi(FAULTS); + meshMode.setValueFromUi(FAULTS_MESH); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setFaultMeshSurfDrawstyle() +{ + // Surf: No Fault Surf + // Mesh ------------- + // No FF FF SF + // Fault FF FF SF + // Mesh SF SF SF + if (this->isGridVisualizationMode()) + { + surfaceMode.setValueFromUi(SURFACE); + } + else + { + surfaceMode.setValueFromUi(FAULTS); + } + + meshMode.setValueFromUi(FAULTS_MESH); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setSurfOnlyDrawstyle() +{ + if (isGridVisualizationMode()) + { + surfaceMode.setValueFromUi(SURFACE); + } + else + { + surfaceMode.setValueFromUi(FAULTS); + } + meshMode.setValueFromUi(NO_MESH); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setShowFaultsOnly(bool showFaults) +{ + if (showFaults) + { + m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(FAULTS); + if (meshMode() != NO_MESH) meshMode.setValueFromUi(FAULTS_MESH); + } + else + { + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE); + if (meshMode() != NO_MESH) meshMode.setValueFromUi(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH: FULL_MESH); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::setSurfaceDrawstyle() +{ + if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::disableLighting(bool disable) +{ + m_disableLighting = disable; + updateCurrentTimeStepAndRedraw(); + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimView::isLightingDisabled() const +{ + return m_disableLighting(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &meshMode) + { + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + } + else if (changedField == &scaleZ) + { + if (scaleZ < 1) scaleZ = 1; + + // Regenerate well paths + RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; + RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; + if (wellPathCollection) wellPathCollection->wellPathCollectionPartMgr()->scheduleGeometryRegen(); + + if (m_viewer) + { + cvf::Vec3d poi = m_viewer->pointOfInterest(); + cvf::Vec3d eye, dir, up; + eye = m_viewer->mainCamera()->position(); + dir = m_viewer->mainCamera()->direction(); + up = m_viewer->mainCamera()->up(); + + eye[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]); + poi[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2); + + m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up); + m_viewer->setPointOfInterest(poi); + + updateScaleTransform(); + createDisplayModelAndRedraw(); + m_viewer->update(); + } + + RiuMainWindow::instance()->updateScaleValue(); + } + else if (changedField == &surfaceMode) + { + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + } + else if (changedField == &m_disableLighting) + { + createDisplayModel(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + } + else if (changedField == &name) + { + updateViewerWidgetWindowTitle(); + } + else if (changedField == &m_currentTimeStep) + { + if (m_viewer) + { + m_viewer->update(); + } + } + else if (changedField == &backgroundColor) + { + if (viewer() != NULL) + { + updateViewerWidget(); + } + } + else if (changedField == &maximumFrameRate) + { + // !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0? + // !! Should be able to specify legal range for number properties + if (m_viewer) + { + m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, + const cvf::Vec3d& displayModelOffset, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + cvf::Transform* scaleTransform) +{ + RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; + RimWellPathCollection* wellPathCollection = oilFields ? oilFields->wellPathCollection() : NULL; + RivWellPathCollectionPartMgr* wellPathCollectionPartMgr = wellPathCollection ? wellPathCollection->wellPathCollectionPartMgr() : NULL; + + if (wellPathCollectionPartMgr) + { + wellPathCollectionPartMgr->appendStaticGeometryPartsToModel(wellPathModelBasicList, + displayModelOffset, + scaleTransform, + characteristicCellSize, + wellPathClipBoundingBox); + } + + wellPathModelBasicList->updateBoundingBoxesRecursive(); +} diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/RimView.h new file mode 100644 index 0000000000..5846d1fec2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimView.h @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cafPdmObject.h" +#include "cafPdmField.h" +#include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" +#include "cafAppEnum.h" +#include "RivCellSetEnum.h" + +class RiuViewer; +class Rim3dOverlayInfoConfig; +class RimCase; +class RimCellRangeFilterCollection; + +namespace cvf +{ + class BoundingBox; + class Scene; + class ModelBasicList; + class Transform; +} + +//================================================================================================== +/// +/// +//================================================================================================== +class RimView : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimView(void); + virtual ~RimView(void); + + // 3D Viewer + RiuViewer* viewer(); + + caf::PdmField name; + caf::PdmField scaleZ; + + caf::PdmField showWindow; + caf::PdmField cameraPosition; + caf::PdmField< cvf::Color3f > backgroundColor; + + caf::PdmField maximumFrameRate; + caf::PdmField hasUserRequestedAnimation; + + caf::PdmField rangeFilterCollection; + + // Draw style + + enum MeshModeType + { + FULL_MESH, + FAULTS_MESH, + NO_MESH + }; + + enum SurfaceModeType + { + SURFACE, + FAULTS, + NO_SURFACE + }; + + caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; + caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; + + void setMeshOnlyDrawstyle(); + void setMeshSurfDrawstyle(); + void setSurfOnlyDrawstyle(); + void setFaultMeshSurfDrawstyle(); + void setSurfaceDrawstyle(); + + void disableLighting(bool disable); + bool isLightingDisabled() const; + + void setShowFaultsOnly(bool showFaults); + bool isGridVisualizationMode() const; + + // Animation + int currentTimeStep() { return m_currentTimeStep;} + void setCurrentTimeStep(int frameIdx); + void updateCurrentTimeStepAndRedraw(); + void endAnimation(); + + virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) = 0; + void scheduleCreateDisplayModelAndRedraw(); + void createDisplayModelAndRedraw(); + +public: + virtual void loadDataAndUpdate() = 0; + virtual RimCase* ownerCase() = 0; + + virtual caf::PdmFieldHandle* objectToggleField() { return &showWindow; } + virtual caf::PdmFieldHandle* userDescriptionField() { return &name; } +protected: + + void setDefaultView(); + + void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, + const cvf::Vec3d& displayModelOffset, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + cvf::Transform* scaleTransform); + + virtual void createDisplayModel() = 0; + virtual void updateDisplayModelVisibility() = 0; + virtual void clampCurrentTimestep() = 0; + + virtual void updateCurrentTimeStep() = 0; + virtual void updateStaticCellColors() = 0; + + virtual void updateScaleTransform() = 0; + virtual cvf::Transform* scaleTransform() = 0; + + void updateViewerWidget(); + virtual void updateViewerWidgetWindowTitle() = 0; + + virtual void resetLegendsInViewer() = 0; + + QPointer m_viewer; + + caf::PdmField m_currentTimeStep; + caf::PdmField overlayInfoConfig; + + // Overridden PDM methods: + virtual void setupBeforeSave(); + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + +private: + bool m_previousGridModeMeshLinesWasFaults; + caf::PdmField m_disableLighting; + +}; + + + diff --git a/ApplicationCode/ProjectDataModel/cafPdmAbstractClassSourceInit.h b/ApplicationCode/ProjectDataModel/cafPdmAbstractClassSourceInit.h new file mode 100644 index 0000000000..896365aa5f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/cafPdmAbstractClassSourceInit.h @@ -0,0 +1,8 @@ +#pragma once + + +#define CAF_PDM_ABSTRACT_SOURCE_INIT(ClassName, keyword) \ + bool ClassName::Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class() { return false;} \ + QString ClassName::classKeywordStatic() { assert(PdmObject::isValidXmlElementName(keyword)); return keyword; } + + diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 06835f0e32..f1e142c668 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -24,7 +24,6 @@ ${CEE_CURRENT_LIST_DIR}RigMainGrid.h ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h ${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h ${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.h -${CEE_CURRENT_LIST_DIR}RigStatisticsMath.h ${CEE_CURRENT_LIST_DIR}RigWellPath.h ${CEE_CURRENT_LIST_DIR}RigFault.h ${CEE_CURRENT_LIST_DIR}RigNNCData.h @@ -33,8 +32,8 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl ${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h ${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h -${CEE_CURRENT_LIST_DIR}RigStatisticsDataCache.h -${CEE_CURRENT_LIST_DIR}RigStatisticsCalculator.h +${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.h +${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -56,14 +55,13 @@ ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp ${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp ${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.cpp -${CEE_CURRENT_LIST_DIR}RigStatisticsMath.cpp ${CEE_CURRENT_LIST_DIR}RigWellPath.cpp ${CEE_CURRENT_LIST_DIR}RigFault.cpp ${CEE_CURRENT_LIST_DIR}RigNNCData.cpp ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp -${CEE_CURRENT_LIST_DIR}RigStatisticsDataCache.cpp -${CEE_CURRENT_LIST_DIR}RigStatisticsCalculator.cpp +${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.cpp +${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.cpp ) list(APPEND CODE_HEADER_FILES @@ -74,4 +72,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ReservoirDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ) +source_group( "ReservoirDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt index 6152868dbe..b066ea1698 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt @@ -14,6 +14,7 @@ include_directories( ${LibViewing_SOURCE_DIR} ${ResInsight_SOURCE_DIR}/ApplicationCode + ${ResInsight_SOURCE_DIR}/ApplicationCode/ResultStatisticsCache ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel ${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface ${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel @@ -53,6 +54,8 @@ source_group( "UnitTests" FILES ${UNIT_TEST_CPP_SOURCES} ) set( LINK_LIBRARIES CommonCode + ResultStatisticsCache + LibViewing LibRender LibGeometry @@ -87,6 +90,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ") +ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_CXX_FLAGS "-DGTEST_USE_OWN_TR1_TUPLE=1") ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index cbe1826d8b..6a1ca42898 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -23,7 +23,8 @@ #include "RigMainGrid.h" #include "RigStatisticsDataCache.h" #include "RigStatisticsMath.h" -#include "RigStatisticsCalculator.h" +#include "RigMultipleDatasetStatCalc.h" +#include "RigNativeStatCalc.h" #include #include @@ -553,9 +554,7 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() // riTRANSXYZ and X,Y,Z { - size_t ntgResIdx = findScalarResultIndex(RimDefines::STATIC_NATIVE, "NTG"); - if ( findScalarResultIndex(RimDefines::STATIC_NATIVE, "NTG") != cvf::UNDEFINED_SIZE_T - && findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMX") != cvf::UNDEFINED_SIZE_T + if ( findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMX") != cvf::UNDEFINED_SIZE_T && findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMY") != cvf::UNDEFINED_SIZE_T && findScalarResultIndex(RimDefines::STATIC_NATIVE, "PERMZ") != cvf::UNDEFINED_SIZE_T) { diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index dc5ddf4182..461339bc77 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -23,6 +23,7 @@ #include "RifReaderInterface.h" #include "RimDefines.h" +#include "RigStatisticsDataCache.h" #include @@ -31,7 +32,6 @@ class RifReaderInterface; class RigMainGrid; -class RigStatisticsDataCache; class RigActiveCellInfo; //================================================================================================== diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigMultipleDatasetStatCalc.cpp similarity index 53% rename from ApplicationCode/ReservoirDataModel/RigStatisticsCalculator.cpp rename to ApplicationCode/ReservoirDataModel/RigMultipleDatasetStatCalc.cpp index af56724a2d..8db3f8a136 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMultipleDatasetStatCalc.cpp @@ -17,149 +17,8 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigStatisticsCalculator.h" - -#include "RigStatisticsMath.h" -#include "RigCaseCellResultsData.h" - -#include // Needed for HUGE_VAL on Linux - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigStatisticsCalculator::meanCellScalarValue(double& meanValue) -{ - double valueSum = 0.0; - size_t sampleCount = 0; - - this->valueSumAndSampleCount(valueSum, sampleCount); - - if (sampleCount == 0) - { - meanValue = HUGE_VAL; - } - else - { - meanValue = valueSum / sampleCount; - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigNativeStatCalc::RigNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex) - : m_resultsData(cellResultsData), - m_scalarResultIndex(scalarResultIndex) -{ - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) -{ - std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex); - - size_t i; - for (i = 0; i < values.size(); i++) - { - if (values[i] == HUGE_VAL) - { - continue; - } - - if (values[i] < min) - { - min = values[i]; - } - - if (values[i] > max) - { - max = values[i]; - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) -{ - std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex); - - size_t i; - for (i = 0; i < values.size(); i++) - { - if (values[i] == HUGE_VAL) - { - continue; - } - - if (values[i] < pos && values[i] > 0) - { - pos = values[i]; - } - - if (values[i] > neg && values[i] < 0) - { - neg = values[i]; - } - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigNativeStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator) -{ - for (size_t tIdx = 0; tIdx < m_resultsData->timeStepCount(m_scalarResultIndex); tIdx++) - { - std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, tIdx); - - histogramCalculator.addData(values); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigNativeStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount) -{ - for (size_t tIdx = 0; tIdx < m_resultsData->timeStepCount(m_scalarResultIndex); tIdx++) - { - std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, tIdx); - size_t undefValueCount = 0; - for (size_t cIdx = 0; cIdx < values.size(); ++cIdx) - { - double value = values[cIdx]; - if (value == HUGE_VAL || value != value) - { - ++undefValueCount; - continue; - } - - valueSum += value; - } - - sampleCount += values.size(); - sampleCount -= undefValueCount; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigNativeStatCalc::timeStepCount() -{ - return m_resultsData->timeStepCount(m_scalarResultIndex); -} - - - +#include "RigMultipleDatasetStatCalc.h" +#include "RigNativeStatCalc.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsCalculator.h b/ApplicationCode/ReservoirDataModel/RigMultipleDatasetStatCalc.h similarity index 55% rename from ApplicationCode/ReservoirDataModel/RigStatisticsCalculator.h rename to ApplicationCode/ReservoirDataModel/RigMultipleDatasetStatCalc.h index 011384b67b..6085aa2e1c 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigMultipleDatasetStatCalc.h @@ -19,6 +19,8 @@ #pragma once +#include "RigStatisticsCalculator.h" + #include "cvfBase.h" #include "cvfObject.h" #include "cvfCollection.h" @@ -28,43 +30,6 @@ class RigHistogramCalculator; class RigCaseCellResultsData; -//================================================================================================== -/// -//================================================================================================== -class RigStatisticsCalculator : public cvf::Object -{ -public: - virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) = 0; - virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) = 0; - - void meanCellScalarValue(double& meanValue); - virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount) = 0; - virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator) = 0; - - virtual size_t timeStepCount() = 0; -}; - - -//================================================================================================== -/// -//================================================================================================== -class RigNativeStatCalc : public RigStatisticsCalculator -{ -public: - RigNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex); - - virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max); - virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg); - virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount); - - virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator); - virtual size_t timeStepCount(); - -private: - RigCaseCellResultsData* m_resultsData; - size_t m_scalarResultIndex; -}; - //================================================================================================== /// diff --git a/ApplicationCode/ReservoirDataModel/RigNativeStatCalc.cpp b/ApplicationCode/ReservoirDataModel/RigNativeStatCalc.cpp new file mode 100644 index 0000000000..605537c75f --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigNativeStatCalc.cpp @@ -0,0 +1,139 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "RigNativeStatCalc.h" + +#include "RigStatisticsMath.h" +#include "RigCaseCellResultsData.h" +#include "RigStatisticsMath.h" + +#include // Needed for HUGE_VAL on Linux + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigNativeStatCalc::RigNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex) + : m_resultsData(cellResultsData), + m_scalarResultIndex(scalarResultIndex) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) +{ + std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex); + + size_t i; + for (i = 0; i < values.size(); i++) + { + if (values[i] == HUGE_VAL) + { + continue; + } + + if (values[i] < min) + { + min = values[i]; + } + + if (values[i] > max) + { + max = values[i]; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) +{ + std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex); + + size_t i; + for (i = 0; i < values.size(); i++) + { + if (values[i] == HUGE_VAL) + { + continue; + } + + if (values[i] < pos && values[i] > 0) + { + pos = values[i]; + } + + if (values[i] > neg && values[i] < 0) + { + neg = values[i]; + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNativeStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator) +{ + for (size_t tIdx = 0; tIdx < m_resultsData->timeStepCount(m_scalarResultIndex); tIdx++) + { + std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, tIdx); + + histogramCalculator.addData(values); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNativeStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount) +{ + for (size_t tIdx = 0; tIdx < m_resultsData->timeStepCount(m_scalarResultIndex); tIdx++) + { + std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, tIdx); + size_t undefValueCount = 0; + for (size_t cIdx = 0; cIdx < values.size(); ++cIdx) + { + double value = values[cIdx]; + if (value == HUGE_VAL || value != value) + { + ++undefValueCount; + continue; + } + + valueSum += value; + } + + sampleCount += values.size(); + sampleCount -= undefValueCount; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigNativeStatCalc::timeStepCount() +{ + return m_resultsData->timeStepCount(m_scalarResultIndex); +} diff --git a/ApplicationCode/ReservoirDataModel/RigNativeStatCalc.h b/ApplicationCode/ReservoirDataModel/RigNativeStatCalc.h new file mode 100644 index 0000000000..5f506457e4 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigNativeStatCalc.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "RigStatisticsCalculator.h" + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfCollection.h" + +class RigHistogramCalculator; +class RigCaseCellResultsData; + +//================================================================================================== +/// +//================================================================================================== +class RigNativeStatCalc : public RigStatisticsCalculator +{ +public: + RigNativeStatCalc(RigCaseCellResultsData* cellResultsData, size_t scalarResultIndex); + + virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max); + virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg); + virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount); + + virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator); + virtual size_t timeStepCount(); + +private: + RigCaseCellResultsData* m_resultsData; + size_t m_scalarResultIndex; +}; diff --git a/ApplicationCode/Resources/GeoMechCase48x48.png b/ApplicationCode/Resources/GeoMechCase48x48.png new file mode 100644 index 0000000000..859c240e91 Binary files /dev/null and b/ApplicationCode/Resources/GeoMechCase48x48.png differ diff --git a/ApplicationCode/Resources/GeoMechCase48x48.xcf b/ApplicationCode/Resources/GeoMechCase48x48.xcf new file mode 100644 index 0000000000..a5a0f28254 Binary files /dev/null and b/ApplicationCode/Resources/GeoMechCase48x48.xcf differ diff --git a/ApplicationCode/Resources/GeoMechCases48x48.png b/ApplicationCode/Resources/GeoMechCases48x48.png new file mode 100644 index 0000000000..c27dd63b30 Binary files /dev/null and b/ApplicationCode/Resources/GeoMechCases48x48.png differ diff --git a/ApplicationCode/Resources/GeoMechCases48x48.xcf b/ApplicationCode/Resources/GeoMechCases48x48.xcf new file mode 100644 index 0000000000..2304b1de5b Binary files /dev/null and b/ApplicationCode/Resources/GeoMechCases48x48.xcf differ diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 384db079ed..873569505e 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -34,7 +34,8 @@ draw_style_meshoutlines_24x24.png draw_style_outlines_24x24.png draw_style_surface_24x24.png - SnapShot.png + disable_lighting_24x24.png + SnapShot.png SnapShotSave.png SnapShotSaveViews.png draw_style_faults_24x24.png @@ -44,6 +45,8 @@ draw_style_WellCellsToRangeFilter_24x24.png draw_style_surface_w_fault_mesh_24x24.png InfoBox16x16.png + GeoMechCase48x48.png + GeoMechCases48x48.png fs_CellFace.glsl diff --git a/ApplicationCode/Resources/disable_lighting_24x24.png b/ApplicationCode/Resources/disable_lighting_24x24.png new file mode 100644 index 0000000000..35d1c86178 Binary files /dev/null and b/ApplicationCode/Resources/disable_lighting_24x24.png differ diff --git a/ApplicationCode/ResultStatisticsCache/CMakeLists.txt b/ApplicationCode/ResultStatisticsCache/CMakeLists.txt new file mode 100644 index 0000000000..4ac1d30def --- /dev/null +++ b/ApplicationCode/ResultStatisticsCache/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required (VERSION 2.8) + +project (ResultStatisticsCache) + +include_directories( + ${LibCore_SOURCE_DIR} +) + +add_library( ${PROJECT_NAME} + RigStatisticsCalculator.h + RigStatisticsCalculator.cpp + RigStatisticsDataCache.h + RigStatisticsDataCache.cpp + RigStatisticsMath.h + RigStatisticsMath.cpp +) + +target_link_libraries(${PROJECT_NAME} LibCore) diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsCalculator.cpp b/ApplicationCode/ResultStatisticsCache/RigStatisticsCalculator.cpp new file mode 100644 index 0000000000..6550dc8e68 --- /dev/null +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsCalculator.cpp @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "RigStatisticsCalculator.h" + +#include // Needed for HUGE_VAL on Linux + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsCalculator::meanCellScalarValue(double& meanValue) +{ + double valueSum = 0.0; + size_t sampleCount = 0; + + this->valueSumAndSampleCount(valueSum, sampleCount); + + if (sampleCount == 0) + { + meanValue = HUGE_VAL; + } + else + { + meanValue = valueSum / sampleCount; + } +} + diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsCalculator.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsCalculator.h new file mode 100644 index 0000000000..c5ee533757 --- /dev/null +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsCalculator.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cvfObject.h" +#include "cvfCollection.h" + +#include + +class RigHistogramCalculator; + +//================================================================================================== +/// +//================================================================================================== +class RigStatisticsCalculator : public cvf::Object +{ +public: + virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) = 0; + virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) = 0; + + void meanCellScalarValue(double& meanValue); + virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount) = 0; + virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator) = 0; + + virtual size_t timeStepCount() = 0; +}; diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsDataCache.cpp b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp similarity index 83% rename from ApplicationCode/ReservoirDataModel/RigStatisticsDataCache.cpp rename to ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp index 87b8c6d403..4a593bb497 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsDataCache.cpp +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp @@ -41,11 +41,14 @@ void RigStatisticsDataCache::clearAllStatistics() { m_minValue = HUGE_VAL; m_maxValue = -HUGE_VAL; + m_isMaxMinCalculated = false; m_posClosestToZero = HUGE_VAL; m_negClosestToZero = -HUGE_VAL; + m_isClosestToZeroCalculated = false; m_p10 = HUGE_VAL; m_p90 = HUGE_VAL; m_meanValue = HUGE_VAL; + m_isMeanCalculated = false; m_histogram.clear(); m_maxMinValuesPrTs.clear(); @@ -57,7 +60,7 @@ void RigStatisticsDataCache::clearAllStatistics() //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::minMaxCellScalarValues(double& min, double& max) { - if (m_minValue == HUGE_VAL) + if (!m_isMaxMinCalculated) { min = HUGE_VAL; max = -HUGE_VAL; @@ -73,6 +76,7 @@ void RigStatisticsDataCache::minMaxCellScalarValues(double& min, double& max) m_minValue = min; m_maxValue = max; + m_isMaxMinCalculated = true; } min = m_minValue; @@ -87,18 +91,21 @@ void RigStatisticsDataCache::minMaxCellScalarValues(size_t timeStepIndex, double if (timeStepIndex >= m_maxMinValuesPrTs.size()) { m_maxMinValuesPrTs.resize(timeStepIndex + 1, std::make_pair(HUGE_VAL, -HUGE_VAL)); - } + m_isMaxMinPrTsCalculated.resize(timeStepIndex + 1, false); + } - if (m_maxMinValuesPrTs[timeStepIndex].first == HUGE_VAL) - { - min = HUGE_VAL; - max = -HUGE_VAL; + if (!m_isMaxMinPrTsCalculated[timeStepIndex]) + { + double tsMin = HUGE_VAL; + double tsMax = -HUGE_VAL; - m_statisticsCalculator->minMaxCellScalarValues(timeStepIndex, min, max); + m_statisticsCalculator->minMaxCellScalarValues(timeStepIndex, tsMin, tsMax); - m_maxMinValuesPrTs[timeStepIndex].first = min; - m_maxMinValuesPrTs[timeStepIndex].second = max; - } + m_maxMinValuesPrTs[timeStepIndex].first = tsMin; + m_maxMinValuesPrTs[timeStepIndex].second = tsMax; + + m_isMaxMinPrTsCalculated[timeStepIndex] = true; + } min = m_maxMinValuesPrTs[timeStepIndex].first; max = m_maxMinValuesPrTs[timeStepIndex].second; @@ -109,7 +116,7 @@ void RigStatisticsDataCache::minMaxCellScalarValues(size_t timeStepIndex, double //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::posNegClosestToZero(double& pos, double& neg) { - if (m_posClosestToZero == HUGE_VAL) + if (!m_isClosestToZeroCalculated) { pos = HUGE_VAL; neg = -HUGE_VAL; @@ -125,6 +132,7 @@ void RigStatisticsDataCache::posNegClosestToZero(double& pos, double& neg) m_posClosestToZero = pos; m_negClosestToZero = neg; + m_isClosestToZeroCalculated = true; } pos = m_posClosestToZero; @@ -134,26 +142,30 @@ void RigStatisticsDataCache::posNegClosestToZero(double& pos, double& neg) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatisticsDataCache::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) +void RigStatisticsDataCache::posNegClosestToZero(size_t timeStepIndex, double& posNearZero, double& negNearZero) { if (timeStepIndex >= m_posNegClosestToZeroPrTs.size()) { m_posNegClosestToZeroPrTs.resize(timeStepIndex + 1, std::make_pair(HUGE_VAL, -HUGE_VAL)); - } + m_isClosestToZeroPrTsCalculated.resize(timeStepIndex + 1, false); + } - if (m_posNegClosestToZeroPrTs[timeStepIndex].first == HUGE_VAL) - { - pos = HUGE_VAL; - neg = -HUGE_VAL; + if (!m_isClosestToZeroPrTsCalculated[timeStepIndex]) + { + + double pos = HUGE_VAL; + double neg = -HUGE_VAL; m_statisticsCalculator->posNegClosestToZero(timeStepIndex, pos, neg); m_posNegClosestToZeroPrTs[timeStepIndex].first = pos; m_posNegClosestToZeroPrTs[timeStepIndex].second = neg; - } - pos = m_posNegClosestToZeroPrTs[timeStepIndex].first; - neg = m_posNegClosestToZeroPrTs[timeStepIndex].second; + m_isClosestToZeroPrTsCalculated[timeStepIndex] = true; + } + + posNearZero = m_posNegClosestToZeroPrTs[timeStepIndex].first; + negNearZero = m_posNegClosestToZeroPrTs[timeStepIndex].second; } //-------------------------------------------------------------------------------------------------- @@ -196,9 +208,10 @@ void RigStatisticsDataCache::p10p90CellScalarValues(double& p10, double& p90) //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::meanCellScalarValues(double& meanValue) { - if (m_meanValue == HUGE_VAL) + if (!m_isMeanCalculated) { m_statisticsCalculator->meanCellScalarValue(m_meanValue); + m_isMeanCalculated = true; } meanValue = m_meanValue; diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsDataCache.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h similarity index 88% rename from ApplicationCode/ReservoirDataModel/RigStatisticsDataCache.h rename to ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h index 0688ea00d0..f1988204c2 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsDataCache.h +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h @@ -49,17 +49,23 @@ class RigStatisticsDataCache : public cvf::Object private: double m_minValue; double m_maxValue; + bool m_isMaxMinCalculated; + double m_posClosestToZero; double m_negClosestToZero; + bool m_isClosestToZeroCalculated; double m_p10; double m_p90; double m_meanValue; + bool m_isMeanCalculated; std::vector m_histogram; std::vector > m_maxMinValuesPrTs; ///< Max min values for each time step + std::vector m_isMaxMinPrTsCalculated; std::vector > m_posNegClosestToZeroPrTs; ///< PosNeg values for each time step + std::vector m_isClosestToZeroPrTsCalculated; cvf::ref m_statisticsCalculator; }; diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp similarity index 91% rename from ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp rename to ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp index 3a7435407c..c63eed6991 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp @@ -214,6 +214,31 @@ void RigHistogramCalculator::addData(const std::vector& data) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigHistogramCalculator::addData(const std::vector& data) +{ + assert(m_histogram); + for (size_t i = 0; i < data.size(); ++i) + { + if (data[i] == HUGE_VAL) + { + continue; + } + + size_t index = 0; + + if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range); + + if(index < m_histogram->size()) // Just clip to the max min range (-index will overflow to positive ) + { + (*m_histogram)[index]++; + m_observationCount++; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h similarity index 97% rename from ApplicationCode/ReservoirDataModel/RigStatisticsMath.h rename to ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h index a8e477b30b..59de3160ab 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h @@ -39,6 +39,7 @@ class RigHistogramCalculator RigHistogramCalculator(double min, double max, size_t nBins, std::vector* histogram); void addData(const std::vector& data); + void addData(const std::vector& data); /// Calculates the estimated percentile from the histogram. /// the percentile is the domain value at which pVal of the observations are below it. diff --git a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp index 2c495d83a5..6ee4e99a5f 100644 --- a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp @@ -26,15 +26,15 @@ #include "RiaApplication.h" #include "RiaPreferences.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirCellResultsStorage.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RigCaseData.h" #include "RigCaseCellResultsData.h" @@ -55,7 +55,7 @@ class RiaGetMainGridDimensions: public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); if (!rimCase) return true; // Write data back to octave: I, J, K dimensions @@ -91,7 +91,7 @@ class RiaGetActiveCellInfo: public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); if (!rimCase) return true; RifReaderInterface::PorosityModelResultType porosityModel = RifReaderInterface::MATRIX_RESULTS; @@ -143,7 +143,7 @@ class RiaGetActiveCellInfo: public RiaSocketCommand return true; } - static void calculateMatrixModelActiveCellInfo(RimCase* reservoirCase, RifReaderInterface::PorosityModelResultType porosityModel, std::vector& gridNumber, std::vector& cellI, std::vector& cellJ, std::vector& cellK, std::vector& parentGridNumber, std::vector& hostCellI, std::vector& hostCellJ, std::vector& hostCellK, std::vector& globalCoarseningBoxIdx) + static void calculateMatrixModelActiveCellInfo(RimEclipseCase* reservoirCase, RifReaderInterface::PorosityModelResultType porosityModel, std::vector& gridNumber, std::vector& cellI, std::vector& cellJ, std::vector& cellK, std::vector& parentGridNumber, std::vector& hostCellI, std::vector& hostCellJ, std::vector& hostCellK, std::vector& globalCoarseningBoxIdx) { gridNumber.clear(); cellI.clear(); @@ -268,7 +268,7 @@ class RiaGetCoarseningInfo : public RiaSocketCommand argCaseGroupId = args[1].toInt(); } - RimCase* rimCase = server->findReservoir(argCaseGroupId); + RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId); if (!rimCase || !rimCase->reservoirData() || !rimCase->reservoirData()->mainGrid()) { quint64 byteCount = 0; @@ -340,7 +340,7 @@ class RiaGetGridDimensions : public RiaSocketCommand argCaseGroupId = args[1].toInt(); } - RimCase* rimCase = server->findReservoir(argCaseGroupId); + RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId); if (!rimCase || !rimCase->reservoirData() || !rimCase->reservoirData()->mainGrid()) { quint64 byteCount = 0; @@ -399,7 +399,7 @@ class RiaGetTimeStepDates : public RiaSocketCommand argCaseGroupId = args[1].toInt(); } - RimCase* rimCase = server->findReservoir(argCaseGroupId); + RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId); bool canFetchData = true; @@ -486,7 +486,7 @@ class RiaGetTimeStepDays : public RiaSocketCommand argCaseGroupId = args[1].toInt(); } - RimCase* rimCase = server->findReservoir(argCaseGroupId); + RimEclipseCase* rimCase = server->findReservoir(argCaseGroupId); bool canFetchData = true; diff --git a/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp b/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp index 018cc97d19..dd0016180a 100644 --- a/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp @@ -23,16 +23,16 @@ #include "RiaSocketServer.h" #include "RiaSocketTools.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirCellResultsStorage.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RigCaseData.h" #include "RigCaseCellResultsData.h" @@ -52,7 +52,7 @@ class RiaGetCellCenters : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); size_t argGridIndex = args[2].toUInt(); if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) ) @@ -134,7 +134,7 @@ class RiaGetActiveCellCenters : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); QString porosityModelName; porosityModelName = args[2]; @@ -214,7 +214,7 @@ class RiaGetCellCorners : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); size_t argGridIndex = args[2].toUInt(); if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) ) @@ -303,7 +303,7 @@ class RiaGetActiveCellCorners : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); QString porosityModelName; porosityModelName = args[2]; diff --git a/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp index 96c2b69c9a..77737c8ad0 100644 --- a/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp @@ -23,16 +23,16 @@ #include "RiaSocketServer.h" #include "RiaSocketTools.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirCellResultsStorage.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RigCaseData.h" #include "RigCaseCellResultsData.h" #include "RiuMainWindow.h" @@ -43,7 +43,7 @@ #include "RimScriptCollection.h" #include "RimWellPathCollection.h" #include "RimOilField.h" -#include "RimAnalysisModels.h" +#include "RimEclipseCaseCollection.h" @@ -84,7 +84,7 @@ class RiaGetCurrentCase : public RiaSocketCommand QString caseType; qint64 caseGroupId = -1; - RimCase* rimCase = server->findReservoir(caseId); + RimEclipseCase* rimCase = server->findReservoir(caseId); if (rimCase) { @@ -174,7 +174,7 @@ class RiaGetCaseGroups : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { RimProject* proj = RiaApplication::instance()->project(); - RimAnalysisModels* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; if (analysisModels) { std::vector groupNames; @@ -239,7 +239,7 @@ class RiaGetCases : public RiaSocketCommand } RimProject* proj = RiaApplication::instance()->project(); - RimAnalysisModels* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; if (analysisModels) { diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 0adb7e85cc..f7ca92460a 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -33,13 +33,13 @@ #include "RigResultModifier.h" #include "RigResultModifierFactory.h" -#include "RimCase.h" -#include "RimInputCase.h" -#include "RimInputProperty.h" -#include "RimInputPropertyCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseInputCase.h" +#include "RimEclipseInputProperty.h" +#include "RimEclipseInputPropertyCollection.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" #include "RimUiTreeModelPdm.h" #include "RiuMainWindow.h" @@ -57,7 +57,7 @@ class RiaGetActiveCellProperty: public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); QString propertyName = args[2]; QString porosityModelName = args[3]; @@ -225,7 +225,7 @@ class RiaGetGridProperty: public RiaSocketCommand QString propertyName = args[3]; QString porosityModelName = args[4]; - RimCase*rimCase = server->findReservoir(caseId); + RimEclipseCase*rimCase = server->findReservoir(caseId); if (rimCase == NULL) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID: \"%1\"").arg(caseId)); @@ -392,7 +392,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { - RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); + RimEclipseCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args); QString propertyName = args[2]; QString porosityModelName = args[3]; @@ -547,6 +547,23 @@ class RiaSetActiveCellProperty: public RiaSocketCommand // Make sure the size of the retreiving container is correct. // If it is, this is noops + { + size_t maxRequestedTimeStepIdx = cvf::UNDEFINED_SIZE_T; + for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx) + { + size_t tsId = m_requestedTimesteps[tIdx]; + if (maxRequestedTimeStepIdx == cvf::UNDEFINED_SIZE_T || tsId > maxRequestedTimeStepIdx) + { + maxRequestedTimeStepIdx = tsId; + } + } + + if (maxRequestedTimeStepIdx != cvf::UNDEFINED_SIZE_T + && m_scalarResultsToAdd->size() <= maxRequestedTimeStepIdx) + { + m_scalarResultsToAdd->resize(maxRequestedTimeStepIdx + 1); + } + } for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx) { @@ -613,14 +630,14 @@ class RiaSetActiveCellProperty: public RiaSocketCommand if (m_currentReservoir != NULL) { // Create a new input property if we have an input reservoir - RimInputCase* inputRes = dynamic_cast(m_currentReservoir); + RimEclipseInputCase* inputRes = dynamic_cast(m_currentReservoir); if (inputRes) { - RimInputProperty* inputProperty = NULL; + RimEclipseInputProperty* inputProperty = NULL; inputProperty = inputRes->m_inputPropertyCollection->findInputProperty(m_currentPropertyName); if (!inputProperty) { - inputProperty = new RimInputProperty; + inputProperty = new RimEclipseInputProperty; inputProperty->resultName = m_currentPropertyName; inputProperty->eclipseKeyword = ""; inputProperty->fileName = ""; @@ -628,7 +645,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); treeModel->updateUiSubTree(inputRes->m_inputPropertyCollection()); } - inputProperty->resolvedState = RimInputProperty::RESOLVED_NOT_SAVED; + inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED_NOT_SAVED; } if( m_currentScalarIndex != cvf::UNDEFINED_SIZE_T && @@ -680,7 +697,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand } private: - RimCase* m_currentReservoir; + RimEclipseCase* m_currentReservoir; std::vector< std::vector >* m_scalarResultsToAdd; size_t m_currentScalarIndex; QString m_currentPropertyName; @@ -720,7 +737,7 @@ class RiaSetGridProperty : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { int caseId = args[1].toInt(); - RimCase* rimCase = server->findReservoir(caseId); + RimEclipseCase* rimCase = server->findReservoir(caseId); if (!rimCase) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId)); @@ -909,6 +926,25 @@ class RiaSetGridProperty : public RiaSocketCommand return true; } + // Resize the timestep container + { + size_t maxRequestedTimeStepIdx = cvf::UNDEFINED_SIZE_T; + for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx) + { + size_t tsId = m_requestedTimesteps[tIdx]; + if (maxRequestedTimeStepIdx == cvf::UNDEFINED_SIZE_T || tsId > maxRequestedTimeStepIdx) + { + maxRequestedTimeStepIdx = tsId; + } + } + + if (maxRequestedTimeStepIdx != cvf::UNDEFINED_SIZE_T + && m_scalarResultsToAdd->size() <= maxRequestedTimeStepIdx) + { + m_scalarResultsToAdd->resize(maxRequestedTimeStepIdx + 1); + } + } + for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx) { size_t tsId = m_requestedTimesteps[tIdx]; @@ -959,14 +995,14 @@ class RiaSetGridProperty : public RiaSocketCommand if (m_currentReservoir != NULL) { // Create a new input property if we have an input reservoir - RimInputCase* inputRes = dynamic_cast(m_currentReservoir); + RimEclipseInputCase* inputRes = dynamic_cast(m_currentReservoir); if (inputRes) { - RimInputProperty* inputProperty = NULL; + RimEclipseInputProperty* inputProperty = NULL; inputProperty = inputRes->m_inputPropertyCollection->findInputProperty(m_currentPropertyName); if (!inputProperty) { - inputProperty = new RimInputProperty; + inputProperty = new RimEclipseInputProperty; inputProperty->resultName = m_currentPropertyName; inputProperty->eclipseKeyword = ""; inputProperty->fileName = ""; @@ -974,7 +1010,7 @@ class RiaSetGridProperty : public RiaSocketCommand RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); treeModel->updateUiSubTree(inputRes->m_inputPropertyCollection()); } - inputProperty->resolvedState = RimInputProperty::RESOLVED_NOT_SAVED; + inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED_NOT_SAVED; } if( m_currentScalarIndex != cvf::UNDEFINED_SIZE_T && @@ -1026,7 +1062,7 @@ class RiaSetGridProperty : public RiaSocketCommand } private: - RimCase* m_currentReservoir; + RimEclipseCase* m_currentReservoir; std::vector< std::vector >* m_scalarResultsToAdd; size_t m_currentGridIndex; size_t m_currentScalarIndex; @@ -1054,7 +1090,7 @@ class RiaGetPropertyNames : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { int caseId = args[1].toInt(); - RimCase* rimCase = server->findReservoir(caseId); + RimEclipseCase* rimCase = server->findReservoir(caseId); if (!rimCase) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId)); diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 28b9bb3826..361cbbf96f 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -30,15 +30,15 @@ #include "RiaApplication.h" #include "RiuMainWindow.h" -#include "RimReservoirView.h" +#include "RimEclipseView.h" #include "RimProject.h" -#include "RimCase.h" +#include "RimEclipseCase.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimIdenticalGridCaseGroup.h" #include "RimScriptCollection.h" @@ -52,7 +52,7 @@ #include "cafFactory.h" #include "RigGridBase.h" #include "RimOilField.h" -#include "RimAnalysisModels.h" +#include "RimEclipseCaseCollection.h" //-------------------------------------------------------------------------------------------------- @@ -142,7 +142,7 @@ void RiaSocketServer::slotNewClientConnection() //-------------------------------------------------------------------------------------------------- /// Find the requested reservoir by caseId //-------------------------------------------------------------------------------------------------- -RimCase* RiaSocketServer::findReservoir(int caseId) +RimEclipseCase* RiaSocketServer::findReservoir(int caseId) { int currCaseId = caseId; if (caseId < 0) @@ -152,9 +152,10 @@ RimCase* RiaSocketServer::findReservoir(int caseId) if (currCaseId < 0) { - if (RiaApplication::instance()->activeReservoirView()) + RimEclipseView* riv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (riv) { - return RiaApplication::instance()->activeReservoirView()->eclipseCase(); + return riv->eclipseCase(); } } else @@ -169,7 +170,7 @@ RimCase* RiaSocketServer::findReservoir(int caseId) { if (cases[i]->caseId == currCaseId) { - return cases[i]; + return dynamic_cast(cases[i]); } } } diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 1dd24af67b..1a2e4659e8 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -31,7 +31,7 @@ class QTcpSocket; class QNetworkSession; class QErrorMessage; class QTimer; -class RimCase; +class RimEclipseCase; class RiaSocketCommand; namespace riOctavePlugin @@ -51,7 +51,7 @@ class RiaSocketServer : public QObject ~RiaSocketServer(); unsigned short serverPort(); - RimCase* findReservoir(int caseId); + RimEclipseCase* findReservoir(int caseId); QErrorMessage* errorMessageDialog() { return m_errorMessageDialog; } QTcpSocket* currentClient() { return m_currentClient; } diff --git a/ApplicationCode/SocketInterface/RiaSocketTools.cpp b/ApplicationCode/SocketInterface/RiaSocketTools.cpp index 71e6d5cd47..510c4d98f3 100644 --- a/ApplicationCode/SocketInterface/RiaSocketTools.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketTools.cpp @@ -25,21 +25,21 @@ #include "RiaSocketTools.h" #include "RiaSocketServer.h" -#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" -#include "RimInputCase.h" +#include "RimEclipseInputCase.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirCellResultsStorage.h" -#include "RimInputPropertyCollection.h" +#include "RimEclipseInputPropertyCollection.h" #include "RiaSocketDataTransfer.h" @@ -48,9 +48,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const QList& args) +RimEclipseCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const QList& args) { - RimCase* rimCase = NULL; + RimEclipseCase* rimCase = NULL; int caseId = -1; if (args.size() > 1) @@ -79,7 +79,13 @@ void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QStri caseId = rimCase->caseId; caseName = rimCase->caseUserDescription; - RimCaseCollection* caseCollection = rimCase->parentCaseCollection(); + RimEclipseCase* eclCase = dynamic_cast (rimCase); + RimCaseCollection* caseCollection = NULL; + if (eclCase) + { + caseCollection = eclCase->parentCaseCollection(); + } + if (caseCollection) { caseGroupId = caseCollection->parentCaseGroup()->groupId; @@ -97,14 +103,18 @@ void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QStri { caseGroupId = -1; - if (dynamic_cast(rimCase)) + if (dynamic_cast(rimCase)) { caseType = "InputCase"; } - else + else if (eclCase) { caseType = "ResultCase"; } + else + { + caseType = "GeoMechCase"; + } } } diff --git a/ApplicationCode/SocketInterface/RiaSocketTools.h b/ApplicationCode/SocketInterface/RiaSocketTools.h index b324a25292..19c09ace29 100644 --- a/ApplicationCode/SocketInterface/RiaSocketTools.h +++ b/ApplicationCode/SocketInterface/RiaSocketTools.h @@ -27,7 +27,7 @@ class QTcpSocket; class RiaSocketTools { public: - static RimCase* findCaseFromArgs(RiaSocketServer* server, const QList& args); + static RimEclipseCase* findCaseFromArgs(RiaSocketServer* server, const QList& args); static void getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId); static bool writeBlockData(RiaSocketServer* server, QTcpSocket* socket, const char* data, quint64 bytesToWrite); diff --git a/ApplicationCode/SocketInterface/RiaWellDataCommands.cpp b/ApplicationCode/SocketInterface/RiaWellDataCommands.cpp index b8b3857ee7..4ed83781d5 100644 --- a/ApplicationCode/SocketInterface/RiaWellDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaWellDataCommands.cpp @@ -29,16 +29,16 @@ #include "RigCaseCellResultsData.h" #include "RimReservoirCellResultsStorage.h" -#include "RimCase.h" -#include "RimInputCase.h" -#include "RimInputPropertyCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseInputCase.h" +#include "RimEclipseInputPropertyCollection.h" #include "RimUiTreeModelPdm.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" -#include "RimCellEdgeResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" +#include "RimCellEdgeColors.h" #include "RimCellRangeFilterCollection.h" -#include "RimCellPropertyFilterCollection.h" -#include "RimWellCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseWellCollection.h" #include "Rim3dOverlayInfoConfig.h" #include @@ -55,7 +55,7 @@ class RiaGetWellNames : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { int caseId = args[1].toInt(); - RimCase* rimCase = server->findReservoir(caseId); + RimEclipseCase* rimCase = server->findReservoir(caseId); if (!rimCase) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId)); @@ -109,7 +109,7 @@ class RiaGetWellStatus : public RiaSocketCommand int caseId = args[1].toInt(); QString wellName = args[2]; - RimCase* rimCase = server->findReservoir(caseId); + RimEclipseCase* rimCase = server->findReservoir(caseId); if (!rimCase) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId)); @@ -248,7 +248,7 @@ class RiaGetWellCells : public RiaSocketCommand QString wellName = args[2]; size_t timeStepIdx = args[3].toInt() - 1; // Interpret timeStepIdx from octave as 1-based - RimCase* rimCase = server->findReservoir(caseId); + RimEclipseCase* rimCase = server->findReservoir(caseId); if (!rimCase) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId)); diff --git a/ApplicationCode/UserInterface/RiuCadNavigation.cpp b/ApplicationCode/UserInterface/RiuCadNavigation.cpp new file mode 100644 index 0000000000..700b1e35f0 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCadNavigation.cpp @@ -0,0 +1,238 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuCadNavigation.h" +#include "cafViewer.h" +#include "cvfCamera.h" +#include "cvfScene.h" +#include "cvfModel.h" +#include "cvfViewport.h" +#include "cvfHitItemCollection.h" +#include "cvfRay.h" + +#include +#include + +using cvf::ManipulatorTrackball; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuCadNavigation::init() +{ + m_trackball = new cvf::ManipulatorTrackball; + m_trackball->setCamera(m_viewer->mainCamera()); + m_isRotCenterInitialized = false; + m_isRotating = false; + m_navigationUpdated = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent) +{ + if (! inputEvent) return false; + bool isEventHandled = false; + + switch (inputEvent->type()) + { + case QEvent::MouseButtonPress: + { + QMouseEvent * me = static_cast( inputEvent); + int translatedMousePosX = me->x(); + int translatedMousePosY = m_viewer->height() - me->y(); + + if (me->button() == Qt::LeftButton) + { + m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY); + m_isRotating = true; + isEventHandled = true; + } + else if (me->button() == Qt::MidButton) + { + if (me->modifiers() & Qt::ShiftModifier) + { + m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY); + m_isRotating = true; + isEventHandled = true; + } + else if (me->modifiers() == Qt::NoModifier) + { + cvf::HitItemCollection hic; + bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic); + + if (hitSomething) + { + cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint(); + m_trackball->setRotationPoint(pointOfInterest); + m_pointOfInterest = pointOfInterest; + } + else + { + initializeRotationCenter(); + } + + m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY); + //m_viewer->setCursor(RiuCursors::get(RiuCursors::ROTATE)); + m_isRotating = true; + isEventHandled = true; + } + } + + if (isEventHandled) + { + m_navigationUpdated = false; + } + } + break; + case QEvent::MouseButtonRelease: + { + if (m_isRotating) + { + QMouseEvent * me = static_cast( inputEvent); + if (me->button() == Qt::MidButton || me->button() == Qt::LeftButton) + { + m_trackball->endNavigation(); + //m_viewer->setCursor(RiuCursors::get(RiuCursors::PICK)); + m_isRotating = false; + + isEventHandled = m_navigationUpdated; + m_navigationUpdated = false; + } + } + } + break; + case QEvent::MouseMove: + { + initializeRotationCenter(); + if (m_isRotCenterInitialized) + { + QMouseEvent * me = static_cast( inputEvent); + int translatedMousePosX = me->x(); + int translatedMousePosY = m_viewer->height() - me->y(); + + if (m_isRotating) + { + bool needRedraw = m_trackball->updateNavigation(translatedMousePosX, translatedMousePosY); + if (needRedraw) + { + m_viewer->update(); + m_navigationUpdated = true; + } + isEventHandled = true; + } + } + } + break; + case QEvent::Wheel: + { + if (inputEvent->modifiers() == Qt::NoModifier) + { + initializeRotationCenter(); + if (m_isRotCenterInitialized) + { + QWheelEvent* we = static_cast(inputEvent); + int translatedMousePosX = we->x(); + int translatedMousePosY = m_viewer->height() - we->y(); + + cvf::ref ray; + if (we->delta() > 0) + ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY); + else + ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY)); + + if (ray.notNull() && abs(we->delta()) > 0) + { + cvf::Vec3d pos, vrp, up; + m_viewer->mainCamera()->toLookAt(&pos, &vrp, &up); + + double scale = -we->delta()/8.0 * 1.0/150 * (pos - m_pointOfInterest).length(); + cvf::Vec3d trans = scale * ray->direction(); + cvf::Vec3d newPos = pos + trans; + cvf::Vec3d newVrp = vrp + trans; + + m_viewer->mainCamera()->setFromLookAt(newPos,newVrp, up ); + m_viewer->update(); + } + } + isEventHandled = true; + } + } + break; + } + + return isEventHandled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuCadNavigation::initializeRotationCenter() +{ + if(m_isRotCenterInitialized || m_trackball.isNull() || !m_viewer->mainScene() || !m_viewer->currentScene()->boundingBox().isValid()) return; + m_pointOfInterest = m_viewer->currentScene()->boundingBox().center(); + + m_trackball->setRotationPoint(m_pointOfInterest); + m_isRotCenterInitialized = true; +} + +//-------------------------------------------------------------------------------------------------- +/// Repositions and orients the camera to view the rotation point along the +/// direction "alongDirection". The distance to the rotation point is maintained. +/// +//-------------------------------------------------------------------------------------------------- +void RiuCadNavigation::setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ) +{ + m_trackball->setView(alongDirection, upDirection); + /* + if (m_camera.isNull()) return; + + Vec3d dir = alongDirection; + if (!dir.normalize()) return; + Vec3d up = upDirection; + if(!up.normalize()) up = Vec3d::Z_AXIS; + + if((up * dir) < 1e-2) up = dir.perpendicularVector(); + + Vec3d cToE = m_camera->position() - m_rotationPoint; + Vec3d newEye = m_rotationPoint - cToE.length() * dir; + + m_camera->setFromLookAt(newEye, m_rotationPoint, upDirection); + */ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RiuCadNavigation::pointOfInterest() +{ + initializeRotationCenter(); + return m_pointOfInterest; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuCadNavigation::setPointOfInterest(cvf::Vec3d poi) +{ + m_pointOfInterest = poi; + m_trackball->setRotationPoint(poi); + m_isRotCenterInitialized = true; +} diff --git a/ApplicationCode/UserInterface/RiuCadNavigation.h b/ApplicationCode/UserInterface/RiuCadNavigation.h new file mode 100644 index 0000000000..08f14c818f --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCadNavigation.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cafNavigationPolicy.h" +#include "cvfManipulatorTrackball.h" +#include "cvfRay.h" + + +class RiuCadNavigation : public caf::NavigationPolicy +{ +protected: + // General navigation policy reimplememtation + virtual void init(); + virtual bool handleInputEvent(QInputEvent* inputEvent); + virtual void setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ); + virtual cvf::Vec3d pointOfInterest(); + virtual void setPointOfInterest(cvf::Vec3d poi); + + + // Cad navigation specific + void initializeRotationCenter(); + + cvf::ref m_trackball; + bool m_isRotCenterInitialized; + bool m_isRotating; + cvf::Vec3d m_pointOfInterest; + bool m_navigationUpdated; +}; diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp new file mode 100644 index 0000000000..d0efee33c4 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -0,0 +1,279 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "RiuFemResultTextBuilder.h" + +#include "RigGeoMechCaseData.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCase.h" +#include "RigFemPartCollection.h" +#include "RigFemPart.h" +#include "RigFemPartGrid.h" +#include "RimGeoMechCellColors.h" +#include "RigFemPartResultsCollection.h" + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuFemResultTextBuilder::RiuFemResultTextBuilder(RimGeoMechView* reservoirView, int gridIndex, int cellIndex, int timeStepIndex) +{ + CVF_ASSERT(reservoirView); + + m_reservoirView = reservoirView; + m_gridIndex = gridIndex; + m_cellIndex = cellIndex; + m_timeStepIndex = timeStepIndex; + + m_intersectionPoint = cvf::Vec3d::UNDEFINED; + m_face = cvf::StructGridInterface::NO_FACE; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuFemResultTextBuilder::setIntersectionPoint(cvf::Vec3d intersectionPoint) +{ + m_intersectionPoint = intersectionPoint; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuFemResultTextBuilder::setFace(cvf::StructGridInterface::FaceType face) +{ + m_face = face; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuFemResultTextBuilder::mainResultText() +{ + QString text; + + text = closestNodeResultText(m_reservoirView->cellResult()); + + if (!text.isEmpty()) text += "\n"; + + QString topoText = this->topologyText("\n"); + text += topoText; + text += "\n"; + + appendDetails(text, gridResultDetails()); + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuFemResultTextBuilder::topologyText(QString itemSeparator) +{ + QString text; + + if (m_reservoirView->geoMechCase()) + { + RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); + if (geomData) + { + + RigFemPart* femPart = geomData->femParts()->part(m_gridIndex); + int elementId = femPart->elmId(m_cellIndex); + text += QString("Element : Id[%1]").arg(elementId); + + size_t i = 0; + size_t j = 0; + size_t k = 0; + if (geomData->femParts()->part(m_gridIndex)->structGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k)) + { + // Adjust to 1-based Eclipse indexing + i++; + j++; + k++; + + cvf::Vec3d domainCoord = m_intersectionPoint; // + geomCase->femParts()->displayModelOffset(); + + //cvf::StructGridInterface::FaceEnum faceEnum(m_face); + + //QString faceText = faceEnum.text(); + + //text += QString("Face : %1").arg(faceText) + itemSeparator; + //text += QString("Fem Part %1").arg(m_gridIndex) + itemSeparator; + text += QString(", ijk[%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator; + + QString formattedText; + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + + text += formattedText; + } + } + } + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuFemResultTextBuilder::gridResultDetails() +{ + QString text; + + if (m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData()) + { + RigGeoMechCaseData* eclipseCaseData = m_reservoirView->geoMechCase()->geoMechData(); + + this->appendTextFromResultColors(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->cellResult(), &text); + + if (!text.isEmpty()) + { + text.prepend("-- Element result details --\n"); + } + } + + return text; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuFemResultTextBuilder::appendTextFromResultColors(RigGeoMechCaseData* geomData, int gridIndex, int cellIndex, int timeStepIndex, RimGeoMechCellColors* resultColors, QString* resultInfoText) +{ + if (!resultColors) + { + return; + } + + if (resultColors->hasResult()) + { + const std::vector& scalarResults = geomData->femPartResults()->resultValues(resultColors->resultAddress(), gridIndex, timeStepIndex); + if (scalarResults.size()) + { + caf::AppEnum resPosAppEnum = resultColors->resultPositionType(); + resultInfoText->append(resPosAppEnum.uiText() + ", "); + resultInfoText->append(resultColors->resultFieldUiName()+ ", ") ; + resultInfoText->append(resultColors->resultComponentUiName() + ":\n"); + + + RigFemPart* femPart = geomData->femParts()->part(gridIndex); + RigElementType elmType = femPart->elementType(cellIndex); + const int* elmentConn = femPart->connectivities(cellIndex); + int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); + for (int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx) + { + + float scalarValue = std::numeric_limits::infinity(); + int nodeIdx = elmentConn[lNodeIdx]; + if (resultColors->resultPositionType() == RIG_NODAL) + { + + scalarValue = scalarResults[nodeIdx]; + } + else + { + size_t resIdx = femPart->elementNodeResultIdx(cellIndex, lNodeIdx); + scalarValue = scalarResults[resIdx]; + } + + resultInfoText->append(QString("\tN:%1 \t: %2\n").arg(femPart->nodes().nodeIds[nodeIdx]).arg(scalarValue)); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuFemResultTextBuilder::appendDetails(QString& text, const QString& details) +{ + if (!details.isEmpty()) + { + text += "\n"; + text += details; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuFemResultTextBuilder::closestNodeResultText(RimGeoMechCellColors* resultColors) +{ + QString text; + if (!resultColors) + { + return text; + } + + if (resultColors->hasResult()) + { + if (! (m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData())) return text; + + RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); + + const std::vector& scalarResults = geomData->femPartResults()->resultValues(resultColors->resultAddress(), m_gridIndex, m_timeStepIndex); + if (scalarResults.size()) + { + + RigFemPart* femPart = geomData->femParts()->part(m_gridIndex); + RigElementType elmType = femPart->elementType(m_cellIndex); + const int* elmentConn = femPart->connectivities(m_cellIndex); + int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); + + // Find the closest node + int closestLocalNode = -1; + float minDist = std::numeric_limits::infinity(); + for (int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx) + { + int nodeIdx = elmentConn[lNodeIdx]; + cvf::Vec3f nodePos = femPart->nodes().coordinates[nodeIdx]; + float dist = (nodePos - cvf::Vec3f(m_intersectionPoint)).lengthSquared(); + if (dist < minDist) + { + closestLocalNode = lNodeIdx; + minDist = dist; + } + } + + // Create a text showing the results from the closest node + if (closestLocalNode >= 0) + { + + float scalarValue = std::numeric_limits::infinity(); + int nodeIdx = elmentConn[closestLocalNode]; + if (resultColors->resultPositionType() == RIG_NODAL) + { + + scalarValue = scalarResults[nodeIdx]; + } + else + { + size_t resIdx = femPart->elementNodeResultIdx(m_cellIndex, closestLocalNode); + scalarValue = scalarResults[resIdx]; + } + + text.append(QString("Closest result: N[%1], %2\n").arg(femPart->nodes().nodeIds[nodeIdx]).arg(scalarValue)); + } + } + } + + return text; +} diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h new file mode 100644 index 0000000000..2d168bc0aa --- /dev/null +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cafPdmPointer.h" +#include "cvfStructGrid.h" +#include + +class RimGeoMechView; +class RimEclipseCellColors; +class RigGeoMechCaseData; +class RimGeoMechCellColors; + +namespace cvf { + class Part; +} + +//================================================================================================== +// +// +//================================================================================================== +class RiuFemResultTextBuilder +{ +public: + RiuFemResultTextBuilder(RimGeoMechView* reservoirView, int gridIndex, int cellIndex, int timeStepIndex); + void setFace(cvf::StructGridInterface::FaceType face); + void setIntersectionPoint(cvf::Vec3d intersectionPoint); + + QString mainResultText(); + + QString topologyText(QString itemSeparator); + +private: + void appendDetails(QString& text, const QString& details); + + QString gridResultDetails(); + + QString closestNodeResultText(RimGeoMechCellColors* resultColors); + + void appendTextFromResultColors(RigGeoMechCaseData* eclipseCase, int gridIndex, int cellIndex, int timeStepIndex, RimGeoMechCellColors* resultColors, QString* resultInfoText); + +private: + caf::PdmPointer m_reservoirView; + + int m_gridIndex; + int m_cellIndex; + int m_timeStepIndex; + + cvf::StructGridInterface::FaceType m_face; + + cvf::Vec3d m_intersectionPoint; +}; diff --git a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp new file mode 100644 index 0000000000..ad27fdcedc --- /dev/null +++ b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp @@ -0,0 +1,250 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuGeoQuestNavigation.h" +#include "cafViewer.h" +#include "cvfCamera.h" +#include "cvfScene.h" +#include "cvfModel.h" +#include "cvfViewport.h" +#include "cvfHitItemCollection.h" +#include "cvfRay.h" + +#include +#include + +using cvf::ManipulatorTrackball; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuGeoQuestNavigation::init() +{ + m_trackball = new cvf::ManipulatorTrackball; + m_trackball->setCamera(m_viewer->mainCamera()); + m_isRotCenterInitialized = false; + m_hasMovedMouseDuringNavigation = false; + m_isNavigating = false; + m_isZooming = false; + m_lastPosX = 0; + m_lastPosY = 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent) +{ + if (! inputEvent) return false; + bool isEventHandled = false; + switch (inputEvent->type()) + { + case QEvent::MouseButtonPress: + { + QMouseEvent * me = static_cast( inputEvent); + int translatedMousePosX = me->x(); + int translatedMousePosY = m_viewer->height() - me->y(); + + if (me->button() == Qt::LeftButton) + { + cvf::HitItemCollection hic; + bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic); + + if (hitSomething) + { + cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint(); + m_trackball->setRotationPoint(pointOfInterest); + m_pointOfInterest = pointOfInterest; + } + else + { + initializeRotationCenter(); + } + + m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY); + //m_viewer->setCursor(RICursors::get(RICursors::ROTATE)); + m_isNavigating = true; + m_hasMovedMouseDuringNavigation = false; + isEventHandled = true; + } + else if (me->button() == Qt::MidButton) + { + if (me->modifiers() == Qt::NoModifier) + { + m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY); + m_isNavigating = true; + m_hasMovedMouseDuringNavigation = false; + isEventHandled = true; + } + } + } + break; + case QEvent::MouseButtonRelease: + { + if (m_isNavigating) + { + QMouseEvent * me = static_cast( inputEvent); + if (me->button() == Qt::LeftButton || me->button() == Qt::MidButton ) + { + m_trackball->endNavigation(); + + m_isNavigating = false; + if (m_hasMovedMouseDuringNavigation) isEventHandled = true; + m_hasMovedMouseDuringNavigation = false; + } + } + } + break; + case QEvent::MouseMove: + { + initializeRotationCenter(); + if (m_isRotCenterInitialized) + { + QMouseEvent * me = static_cast( inputEvent); + int translatedMousePosX = me->x(); + int translatedMousePosY = m_viewer->height() - me->y(); + + if (m_isNavigating) + { + if (m_isZooming) + { + int delta = 3*(m_lastPosY - me->y()); + this->zoomAlongRay(m_zoomRay.p(), delta); + m_lastPosX = me->x(); + m_lastPosY = me->y(); + } + else + { + bool needRedraw = m_trackball->updateNavigation(translatedMousePosX, translatedMousePosY); + if (needRedraw) + { + m_viewer->update(); + } + } + isEventHandled = true; + m_hasMovedMouseDuringNavigation = true; + } + } + } + break; + case QEvent::Wheel: + { + if (inputEvent->modifiers() == Qt::NoModifier) + { + initializeRotationCenter(); + if (m_isRotCenterInitialized) + { + QWheelEvent* we = static_cast ( inputEvent); + int translatedMousePosX = we->x(); + int translatedMousePosY = m_viewer->height() - we->y(); + int delta = we->delta(); + + cvf::ref ray; + if (delta < 0) + ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY); + else + ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY)); + + zoomAlongRay(ray.p(), -delta); + + } + isEventHandled = true; + } + } + break; + } + + return false;//isEventHandled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuGeoQuestNavigation::initializeRotationCenter() +{ + if(m_isRotCenterInitialized || m_trackball.isNull() || !m_viewer->mainScene() || !m_viewer->currentScene()->boundingBox().isValid()) return; + m_pointOfInterest = m_viewer->currentScene()->boundingBox().center(); + + m_trackball->setRotationPoint(m_pointOfInterest); + m_isRotCenterInitialized = true; +} + +//-------------------------------------------------------------------------------------------------- +/// Repositions and orients the camera to view the rotation point along the +/// direction "alongDirection". The distance to the rotation point is maintained. +/// +//-------------------------------------------------------------------------------------------------- +void RiuGeoQuestNavigation::setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ) +{ + m_trackball->setView(alongDirection, upDirection); + /* + if (m_camera.isNull()) return; + + Vec3d dir = alongDirection; + if (!dir.normalize()) return; + Vec3d up = upDirection; + if(!up.normalize()) up = Vec3d::Z_AXIS; + + if((up * dir) < 1e-2) up = dir.perpendicularVector(); + + Vec3d cToE = m_camera->position() - m_rotationPoint; + Vec3d newEye = m_rotationPoint - cToE.length() * dir; + + m_camera->setFromLookAt(newEye, m_rotationPoint, upDirection); + */ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RiuGeoQuestNavigation::pointOfInterest() +{ + initializeRotationCenter(); + return m_pointOfInterest; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuGeoQuestNavigation::setPointOfInterest(cvf::Vec3d poi) +{ + m_pointOfInterest = poi; + m_trackball->setRotationPoint(poi); + m_isRotCenterInitialized = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuGeoQuestNavigation::zoomAlongRay(cvf::Ray* ray, int delta) +{ + if (ray && abs(delta) > 0) + { + cvf::Vec3d pos, vrp, up; + m_viewer->mainCamera()->toLookAt(&pos, &vrp, &up); + + double scale = delta/8.0 * 1.0/150 * (pos - m_pointOfInterest).length(); + cvf::Vec3d trans = scale * ray->direction(); + cvf::Vec3d newPos = pos + trans; + cvf::Vec3d newVrp = vrp + trans; + + m_viewer->mainCamera()->setFromLookAt(newPos, newVrp, up ); + m_viewer->update(); + } +} diff --git a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.h b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.h new file mode 100644 index 0000000000..6dce37449b --- /dev/null +++ b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cafNavigationPolicy.h" +#include "cvfManipulatorTrackball.h" +#include "cvfRay.h" + + +class RiuGeoQuestNavigation : public caf::NavigationPolicy +{ +protected: + // General navigation policy overrides + virtual void init(); + virtual bool handleInputEvent(QInputEvent* inputEvent); + + virtual void setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ); + virtual cvf::Vec3d pointOfInterest(); + virtual void setPointOfInterest(cvf::Vec3d poi); + + // PdvNavigation specific + void initializeRotationCenter(); + cvf::ref m_trackball; + bool m_isRotCenterInitialized; + cvf::Vec3d m_pointOfInterest; + + bool m_isNavigating; + bool m_hasMovedMouseDuringNavigation; + + // Handle mid mouse button zoom + void zoomAlongRay( cvf::Ray* ray, int delta ); + bool m_isZooming; + cvf::ref m_zoomRay; + int m_lastPosX; /// Previous mouse position + int m_lastPosY; + +}; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 5ebb970e73..a817cb6606 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -27,21 +27,25 @@ #include "RiaPreferences.h" #include "RiaRegressionTest.h" #include "RigCaseCellResultsData.h" -#include "RimAnalysisModels.h" -#include "RimCase.h" +#include "RimEclipseCaseCollection.h" +#include "RimEclipseCase.h" #include "RimCaseCollection.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimCommandObject.h" #include "RimFaultCollection.h" #include "RimOilField.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseView.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCase.h" + +#include "RimEclipseCellColors.h" +#include "RimGeoMechCellColors.h" #include "RimTools.h" #include "RimUiTreeModelPdm.h" #include "RimUiTreeView.h" -#include "RimWellCollection.h" +#include "RimEclipseWellCollection.h" #include "RimWellPathCollection.h" #include "RimWellPathImport.h" #include "RiuMultiCaseImportDialog.h" @@ -50,6 +54,8 @@ #include "RiuViewer.h" #include "RiuWellImportWizard.h" +#include "RigGeoMechCaseData.h" + #include "cafAboutDialog.h" #include "cafAnimationToolBar.h" #include "cafPdmFieldCvfMat4d.h" @@ -57,6 +63,9 @@ #include "cafPdmUiPropertyView.h" #include "cvfTimer.h" +#include "RimGeoMechModels.h" +#include "RimGeoMechView.h" +#include "RigFemPartResultsCollection.h" //================================================================================================== @@ -184,6 +193,7 @@ void RiuMainWindow::createActions() m_importEclipseCaseAction = new QAction(QIcon(":/Case48x48.png"), "Import &Eclipse Case", this); m_importInputEclipseFileAction= new QAction(QIcon(":/EclipseInput48x48.png"), "Import &Input Eclipse Case", this); + m_importGeoMechCaseAction = new QAction(QIcon(":/GeoMechCase48x48.png"), "Import &Geo Mechanical Model", this); m_openMultipleEclipseCasesAction = new QAction(QIcon(":/CreateGridCaseGroup16x16.png"), "&Create Grid Case Group from Files", this); m_importWellPathsFromFileAction = new QAction(QIcon(":/Well.png"), "Import &Well Paths from File", this); @@ -220,6 +230,8 @@ void RiuMainWindow::createActions() connect(m_openProjectAction, SIGNAL(triggered()), SLOT(slotOpenProject())); connect(m_openLastUsedProjectAction, SIGNAL(triggered()), SLOT(slotOpenLastUsedProject())); connect(m_importEclipseCaseAction, SIGNAL(triggered()), SLOT(slotImportEclipseCase())); + connect(m_importGeoMechCaseAction, SIGNAL(triggered()), SLOT(slotImportGeoMechModel())); + connect(m_importInputEclipseFileAction, SIGNAL(triggered()), SLOT(slotImportInputEclipseFiles())); connect(m_openMultipleEclipseCasesAction, SIGNAL(triggered()), SLOT(slotOpenMultipleCases())); connect(m_importWellPathsFromFileAction, SIGNAL(triggered()), SLOT(slotImportWellPathsFromFile())); @@ -307,7 +319,11 @@ void RiuMainWindow::createActions() connect(m_dsActionGroup, SIGNAL(triggered(QAction*)), SLOT(slotDrawStyleChanged(QAction*))); - + + m_disableLightingAction = new QAction(QIcon(":/disable_lighting_24x24.png"), "&Disable Results Lighting", this); + m_disableLightingAction->setCheckable(true); + connect(m_disableLightingAction, SIGNAL(toggled(bool)), SLOT(slotDisableLightingAction(bool))); + m_drawStyleToggleFaultsAction = new QAction( QIcon(":/draw_style_faults_24x24.png"), "&Show Faults Only", this); m_drawStyleToggleFaultsAction->setCheckable(true); @@ -382,6 +398,10 @@ void RiuMainWindow::createMenus() importMenu->addAction(m_importInputEclipseFileAction); importMenu->addAction(m_openMultipleEclipseCasesAction); importMenu->addSeparator(); + #ifdef USE_ODB_API + importMenu->addAction(m_importGeoMechCaseAction); + importMenu->addSeparator(); + #endif importMenu->addAction(m_importWellPathsFromFileAction); importMenu->addAction(m_importWellPathsFromSSIHubAction); @@ -493,6 +513,7 @@ void RiuMainWindow::createToolBars() m_viewToolBar->addAction(m_drawStyleLinesSolidAction); m_viewToolBar->addAction(m_drawStyleSurfOnlyAction); m_viewToolBar->addAction(m_drawStyleFaultLinesSolidAction); + m_viewToolBar->addAction(m_disableLightingAction); m_viewToolBar->addAction(m_drawStyleToggleFaultsAction); m_viewToolBar->addAction(m_toggleFaultsLabelAction); m_viewToolBar->addAction(m_addWellCellsToRangeFilterAction); @@ -686,13 +707,13 @@ void RiuMainWindow::slotRefreshViewActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::refreshAnimationActions() { - caf::FrameAnimationControl* ac = NULL; + caf::FrameAnimationControl* animationControl = NULL; if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - ac = RiaApplication::instance()->activeReservoirView()->viewer()->animationControl(); + animationControl = RiaApplication::instance()->activeReservoirView()->viewer()->animationControl(); } - m_animationToolBar->connectAnimationControl(ac); + m_animationToolBar->connectAnimationControl(animationControl); QStringList timeStepStrings; int currentTimeStepIndex = 0; @@ -700,45 +721,67 @@ void RiuMainWindow::refreshAnimationActions() RiaApplication* app = RiaApplication::instance(); bool enableAnimControls = false; - if (app->activeReservoirView() && - app->activeReservoirView()->viewer() && - app->activeReservoirView()->viewer()->frameCount()) + RimView * activeView = app->activeReservoirView(); + if (activeView && + activeView->viewer() && + activeView->viewer()->frameCount()) { enableAnimControls = true; + RimEclipseView * activeRiv = dynamic_cast(activeView); - if (app->activeReservoirView()->currentGridCellResults()) + if (activeRiv) { - if (app->activeReservoirView()->isTimeStepDependentDataVisible()) + if (activeRiv->currentGridCellResults()) { - std::vector timeStepDates = app->activeReservoirView()->currentGridCellResults()->cellResults()->timeStepDates(0); - bool showHoursAndMinutes = false; - for (size_t i = 0; i < timeStepDates.size(); i++) + if (activeRiv->isTimeStepDependentDataVisible()) { - if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0) + std::vector timeStepDates = activeRiv->currentGridCellResults()->cellResults()->timeStepDates(0); + bool showHoursAndMinutes = false; + for (size_t i = 0; i < timeStepDates.size(); i++) { - showHoursAndMinutes = true; + if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0) + { + showHoursAndMinutes = true; + } } - } - QString formatString = "dd.MMM yyyy"; - if (showHoursAndMinutes) - { - formatString += " - hh:mm"; - } + QString formatString = "dd.MMM yyyy"; + if (showHoursAndMinutes) + { + formatString += " - hh:mm"; + } - for (size_t i = 0; i < timeStepDates.size(); i++) + for (size_t i = 0; i < timeStepDates.size(); i++) + { + timeStepStrings += timeStepDates[i].toString(formatString); + } + currentTimeStepIndex = RiaApplication::instance()->activeReservoirView()->currentTimeStep(); + } + else { - timeStepStrings += timeStepDates[i].toString(formatString); + timeStepStrings.push_back(tr("Static Property")); } - currentTimeStepIndex = RiaApplication::instance()->activeReservoirView()->currentTimeStep(); } - else + } + else + { + RimGeoMechView * activeGmv = dynamic_cast(activeView); + if (activeGmv) { - timeStepStrings.push_back(tr("Static Property")); + if (activeGmv->isTimeStepDependentDataVisible()) + { + std::vector stepNames = activeGmv->geoMechCase()->geoMechData()->femPartResults()->stepNames(); + for (size_t i = 0; i < stepNames.size(); i++) + { + timeStepStrings += QString::fromStdString(stepNames[i]); + } + currentTimeStepIndex = RiaApplication::instance()->activeReservoirView()->currentTimeStep(); + } } } // Animation control is only relevant for more than one time step + if (timeStepStrings.size() < 2) { enableAnimControls = false; @@ -837,6 +880,36 @@ void RiuMainWindow::slotImportInputEclipseFiles() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindow::slotImportGeoMechModel() +{ + if (checkForDocumentModifications()) + { + RiaApplication* app = RiaApplication::instance(); + + QString defaultDir = app->defaultFileDialogDirectory("GEOMECH_MODEL"); + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)"); + if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); + app->setDefaultFileDialogDirectory("GEOMECH_MODEL", defaultDir); + + int i; + for (i = 0; i < fileNames.size(); i++) + { + QString fileName = fileNames[i]; + + if (!fileNames.isEmpty()) + { + if (app->openOdbCaseFromFile(fileName)) + { + addRecentFiles(fileName); + } + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// @@ -1009,6 +1082,10 @@ void RiuMainWindow::slotOpenRecentFile() { loadingSucceded = RiaApplication::instance()->openEclipseCaseFromFile(filename); } + else if (filename.contains(".odb", Qt::CaseInsensitive) ) + { + loadingSucceded = RiaApplication::instance()->openOdbCaseFromFile(filename); + } if (loadingSucceded) { @@ -1256,90 +1333,89 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) { RimProject * proj = RiaApplication::instance()->project(); if (!proj) return; + if (!subWindow) return; // Iterate all cases in each oil field - for (size_t oilFieldIdx = 0; oilFieldIdx < proj->oilFields().size(); oilFieldIdx++) + std::vector allCases; + proj->allCases(allCases); + + for (size_t caseIdx = 0; caseIdx < allCases.size(); ++caseIdx) { - RimOilField* oilField = proj->oilFields[oilFieldIdx]; - RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL; - if (analysisModels == NULL) continue; + RimCase* reservoirCase = allCases[caseIdx]; + if (reservoirCase == NULL) continue; + + std::vector views = reservoirCase->views(); - for (size_t caseIdx = 0; caseIdx < analysisModels->cases().size(); caseIdx++) + size_t viewIdx; + for (viewIdx = 0; viewIdx < views.size(); viewIdx++) { - RimCase* reservoirCase = analysisModels->cases[caseIdx]; - if (reservoirCase == NULL) continue; + RimView* riv = views[viewIdx]; - size_t viewIdx; - for (viewIdx = 0; viewIdx < reservoirCase->reservoirViews().size(); viewIdx++) + if (riv && + riv->viewer() && + riv->viewer()->layoutWidget() && + riv->viewer()->layoutWidget()->parent() == subWindow) { - RimReservoirView* riv = reservoirCase->reservoirViews()[viewIdx]; - - if (riv && - riv->viewer() && - riv->viewer()->layoutWidget() && - riv->viewer()->layoutWidget()->parent() == subWindow) + RimView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView(); + RiaApplication::instance()->setActiveReservoirView(riv); + if (previousActiveReservoirView && previousActiveReservoirView != riv) { - RimReservoirView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView(); - RiaApplication::instance()->setActiveReservoirView(riv); - if (previousActiveReservoirView && previousActiveReservoirView != riv) - { - QModelIndex previousViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(previousActiveReservoirView); - QModelIndex newViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(riv); - - QModelIndex newSelectionIndex = newViewModelIndex; - QModelIndex currentSelectionIndex = m_treeView->selectionModel()->currentIndex(); + QModelIndex previousViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(previousActiveReservoirView); + QModelIndex newViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(riv); - if (currentSelectionIndex != newViewModelIndex && - currentSelectionIndex.isValid()) - { - QVector route; // Contains all model indices from current selection up to previous view + QModelIndex newSelectionIndex = newViewModelIndex; + QModelIndex currentSelectionIndex = m_treeView->selectionModel()->currentIndex(); - QModelIndex tmpModelIndex = currentSelectionIndex; + if (currentSelectionIndex != newViewModelIndex && + currentSelectionIndex.isValid()) + { + QVector route; // Contains all model indices from current selection up to previous view - while (tmpModelIndex.isValid() && tmpModelIndex != previousViewModelIndex) - { - // NB! Add model index to front of vector to be able to do a for-loop with correct ordering - route.push_front(tmpModelIndex); + QModelIndex tmpModelIndex = currentSelectionIndex; - tmpModelIndex = tmpModelIndex.parent(); - } + while (tmpModelIndex.isValid() && tmpModelIndex != previousViewModelIndex) + { + // NB! Add model index to front of vector to be able to do a for-loop with correct ordering + route.push_front(tmpModelIndex); - // Traverse model indices from new view index to currently selected item - int i; - for (i = 0; i < route.size(); i++) - { - QModelIndex tmp = route[i]; - if (newSelectionIndex.isValid()) - { - newSelectionIndex = m_treeModelPdm->index(tmp.row(), tmp.column(), newSelectionIndex); - } - } + tmpModelIndex = tmpModelIndex.parent(); + } - // Use view model index if anything goes wrong - if (!newSelectionIndex.isValid()) + // Traverse model indices from new view index to currently selected item + int i; + for (i = 0; i < route.size(); i++) + { + QModelIndex tmp = route[i]; + if (newSelectionIndex.isValid()) { - newSelectionIndex = newViewModelIndex; + newSelectionIndex = m_treeModelPdm->index(tmp.row(), tmp.column(), newSelectionIndex); } } - m_treeView->setCurrentIndex(newSelectionIndex); - if (newSelectionIndex != newViewModelIndex) + // Use view model index if anything goes wrong + if (!newSelectionIndex.isValid()) { - m_treeView->setExpanded(newViewModelIndex, true); + newSelectionIndex = newViewModelIndex; } } - slotRefreshViewActions(); - refreshAnimationActions(); - refreshDrawStyleActions(); - break; + m_treeView->setCurrentIndex(newSelectionIndex); + if (newSelectionIndex != newViewModelIndex) + { + m_treeView->setExpanded(newViewModelIndex, true); + } } + + slotRefreshViewActions(); + refreshAnimationActions(); + refreshDrawStyleActions(); + break; } } - } } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1433,7 +1509,7 @@ void RiuMainWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous) { - RimReservoirView* activeReservoirView = RiaApplication::instance()->activeReservoirView(); + RimView* activeReservoirView = RiaApplication::instance()->activeReservoirView(); QModelIndex activeViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(activeReservoirView); QModelIndex tmp = current; @@ -1444,7 +1520,7 @@ void RiuMainWindow::slotCurrentChanged(const QModelIndex & current, const QModel caf::PdmUiTreeItem* treeItem = m_treeModelPdm->getTreeItemFromIndex(tmp); caf::PdmObject* pdmObject = treeItem->dataObject(); - RimReservoirView* rimReservoirView = dynamic_cast(pdmObject); + RimView* rimReservoirView = dynamic_cast(pdmObject); if (rimReservoirView) { // If current selection is an item within a different reservoir view than active, @@ -1652,9 +1728,10 @@ void RiuMainWindow::slotToggleFaultsAction(bool showFaults) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) { - if (!RiaApplication::instance()->activeReservoirView()) return; + RimEclipseView* activeRiv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (!activeRiv) return; - RiaApplication::instance()->activeReservoirView()->faultCollection->showFaultLabel.setValueFromUi(showLabels); + activeRiv->faultCollection->showFaultLabel.setValueFromUi(showLabels); refreshDrawStyleActions(); } @@ -1664,12 +1741,24 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::refreshDrawStyleActions() { - bool enable = RiaApplication::instance()->activeReservoirView() != NULL; + RimView* view = RiaApplication::instance()->activeReservoirView(); + bool enable = view != NULL; m_drawStyleLinesAction->setEnabled(enable); m_drawStyleLinesSolidAction->setEnabled(enable); m_drawStyleSurfOnlyAction->setEnabled(enable); m_drawStyleFaultLinesSolidAction->setEnabled(enable); + m_disableLightingAction->setEnabled(enable); + + RimGeoMechView* geoMechView = dynamic_cast(view); + bool lightingDisabledInView = view ? view->isLightingDisabled() : false; + + m_disableLightingAction->blockSignals(true); + m_disableLightingAction->setChecked(lightingDisabledInView); + m_disableLightingAction->blockSignals(false); + + RimEclipseView* eclView = dynamic_cast(view); + enable = enable && eclView; m_drawStyleToggleFaultsAction->setEnabled(enable); m_toggleFaultsLabelAction->setEnabled(enable); @@ -1677,22 +1766,35 @@ void RiuMainWindow::refreshDrawStyleActions() m_addWellCellsToRangeFilterAction->setEnabled(enable); if (enable) - { - RimReservoirView* riv = RiaApplication::instance()->activeReservoirView(); + { m_drawStyleToggleFaultsAction->blockSignals(true); - m_drawStyleToggleFaultsAction->setChecked( !riv->isGridVisualizationMode()); + m_drawStyleToggleFaultsAction->setChecked(!eclView->isGridVisualizationMode()); m_drawStyleToggleFaultsAction->blockSignals(false); m_toggleFaultsLabelAction->blockSignals(true); - m_toggleFaultsLabelAction->setChecked(riv->faultCollection()->showFaultLabel()); + m_toggleFaultsLabelAction->setChecked(eclView->faultCollection()->showFaultLabel()); m_toggleFaultsLabelAction->blockSignals(false); m_addWellCellsToRangeFilterAction->blockSignals(true); - m_addWellCellsToRangeFilterAction->setChecked( riv->wellCollection()->wellCellsToRangeFilterMode() != RimWellCollection::RANGE_ADD_NONE); + m_addWellCellsToRangeFilterAction->setChecked(eclView->wellCollection()->wellCellsToRangeFilterMode() != RimEclipseWellCollection::RANGE_ADD_NONE); m_addWellCellsToRangeFilterAction->blockSignals(false); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindow::slotDisableLightingAction(bool disable) +{ + RimView* view = RiaApplication::instance()->activeReservoirView(); + if (view) + { + view->disableLighting(disable); + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1967,11 +2069,11 @@ void RiuMainWindow::setDefaultWindowSize() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotAddWellCellsToRangeFilterAction(bool doAdd) { - RimReservoirView* riv = RiaApplication::instance()->activeReservoirView(); + RimEclipseView* riv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); if (riv) { - caf::AppEnum rangeAddType; - rangeAddType = doAdd ? RimWellCollection::RANGE_ADD_INDIVIDUAL : RimWellCollection::RANGE_ADD_NONE; + caf::AppEnum rangeAddType; + rangeAddType = doAdd ? RimEclipseWellCollection::RANGE_ADD_INDIVIDUAL : RimEclipseWellCollection::RANGE_ADD_NONE; riv->wellCollection()->wellCellsToRangeFilterMode.setValueFromUi(static_cast(rangeAddType.index())); } } @@ -1981,7 +2083,7 @@ void RiuMainWindow::slotAddWellCellsToRangeFilterAction(bool doAdd) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotOpenUsersGuideInBrowserAction() { - QString usersGuideUrl = "http://resinsight.org/"; + QString usersGuideUrl = "http://resinsight.org/docs/home"; if (!QDesktopServices::openUrl(usersGuideUrl)) { @@ -2005,12 +2107,18 @@ void RiuMainWindow::appendActionsContextMenuForPdmObject(caf::PdmObject* pdmObje menu->addAction(m_importWellPathsFromFileAction); menu->addAction(m_importWellPathsFromSSIHubAction); } - else if (dynamic_cast(pdmObject)) + else if (dynamic_cast(pdmObject)) { menu->addAction(m_importEclipseCaseAction); menu->addAction(m_importInputEclipseFileAction); menu->addAction(m_openMultipleEclipseCasesAction); } + else if (dynamic_cast(pdmObject)) + { + #ifdef USE_ODB_API + menu->addAction(m_importGeoMechCaseAction); + #endif + } } //-------------------------------------------------------------------------------------------------- @@ -2024,3 +2132,14 @@ void RiuMainWindow::setExpanded(const caf::PdmObject* pdmObject, bool expanded) m_treeView->setExpanded(mi, expanded); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindow::forceProjectTreeRepaint() +{ + // This is a hack to force the treeview redraw. + // Needed for some reason when changing names and icons in the model + m_treeView->scroll(0,1); + m_treeView->scroll(0,-1); +} diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 8ce06d71b1..04bc6ac9cb 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -42,6 +42,7 @@ class RiuResultInfoPanel; class RiuProcessMonitor; class RimUiTreeModelPdm; class RimUiTreeView; +class RimEclipseCase; class RimCase; namespace caf @@ -83,6 +84,7 @@ class RiuMainWindow : public QMainWindow void refreshAnimationActions(); void updateScaleValue(); + void forceProjectTreeRepaint(); RimUiTreeModelPdm* uiPdmModel() { return m_treeModelPdm;} @@ -132,6 +134,7 @@ class RiuMainWindow : public QMainWindow // File actions QAction* m_importEclipseCaseAction; QAction* m_importInputEclipseFileAction; + QAction* m_importGeoMechCaseAction; QAction* m_openMultipleEclipseCasesAction; QAction* m_openProjectAction; QAction* m_openLastUsedProjectAction; @@ -206,6 +209,7 @@ private slots: // File slots void slotImportEclipseCase(); void slotImportInputEclipseFiles(); + void slotImportGeoMechModel(); void slotOpenMultipleCases(); void slotOpenProject(); void slotOpenLastUsedProject(); @@ -238,6 +242,7 @@ private slots: void slotDrawStyleChanged(QAction* activatedAction); void slotToggleFaultsAction(bool); void slotToggleFaultLabelsAction(bool); + void slotDisableLightingAction(bool); void slotAddWellCellsToRangeFilterAction(bool doAdd); @@ -279,7 +284,6 @@ private slots: // Pdm System : public: void setPdmRoot(caf::PdmObject* pdmRoot); - private: RimUiTreeView* m_treeView; RimUiTreeModelPdm* m_treeModelPdm; @@ -289,6 +293,7 @@ private slots: QSpinBox* m_scaleFactor; QActionGroup* m_dsActionGroup; + QAction* m_disableLightingAction; QAction* m_drawStyleToggleFaultsAction; QAction* m_toggleFaultsLabelAction; QAction* m_drawStyleLinesAction; diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index e6014f07a1..8a3466df5a 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -53,6 +53,13 @@ class FileListModel: public QStringListModel } } + void removeFileNames(const QModelIndexList& indexes) + { + for (int i = indexes.size() - 1; i >= 0; i--) + { + removeRow(indexes[i].row(), indexes[i].parent()); + } + } void setItemsEditable(bool isEditable) { @@ -237,26 +244,9 @@ void RiuMultiCaseImportDialog::on_m_removeEclipseCaseButton_clicked() QModelIndexList selection = ui->m_eclipseCasesList->selectionModel()->selectedIndexes(); if (selection.size()) { - for (int i = 0; i < selection.size(); ++i) - { - ui->m_eclipseCasesList->model()->removeRow(selection[i].row(), selection[i].parent()); - } - - QModelIndexList selection = ui->m_eclipseCasesList->selectionModel()->selectedIndexes(); - QStringList fileNames = m_eclipseGridFiles->stringList(); - - QStringList filenamesToRemove; - - for (int i = 0; i < selection.size(); ++i) - { - filenamesToRemove.push_back(fileNames[selection[i].row()]); - } - - for (int i = 0; i < filenamesToRemove.size(); ++i) - { - fileNames.removeOne(filenamesToRemove[i]); - } + FileListModel* dataModel = static_cast(ui->m_eclipseCasesList->model()); + Q_ASSERT(dataModel); - m_eclipseGridFiles->setStringList(fileNames); + dataModel->removeFileNames(selection); } } diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index a21b951e17..b798cdc4f9 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -25,19 +25,19 @@ #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" -#include "RimCase.h" -#include "RimCellEdgeResultSlot.h" -#include "RimFaultResultSlot.h" +#include "RimEclipseCase.h" +#include "RimCellEdgeColors.h" +#include "RimEclipseFaultColors.h" #include "RimReservoirCellResultsStorage.h" -#include "RimReservoirView.h" -#include "RimResultSlot.h" +#include "RimEclipseView.h" +#include "RimEclipseCellColors.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuResultTextBuilder::RiuResultTextBuilder(RimReservoirView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex) +RiuResultTextBuilder::RiuResultTextBuilder(RimEclipseView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex) { CVF_ASSERT(reservoirView); @@ -86,19 +86,23 @@ QString RiuResultTextBuilder::mainResultText() // Priority defined as follows : NNC, Fault, Grid { QString nncText = nncResultText(); - QString faultText = faultResultText(); - if (!nncText.isEmpty()) { text = "NNC : " + nncText; } - else if (!faultResultText().isEmpty()) - { - text = "Fault : " + faultText; - } - else + + if (m_cellIndex != cvf::UNDEFINED_SIZE_T) { - text = "Grid cell : " + gridResultText(); + QString faultText = faultResultText(); + + if (!faultResultText().isEmpty()) + { + text = "Fault : " + faultText; + } + else + { + text = "Grid cell : " + gridResultText(); + } } text += "\n"; @@ -110,13 +114,13 @@ QString RiuResultTextBuilder::mainResultText() appendDetails(text, nncDetails()); - appendDetails(text, faultResultDetails()); - - appendDetails(text, cellEdgeResultDetails()); - - appendDetails(text, gridResultDetails()); - - appendDetails(text, wellResultText()); + if (m_cellIndex != cvf::UNDEFINED_SIZE_T) + { + appendDetails(text, faultResultDetails()); + appendDetails(text, cellEdgeResultDetails()); + appendDetails(text, gridResultDetails()); + appendDetails(text, wellResultText()); + } return text; } @@ -133,31 +137,34 @@ QString RiuResultTextBuilder::topologyText(QString itemSeparator) const RigCaseData* eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); if (eclipseCase) { - size_t i = 0; - size_t j = 0; - size_t k = 0; - if (eclipseCase->grid(m_gridIndex)->ijkFromCellIndex(m_cellIndex, &i, &j, &k)) + if (m_cellIndex != cvf::UNDEFINED_SIZE_T) { - // Adjust to 1-based Eclipse indexing - i++; - j++; - k++; + size_t i = 0; + size_t j = 0; + size_t k = 0; + if (eclipseCase->grid(m_gridIndex)->ijkFromCellIndex(m_cellIndex, &i, &j, &k)) + { + // Adjust to 1-based Eclipse indexing + i++; + j++; + k++; - cvf::Vec3d domainCoord = m_intersectionPoint + eclipseCase->grid(m_gridIndex)->displayModelOffset(); + cvf::StructGridInterface::FaceEnum faceEnum(m_face); - cvf::StructGridInterface::FaceEnum faceEnum(m_face); + QString faceText = faceEnum.text(); - QString faceText = faceEnum.text(); + text += QString("Face : %1").arg(faceText) + itemSeparator; + text += QString("Hit grid %1").arg(m_gridIndex) + itemSeparator; + text += QString("Cell : [%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator; + } + } - text += QString("Face : %1").arg(faceText) + itemSeparator; - text += QString("Hit grid %1").arg(m_gridIndex) + itemSeparator; - text += QString("Cell : [%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator; + cvf::Vec3d domainCoord = m_intersectionPoint + eclipseCase->grid(0)->displayModelOffset(); - QString formattedText; - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + QString formattedText; + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); - text += formattedText; - } + text += formattedText; } } @@ -176,7 +183,7 @@ QString RiuResultTextBuilder::gridResultDetails() RigCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->reservoirData(); RigGridBase* grid = eclipseCaseData->grid(m_gridIndex); - this->appendTextFromResultSlot(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->cellResult(), &text); + this->appendTextFromResultColors(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->cellResult(), &text); if (!text.isEmpty()) { @@ -213,7 +220,7 @@ QString RiuResultTextBuilder::faultResultDetails() if (m_reservoirView->faultResultSettings()->hasValidCustomResult()) { text += "Fault result data:\n"; - this->appendTextFromResultSlot(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->currentFaultResultSlot(), &text); + this->appendTextFromResultColors(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->currentFaultResultColors(), &text); } } } @@ -252,7 +259,7 @@ QString RiuResultTextBuilder::faultResultText() cvf::StructGridInterface::FaceEnum faceHelper(m_face); if (m_reservoirView->faultResultSettings()->hasValidCustomResult()) { - text = cellResultText(m_reservoirView->currentFaultResultSlot()); + text = cellResultText(m_reservoirView->currentFaultResultColors()); } } } @@ -285,13 +292,13 @@ QString RiuResultTextBuilder::nncResultText() const RigConnection& conn = nncData->connections()[m_nncIndex]; cvf::StructGridInterface::FaceEnum face(conn.m_c1Face); - if (m_reservoirView->currentFaultResultSlot()) + if (m_reservoirView->currentFaultResultColors()) { - size_t scalarResultIdx = m_reservoirView->currentFaultResultSlot()->scalarResultIndex(); + size_t scalarResultIdx = m_reservoirView->currentFaultResultColors()->scalarResultIndex(); const std::vector* nncValues = nncData->connectionScalarResult(scalarResultIdx); if (nncValues) { - QString resultVar = m_reservoirView->currentFaultResultSlot()->resultVariable(); + QString resultVar = m_reservoirView->currentFaultResultColors()->resultVariable(); double scalarValue = (*nncValues)[m_nncIndex]; text = QString("%1 : %2").arg(resultVar).arg(scalarValue); @@ -307,17 +314,17 @@ QString RiuResultTextBuilder::nncResultText() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, size_t gridIndex, size_t cellIndex, size_t timeStepIndex, RimResultSlot* resultSlot, QString* resultInfoText) +void RiuResultTextBuilder::appendTextFromResultColors(RigCaseData* eclipseCase, size_t gridIndex, size_t cellIndex, size_t timeStepIndex, RimEclipseCellColors* resultColors, QString* resultInfoText) { - if (!resultSlot) + if (!resultColors) { return; } - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel()); - if (resultSlot->isTernarySaturationSelected()) + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultColors->porosityModel()); + if (resultColors->isTernarySaturationSelected()) { - RimReservoirCellResultsStorage* gridCellResults = resultSlot->currentGridCellResults(); + RimReservoirCellResultsStorage* gridCellResults = resultColors->currentGridCellResults(); if (gridCellResults) { size_t soilScalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); @@ -343,14 +350,14 @@ void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, si resultInfoText->append(QString("SWAT : %1\n").arg(scalarValue)); } } - else if (resultSlot->hasResult()) + else if (resultColors->hasResult()) { - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultColors->porosityModel()); cvf::ref resultAccessor; - if (resultSlot->hasStaticResult()) + if (resultColors->hasStaticResult()) { - if (resultSlot->resultVariable().compare(RimDefines::combinedTransmissibilityResultName(), Qt::CaseInsensitive) == 0) + if (resultColors->resultVariable().compare(RimDefines::combinedTransmissibilityResultName(), Qt::CaseInsensitive) == 0) { cvf::ref transResultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, RimDefines::combinedTransmissibilityResultName()); { @@ -364,7 +371,7 @@ void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, si resultInfoText->append(QString("Tran Z : %1\n").arg(scalarValue)); } } - else if (resultSlot->resultVariable().compare(RimDefines::combinedMultResultName(), Qt::CaseInsensitive) == 0) + else if (resultColors->resultVariable().compare(RimDefines::combinedMultResultName(), Qt::CaseInsensitive) == 0) { cvf::ref multResultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, RimDefines::combinedMultResultName()); { @@ -386,7 +393,7 @@ void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, si resultInfoText->append(QString("MULTZ- : %1\n").arg(scalarValue)); } } - else if (resultSlot->resultVariable().compare(RimDefines::combinedRiTranResultName(), Qt::CaseInsensitive) == 0) + else if (resultColors->resultVariable().compare(RimDefines::combinedRiTranResultName(), Qt::CaseInsensitive) == 0) { cvf::ref transResultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, RimDefines::combinedRiTranResultName()); { @@ -400,7 +407,7 @@ void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, si resultInfoText->append(QString("riTran Z : %1\n").arg(scalarValue)); } } - else if (resultSlot->resultVariable().compare(RimDefines::combinedRiMultResultName(), Qt::CaseInsensitive) == 0) + else if (resultColors->resultVariable().compare(RimDefines::combinedRiMultResultName(), Qt::CaseInsensitive) == 0) { cvf::ref resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, RimDefines::combinedRiMultResultName()); { @@ -414,7 +421,7 @@ void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, si resultInfoText->append(QString("riMult Z : %1\n").arg(scalarValue)); } } - else if (resultSlot->resultVariable().compare(RimDefines::combinedRiAreaNormTranResultName(), Qt::CaseInsensitive) == 0) + else if (resultColors->resultVariable().compare(RimDefines::combinedRiAreaNormTranResultName(), Qt::CaseInsensitive) == 0) { cvf::ref resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, RimDefines::combinedRiAreaNormTranResultName()); { @@ -430,19 +437,19 @@ void RiuResultTextBuilder::appendTextFromResultSlot(RigCaseData* eclipseCase, si } else { - resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, resultSlot->scalarResultIndex()); + resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, 0, resultColors->scalarResultIndex()); } } else { - resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, timeStepIndex, resultSlot->scalarResultIndex()); + resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, timeStepIndex, resultColors->scalarResultIndex()); } if (resultAccessor.notNull()) { double scalarValue = resultAccessor->cellScalar(cellIndex); resultInfoText->append("Cell result : "); - resultInfoText->append(resultSlot->resultVariable()); + resultInfoText->append(resultColors->resultVariable()); resultInfoText->append(QString(" : %1\n").arg(scalarValue)); } } @@ -574,7 +581,7 @@ void RiuResultTextBuilder::appendDetails(QString& text, const QString& details) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuResultTextBuilder::cellResultText(RimResultSlot* resultSlot) +QString RiuResultTextBuilder::cellResultText(RimEclipseCellColors* resultColors) { QString text; @@ -583,11 +590,11 @@ QString RiuResultTextBuilder::cellResultText(RimResultSlot* resultSlot) RigCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->reservoirData(); RigGridBase* grid = eclipseCaseData->grid(m_gridIndex); - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultColors->porosityModel()); - QString resultVar = resultSlot->resultVariable(); + QString resultVar = resultColors->resultVariable(); - if (resultSlot->isTernarySaturationSelected()) + if (resultColors->isTernarySaturationSelected()) { RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->cellResult()->currentGridCellResults(); if (gridCellResults) @@ -644,7 +651,7 @@ QString RiuResultTextBuilder::wellResultText() { RigSingleWellResultsData* singleWellResultData = wellResults.at(i); - if (m_timeStepIndex < static_cast(singleWellResultData->firstResultTimeStep())) + if (m_timeStepIndex < singleWellResultData->firstResultTimeStep()) { continue; } diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.h b/ApplicationCode/UserInterface/RiuResultTextBuilder.h index 0b7aaede2c..c02beeddd6 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.h @@ -24,8 +24,8 @@ #include "cvfStructGrid.h" -class RimReservoirView; -class RimResultSlot; +class RimEclipseView; +class RimEclipseCellColors; class QString; class RigCaseData; @@ -40,7 +40,7 @@ namespace cvf { class RiuResultTextBuilder { public: - RiuResultTextBuilder(RimReservoirView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex); + RiuResultTextBuilder(RimEclipseView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex); void setFace(cvf::StructGridInterface::FaceType face); void setNncIndex(size_t nncIndex); void setIntersectionPoint(cvf::Vec3d intersectionPoint); @@ -62,12 +62,12 @@ class RiuResultTextBuilder QString nncResultText(); QString wellResultText(); - QString cellResultText(RimResultSlot* resultSlot); + QString cellResultText(RimEclipseCellColors* resultColors); - void appendTextFromResultSlot(RigCaseData* eclipseCase, size_t gridIndex, size_t cellIndex, size_t timeStepIndex, RimResultSlot* resultSlot, QString* resultInfoText); + void appendTextFromResultColors(RigCaseData* eclipseCase, size_t gridIndex, size_t cellIndex, size_t timeStepIndex, RimEclipseCellColors* resultColors, QString* resultInfoText); private: - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; size_t m_gridIndex; size_t m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuRmsNavigation.cpp b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp new file mode 100644 index 0000000000..74b7db7c60 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp @@ -0,0 +1,274 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuRmsNavigation.h" +#include "cafViewer.h" +#include "cvfCamera.h" +#include "cvfScene.h" +#include "cvfModel.h" +#include "cvfViewport.h" +#include "cvfHitItemCollection.h" +#include "cvfRay.h" + +#include +#include + +using cvf::ManipulatorTrackball; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuRmsNavigation::init() +{ + m_trackball = new cvf::ManipulatorTrackball; + m_trackball->setCamera(m_viewer->mainCamera()); + m_isRotCenterInitialized = false; + m_hasMovedMouseDuringNavigation = false; + m_isNavigating = false; + m_isZooming = false; + m_lastPosX = 0; + m_lastPosY = 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent) +{ + if (! inputEvent) return false; + bool isEventHandled = false; + switch (inputEvent->type()) + { + case QEvent::MouseButtonPress: + { + QMouseEvent * me = static_cast( inputEvent); + int translatedMousePosX = me->x(); + int translatedMousePosY = m_viewer->height() - me->y(); + + if (me->button() == Qt::MidButton) + { + cvf::HitItemCollection hic; + bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic); + + if (hitSomething) + { + cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint(); + m_trackball->setRotationPoint(pointOfInterest); + m_pointOfInterest = pointOfInterest; + } + else + { + initializeRotationCenter(); + } + + m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY); + //m_viewer->setCursor(RICursors::get(RICursors::ROTATE)); + m_isNavigating = true; + m_hasMovedMouseDuringNavigation = false; + isEventHandled = true; + } + else if (me->button() == Qt::LeftButton) + { + if (me->modifiers() == Qt::NoModifier) + { + QMouseEvent* we = static_cast ( inputEvent); + m_lastPosX = we->x(); + m_lastPosY = we->y(); + + m_zoomRay = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY); + + m_isNavigating = true; + m_hasMovedMouseDuringNavigation = false; + isEventHandled = true; + m_isZooming = true; + } + } + else if (me->button() == Qt::RightButton) + { + if (me->modifiers() == Qt::NoModifier) + { + m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY); + m_isNavigating = true; + m_hasMovedMouseDuringNavigation = false; + isEventHandled = true; + } + } + } + break; + case QEvent::MouseButtonRelease: + { + if (m_isNavigating) + { + QMouseEvent * me = static_cast( inputEvent); + if (me->button() == Qt::RightButton || me->button() == Qt::MidButton ) + { + m_trackball->endNavigation(); + + m_isNavigating = false; + if (m_hasMovedMouseDuringNavigation) isEventHandled = true; + m_hasMovedMouseDuringNavigation = false; + } + else if ( me->button() == Qt::LeftButton ) + { + m_isZooming = false; + + m_isNavigating = false; + if (m_hasMovedMouseDuringNavigation) isEventHandled = true; + m_hasMovedMouseDuringNavigation = false; + } + } + } + break; + case QEvent::MouseMove: + { + initializeRotationCenter(); + if (m_isRotCenterInitialized) + { + QMouseEvent * me = static_cast( inputEvent); + int translatedMousePosX = me->x(); + int translatedMousePosY = m_viewer->height() - me->y(); + + if (m_isNavigating) + { + if (m_isZooming) + { + int delta = -3*(m_lastPosY - me->y()); + this->zoomAlongRay(m_zoomRay.p(), delta); + m_lastPosX = me->x(); + m_lastPosY = me->y(); + } + else + { + bool needRedraw = m_trackball->updateNavigation(translatedMousePosX, translatedMousePosY); + if (needRedraw) + { + m_viewer->update(); + } + } + isEventHandled = true; + m_hasMovedMouseDuringNavigation = true; + } + } + } + break; + case QEvent::Wheel: + { + if (inputEvent->modifiers() == Qt::NoModifier) + { + initializeRotationCenter(); + if (m_isRotCenterInitialized) + { + QWheelEvent* we = static_cast ( inputEvent); + int translatedMousePosX = we->x(); + int translatedMousePosY = m_viewer->height() - we->y(); + int delta = we->delta(); + + cvf::ref ray; + if (delta < 0) + ray = m_viewer->mainCamera()->rayFromWindowCoordinates(translatedMousePosX, translatedMousePosY); + else + ray = m_viewer->mainCamera()->rayFromWindowCoordinates((int)(1.0*translatedMousePosX), (int)(1.0*translatedMousePosY)); + + zoomAlongRay(ray.p(), -delta); + + } + isEventHandled = true; + } + } + break; + } + + return false;//isEventHandled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuRmsNavigation::initializeRotationCenter() +{ + if(m_isRotCenterInitialized || m_trackball.isNull() || !m_viewer->mainScene() || !m_viewer->currentScene()->boundingBox().isValid()) return; + m_pointOfInterest = m_viewer->currentScene()->boundingBox().center(); + + m_trackball->setRotationPoint(m_pointOfInterest); + m_isRotCenterInitialized = true; +} + +//-------------------------------------------------------------------------------------------------- +/// Repositions and orients the camera to view the rotation point along the +/// direction "alongDirection". The distance to the rotation point is maintained. +/// +//-------------------------------------------------------------------------------------------------- +void RiuRmsNavigation::setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ) +{ + m_trackball->setView(alongDirection, upDirection); + /* + if (m_camera.isNull()) return; + + Vec3d dir = alongDirection; + if (!dir.normalize()) return; + Vec3d up = upDirection; + if(!up.normalize()) up = Vec3d::Z_AXIS; + + if((up * dir) < 1e-2) up = dir.perpendicularVector(); + + Vec3d cToE = m_camera->position() - m_rotationPoint; + Vec3d newEye = m_rotationPoint - cToE.length() * dir; + + m_camera->setFromLookAt(newEye, m_rotationPoint, upDirection); + */ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RiuRmsNavigation::pointOfInterest() +{ + initializeRotationCenter(); + return m_pointOfInterest; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuRmsNavigation::setPointOfInterest(cvf::Vec3d poi) +{ + m_pointOfInterest = poi; + m_trackball->setRotationPoint(poi); + m_isRotCenterInitialized = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuRmsNavigation::zoomAlongRay(cvf::Ray* ray, int delta) +{ + if (ray && abs(delta) > 0) + { + cvf::Vec3d pos, vrp, up; + m_viewer->mainCamera()->toLookAt(&pos, &vrp, &up); + + double scale = delta/8.0 * 1.0/150 * (pos - m_pointOfInterest).length(); + cvf::Vec3d trans = scale * ray->direction(); + cvf::Vec3d newPos = pos + trans; + cvf::Vec3d newVrp = vrp + trans; + + m_viewer->mainCamera()->setFromLookAt(newPos, newVrp, up ); + m_viewer->update(); + } +} diff --git a/ApplicationCode/UserInterface/RiuRmsNavigation.h b/ApplicationCode/UserInterface/RiuRmsNavigation.h new file mode 100644 index 0000000000..93fb068ec2 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRmsNavigation.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cafNavigationPolicy.h" +#include "cvfManipulatorTrackball.h" +#include "cvfRay.h" + + +class RiuRmsNavigation : public caf::NavigationPolicy +{ +protected: + // General navigation policy overrides + virtual void init(); + virtual bool handleInputEvent(QInputEvent* inputEvent); + + virtual void setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection ); + virtual cvf::Vec3d pointOfInterest(); + virtual void setPointOfInterest(cvf::Vec3d poi); + + // PdvNavigation specific + void initializeRotationCenter(); + cvf::ref m_trackball; + bool m_isRotCenterInitialized; + cvf::Vec3d m_pointOfInterest; + + bool m_isNavigating; + bool m_hasMovedMouseDuringNavigation; + + // Handle mid mouse button zoom + void zoomAlongRay( cvf::Ray* ray, int delta ); + bool m_isZooming; + cvf::ref m_zoomRay; + int m_lastPosX; /// Previous mouse position + int m_lastPosY; + +}; diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index ece963d70a..68ea3b4a1f 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -21,20 +21,26 @@ #include "RiaStdInclude.h" #include "RiuViewer.h" +#include "RiuViewerCommands.h" #include "RiaApplication.h" #include "RiuMainWindow.h" -#include "RimReservoirView.h" +#include "cafCeetronPlusNavigation.h" +#include "RiuCadNavigation.h" +#include "RiuRmsNavigation.h" +#include "RiuGeoQuestNavigation.h" + +#include "RimEclipseView.h" #include "Rim3dOverlayInfoConfig.h" -#include "RimCase.h" -#include "RimCellEdgeResultSlot.h" -#include "RimCellPropertyFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimCellEdgeColors.h" +#include "RimEclipsePropertyFilterCollection.h" #include "RimCellRangeFilterCollection.h" #include "RimFaultCollection.h" -#include "RimResultSlot.h" -#include "RimWellCollection.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseWellCollection.h" #include "RimUiTreeModelPdm.h" @@ -50,7 +56,16 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" #include "RivSourceInfo.h" +#include "RivFemPickSourceInfo.h" + #include "RiuResultTextBuilder.h" +#include "RivFemPartGeometryGenerator.h" +#include "RimGeoMechView.h" +#include "RimGeoMechCase.h" +#include "RigGeoMechCaseData.h" +#include "RigFemPartCollection.h" +#include "RigFemPart.h" +#include "RigFemPartGrid.h" using cvf::ManipulatorTrackball; @@ -66,6 +81,8 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1; /// //================================================================================================== +#include "RiaBaseDefs.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -116,6 +133,18 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_InfoLabel->setFrameShape(QFrame::Box); m_showInfoText = true; + // Version info label + m_versionInfoLabel = new QLabel(); + m_versionInfoLabel->setFrameShape(QFrame::NoFrame); + m_versionInfoLabel->setAlignment(Qt::AlignRight); + m_versionInfoLabel->setText(QString("%1 v%2").arg(RI_APPLICATION_NAME, RiaApplication::getVersionStringApp(false))); + + QPalette versionInfoPalette = p; + QColor versionInfoLabelColor = p.color(QPalette::Window); + versionInfoLabelColor.setAlpha(0); + versionInfoPalette.setColor(QPalette::Window, versionInfoLabelColor); + m_versionInfoLabel->setPalette(versionInfoPalette); + // Animation progress bar m_animationProgress = new QProgressBar(); m_animationProgress->setPalette(p); @@ -131,6 +160,18 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_histogramWidget->setPalette(p); m_showHistogram = false; + m_viewerCommands = new RiuViewerCommands(this); + + if (RiaApplication::instance()->isRunningRegressionTests()) + { + QFont regTestFont = m_InfoLabel->font(); + regTestFont.setPixelSize(11); + + m_InfoLabel->setFont(regTestFont); + m_versionInfoLabel->setFont(regTestFont); + m_animationProgress->setFont(regTestFont); + m_histogramWidget->setFont(regTestFont); + } } @@ -139,9 +180,11 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) //-------------------------------------------------------------------------------------------------- RiuViewer::~RiuViewer() { - m_reservoirView->showWindow = false; - m_reservoirView->cameraPosition = m_mainCamera->viewMatrix(); - + if (m_reservoirView) + { + m_reservoirView->showWindow = false; + m_reservoirView->cameraPosition = m_mainCamera->viewMatrix(); + } delete m_InfoLabel; delete m_animationProgress; delete m_histogramWidget; @@ -190,21 +233,15 @@ void RiuViewer::setDefaultView() //-------------------------------------------------------------------------------------------------- void RiuViewer::mouseReleaseEvent(QMouseEvent* event) { - m_mouseState.updateFromMouseEvent(event); - if (!this->canRender()) return; - // Picking if (event->button() == Qt::LeftButton) { - handlePickAction(event->x(), event->y()); + m_viewerCommands->handlePickAction(event->x(), event->y()); return; } else if (event->button() == Qt::RightButton) { - m_currentGridIdx = cvf::UNDEFINED_SIZE_T; - m_currentCellIndex = cvf::UNDEFINED_SIZE_T; - QPoint diffPoint = event->pos() - m_lastMousePressPosition; if (diffPoint.manhattanLength() > 3) { @@ -212,251 +249,11 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event) return; } - int winPosX = event->x(); - int winPosY = event->y(); - - uint faceIndex = cvf::UNDEFINED_UINT; - cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO); - - cvf::Part* firstHitPart = NULL; - cvf::Part* nncFirstHitPart = NULL; - pickPointAndFace(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL); - if (firstHitPart) - { - if (faceIndex != cvf::UNDEFINED_UINT) - { - if (firstHitPart->sourceInfo()) - { - const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); - if (rivSourceInfo) - { - if (rivSourceInfo->hasCellFaceMapping()) - { - m_currentGridIdx = firstHitPart->id(); - m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex); - m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex); - - QMenu menu; - - menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI())); - menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ())); - menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK())); - - const RigCaseData* reservoir = m_reservoirView->eclipseCase()->reservoirData(); - const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); - if (fault) - { - menu.addSeparator(); - - QString faultName = fault->name(); - menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault())); - } - - menu.exec(event->globalPos()); - } - } - } - } - } - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuViewer::slotRangeFilterI() -{ - size_t i, j, k; - ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); - - RiuMainWindow* mainWindow = RiuMainWindow::instance(); - RimUiTreeModelPdm* myModel = mainWindow->uiPdmModel(); - if (myModel) - { - RimCellRangeFilterCollection* rangeFilterCollection = m_reservoirView->rangeFilterCollection(); - - QModelIndex collectionModelIndex = myModel->getModelIndexFromPdmObject(rangeFilterCollection); - - QModelIndex insertedIndex; - RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(collectionModelIndex, insertedIndex); - - rangeFilter->name = QString("Slice I (%1)").arg(rangeFilterCollection->rangeFilters().size()); - rangeFilter->cellCountI = 1; - int startIndex = CVF_MAX(static_cast(i + 1), 1); - rangeFilter->startIndexI = startIndex; - - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); - - rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); - - mainWindow->setCurrentObjectInTreeView(rangeFilter); - } - - m_reservoirView->setSurfaceDrawstyle(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuViewer::slotRangeFilterJ() -{ - size_t i, j, k; - ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); - - RiuMainWindow* mainWindow = RiuMainWindow::instance(); - RimUiTreeModelPdm* myModel = mainWindow->uiPdmModel(); - if (myModel) - { - RimCellRangeFilterCollection* rangeFilterCollection = m_reservoirView->rangeFilterCollection(); - - QModelIndex collectionModelIndex = myModel->getModelIndexFromPdmObject(rangeFilterCollection); - - QModelIndex insertedIndex; - RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(collectionModelIndex, insertedIndex); - - rangeFilter->name = QString("Slice J (%1)").arg(rangeFilterCollection->rangeFilters().size()); - rangeFilter->cellCountJ = 1; - int startIndex = CVF_MAX(static_cast(j + 1), 1); - rangeFilter->startIndexJ = startIndex; - - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); - - rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); - - mainWindow->setCurrentObjectInTreeView(rangeFilter); - } - - m_reservoirView->setSurfaceDrawstyle(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuViewer::slotRangeFilterK() -{ - size_t i, j, k; - ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); - - RiuMainWindow* mainWindow = RiuMainWindow::instance(); - RimUiTreeModelPdm* myModel = mainWindow->uiPdmModel(); - if (myModel) - { - RimCellRangeFilterCollection* rangeFilterCollection = m_reservoirView->rangeFilterCollection(); - - QModelIndex collectionModelIndex = myModel->getModelIndexFromPdmObject(rangeFilterCollection); - - QModelIndex insertedIndex; - RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(collectionModelIndex, insertedIndex); - - rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size()); - rangeFilter->cellCountK = 1; - int startIndex = CVF_MAX(static_cast(k + 1), 1); - rangeFilter->startIndexK = startIndex; - - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED); - rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE); - - rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); - - mainWindow->setCurrentObjectInTreeView(rangeFilter); - } - - m_reservoirView->setSurfaceDrawstyle(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuViewer::keyPressEvent(QKeyEvent* event) -{ - // Trap escape key so we can get out of direct button press actions - if (event->key() == Qt::Key_Escape) - { - - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuViewer::handlePickAction(int winPosX, int winPosY) -{ - RiaApplication* app = RiaApplication::instance(); - - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if (!mainWnd) return; - - size_t gridIndex = cvf::UNDEFINED_SIZE_T; - size_t cellIndex = cvf::UNDEFINED_SIZE_T; - size_t nncIndex = cvf::UNDEFINED_SIZE_T; - cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE; - cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO); - - { - cvf::Part* firstHitPart = NULL; - uint firstPartFaceIndex = cvf::UNDEFINED_UINT; - - cvf::Part* firstNncHitPart = NULL; - uint nncPartFaceIndex = cvf::UNDEFINED_UINT; - - pickPointAndFace(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &firstPartFaceIndex, &firstNncHitPart, &nncPartFaceIndex); - - if (firstHitPart) - { - gridIndex = firstHitPart->id(); - if (firstHitPart->sourceInfo()) - { - const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); - if (rivSourceInfo) - { - if (rivSourceInfo->hasCellFaceMapping()) - { - CVF_ASSERT(rivSourceInfo->m_cellFaceFromTriangleMapper.notNull()); - - cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(firstPartFaceIndex); - face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(firstPartFaceIndex); - } - } - } - } - - - if (firstNncHitPart && firstNncHitPart->sourceInfo()) - { - const RivSourceInfo* rivSourceInfo = dynamic_cast(firstNncHitPart->sourceInfo()); - if (rivSourceInfo) - { - if (nncPartFaceIndex < rivSourceInfo->m_NNCIndices->size()) - { - nncIndex = rivSourceInfo->m_NNCIndices->get(nncPartFaceIndex); - } - } - } - } - - QString pickInfo = "No hits"; - QString resultInfo = ""; - - if (cellIndex != cvf::UNDEFINED_SIZE_T) - { - RiuResultTextBuilder textBuilder(m_reservoirView, gridIndex, cellIndex, m_reservoirView->currentTimeStep()); - textBuilder.setFace(face); - textBuilder.setNncIndex(nncIndex); - textBuilder.setIntersectionPoint(localIntersectionPoint); - - resultInfo = textBuilder.mainResultText(); - - pickInfo = textBuilder.topologyText(", "); + m_viewerCommands->displayContextMenu(event); + return; } - - mainWnd->statusBar()->showMessage(pickInfo); - mainWnd->setResultInfo(resultInfo); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -504,9 +301,10 @@ void RiuViewer::setPointOfInterest(cvf::Vec3d poi) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::setOwnerReservoirView(RimReservoirView * owner) +void RiuViewer::setOwnerReservoirView(RimView * owner) { m_reservoirView = owner; + m_viewerCommands->setOwnerView(owner); } //-------------------------------------------------------------------------------------------------- @@ -517,96 +315,6 @@ void RiuViewer::setEnableMask(unsigned int mask) m_mainRendering->setEnableMask(mask); } -//-------------------------------------------------------------------------------------------------- -/// Perform picking and return the index of the face that was hit, if a drawable geo was hit -//-------------------------------------------------------------------------------------------------- -void RiuViewer::pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit) -{ - cvf::HitItemCollection hitItems; - bool isSomethingHit = rayPick(winPosX, winPosY, &hitItems); - - if (isSomethingHit) - { - CVF_ASSERT(hitItems.count() > 0); - - double characteristicCellSize = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize(); - double pickDepthThresholdSquared = characteristicCellSize / 100.0; - pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared; - - cvf::HitItem* firstNonNncHitItem = NULL; - cvf::Vec3d firstItemIntersectionPoint = hitItems.item(0)->intersectionPoint(); - - // Check if we have a close hit item with NNC data - for (size_t i = 0; i < hitItems.count(); i++) - { - cvf::HitItem* hitItemCandidate = hitItems.item(i); - cvf::Vec3d diff = firstItemIntersectionPoint - hitItemCandidate->intersectionPoint(); - - const cvf::Part* pickedPartCandidate = hitItemCandidate->part(); - bool isNncpart = false; - if (pickedPartCandidate && pickedPartCandidate->sourceInfo()) - { - // Hit items are ordered by distance from eye - if (diff.lengthSquared() < pickDepthThresholdSquared) - { - const RivSourceInfo* rivSourceInfo = dynamic_cast(pickedPartCandidate->sourceInfo()); - if (rivSourceInfo && rivSourceInfo->hasNNCIndices()) - { - *nncPart = const_cast(pickedPartCandidate); - - const cvf::HitDetailDrawableGeo* detail = dynamic_cast(hitItemCandidate->detail()); - if (detail && nncPartFaceHit) - { - *nncPartFaceHit = detail->faceIndex(); - } - - isNncpart = true; - } - } - } - - if (!isNncpart && !firstNonNncHitItem) - { - firstNonNncHitItem = hitItemCandidate; - firstItemIntersectionPoint = firstNonNncHitItem->intersectionPoint(); - } - - if (firstNonNncHitItem && *nncPart) - { - break; - } - } - - const cvf::Part* pickedPart = firstNonNncHitItem->part(); - CVF_ASSERT(pickedPart); - *firstPart = const_cast(pickedPart); - - const cvf::Transform* xf = pickedPart->transform(); - cvf::Vec3d globalPickedPoint = firstNonNncHitItem->intersectionPoint(); - - if(localIntersectionPoint) - { - if (xf) - { - *localIntersectionPoint = globalPickedPoint.getTransformedPoint(xf->worldTransform().getInverted()); - } - else - { - *localIntersectionPoint = globalPickedPoint; - } - } - - if (firstPartFaceHit) - { - const cvf::HitDetailDrawableGeo* detail = dynamic_cast(firstNonNncHitItem->detail()); - if (detail) - { - *firstPartFaceHit = detail->faceIndex(); - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -653,7 +361,16 @@ void RiuViewer::paintOverlayItems(QPainter* painter) { m_histogramWidget->resize(columnWidth, 40); m_histogramWidget->render(painter,QPoint(columnPos, yPos)); - yPos += m_InfoLabel->height() + margin; + yPos += m_histogramWidget->height() + margin; + } + + if (m_showInfoText) + { + QSize size(m_versionInfoLabel->sizeHint().width(), m_versionInfoLabel->sizeHint().height()); + QPoint pos(this->width() - size.width() - margin, this->height() - size.height() - margin); + m_versionInfoLabel->resize(size.width(), size.height()); + m_versionInfoLabel->render(painter, pos); + yPos += size.height() + margin; } } @@ -706,17 +423,6 @@ void RiuViewer::showHistogram(bool enable) m_showHistogram = enable; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuViewer::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k) -{ - if (m_reservoirView->eclipseCase()) - { - m_reservoirView->eclipseCase()->reservoirData()->grid(gridIdx)->ijkFromCellIndex(cellIndex, i, j, k); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -726,24 +432,6 @@ void RiuViewer::mousePressEvent(QMouseEvent* event) } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuViewer::slotHideFault() -{ - const RigCaseData* reservoir = m_reservoirView->eclipseCase()->reservoirData(); - const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); - if (fault) - { - QString faultName = fault->name(); - - RimFault* rimFault = m_reservoirView->faultCollection()->findFaultByName(faultName); - if (rimFault) - { - rimFault->showFault.setValueFromUi(!rimFault->showFault); - } - } -} //-------------------------------------------------------------------------------------------------- /// @@ -775,3 +463,31 @@ void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::updateNavigationPolicy() +{ + switch (RiaApplication::instance()->navigationPolicy()) + { + case RiaApplication::NAVIGATION_POLICY_CAD: + setNavigationPolicy(new RiuCadNavigation); + break; + + case RiaApplication::NAVIGATION_POLICY_CEETRON: + setNavigationPolicy(new caf::CeetronPlusNavigation); + break; + + case RiaApplication::NAVIGATION_POLICY_GEOQUEST: + setNavigationPolicy(new RiuGeoQuestNavigation); + break; + + case RiaApplication::NAVIGATION_POLICY_RMS: + setNavigationPolicy(new RiuRmsNavigation); + break; + + default: + CVF_ASSERT(0); + break; + } +} diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index a8131d63da..4374af1d8d 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -28,11 +28,12 @@ #include "cafMouseState.h" #include "cvfStructGrid.h" -class RimReservoirView; +class RimView; class QLabel; class QProgressBar; class RiuSimpleHistogramWidget; class QCDEStyle; +class RiuViewerCommands; namespace cvf { @@ -56,7 +57,7 @@ class RiuViewer : public caf::Viewer void setDefaultView(); cvf::Vec3d pointOfInterest(); void setPointOfInterest(cvf::Vec3d poi); - void setOwnerReservoirView(RimReservoirView * owner); + void setOwnerReservoirView(RimView * owner); void setEnableMask(unsigned int mask); void showInfoText(bool enable); @@ -70,33 +71,20 @@ class RiuViewer : public caf::Viewer void removeAllColorLegends(); void addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend); + void updateNavigationPolicy(); public slots: virtual void slotSetCurrentFrame(int frameIndex); virtual void slotEndAnimation(); -protected: +private: void paintOverlayItems(QPainter* painter); - void keyPressEvent(QKeyEvent* event); + void mouseReleaseEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event); - void handlePickAction(int winPosX, int winPosY); - void pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit); - -private slots: - void slotRangeFilterI(); - void slotRangeFilterJ(); - void slotRangeFilterK(); - void slotHideFault(); - -private: - void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k); - -private: - caf::QtMouseState m_mouseState; - QLabel* m_InfoLabel; + QLabel* m_versionInfoLabel; bool m_showInfoText;; QProgressBar* m_animationProgress; @@ -109,11 +97,9 @@ private slots: cvf::Collection m_visibleLegends; - caf::PdmPointer m_reservoirView; + caf::PdmPointer m_reservoirView; + QPoint m_lastMousePressPosition; - size_t m_currentGridIdx; - size_t m_currentCellIndex; - cvf::StructGridInterface::FaceType m_currentFaceIndex; - - QPoint m_lastMousePressPosition; + RiuViewerCommands * m_viewerCommands; }; + diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp new file mode 100644 index 0000000000..e12a06f719 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -0,0 +1,576 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RiuViewerCommands.h" +#include "RiuViewer.h" +#include "RimUiTreeModelPdm.h" +#include "RimCellRangeFilter.h" +#include "RimView.h" +#include "RimCellRangeFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimGeoMechView.h" +#include "RimFaultCollection.h" +#include "RimEclipseCellColors.h" +#include "RimEclipsePropertyFilter.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimGeoMechView.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechCellColors.h" + +#include "RivSourceInfo.h" +#include "RivFemPickSourceInfo.h" +#include "RivFemPartGeometryGenerator.h" +#include "RigCaseData.h" +#include "RiuMainWindow.h" +#include "RiaApplication.h" +#include "RiuResultTextBuilder.h" +#include "RigGeoMechCaseData.h" +#include "RimGeoMechCase.h" +#include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" + +#include "cvfDrawableGeo.h" +#include "cvfPart.h" +#include "cvfHitItemCollection.h" + +#include +#include + +#include +#include "RiuFemResultTextBuilder.h" + +//================================================================================================== +// +// RiaViewerCommands +// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer) : QObject(ownerViewer), m_viewer(ownerViewer) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuViewerCommands::~RiuViewerCommands() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::setOwnerView(RimView * owner) +{ + m_reservoirView = owner; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::displayContextMenu(QMouseEvent* event) +{ + m_currentGridIdx = cvf::UNDEFINED_SIZE_T; + m_currentCellIndex = cvf::UNDEFINED_SIZE_T; + + int winPosX = event->x(); + int winPosY = event->y(); + + uint faceIndex = cvf::UNDEFINED_UINT; + cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO); + + cvf::Part* firstHitPart = NULL; + cvf::Part* nncFirstHitPart = NULL; + + cvf::HitItemCollection hitItems; + + if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) + { + extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL); + } + + if (!firstHitPart) return; + + if (faceIndex == cvf::UNDEFINED_UINT) return; + + if (!firstHitPart->sourceInfo()) return; + + const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + const RivFemPickSourceInfo* femSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + + if (!(rivSourceInfo || femSourceInfo) ) return; + + if (rivSourceInfo) + { + if (!rivSourceInfo->hasCellFaceMapping()) return; + + // Set the data regarding what was hit + + m_currentGridIdx = rivSourceInfo->gridIndex(); + m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex); + m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex); + } + else + { + m_currentGridIdx = femSourceInfo->femPartIndex(); + m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(faceIndex); + } + + // IJK -slice commands + + QMenu menu; + + menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI())); + menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ())); + menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK())); + + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if (eclipseView) + { + RimEclipseCellColors* cellColors = eclipseView->cellResult().p(); + if (cellColors) + { + menu.addAction(QString("Add property filter"), this, SLOT(slotAddEclipsePropertyFilter())); + } + + // Hide faults command + const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData(); + const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); + if (fault) + { + menu.addSeparator(); + + QString faultName = fault->name(); + menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault())); + } + } + + RimGeoMechView* geoMechView = dynamic_cast(m_reservoirView.p()); + if (geoMechView) + { + RimGeoMechCellColors* cellColors = geoMechView->cellResult().p(); + if (cellColors) + { + menu.addAction(QString("Add property filter"), this, SLOT(slotAddGeoMechPropertyFilter())); + } + } + + menu.exec(event->globalPos()); +} + +//-------------------------------------------------------------------------------------------------- +/// Todo: Move this to a command instead +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::slotRangeFilterI() +{ + createSliceRangeFilter(0); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::slotRangeFilterJ() +{ + createSliceRangeFilter(1); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::slotRangeFilterK() +{ + createSliceRangeFilter(2); +} + +void RiuViewerCommands::createSliceRangeFilter(int ijOrk) +{ + RimView* eclipseView = m_reservoirView.p(); + if (!eclipseView) return; + + size_t i, j, k; + ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); + + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + RimUiTreeModelPdm* myModel = mainWindow->uiPdmModel(); + if (myModel) + { + RimCellRangeFilterCollection* rangeFilterCollection = eclipseView->rangeFilterCollection(); + + QModelIndex collectionModelIndex = myModel->getModelIndexFromPdmObject(rangeFilterCollection); + + QModelIndex insertedIndex; + RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(collectionModelIndex, insertedIndex); + + if (ijOrk == 0){ + rangeFilter->name = QString("Slice I (%1)").arg(rangeFilterCollection->rangeFilters().size()); + rangeFilter->cellCountI = 1; + int startIndex = CVF_MAX(static_cast(i + 1), 1); + rangeFilter->startIndexI = startIndex; + + } + else if (ijOrk == 1){ + rangeFilter->name = QString("Slice J (%1)").arg(rangeFilterCollection->rangeFilters().size()); + rangeFilter->cellCountJ = 1; + int startIndex = CVF_MAX(static_cast(j + 1), 1); + rangeFilter->startIndexJ = startIndex; + + } + else if (ijOrk == 2){ + rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size()); + rangeFilter->cellCountK = 1; + int startIndex = CVF_MAX(static_cast(k + 1), 1); + rangeFilter->startIndexK = startIndex; + } + + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED); + rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); + + rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); + + mainWindow->setCurrentObjectInTreeView(rangeFilter); + } + + eclipseView->setSurfaceDrawstyle(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::slotHideFault() +{ + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if(!eclipseView) return; + + + const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData(); + const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); + if (fault) + { + QString faultName = fault->name(); + + RimFault* rimFault = eclipseView->faultCollection()->findFaultByName(faultName); + if (rimFault) + { + rimFault->showFault.setValueFromUi(!rimFault->showFault); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::slotAddEclipsePropertyFilter() +{ + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if (eclipseView) + { + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + RimUiTreeModelPdm* myModel = mainWindow->uiPdmModel(); + if (myModel) + { + RimEclipsePropertyFilterCollection* filterCollection = eclipseView->propertyFilterCollection(); + + QModelIndex collectionModelIndex = myModel->getModelIndexFromPdmObject(filterCollection); + + QModelIndex insertedIndex; + RimEclipsePropertyFilter* propertyFilter = myModel->addPropertyFilter(collectionModelIndex, insertedIndex); + + mainWindow->setCurrentObjectInTreeView(propertyFilter); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::slotAddGeoMechPropertyFilter() +{ + RimGeoMechView* geoMechView = dynamic_cast(m_reservoirView.p()); + if (geoMechView) + { + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + RimUiTreeModelPdm* myModel = mainWindow->uiPdmModel(); + if (myModel) + { + RimGeoMechPropertyFilterCollection* filterCollection = geoMechView->propertyFilterCollection(); + + QModelIndex collectionModelIndex = myModel->getModelIndexFromPdmObject(filterCollection); + + QModelIndex insertedIndex; + RimGeoMechPropertyFilter* propertyFilter = myModel->addGeoMechPropertyFilter(collectionModelIndex, insertedIndex); + + mainWindow->setCurrentObjectInTreeView(propertyFilter); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::handlePickAction(int winPosX, int winPosY) +{ + + size_t gridIndex = cvf::UNDEFINED_SIZE_T; + size_t cellIndex = cvf::UNDEFINED_SIZE_T; + size_t nncIndex = cvf::UNDEFINED_SIZE_T; + cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE; + cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO); + + // Extract all the above information from the pick + { + cvf::Part* firstHitPart = NULL; + uint firstPartTriangleIndex = cvf::UNDEFINED_UINT; + + cvf::Part* firstNncHitPart = NULL; + uint nncPartTriangleIndex = cvf::UNDEFINED_UINT; + + cvf::HitItemCollection hitItems; + + if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) + { + extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &firstNncHitPart, &nncPartTriangleIndex); + } + + if (firstHitPart && firstHitPart->sourceInfo()) + { + const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + const RivFemPickSourceInfo* femSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + + if (rivSourceInfo) + { + gridIndex = rivSourceInfo->gridIndex(); + if (rivSourceInfo->hasCellFaceMapping()) + { + CVF_ASSERT(rivSourceInfo->m_cellFaceFromTriangleMapper.notNull()); + + cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(firstPartTriangleIndex); + face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(firstPartTriangleIndex); + } + } + else if (femSourceInfo) + { + gridIndex = femSourceInfo->femPartIndex(); + cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(firstPartTriangleIndex); + } + } + + + + if (firstNncHitPart && firstNncHitPart->sourceInfo()) + { + const RivSourceInfo* rivSourceInfo = dynamic_cast(firstNncHitPart->sourceInfo()); + if (rivSourceInfo) + { + if (nncPartTriangleIndex < rivSourceInfo->m_NNCIndices->size()) + { + nncIndex = rivSourceInfo->m_NNCIndices->get(nncPartTriangleIndex); + } + } + } + } + + // Compose a info text regarding the hit + + QString pickInfo = "No hits"; + QString resultInfo = ""; + + if (cellIndex != cvf::UNDEFINED_SIZE_T || nncIndex != cvf::UNDEFINED_SIZE_T) + { + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); + + if (eclipseView) + { + RiuResultTextBuilder textBuilder(eclipseView, gridIndex, cellIndex, eclipseView->currentTimeStep()); + textBuilder.setFace(face); + textBuilder.setNncIndex(nncIndex); + textBuilder.setIntersectionPoint(localIntersectionPoint); + + resultInfo = textBuilder.mainResultText(); + + pickInfo = textBuilder.topologyText(", "); + } + else if (geomView) + { + RiuFemResultTextBuilder textBuilder(geomView, (int)gridIndex, (int)cellIndex, geomView->currentTimeStep()); + //textBuilder.setFace(face); + + textBuilder.setIntersectionPoint(localIntersectionPoint); + + resultInfo = textBuilder.mainResultText(); + + pickInfo = textBuilder.topologyText(", "); + } + } + + // Display the text + + RiuMainWindow* mainWnd = RiuMainWindow::instance(); + if (!mainWnd) return; + + mainWnd->statusBar()->showMessage(pickInfo); + mainWnd->setResultInfo(resultInfo); +} + +//-------------------------------------------------------------------------------------------------- +/// Perform picking and return the index of the face that was hit, if a drawable geo was hit +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hitItems, + cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, + cvf::Part** nncPart, uint* nncPartFaceHit) +{ + CVF_ASSERT(hitItems.count() > 0); + + double pickDepthThresholdSquared = 0.05 *0.05; + { + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + + if (eclipseView && eclipseView->eclipseCase()) + { + double characteristicCellSize = eclipseView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize(); + pickDepthThresholdSquared = characteristicCellSize / 100.0; + pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared; + } + } + + const cvf::HitItem* firstNonNncHitItem = NULL; + cvf::Vec3d firstItemIntersectionPoint = hitItems.item(0)->intersectionPoint(); + + // Check if we have a close hit item with NNC data + + for (size_t i = 0; i < hitItems.count(); i++) + { + const cvf::HitItem* hitItemCandidate = hitItems.item(i); + cvf::Vec3d diff = firstItemIntersectionPoint - hitItemCandidate->intersectionPoint(); + + const cvf::Part* pickedPartCandidate = hitItemCandidate->part(); + bool isNncpart = false; + + if (pickedPartCandidate && pickedPartCandidate->sourceInfo()) + { + const RivSourceInfo* rivSourceInfo = dynamic_cast(pickedPartCandidate->sourceInfo()); + if (rivSourceInfo && rivSourceInfo->hasNNCIndices()) + { + + // Hit items are ordered by distance from eye + if (diff.lengthSquared() < pickDepthThresholdSquared) + { + *nncPart = const_cast(pickedPartCandidate); + + const cvf::HitDetailDrawableGeo* detail = dynamic_cast(hitItemCandidate->detail()); + if (detail && nncPartFaceHit) + { + *nncPartFaceHit = detail->faceIndex(); + } + + isNncpart = true; + } + } + } + + if (!isNncpart && !firstNonNncHitItem) + { + firstNonNncHitItem = hitItemCandidate; + firstItemIntersectionPoint = firstNonNncHitItem->intersectionPoint(); + } + + if (firstNonNncHitItem && *nncPart) + { + break; + } + } + + if (firstNonNncHitItem) + { + const cvf::Part* pickedPart = firstNonNncHitItem->part(); + CVF_ASSERT(pickedPart); + *firstPart = const_cast(pickedPart); + + const cvf::Transform* xf = pickedPart->transform(); + cvf::Vec3d globalPickedPoint = firstNonNncHitItem->intersectionPoint(); + + if (localIntersectionPoint) + { + if (xf) + { + *localIntersectionPoint = globalPickedPoint.getTransformedPoint(xf->worldTransform().getInverted()); + } + else + { + *localIntersectionPoint = globalPickedPoint; + } + } + + if (firstPartFaceHit) + { + const cvf::HitDetailDrawableGeo* detail = dynamic_cast(firstNonNncHitItem->detail()); + if (detail) + { + *firstPartFaceHit = detail->faceIndex(); + } + } + } + else + { + if (localIntersectionPoint && nncPart && *nncPart) + { + cvf::Vec3d globalPickedPoint = firstItemIntersectionPoint; + + const cvf::Transform* xf = (*nncPart)->transform(); + if (xf) + { + *localIntersectionPoint = globalPickedPoint.getTransformedPoint(xf->worldTransform().getInverted()); + } + else + { + *localIntersectionPoint = globalPickedPoint; + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewerCommands::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k) +{ + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); + + + if (eclipseView && eclipseView->eclipseCase()) + { + eclipseView->eclipseCase()->reservoirData()->grid(gridIdx)->ijkFromCellIndex(cellIndex, i, j, k); + } + + if (geomView && geomView->geoMechCase()) + { + geomView->geoMechCase()->geoMechData()->femParts()->part(gridIdx)->structGrid()->ijkFromCellIndex(cellIndex, i, j, k); + } +} + + diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.h b/ApplicationCode/UserInterface/RiuViewerCommands.h new file mode 100644 index 0000000000..7495394079 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuViewerCommands.h @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 + +class RiuViewer; +class RimView; +class RimEclipseView; +class RimGeoMechView; + +class QMouseEvent; + +#include "cvfStructGrid.h" +#include "cafPdmPointer.h" +#include + +namespace cvf { + class HitItemCollection; + class Part; +} + +class RiuViewerCommands: public QObject +{ + Q_OBJECT + +public: + RiuViewerCommands(RiuViewer* ownerViewer); + ~RiuViewerCommands(); + + void setOwnerView(RimView * owner); + + void displayContextMenu(QMouseEvent* event); + void handlePickAction(int winPosX, int winPosY); + +private slots: + void slotRangeFilterI(); + void slotRangeFilterJ(); + void slotRangeFilterK(); + void slotHideFault(); + void slotAddEclipsePropertyFilter(); + void slotAddGeoMechPropertyFilter(); + +private: + void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k); + void createSliceRangeFilter(int ijOrk); + void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit); + + size_t m_currentGridIdx; + size_t m_currentCellIndex; + cvf::StructGridInterface::FaceType m_currentFaceIndex; + + caf::PdmPointer m_reservoirView; + + QPointer m_viewer; +}; + + diff --git a/ApplicationCode/resinsight b/ApplicationCode/resinsight index 039f30afa6..041ffd688c 100644 --- a/ApplicationCode/resinsight +++ b/ApplicationCode/resinsight @@ -11,5 +11,5 @@ cd "$INSTALL_PATH" # Start the application making the default file open path become the users cwd -CommandLine="./ResInsight -startdir $WORKING_DIR $@" +CommandLine="./ResInsight --startdir $WORKING_DIR $@" exec $CommandLine diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ed8203cdd..faced5354d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project (ResInsight) set (VIZ_MODULES_FOLDER_NAME Fwk/VizFwk) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) ################################################################################ @@ -57,24 +58,55 @@ SET(INSTALL_ERT OFF CACHE BOOL "ERT: Install library") SET(BUILD_SHARED_LIBS OFF CACHE BOOL "ERT: Build shared libraries") SET(ERT_USE_OPENMP ${OPENMP_FOUND} CACHE BOOL "ERT: Compile using OpenMP") - -add_subdirectory(ThirdParty/Ert/devel) - -include_directories( +option( ERT_EXTERNAL "Build ERT from external source" OFF) +SET(EXT_ERT_ROOT "" CACHE STRING "Path to ERT CMakeList.txt (source path)") + +if (ERT_EXTERNAL) + if (EXT_ERT_ROOT) + set(ERT_SOURCE_PATH "${EXT_ERT_ROOT}") + + add_subdirectory(${ERT_SOURCE_PATH} ${CMAKE_BINARY_DIR}/ThirdParty/Ert) + include_directories( + ${ERT_SOURCE_PATH}/libecl/include/ert/ecl + ${ERT_SOURCE_PATH}/libert_util/include/ert/util + ${ERT_SOURCE_PATH}/libgeometry/include/ert/geometry + ${ERT_SOURCE_PATH}/libecl_well/include/ert/ecl_well + ${ERT_SOURCE_PATH}/libecl/include + ${ERT_SOURCE_PATH}/libert_util/include + ${ERT_SOURCE_PATH}/libgeometry/include + ${ERT_SOURCE_PATH}/libecl_well/include + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/libert_util/include/ert/util + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/libert_util/include + ) + endif(EXT_ERT_ROOT) + +else (ERT_EXTERNAL) + add_subdirectory(ThirdParty/Ert/devel) + include_directories( ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl/include/ert/ecl ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libert_util/include/ert/util ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libgeometry/include/ert/geometry ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl/include + ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl/include ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libert_util/include ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libgeometry/include ${CMAKE_SOURCE_DIR}/ThirdParty/Ert/devel/libecl_well/include ${CMAKE_BINARY_DIR}/ThirdParty/Ert/devel/libert_util/include/ert/util + ${CMAKE_BINARY_DIR}/ThirdParty/Ert/devel/libert_util/include/ert/util ${CMAKE_BINARY_DIR}/ThirdParty/Ert/devel/libert_util/include + ) +endif (ERT_EXTERNAL) + +set_property(TARGET + ecl + ecl_well + ert_geometry + ert_util + PROPERTY FOLDER "ERT" ) - ################################################################################ # Qt ################################################################################ @@ -132,6 +164,15 @@ include_directories( ${LibGuiQt_SOURCE_DIR} ) +set_property(TARGET + LibCore + LibGeometry + LibGuiQt + LibRender + LibViewing + PROPERTY FOLDER "VizFwk" +) + ################################################################################ # Application Framework @@ -143,6 +184,7 @@ add_subdirectory(Fwk/AppFwk/cafAnimControl) add_subdirectory(Fwk/AppFwk/cafViewer) add_subdirectory(Fwk/AppFwk/cafUserInterface) add_subdirectory(Fwk/AppFwk/cafPdmCvf) +add_subdirectory(Fwk/AppFwk/cafTensor) include_directories( ${cafUserInterface_SOURCE_DIR} @@ -151,8 +193,21 @@ include_directories( ${CommonCode_SOURCE_DIR} ${cafAnimControl_SOURCE_DIR} ${cafViewer_SOURCE_DIR} + ${cafTensor_SOURCE_DIR} ) +set_property(TARGET + cafAnimControl + cafPdmCvf + cafProjectDataModel + cafUserInterface + cafViewer + cafTensor + CommonCode + PROPERTY FOLDER "AppFwk" +) + + ################################################################################ # Installation settings ################################################################################ @@ -178,8 +233,6 @@ endif (RESINSIGHT_PRIVATE_INSTALL) add_subdirectory(ApplicationCode) add_subdirectory(OctavePlugin) -# - ################################################################################ # Unit tests ################################################################################ @@ -187,7 +240,12 @@ add_subdirectory(ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests add_subdirectory(ApplicationCode/FileInterface/FileInterface_UnitTests) add_subdirectory(ApplicationCode/ModelVisualization/ModelVisualization_UnitTests) - +set_property(TARGET + ModelVisualization_UnitTests + FileInterface_UnitTests + RigReservoirDataModel_UnitTests + PROPERTY FOLDER "UnitTests" +) ################################################################################ diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index e5049e0d8d..642c24b4e1 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -93,7 +93,6 @@ static const char light_AmbientDiffuse_inl[] = " return vec4(ambient + diffuse, srcFragColor.a); \n" "} \n"; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -103,7 +102,6 @@ cvf::String CommonShaderSources::light_AmbientDiffuse() } - //-------------------------------------------------------------------------------------------------- /// Static helper to configure polygon offset render state from enum //-------------------------------------------------------------------------------------------------- @@ -395,6 +393,7 @@ ScalarMapperEffectGenerator::ScalarMapperEffectGenerator(const cvf::ScalarMapper m_opacityLevel = 1.0f; m_faceCulling = FC_NONE; m_enableDepthWrite = true; + m_disableLighting = false; } //-------------------------------------------------------------------------------------------------- @@ -407,8 +406,16 @@ void ScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::Effect* eff cvf::ShaderProgramGenerator gen("ScalarMapperEffectGenerator", cvf::ShaderSourceProvider::instance()); gen.addVertexCode(cvf::ShaderSourceRepository::vs_Standard); gen.addFragmentCode(cvf::ShaderSourceRepository::src_Texture); - gen.addFragmentCode(CommonShaderSources::light_AmbientDiffuse()); - gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + + if (m_disableLighting) + { + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit); + } + else + { + gen.addFragmentCode(CommonShaderSources::light_AmbientDiffuse()); + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + } cvf::ref prog = gen.generate(); eff->setShaderProgram(prog.p()); @@ -447,6 +454,7 @@ void ScalarMapperEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* e cvf::ref lighting = new cvf::RenderStateLighting_FF; lighting->enableTwoSided(true); + lighting->enable(!m_disableLighting); eff->setRenderState(lighting.p()); // Result mapping texture @@ -534,7 +542,8 @@ bool ScalarMapperEffectGenerator::isEqual(const EffectGenerator* other) const && m_opacityLevel == otherTextureResultEffect->m_opacityLevel && m_undefinedColor == otherTextureResultEffect->m_undefinedColor && m_faceCulling == otherTextureResultEffect->m_faceCulling - && m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite) + && m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite + && m_disableLighting == otherTextureResultEffect->m_disableLighting) { cvf::ref texImg2 = new cvf::TextureImage; otherTextureResultEffect->m_scalarMapper->updateTexture(texImg2.p()); @@ -557,6 +566,7 @@ EffectGenerator* ScalarMapperEffectGenerator::copy() const scEffGen->m_undefinedColor = m_undefinedColor; scEffGen->m_faceCulling = m_faceCulling; scEffGen->m_enableDepthWrite = m_enableDepthWrite; + scEffGen->m_disableLighting = m_disableLighting; return scEffGen; } diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h index 9d79c9d5c4..56adcf3849 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h @@ -161,7 +161,8 @@ class ScalarMapperEffectGenerator : public EffectGenerator void setOpacityLevel(float opacity) { m_opacityLevel = cvf::Math::clamp(opacity, 0.0f , 1.0f ); } void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; } void setFaceCulling(FaceCulling faceCulling) { m_faceCulling = faceCulling; } - void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; } + void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; } + void disableLighting(bool disable) { m_disableLighting = disable; } public: static cvf::ref addAlphaAndUndefStripes(const cvf::TextureImage* texImg, const cvf::Color3f& undefScalarColor, float opacityLevel); @@ -185,6 +186,7 @@ class ScalarMapperEffectGenerator : public EffectGenerator cvf::Color3f m_undefinedColor; FaceCulling m_faceCulling; bool m_enableDepthWrite; + bool m_disableLighting; }; diff --git a/Fwk/AppFwk/CommonCode/cvfStructGrid.h b/Fwk/AppFwk/CommonCode/cvfStructGrid.h index 0ed191f09a..2291415d11 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGrid.h +++ b/Fwk/AppFwk/CommonCode/cvfStructGrid.h @@ -37,6 +37,7 @@ #pragma once +#include #include "cvfObject.h" #include "cvfVector3.h" @@ -70,7 +71,7 @@ class StructGridInterface : public Object public: - StructGridInterface();; + StructGridInterface(); virtual size_t gridPointCountI() const = 0; virtual size_t gridPointCountJ() const = 0; diff --git a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp index 3af8efd688..e3fe26dcfa 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp @@ -140,6 +140,15 @@ bool CellRangeFilter::isCellExcluded(size_t i, size_t j, size_t k, bool isInSubG return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool CellRangeFilter::hasIncludeRanges() const +{ + if (m_includeRanges.size() > 0) return true; + else return false; +} + diff --git a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h index cced178fe9..953043654d 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h +++ b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h @@ -64,6 +64,8 @@ class CellRangeFilter bool isCellVisible(size_t i, size_t j, size_t k, bool isInSubGridArea) const; bool isCellExcluded(size_t i, size_t j, size_t k, bool isInSubGridArea) const; + bool hasIncludeRanges() const; + private: class CellRange { diff --git a/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.cpp b/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.cpp index 3121662b04..0ad39ec519 100644 --- a/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.cpp +++ b/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.cpp @@ -148,7 +148,8 @@ void AnimationToolBar::connectAnimationControl(caf::FrameAnimationControl* anima // Animation action connections if (m_activeAnimationControl) { - m_activeAnimationControl->disconnect(m_timestepCombo, SLOT(setCurrentIndex(int))); + m_activeAnimationControl->disconnect(this, SLOT(slotUpdateComboBoxIndex(int))); + m_activeAnimationControl->disconnect(this, SLOT(slotUpdateTimestepList(int))); } m_activeAnimationControl = animationControl; @@ -170,28 +171,31 @@ void AnimationToolBar::connectAnimationControl(caf::FrameAnimationControl* anima if (animationControl) { - connect(m_animSkipToStartAction, SIGNAL(triggered()), animationControl, SLOT(slotSkipToStart())); - connect(m_animStepBackwardAction, SIGNAL(triggered()), animationControl, SLOT(slotStepBackward())); - connect(m_animStopAction, SIGNAL(triggered()), animationControl, SLOT(slotStop())); - connect(m_animPauseAction, SIGNAL(triggered()), animationControl, SLOT(slotPause())); - connect(m_animPlayAction, SIGNAL(triggered()), animationControl, SLOT(slotPlayFwd())); - connect(m_animStepForwardAction, SIGNAL(triggered()), animationControl, SLOT(slotStepForward())); - connect(m_animSkipToEndAction, SIGNAL(triggered()), animationControl, SLOT(slotSkipToEnd())); - - connect(m_animPlayBwdAction ,SIGNAL(triggered()), animationControl, SLOT(slotPlayBwd())); + connect(m_animSkipToStartAction, SIGNAL(triggered()), animationControl, SLOT(slotSkipToStart())); + connect(m_animStepBackwardAction, SIGNAL(triggered()), animationControl, SLOT(slotStepBackward())); + connect(m_animStopAction, SIGNAL(triggered()), animationControl, SLOT(slotStop())); + connect(m_animPauseAction, SIGNAL(triggered()), animationControl, SLOT(slotPause())); + connect(m_animPlayAction, SIGNAL(triggered()), animationControl, SLOT(slotPlayFwd())); + connect(m_animStepForwardAction, SIGNAL(triggered()), animationControl, SLOT(slotStepForward())); + connect(m_animSkipToEndAction, SIGNAL(triggered()), animationControl, SLOT(slotSkipToEnd())); + + connect(m_animPlayBwdAction ,SIGNAL(triggered()), animationControl, SLOT(slotPlayBwd())); + m_animRepeatFromStartAction->setChecked(animationControl->isRepeatingFromStart()); m_animRepeatFwdBwdAction->setChecked(animationControl->isRepeatingFwdBwd()); - connect(m_animRepeatFromStartAction,SIGNAL(triggered(bool)), animationControl, SLOT(slotRepeatFromStart(bool))); - connect(m_animRepeatFwdBwdAction ,SIGNAL(triggered(bool)), animationControl, SLOT(slotRepeatFwdBwd(bool))); - connect(m_animRepeatFromStartAction,SIGNAL(triggered(bool)), this, SLOT(slotFromStartModeToggled(bool))); - connect(m_animRepeatFwdBwdAction ,SIGNAL(triggered(bool)), this, SLOT(slotFwdBwdModeToggled(bool))); + connect(m_animRepeatFromStartAction,SIGNAL(triggered(bool)), animationControl, SLOT(slotRepeatFromStart(bool))); + connect(m_animRepeatFwdBwdAction ,SIGNAL(triggered(bool)), animationControl, SLOT(slotRepeatFwdBwd(bool))); + + connect(m_animRepeatFromStartAction,SIGNAL(triggered(bool)), this, SLOT(slotFromStartModeToggled(bool))); + connect(m_animRepeatFwdBwdAction ,SIGNAL(triggered(bool)), this, SLOT(slotFwdBwdModeToggled(bool))); connect(m_timestepCombo, SIGNAL(currentIndexChanged(int)), animationControl, SLOT(setCurrentFrame(int))); - connect(m_frameRateSlider, SIGNAL(valueChanged(int)), this, SLOT(slotFrameRateSliderChanged(int))); + connect(m_frameRateSlider, SIGNAL(valueChanged(int)), this, SLOT(slotFrameRateSliderChanged(int))); + + connect(animationControl, SIGNAL(changeFrame(int)), this, SLOT(slotUpdateComboBoxIndex(int))); + connect(animationControl, SIGNAL(frameCountChanged(int)), this, SLOT(slotUpdateTimestepList(int))); - connect(animationControl, SIGNAL(changeFrame(int)), SLOT(slotUpdateComboBoxIndex(int))); - connect(animationControl, SIGNAL(frameCountChanged(int)), this, SLOT(slotUpdateTimestepList(int))); int timeout = animationControl->timeout(); double initialFrameRate = 1000; if (timeout > 0) initialFrameRate = 1000.0/timeout; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h index 1b9a200c0a..4fb204edd1 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.h @@ -75,37 +75,7 @@ class PdmObjectGroup : public PdmObject } template - void createCopyByType(std::vector >* copyOfTypedObjects) const - { - std::vector > sourceTypedObjects; - objectsByType(&sourceTypedObjects); - - QString encodedXml; - { - // Write original objects to XML file - PdmObjectGroup typedObjectGroup; - for (size_t i = 0; i < sourceTypedObjects.size(); i++) - { - typedObjectGroup.addObject(sourceTypedObjects[i]); - } - - QXmlStreamWriter xmlStream(&encodedXml); - xmlStream.setAutoFormatting(true); - - typedObjectGroup.writeFields(xmlStream); - } - - // Read back XML into object group, factory methods will be called that will create new objects - PdmObjectGroup destinationObjectGroup; - QXmlStreamReader xmlStream(encodedXml); - destinationObjectGroup.readFields(xmlStream); - - for (size_t it = 0; it < destinationObjectGroup.objects.size(); it++) - { - T* obj = dynamic_cast(destinationObjectGroup.objects[it]); - if (obj) copyOfTypedObjects->push_back(obj); - } - } + void createCopyByType(std::vector >* copyOfTypedObjects) const; }; //================================================================================================== @@ -129,12 +99,49 @@ class PdmDocument: public PdmObjectGroup static void updateUiIconStateRecursively(PdmObject * root); static void initAfterReadTraversal(PdmObject * root); -private: static void setupBeforeSaveTraversal(PdmObject * root); }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void PdmObjectGroup::createCopyByType(std::vector >* copyOfTypedObjects) const +{ + std::vector > sourceTypedObjects; + objectsByType(&sourceTypedObjects); + + QString encodedXml; + { + // Write original objects to XML file + PdmObjectGroup typedObjectGroup; + for (size_t i = 0; i < sourceTypedObjects.size(); i++) + { + typedObjectGroup.addObject(sourceTypedObjects[i]); + PdmDocument::setupBeforeSaveTraversal(sourceTypedObjects[i]); + } + + QXmlStreamWriter xmlStream(&encodedXml); + xmlStream.setAutoFormatting(true); + + typedObjectGroup.writeFields(xmlStream); + } + + // Read back XML into object group, factory methods will be called that will create new objects + PdmObjectGroup destinationObjectGroup; + QXmlStreamReader xmlStream(encodedXml); + destinationObjectGroup.readFields(xmlStream); + + for (size_t it = 0; it < destinationObjectGroup.objects.size(); it++) + { + T* obj = dynamic_cast(destinationObjectGroup.objects[it]); + if (obj) copyOfTypedObjects->push_back(obj); + } +} + + } // End of namespace caf diff --git a/Fwk/AppFwk/cafTensor/CMakeLists.txt b/Fwk/AppFwk/cafTensor/CMakeLists.txt new file mode 100644 index 0000000000..073a78e53a --- /dev/null +++ b/Fwk/AppFwk/cafTensor/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required (VERSION 2.8) + +project (cafTensor) + +include_directories ( + ${LibCore_SOURCE_DIR} +) + +set( PROJECT_FILES + cafTensor3.cpp + cafTensor3.h + cafTensor3.inl +) + + +add_library( ${PROJECT_NAME} + ${PROJECT_FILES} +) + +target_link_libraries( ${PROJECT_NAME} LibCore ) + +source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file diff --git a/Fwk/AppFwk/cafTensor/cafTensor3.cpp b/Fwk/AppFwk/cafTensor/cafTensor3.cpp new file mode 100644 index 0000000000..e10b924a83 --- /dev/null +++ b/Fwk/AppFwk/cafTensor/cafTensor3.cpp @@ -0,0 +1,150 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cafTensor3.h" +#include "cvfVector3.h" + +#include "cvfMatrix3.h" + +namespace caf { + +//-------------------------------------------------------------------------------------------------- +/// Compute the cofactors of the 3x3 matrix +/// Cofactor: +/// The determinant obtained by deleting the row and column of a given element and +/// preceded by a + or – sign depending whether the element is in a + or – position as follows: +/// +/// + - + +/// - + - +/// + - + +//-------------------------------------------------------------------------------------------------- +cvf::Mat3d cofactor3(const cvf::Mat3d& mx) +{ + int detIdxi[2]; + int detIdxj[2]; + + cvf::Mat3d cof; + + double sign; + for (int i = 0; i < 3; i++) + { + detIdxi[0] = (i == 0) ? 1 : 0; + detIdxi[1] = (i == 2) ? 1 : 2; + + for (int j = 0; j < 3; j++) + { + detIdxj[0] = (j == 0) ? 1 : 0; + detIdxj[1] = (j == 2) ? 1 : 2; + sign = (abs(j - i) == 1) ? -1 : 1; + + cof(i, j) = sign * ( mx(detIdxi[0], detIdxj[0]) * mx(detIdxi[1], detIdxj[1]) + - mx(detIdxi[0], detIdxj[1]) * mx(detIdxi[1], detIdxj[0])); + } + } + + return cof; +} +//-------------------------------------------------------------------------------------------------- +/// Compute the eigenvector of the matrix corresponding to the provided eigenvalue +/// The provided eigenvalue must be an actual eigenvalue of the matrix +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d eigenVector3(const cvf::Mat3d& mx, double eigenValue, bool* computedOk) +{ + const double doubleThreshold = 1.0e-60; + if (computedOk) (*computedOk) = false; + cvf::Mat3d mxMinusEigv = mx; + + for (int i = 0; i < 3; i++) + { + mxMinusEigv(i, i) -= eigenValue; + } + + cvf::Mat3d cof = cofactor3(mxMinusEigv); + + // Find largest absolute cofactor + + int largestCof_i = -1; + int largestCof_j = -1; + double largestCof = 0.0; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + double absCof = fabs(cof(i,j)); + + if (absCof > largestCof) + { + largestCof = absCof; + largestCof_i = i; + largestCof_j = j; + } + } + } + + if (fabs(largestCof) < doubleThreshold) return cvf::Vec3d::ZERO; + + // Find largest matrix element not in the max cofactor row/col + + int largestMxElm_i = -1; + int largestMxElm_j = -1; + double largestMxElm = 0.0; + for (int i = 0; i < 3; i++) + { + if (i != largestCof_i) + { + for (int j = 0; j < 3; j++) + { + if (j != largestCof_j) + { + double absMxElm = fabs(mxMinusEigv(i,j)); + + if (absMxElm > largestMxElm) + { + largestMxElm = absMxElm; + largestMxElm_i = i; + largestMxElm_j = j; + } + } + } + } + } + + // Check if largest coefficient is zero + if (fabs(largestMxElm) < doubleThreshold) return cvf::Vec3d::ZERO; + + // Find last component index + int lastComp_j = 0; + for (int i = 0; i < 3; i++) + { + if ((i != largestCof_j) && (i != largestMxElm_j)) lastComp_j = i; + } + + cvf::Vec3d eigenVector; + eigenVector[largestCof_j] = 1.0; + eigenVector[lastComp_j] = cof(largestCof_i, lastComp_j) / cof(largestCof_i, largestCof_j); + eigenVector[largestMxElm_j] = (-mxMinusEigv(largestMxElm_i, largestCof_j) - mxMinusEigv(largestMxElm_i, lastComp_j)*eigenVector[lastComp_j] ) + / mxMinusEigv(largestMxElm_i, largestMxElm_j); + + if (computedOk) (*computedOk) = true; + + return eigenVector; +} + + +} \ No newline at end of file diff --git a/Fwk/AppFwk/cafTensor/cafTensor3.h b/Fwk/AppFwk/cafTensor/cafTensor3.h new file mode 100644 index 0000000000..e06357450d --- /dev/null +++ b/Fwk/AppFwk/cafTensor/cafTensor3.h @@ -0,0 +1,58 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfBase.h" +#include "cvfVector3.h" + +namespace caf +{ +template< typename S> +class Tensor3 +{ + S m_tensor[6]; // SXX, SYY, SZZ, SXY, SYZ, SZX +public: + Tensor3() {} + Tensor3(S sxx, S syy, S szz, S sxy, S syz, S szx); + Tensor3(const Tensor3& other); + + inline Tensor3& operator=(const Tensor3& rhs); + + bool equals(const Tensor3& mat) const; + bool operator==(const Tensor3& rhs) const; + bool operator!=(const Tensor3& rhs) const; + + enum TensorComponentEnum { SXX, SYY, SZZ, SXY, SYZ, SZX }; + inline S& operator[](TensorComponentEnum comp); + inline S operator[](TensorComponentEnum comp) const; + + void setFromInternalLayout(S* tensorData); + void setFromAbaqusLayout(S* tensorData); + + cvf::Vec3f calculatePrincipals(cvf::Vec3f principalDirections[3]); + float calculateVonMises(); +}; + + +typedef Tensor3 Ten3f; + +} + +#include "cafTensor3.inl" diff --git a/Fwk/AppFwk/cafTensor/cafTensor3.inl b/Fwk/AppFwk/cafTensor/cafTensor3.inl new file mode 100644 index 0000000000..1b21b9a545 --- /dev/null +++ b/Fwk/AppFwk/cafTensor/cafTensor3.inl @@ -0,0 +1,325 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cvfAssert.h" +#include "cvfMath.h" +#include "cvfSystem.h" +#include +#include "cvfMatrix3.h" +#include + +namespace caf { + + + +//---------------------------------------------------------------------------------------------------- +/// Copy constructor +//---------------------------------------------------------------------------------------------------- +template +inline Tensor3::Tensor3(const Tensor3& other) +{ + cvf::System::memcpy(m_tensor, sizeof(m_tensor), other.m_tensor, sizeof(other.m_tensor)); +} + +//---------------------------------------------------------------------------------------------------- +/// Constructor with explicit initialization of all tensor elements. +/// +//---------------------------------------------------------------------------------------------------- +template +Tensor3::Tensor3(S sxx, S syy, S szz, S sxy, S syz, S szx) +{ + m_tensor[0] = sxx; + m_tensor[1] = syy; + m_tensor[2] = szz; + m_tensor[3] = sxy; + m_tensor[4] = syz; + m_tensor[5] = szx; +} + +//---------------------------------------------------------------------------------------------------- +/// Assignment operator +//---------------------------------------------------------------------------------------------------- +template +inline Tensor3& Tensor3::operator=(const Tensor3& obj) +{ + cvf::System::memcpy(m_tensor, sizeof(m_tensor), obj.m_tensor, sizeof(obj.m_tensor)); + return *this; +} + + +//---------------------------------------------------------------------------------------------------- +/// Check if matrices are equal using exact comparisons. +//---------------------------------------------------------------------------------------------------- +template +bool Tensor3::equals(const Tensor3& ten) const +{ + for (int i = 0; i < 6; i++) + { + if (m_tensor[i] != ten.m_tensor[i]) return false; + } + + return true; +} + + +//---------------------------------------------------------------------------------------------------- +/// Comparison operator. Checks for equality using exact comparisons. +//---------------------------------------------------------------------------------------------------- +template +bool Tensor3::operator==(const Tensor3& rhs) const +{ + return this->equals(rhs); +} + + +//---------------------------------------------------------------------------------------------------- +/// Comparison operator. Checks for not equal using exact comparisons. +//---------------------------------------------------------------------------------------------------- +template +bool Tensor3::operator!=(const Tensor3& rhs) const +{ + int i; + for (i = 0; i < 6; i++) + { + if (m_tensor[i] != rhs.m_tensor[i]) return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// Get modifiable component 0,1,2. E.g. x = v[0]; +//-------------------------------------------------------------------------------------------------- +template +inline S Tensor3::operator[](TensorComponentEnum index) const +{ + CVF_TIGHT_ASSERT(index >= 0); + CVF_TIGHT_ASSERT(index < 6); + + return m_tensor[index]; +} + + +//-------------------------------------------------------------------------------------------------- +/// Get const component 0,1,2. E.g. x = v[0]; +//-------------------------------------------------------------------------------------------------- +template +inline S& Tensor3::operator[](TensorComponentEnum index) +{ + CVF_TIGHT_ASSERT(index >= 0); + CVF_TIGHT_ASSERT(index < 6); + + return m_tensor[index]; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template< typename S> +void Tensor3::setFromInternalLayout(S* tensorData) +{ + m_tensor[0] = tensorData[0]; + m_tensor[1] = tensorData[1]; + m_tensor[2] = tensorData[2]; + m_tensor[3] = tensorData[3]; + m_tensor[4] = tensorData[4]; + m_tensor[5] = tensorData[5]; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template< typename S> +void Tensor3::setFromAbaqusLayout(S* tensorData) +{ + m_tensor[0] = tensorData[0]; + m_tensor[1] = tensorData[1]; + m_tensor[2] = tensorData[2]; + m_tensor[3] = tensorData[3]; + m_tensor[4] = tensorData[5]; + m_tensor[5] = tensorData[4]; +} + + + +cvf::Mat3d cofactor3(const cvf::Mat3d& mx); +cvf::Vec3d eigenVector3(const cvf::Mat3d& mx, double eigenValue, bool* computedOk); + +//-------------------------------------------------------------------------------------------------- +/// Compute principal values and optionally the principal directions +/// The tensor must be laid out as follows: SXX, SYY, SZZ, SXY, SYZ, SZX +//-------------------------------------------------------------------------------------------------- +template +cvf::Vec3f Tensor3::calculatePrincipals( cvf::Vec3f principalDirections[3]) +{ + CVF_TIGHT_ASSERT(m_tensor); + + const float floatThreshold = 1.0e-30f; + const double doubleThreshold = 1.0e-60; + + cvf::Vec3f principalValues; + + // Init return arrays to invalid + + principalValues[0] = std::numeric_limits::infinity(); + principalValues[1] = std::numeric_limits::infinity(); + principalValues[2] = std::numeric_limits::infinity(); + + if (principalDirections) + { + principalDirections[0] = cvf::Vec3f::ZERO; + principalDirections[1] = cvf::Vec3f::ZERO; + principalDirections[2] = cvf::Vec3f::ZERO; + } + + // Return if we have an undefined component + + int i; + for (i = 0; i < 6; i++) + { + if (m_tensor[i] == std::numeric_limits::infinity()) + { + return principalValues; + } + } + + // Return 0, 0, 0 if all components are zero + + bool isAllTensCompsZero = true; + for (i = 0; i < 6; i++) + { + if (!(abs(m_tensor[i]) < floatThreshold)) + { + isAllTensCompsZero = false; + break; + } + } + + if (isAllTensCompsZero) + { + return cvf::Vec3f::ZERO; + } + + double SXX = m_tensor[0], SYY = m_tensor[1], SZZ = m_tensor[2]; + double SXY = m_tensor[3], SYZ = m_tensor[4], SZX = m_tensor[5]; + + double pressure = -(SXX + SYY + SZZ)/3.0; + + // Normally we would solve the eigenvalues by solving the 3'rd degree equation: + // -sigma^3 + A*sigma^2 - B*sigma + C = 0 + // in which A, B, and C are the invariants of the stress tensor. + // http://www.engapplets.vt.edu/Mohr/java/nsfapplets/MohrCircles2-3D/Theory/theory.htm + + // But the roots(eigenvalues) are calculated by transforming the above equation into + // s**3 + aa*s + b = 0 and using the trignometric solution. + // See crc standard mathematical tables 19th edition pp. 103-104. + + SXX += pressure; + SYY += pressure; + SZZ += pressure; + + double S1, S2, S3; + double AA, BB, CC, DD, angleP; + + AA = SXY*SXY + SYZ*SYZ + SZX*SZX - SXX*SYY - SYY*SZZ - SXX*SZZ; + + BB = SXX * SYZ * SYZ + + SYY * SZX * SZX + + SZZ * SXY * SXY + - SXX * SYY * SZZ + - 2.0 * SXY * SYZ * SZX; + + if (fabs(AA) < doubleThreshold) + { + S1 = 0.0; + S2 = 0.0; + S3 = 0.0; + } + else + { + CC = -sqrt(27.0/AA) * BB * 0.5 / AA; + + if (CC > 1.0) CC = 1.0; + else if (CC < -1.0) CC = -1.0; + + angleP = acos(CC)/3.0; + DD = 2.0*sqrt(AA/3.0); + S1 = DD*cos(angleP); + S2 = DD*cos(angleP + 4.0*cvf::PI_D/3.0); + S3 = DD*cos(angleP + 2.0*cvf::PI_D/3.0); + } + + int idxPMin = 2; + int idxPMid = 1; + int idxPMax = 0; + + double principalsd[3]; + principalsd[idxPMax] = (S1 - pressure); + principalsd[idxPMid] = (S2 - pressure); + principalsd[idxPMin] = (S3 - pressure); + + // Sort the principals if we have no Z component in the tensor at all + if ((m_tensor[2] == 0.0f) && (m_tensor[4] == 0.0f) && (m_tensor[5] == 0.0f)) + { + if (fabs(principalsd[idxPMin]) > fabs(principalsd[idxPMid])) std::swap(idxPMin, idxPMid); + if (fabs(principalsd[idxPMin]) > fabs(principalsd[idxPMax])) std::swap(idxPMin, idxPMax); + if (principalsd[idxPMax] < principalsd[idxPMid]) std::swap(idxPMax, idxPMid); + + principalsd[idxPMin] = 0; + } + + // Calculate the principal directions if needed + + if (principalDirections) + { + cvf::Mat3d T; + T(0,0) = m_tensor[0]; T(0,1) = m_tensor[3]; T(0,2) = m_tensor[5]; + T(1,0) = m_tensor[3]; T(1,1) = m_tensor[1]; T(1,2) = m_tensor[4]; + T(2,0) = m_tensor[5]; T(2,1) = m_tensor[4]; T(2,2) = m_tensor[2]; + + principalDirections[0] = cvf::Vec3f(eigenVector3(T, principalsd[idxPMax], NULL)); + principalDirections[0].normalize(); + principalDirections[1] = cvf::Vec3f(eigenVector3(T, principalsd[idxPMid], NULL)); + principalDirections[1].normalize(); + principalDirections[2] = cvf::Vec3f(eigenVector3(T, principalsd[idxPMin], NULL)); + principalDirections[2].normalize(); + } + + principalValues[0] = (float)principalsd[idxPMax]; + principalValues[1] = (float)principalsd[idxPMid]; + principalValues[2] = (float)principalsd[idxPMin]; + + return principalValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template< typename S> +float caf::Tensor3::calculateVonMises() +{ + return (float) sqrt( ( (m_tensor[0]*m_tensor[0] + m_tensor[1]*m_tensor[1] + m_tensor[2]*m_tensor[2]) ) + + ( -(m_tensor[0]*m_tensor[1] + m_tensor[1]*m_tensor[2] + m_tensor[0]*m_tensor[2]) ) + + ( 3*(m_tensor[3]*m_tensor[3] + m_tensor[4]*m_tensor[4] + m_tensor[5]*m_tensor[5]) ) ); +} + +} + diff --git a/Fwk/AppFwk/cafTests/cafTensor_UnitTest/CMakeLists.txt b/Fwk/AppFwk/cafTests/cafTensor_UnitTest/CMakeLists.txt new file mode 100644 index 0000000000..a1df15fe93 --- /dev/null +++ b/Fwk/AppFwk/cafTests/cafTensor_UnitTest/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required (VERSION 2.8) + +project ( cafTensor_UnitTests ) + +set(RI_VIZ_FWK_ROOT ../../../Fwk/VizFwk CACHE PATH "Path to VizFwk") +set(RI_GTEST_ROOT .. CACHE PATH "Path to folder containing gtest folder") +set(RI_SRC_ROOT ../../cafTensor CACHE PATH "Path to the code to test") +set(RI_TEST_FILE "" CACHE FILEPATH "Path to test file") + +include(${RI_VIZ_FWK_ROOT}/CMake/Utils/ceeDetermineCompilerFlags.cmake) + +add_subdirectory(${RI_VIZ_FWK_ROOT}/LibCore buildVizFwk) + +add_definitions( -DTEST_FILE="${RI_TEST_FILE}") + +include_directories(${RI_VIZ_FWK_ROOT}/LibCore) +include_directories(${RI_GTEST_ROOT}) +include_directories(${RI_SRC_ROOT}) + +set( UNIT_TEST_CPP_SOURCES + main.cpp + cafTensor_UnitTests.cpp + ${RI_SRC_ROOT}/cafTensor3.cpp + ${RI_SRC_ROOT}/cafTensor3.h + ${RI_SRC_ROOT}/cafTensor3.inl + + ${RI_GTEST_ROOT}/gtest/gtest-all.cpp +) + +add_executable( ${PROJECT_NAME} ${UNIT_TEST_CPP_SOURCES} ) +target_link_libraries( ${PROJECT_NAME} LibCore) + diff --git a/Fwk/AppFwk/cafTests/cafTensor_UnitTest/cafTensor_UnitTests.cpp b/Fwk/AppFwk/cafTests/cafTensor_UnitTest/cafTensor_UnitTests.cpp new file mode 100644 index 0000000000..f6b43a695b --- /dev/null +++ b/Fwk/AppFwk/cafTests/cafTensor_UnitTest/cafTensor_UnitTests.cpp @@ -0,0 +1,194 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cafTensor3.h" + +#include "gtest/gtest.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(cafTensor3Test, BasicTests) +{ + caf::Ten3f T1; + caf::Ten3f T2(1, 2, 3, 4, 5, 6); + caf::Ten3f T3(T2); + + EXPECT_EQ(1, T2[caf::Ten3f::SXX]); + EXPECT_EQ(2, T2[caf::Ten3f::SYY]); + EXPECT_EQ(3, T2[caf::Ten3f::SZZ]); + EXPECT_EQ(4, T2[caf::Ten3f::SXY]); + EXPECT_EQ(5, T2[caf::Ten3f::SYZ]); + EXPECT_EQ(6, T2[caf::Ten3f::SZX]); + + T1 = T2; + EXPECT_EQ(1, T1[caf::Ten3f::SXX]); + EXPECT_EQ(2, T1[caf::Ten3f::SYY]); + EXPECT_EQ(3, T1[caf::Ten3f::SZZ]); + EXPECT_EQ(4, T1[caf::Ten3f::SXY]); + EXPECT_EQ(5, T1[caf::Ten3f::SYZ]); + EXPECT_EQ(6, T1[caf::Ten3f::SZX]); + + EXPECT_TRUE(T2 == T3); + + EXPECT_TRUE(T1 == T2); + EXPECT_TRUE(T1.equals(T2)); + EXPECT_FALSE(T1 != T2); + + T1[caf::Ten3f::SXX] = 7; + + EXPECT_TRUE(T1 != T2); + EXPECT_FALSE(T1 == T2); + EXPECT_FALSE(T1.equals(T2)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(cafTensor3Test, setFromNativeArray) +{ + float tensData[6] = {11,12,13,14,15,16}; + caf::Ten3f T1; + + T1.setFromAbaqusLayout(tensData); + EXPECT_EQ(11, T1[caf::Ten3f::SXX]); + EXPECT_EQ(12, T1[caf::Ten3f::SYY]); + EXPECT_EQ(13, T1[caf::Ten3f::SZZ]); + EXPECT_EQ(14, T1[caf::Ten3f::SXY]); + EXPECT_EQ(15, T1[caf::Ten3f::SZX]); + EXPECT_EQ(16, T1[caf::Ten3f::SYZ]); + + caf::Ten3f T2; + T2.setFromInternalLayout(tensData); + EXPECT_EQ(11, T2[caf::Ten3f::SXX]); + EXPECT_EQ(12, T2[caf::Ten3f::SYY]); + EXPECT_EQ(13, T2[caf::Ten3f::SZZ]); + EXPECT_EQ(14, T2[caf::Ten3f::SXY]); + EXPECT_EQ(15, T2[caf::Ten3f::SYZ]); + EXPECT_EQ(16, T2[caf::Ten3f::SZX]); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(cafTensor3Test, zero) +{ + caf::Ten3f T0(0,0,0,0,0,0); + + cvf::Vec3f pDirs[3]; + cvf::Vec3f p0 = T0.calculatePrincipals(pDirs); + + EXPECT_TRUE(p0 == cvf::Vec3f::ZERO); + EXPECT_TRUE(pDirs[0] == cvf::Vec3f::ZERO); + EXPECT_TRUE(pDirs[1] == cvf::Vec3f::ZERO); + EXPECT_TRUE(pDirs[2] == cvf::Vec3f::ZERO); + + float vm = T0.calculateVonMises(); + EXPECT_EQ(0.0f, vm ); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(cafTensor3Test, undef) +{ + float inf = std::numeric_limits::infinity(); + caf::Ten3f T0(0,0,0,0,0,inf); + + cvf::Vec3f pDirs[3]; + cvf::Vec3f p0 = T0.calculatePrincipals(pDirs); + + EXPECT_TRUE(p0 == cvf::Vec3f(inf, inf, inf)); + EXPECT_TRUE(pDirs[0] == cvf::Vec3f::ZERO); + EXPECT_TRUE(pDirs[1] == cvf::Vec3f::ZERO); + EXPECT_TRUE(pDirs[2] == cvf::Vec3f::ZERO); + + float vm = T0.calculateVonMises(); + EXPECT_EQ(inf, vm ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(cafTensor3Test, realTensors1) +{ + caf::Ten3f T0(80,50,20,40,45,50); + + cvf::Vec3f pDirs[3]; + cvf::Vec3f p0 = T0.calculatePrincipals(pDirs); + + EXPECT_NEAR( 143.8f, p0[0], 0.1 ); + EXPECT_NEAR( 23.6f, p0[1], 0.1 ); + EXPECT_NEAR( -17.4f, p0[2], 0.1 ); + + float vm = T0.calculateVonMises(); + EXPECT_NEAR(145.2f, vm, 0.1 ); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(cafTensor3Test, realTensors2) +{ + caf::Ten3f T0(20,50,80,50,45,40); + + cvf::Vec3f pDirs[3]; + cvf::Vec3f p0 = T0.calculatePrincipals(pDirs); + + EXPECT_NEAR( 143.8f, p0[0], 0.1 ); + EXPECT_NEAR( 23.9f, p0[1], 0.1 ); + EXPECT_NEAR( -17.6f, p0[2], 0.1 ); + + float vm = T0.calculateVonMises(); + EXPECT_NEAR(145.2f, vm, 0.1 ); +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(cafTensor3Test, realTensors3) +{ + caf::Ten3f T0(10,20,30,0,0,0); + + cvf::Vec3f pDirs[3]; + cvf::Vec3f p0 = T0.calculatePrincipals(pDirs); + + EXPECT_NEAR( 30.0f, p0[0], 0.1 ); + EXPECT_NEAR( 20.0f, p0[1], 0.1 ); + EXPECT_NEAR( 10.0f, p0[2], 0.1 ); + + EXPECT_NEAR( 0.0f, pDirs[0][0], 0.1 ); + EXPECT_NEAR( 0.0f, pDirs[0][1], 0.1 ); + EXPECT_NEAR( 1.0f, pDirs[0][2], 0.1 ); + + EXPECT_NEAR( 0.0f, pDirs[1][0], 0.1); + EXPECT_NEAR( 1.0f, pDirs[1][1], 0.1 ); + EXPECT_NEAR( 0.0f, pDirs[1][2], 0.1 ); + + EXPECT_NEAR( 1.0f, pDirs[2][0], 0.1 ); + EXPECT_NEAR( 0.0f, pDirs[2][1], 0.1 ); + EXPECT_NEAR( 0.0f, pDirs[2][2], 0.1 ); + + + float vm = T0.calculateVonMises(); + EXPECT_NEAR(17.3f, vm, 0.1 ); +} + + diff --git a/Fwk/AppFwk/cafTests/cafTensor_UnitTest/main.cpp b/Fwk/AppFwk/cafTests/cafTensor_UnitTest/main.cpp new file mode 100644 index 0000000000..143593e6c0 --- /dev/null +++ b/Fwk/AppFwk/cafTests/cafTensor_UnitTest/main.cpp @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015 - Statoil ASA +// Copyright (C) 2015 - Ceetron Solutions AS +// +// 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 "cvfBase.h" + +#include "gtest/gtest.h" +#include + +#include "cvfTrace.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int main(int argc, char **argv) +{ + cvf::Assert::setReportMode(cvf::Assert::CONSOLE); + + testing::InitGoogleTest(&argc, argv); + + int result = RUN_ALL_TESTS(); + + std::cout << "Please press to close the window."; + std::cin.get(); + + return result; +} diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp index c395611f10..09ef67ab65 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiSliderEditor.cpp @@ -117,6 +117,7 @@ QWidget* PdmUiSliderEditor::createEditorWidget(QWidget * parent) m_spinBox = new QSpinBox(containerWidget); m_spinBox->setMaximumWidth(60); + m_spinBox->setKeyboardTracking(false); connect(m_spinBox, SIGNAL(valueChanged(int)), this, SLOT(slotSpinBoxValueChanged(int))); m_slider = new QSlider(Qt::Horizontal, containerWidget); diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index 94abc195ba..b0a70ac7c1 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -70,7 +70,9 @@ namespace caf { //================================================================================================== //-------------------------------------------------------------------------------------------------- -/// +/// The title will be written centered in the dialog, under other progress titles in action. +/// If you do not need a title for a particular level, simply pass "" and it will be ignored. +/// \sa setProgressDescription //-------------------------------------------------------------------------------------------------- ProgressInfo::ProgressInfo(size_t maxProgressValue, const QString& title) { @@ -97,7 +99,12 @@ ProgressInfo::~ProgressInfo() //-------------------------------------------------------------------------------------------------- /// Sets a description of the step currently being executed. -/// Used to create a nice text in the progressDialog +/// Used to create a nice text in the progressDialog, by appending " : " +/// to the current levels title. If no title is requested for this level, the ":" is omitted. +/// So: One line per level that has title and/or description. +/// in the format: +/// : <Description> +/// The ":" is only there when needed //-------------------------------------------------------------------------------------------------- void ProgressInfo::setProgressDescription(const QString& description) { diff --git a/Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp b/Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp index 2c6953eb09..0cb825a83f 100644 --- a/Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp +++ b/Fwk/VizFwk/LibCore/cvfAtomicCounter.cpp @@ -99,12 +99,6 @@ AtomicCounter::AtomicCounter(int initialValue) } -AtomicCounter::AtomicCounter(const AtomicCounter& counter) - : m_counter(counter.value()) -{ -} - - AtomicCounter::~AtomicCounter() { } diff --git a/Fwk/VizFwk/LibCore/cvfMutex.cpp b/Fwk/VizFwk/LibCore/cvfMutex.cpp index 139c203051..3b8607d497 100644 --- a/Fwk/VizFwk/LibCore/cvfMutex.cpp +++ b/Fwk/VizFwk/LibCore/cvfMutex.cpp @@ -45,7 +45,7 @@ #pragma warning (pop) #endif -#if defined CVF_LINUX || defined(CVF_ANDROID) +#if defined(CVF_LINUX) || defined(CVF_ANDROID) || defined(CVF_OSX) #include <pthread.h> #endif diff --git a/Fwk/VizFwk/LibRender/cvfOpenGL.cpp b/Fwk/VizFwk/LibRender/cvfOpenGL.cpp index 0e535170c0..f27d8c3571 100644 --- a/Fwk/VizFwk/LibRender/cvfOpenGL.cpp +++ b/Fwk/VizFwk/LibRender/cvfOpenGL.cpp @@ -200,7 +200,11 @@ void OpenGL::cvf_check_ogl(OpenGLContext* oglContext, const CodeLocation& codeLo CVF_ASSERT(oglContext->isCurrent()); Logger* logger = oglContext->group()->logger(); +#if defined(CVF_OSX) + if (logger && (err != GL_INVALID_FRAMEBUFFER_OPERATION)) +#else if (logger) +#endif /* defined(CVF_OSX) */ { String errCodeStr = mapOpenGLErrorToString(err); String msg = "OGL(" + errCodeStr + "): "; diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapper.cpp b/Fwk/VizFwk/LibRender/cvfScalarMapper.cpp index 974116937e..9858fa31a7 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapper.cpp +++ b/Fwk/VizFwk/LibRender/cvfScalarMapper.cpp @@ -375,16 +375,16 @@ ref<Color3ubArray> ScalarMapper::interpolateColorArray(const Color3ubArray& colo ref<Color3ubArray> colors = new Color3ubArray; colors->reserve(targetColorCount); - const uint inputLevelCount = inputColorCount - 1; - const uint outputLevelCount = targetColorCount - 1; + const uint inputColorsMaxIdx = inputColorCount - 1; + const uint outputColorsMaxIdx = targetColorCount - 1; uint outputLevelIdx; - for (outputLevelIdx = 0; outputLevelIdx < outputLevelCount; outputLevelIdx++) + for (outputLevelIdx = 0; outputLevelIdx < outputColorsMaxIdx; outputLevelIdx++) { - double dblInputLevelIndex = inputLevelCount * (outputLevelIdx / static_cast<double>(outputLevelCount)); + double dblInputLevelIndex = inputColorsMaxIdx * (outputLevelIdx / static_cast<double>(outputColorsMaxIdx)); const uint inputLevelIndex = static_cast<uint>(dblInputLevelIndex); - CVF_ASSERT(inputLevelIndex < inputLevelCount); + CVF_ASSERT(inputLevelIndex < inputColorsMaxIdx); double t = dblInputLevelIndex - inputLevelIndex; CVF_ASSERT(t >= 0 && t <= 1.0); diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.cpp b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.cpp index 38d7cb2376..5d8d9872bd 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.cpp +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.cpp @@ -54,38 +54,37 @@ ScalarMapperDiscreteLinear::ScalarMapperDiscreteLinear() } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Vec2f ScalarMapperDiscreteLinear::mapToTextureCoord(double scalarValue) const -{ - double discVal = discretize(scalarValue, m_sortedLevels); - return ScalarMapperRangeBased::mapToTextureCoord(discVal); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- Color3ub ScalarMapperDiscreteLinear::mapToColor(double scalarValue) const { - double discVal = discretize(scalarValue, m_sortedLevels); - return ScalarMapperRangeBased::mapToColor(discVal); + double discVal = ScalarMapperDiscreteLinear::discretizeToLevelBelow(scalarValue, m_sortedLevels); + std::set<double>::reverse_iterator it = m_sortedLevels.rbegin(); + it++; + double levelUnderMax = *it; + double normDiscVal = normalizedValue(discVal); + double normSemiMaxVal = normalizedValue(levelUnderMax); + double adjustedNormVal = 0; + if (normSemiMaxVal != 0) adjustedNormVal = cvf::Math::clamp(normDiscVal/normSemiMaxVal, 0.0, 1.0); + + return colorFromUserColorGradient(adjustedNormVal); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double ScalarMapperDiscreteLinear::discretize(double scalarValue, const std::set<double>& sortedLevels) +double ScalarMapperDiscreteLinear::discretizeToLevelBelow(double scalarValue, const std::set<double>& sortedLevels) { std::set<double>::iterator it; it = sortedLevels.upper_bound(scalarValue); if (it == sortedLevels.begin()) return (*it); if (it == sortedLevels.end()) return (*sortedLevels.rbegin()); - double upperValue = *it; it--; double lowerValue = *it; - return 0.5 * (upperValue + lowerValue); + + return lowerValue; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.h b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.h index b1fa923487..59efdb5b45 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.h +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLinear.h @@ -55,13 +55,12 @@ class ScalarMapperDiscreteLinear : public ScalarMapperRangeBased // Scalarmapper interface implementation - virtual Vec2f mapToTextureCoord(double scalarValue) const; virtual Color3ub mapToColor(double scalarValue) const; virtual double normalizedValue( double domainValue ) const; virtual double domainValue( double normalizedPosition ) const; private: - static double discretize(double scalarValue, const std::set<double>& sortedLevels); + static double discretizeToLevelBelow(double scalarValue, const std::set<double>& sortedLevels); friend class ScalarMapperDiscreteLog; }; diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.cpp b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.cpp index 204a02c817..858bdfcede 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.cpp +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.cpp @@ -58,24 +58,26 @@ ScalarMapperDiscreteLog::ScalarMapperDiscreteLog() m_decadeLevelCount = 2; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -Vec2f ScalarMapperDiscreteLog::mapToTextureCoord(double scalarValue) const -{ - double discVal = ScalarMapperDiscreteLinear::discretize(scalarValue, m_sortedLevels); - return ScalarMapperRangeBased::mapToTextureCoord(discVal); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- Color3ub ScalarMapperDiscreteLog::mapToColor(double scalarValue) const { - double discVal = ScalarMapperDiscreteLinear::discretize(scalarValue, m_sortedLevels); - return ScalarMapperRangeBased::mapToColor(discVal); + double discVal = ScalarMapperDiscreteLinear::discretizeToLevelBelow(scalarValue, m_sortedLevels); + std::set<double>::reverse_iterator it = m_sortedLevels.rbegin(); + it++; + double levelUnderMax = *it; + double normDiscVal = normalizedValue(discVal); + double normSemiMaxVal = normalizedValue(levelUnderMax); + double adjustedNormVal = 0; + if (normSemiMaxVal != 0) adjustedNormVal = normDiscVal/normSemiMaxVal; + adjustedNormVal = cvf::Math::clamp(adjustedNormVal, 0.0, 1.0); + + return colorFromUserColorGradient(adjustedNormVal); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.h b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.h index d7bc22fd58..15126126ad 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.h +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperDiscreteLog.h @@ -53,7 +53,7 @@ class ScalarMapperDiscreteLog : public ScalarMapperRangeBased ScalarMapperDiscreteLog(); // Implementing the Scalarmapper interface - virtual Vec2f mapToTextureCoord(double scalarValue) const; + virtual Color3ub mapToColor(double scalarValue) const; virtual double normalizedValue( double domainValue ) const; virtual double domainValue( double normalizedPosition ) const; diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp index 80ea76a0a6..9fd13eaea2 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp @@ -58,9 +58,9 @@ ScalarMapperRangeBased::ScalarMapperRangeBased() m_textureSize(2048), // Large enough, I guess and a power of two m_adjustLevels(true) { - m_colors.resize(m_textureSize); - m_colors.setAll(Color3ub::WHITE); - setColors(ScalarMapper::NORMAL); + m_interpolatedUserGradientColors.resize(m_textureSize); + m_interpolatedUserGradientColors.setAll(Color3ub::WHITE); + setColors(*normalColorTableArray(13)); } @@ -83,7 +83,7 @@ void ScalarMapperRangeBased::setRange(double min, double max) //-------------------------------------------------------------------------------------------------- void ScalarMapperRangeBased::setColors(const Color3ubArray& colorArray) { - m_colors = *interpolateColorArray(colorArray, m_textureSize); + m_interpolatedUserGradientColors = *interpolateColorArray(colorArray, m_textureSize); } //-------------------------------------------------------------------------------------------------- @@ -137,10 +137,7 @@ Vec2f ScalarMapperRangeBased::mapToTextureCoord(double scalarValue) const //-------------------------------------------------------------------------------------------------- Color3ub ScalarMapperRangeBased::mapToColor(double scalarValue) const { - size_t colorIdx = static_cast<size_t>(normalizedValue(scalarValue) * (m_textureSize - 1)); - - CVF_TIGHT_ASSERT(colorIdx < m_colors.size()); - return m_colors[colorIdx]; + return colorFromUserColorGradient(normalizedValue(scalarValue)); } //-------------------------------------------------------------------------------------------------- @@ -170,7 +167,7 @@ bool ScalarMapperRangeBased::updateTexture(TextureImage* image) const uint ic; for (ic = 0; ic < m_textureSize; ic++) { - const Color4ub clr(m_colors[ic], 255); + const Color4ub clr(mapToColor(domainValue(((double)ic)/(m_textureSize-1))), 255); image->setPixel(ic, 0, clr); } @@ -279,5 +276,18 @@ void ScalarMapperRangeBased::majorTickValues( std::vector<double>* domainValues) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3ub ScalarMapperRangeBased::colorFromUserColorGradient(double normalizedValue) const +{ + CVF_TIGHT_ASSERT(0.0 <= normalizedValue && normalizedValue <= 1.0); + + size_t colorIdx = static_cast<size_t>(normalizedValue * (m_textureSize - 1)); + + CVF_TIGHT_ASSERT(colorIdx < m_interpolatedUserGradientColors.size()); + return m_interpolatedUserGradientColors[colorIdx]; +} + } // namespace cvf diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.h b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.h index a4954b9847..cbeaedaaf7 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.h +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.h @@ -67,6 +67,7 @@ class ScalarMapperRangeBased : public ScalarMapper protected: virtual void rangeUpdated() {}; //< Called when the range is changed. Subclasses can reimplment to recalculate cached values + Color3ub colorFromUserColorGradient(double normalizedValue) const; double m_rangeMin; double m_rangeMax; @@ -81,7 +82,7 @@ class ScalarMapperRangeBased : public ScalarMapper bool m_adjustLevels; //< Toggles wether to round tick positions to nice numbers std::set<double> m_userDefinedLevelValues; - Color3ubArray m_colors; + Color3ubArray m_interpolatedUserGradientColors; //< Table of smooth interpolated colors as a result of the users color request uint m_textureSize; // The size of texture that updateTexture() will produce. }; diff --git a/Fwk/VizFwk/LibRender/cvfShaderProgram.cpp b/Fwk/VizFwk/LibRender/cvfShaderProgram.cpp index a38b280a70..d6073fb321 100644 --- a/Fwk/VizFwk/LibRender/cvfShaderProgram.cpp +++ b/Fwk/VizFwk/LibRender/cvfShaderProgram.cpp @@ -286,7 +286,9 @@ bool ShaderProgram::useProgram(OpenGLContext* oglContext) const } CVF_ASSERT(OglRc::safeOglId(m_oglRcProgram.p()) != 0); +#ifndef CVF_OSX CVF_ASSERT(validateProgram(oglContext)); +#endif // Need this check to clear any "hanging" errors that is not produced by glUseProgram below, but still // will make this method return false. diff --git a/OctavePlugin/CMakeLists.txt b/OctavePlugin/CMakeLists.txt index 3a017e61de..4ff452e42e 100644 --- a/OctavePlugin/CMakeLists.txt +++ b/OctavePlugin/CMakeLists.txt @@ -37,10 +37,40 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") set (QT_LIBRARY_POSTFIX 4) if (CMAKE_CL_64) - option(RESINSIGHT_OCTAVE_PLUGIN_32_BIT "Use 32-bit environment for compilation on Windows (mkoctfile and Qt used for Octave must match)" OFF) + option(RESINSIGHT_OCTAVE_PLUGIN_32_BIT "Set 32-bit MSVC compiler environment while while running mkoctfile" OFF) endif() endif() +# recreate the magic that CMake does for MacOS X frameworks in the +# include list when we call mkoctfile as a custom command +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set (QT_INCLUDES) + set (QT_FRAMEWORKS) + # QT_INCLUDE_DIR contains two items; the first is the directory + # containing header files, the second is the framework. This + # setup is specially processed in include_directories (); CMake + # will add -F before the frameworks. We will have to replicate + # that setup here when we want to pass it directly to a command + # see <http://www.cmake.org/Bug/print_bug_page.php?bug_id=10632> + foreach (item IN ITEMS ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_INCLUDE_DIR}) + if ("${item}" MATCHES ".framework$") + get_filename_component (frmwrk_path ${item} PATH) + get_filename_component (frmwrk_name ${item} NAME_WE) + # mkoctfile doesn't support arbitrary compiler command, + # so we must wrap in -Wl, to pass to the linker + list (APPEND QT_FRAMEWORKS "-Wl,-F${frmwrk_path}") + list (APPEND QT_FRAMEWORKS "-Wl,-framework,${frmwrk_name}") + else () + list (APPEND QT_INCLUDES "-I${item}") + endif () + endforeach (item) + if (QT_INCLUDES) + list (REMOVE_DUPLICATES QT_INCLUDES) + endif () + if (QT_FRAMEWORKS) + list (REMOVE_DUPLICATES QT_FRAMEWORKS) + endif () +endif () # Find location of Octave based on mkoctfile find_program(RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE mkoctfile) @@ -52,13 +82,13 @@ else() endif() -set(RESINSIGHT_OCTAVE_PLUGIN_QMAKE "" CACHE FILEPATH "Location of custom qmake to be able to use a different Qt when compiling Octave plugins") +set(RESINSIGHT_OCTAVE_PLUGIN_QMAKE "" CACHE FILEPATH "Location of Qt to use when compiling Octave plugins. Must be compatible with octave runtime. (Use the Qt embedded in Octave)( The qmake.exe itself is not used, only the path to the directory.)") if(RESINSIGHT_OCTAVE_PLUGIN_QMAKE) get_filename_component(OCTAVE_QMAKE_DIR ${RESINSIGHT_OCTAVE_PLUGIN_QMAKE} PATH) STRING(REPLACE "/bin" "" OCTAVE_QT_ROOT ${OCTAVE_QMAKE_DIR}) - message("Compiling Octave plugins using custom Qt located at ${OCTAVE_QT_ROOT}") + message(STATUS "Compiling Octave plugins using custom Qt located at ${OCTAVE_QT_ROOT}") SET(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_QT_ROOT}/include) SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_QT_ROOT}/include/QtCore) @@ -67,7 +97,7 @@ if(RESINSIGHT_OCTAVE_PLUGIN_QMAKE) else() set (RESINSIGHT_OCTAVE_PLUGIN_QMAKE ${QT_QMAKE_EXECUTABLE}) - message("Compiling Octave plugins using system Qt - include path located at ${RESINSIGHT_OCTAVE_PLUGIN_QMAKE}") + message(STATUS "Compiling Octave plugins using system Qt - include path located at ${RESINSIGHT_OCTAVE_PLUGIN_QMAKE}") SET(OCTAVE_QT_INCLUDE_DIR ${QT_INCLUDE_DIR}) SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${QT_QTCORE_INCLUDE_DIR}) @@ -92,27 +122,36 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE) if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") if (CMAKE_CL_64 AND RESINSIGHT_OCTAVE_PLUGIN_32_BIT) - # The following line calls the build configuration for x86 VS2010 compiler - # call "\"%VS100COMNTOOLS%../../VC/vcvarsall.bat\"" x86 - add_custom_command( - OUTPUT "${octFileName}" - COMMAND call "\"%VS100COMNTOOLS%../../VC/vcvarsall.bat\"" x86 - COMMAND ${CMAKE_COMMAND} ARGS -E chdir ${RESINSIGHT_OCTAVE_BIN_DIR} ${RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE} -I${OCTAVE_QT_QTNETWORK_INCLUDE_DIR} - -I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} -I${ResInsight_SOURCE_DIR}/ApplicationCode/SocketInterface ${RPATH_COMMAND} - -L${OCTAVE_QT_LIBRARY_DIR} -lQtCore${QT_LIBRARY_POSTFIX} -lQtNetwork${QT_LIBRARY_POSTFIX} -o "${octFileName}" "${srcFileName}" - DEPENDS "${srcFileName}" - COMMENT "===> 32-bit x86 VS2010 : Generating ${octFileName}" - ) - else() - add_custom_command( - OUTPUT "${octFileName}" - COMMAND ${CMAKE_COMMAND} ARGS -E chdir ${RESINSIGHT_OCTAVE_BIN_DIR} ${RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE} -I${OCTAVE_QT_QTNETWORK_INCLUDE_DIR} - -I${OCTAVE_QT_QTCORE_INCLUDE_DIR} -I${OCTAVE_QT_INCLUDE_DIR} -I${ResInsight_SOURCE_DIR}/ApplicationCode/SocketInterface ${RPATH_COMMAND} - -L${OCTAVE_QT_LIBRARY_DIR} -lQtCore${QT_LIBRARY_POSTFIX} -lQtNetwork${QT_LIBRARY_POSTFIX} -o "${octFileName}" "${srcFileName}" - DEPENDS "${srcFileName}" - COMMENT "===> Generating ${octFileName}" - ) + SET(RESINSIGHT_VCVARS_32BIT_CMD call "\"%VS100COMNTOOLS%../../VC/vcvarsall.bat\"" x86) endif() + add_custom_command( + OUTPUT "${octFileName}" + COMMAND ${RESINSIGHT_VCVARS_32BIT_CMD} + COMMAND set "OCTAVE_HOME=${OCTAVE_HOME}" + COMMAND set "PATH=%OCTAVE_HOME%\\bin;%PATH%" + COMMAND mkoctfile -I${OCTAVE_QT_QTNETWORK_INCLUDE_DIR} + -I${OCTAVE_QT_QTCORE_INCLUDE_DIR} + -I${OCTAVE_QT_INCLUDE_DIR} + -I${ResInsight_SOURCE_DIR}/ApplicationCode/SocketInterface + ${RPATH_COMMAND} -L${OCTAVE_QT_LIBRARY_DIR} -lQtCore${QT_LIBRARY_POSTFIX} -lQtNetwork${QT_LIBRARY_POSTFIX} + -o "${octFileName}" "${srcFileName}" + DEPENDS "${srcFileName}" + COMMENT "===> Generating ${octFileName}" + ) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + add_custom_command( + OUTPUT "${octFileName}" + COMMAND ${RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE} + ${QT_INCLUDES} + ${QT_FRAMEWORKS} + -I${ResInsight_SOURCE_DIR}/ApplicationCode/SocketInterface + ${RPATH_COMMAND} + -L${QT_LIBRARY_DIR} -Wl,-framework,QtCore -Wl,-framework,QtNetwork + -o "${octFileName}" + "${srcFileName}" + DEPENDS "${srcFileName}" + COMMENT "===> Generating ${octFileName}" + ) else() add_custom_command( OUTPUT "${octFileName}" @@ -127,7 +166,7 @@ if (RESINSIGHT_OCTAVE_PLUGIN_QMAKE AND RESINSIGHT_OCTAVE_PLUGIN_MKOCTFILE) list(APPEND OCTAVE_BINARY_OCT_FILES "${octFileName}") endforeach() - + add_custom_target(octave_plugins ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellProperty.oct" "${CMAKE_CURRENT_BINARY_DIR}/riSetActiveCellProperty.oct" diff --git a/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m b/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m index 0dfa441bc8..77c886cc92 100644 --- a/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m +++ b/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m @@ -61,8 +61,7 @@ %! CoarseInfo1 = riGetCoarseningInfo(); %! assert(rows(CoarseInfo1) == 0); %! assert(columns(CoarseInfo1) == 6); -%! CoarseInfo2 = riGetCoarseningInfo(1); -%! assert(CoarseInfo1 == CoarseInfo2); + ### Matrix[numGrids][3] riGetGridDimensions([CaseId]) %!test diff --git a/OctavePlugin/riGetCaseGroups.cpp b/OctavePlugin/riGetCaseGroups.cpp index d1e9b896e5..58ec3bd3e8 100644 --- a/OctavePlugin/riGetCaseGroups.cpp +++ b/OctavePlugin/riGetCaseGroups.cpp @@ -126,7 +126,7 @@ DEFUN_DLD (riGetCaseGroups, args, nargout, // Build a map between the field name and field cell values - Octave_map m; + octave_map m; m.assign(riOctavePlugin::caseGroupInfo_CaseGroupId, cellValuesA); m.assign(riOctavePlugin::caseGroupInfo_CaseGroupName, cellValuesB); diff --git a/OctavePlugin/riGetCases.cpp b/OctavePlugin/riGetCases.cpp index 5fb681ac01..9d68816376 100644 --- a/OctavePlugin/riGetCases.cpp +++ b/OctavePlugin/riGetCases.cpp @@ -144,7 +144,7 @@ DEFUN_DLD (riGetCases, args, nargout, // Build a map between the field name and field cell values - Octave_map m; + octave_map m; m.assign(riOctavePlugin::caseInfo_CaseId, cellValuesA); m.assign(riOctavePlugin::caseInfo_CaseName, cellValuesB); diff --git a/OctavePlugin/riGetCurrentCase.cpp b/OctavePlugin/riGetCurrentCase.cpp index 80b0ffe4ac..90bd23aac1 100644 --- a/OctavePlugin/riGetCurrentCase.cpp +++ b/OctavePlugin/riGetCurrentCase.cpp @@ -95,12 +95,12 @@ DEFUN_DLD (riGetCurrentCase, args, nargout, getCurrentCase(caseId, caseName, caseType, caseGroupId, "127.0.0.1", 40001); - Octave_map fieldMap; + octave_map fieldMap; - fieldMap.assign(riOctavePlugin::caseInfo_CaseId, caseId); - fieldMap.assign(riOctavePlugin::caseInfo_CaseName, caseName.toLatin1().data()); - fieldMap.assign(riOctavePlugin::caseInfo_CaseType, caseType.toLatin1().data()); - fieldMap.assign(riOctavePlugin::caseInfo_CaseGroupId, caseGroupId); + fieldMap.assign(riOctavePlugin::caseInfo_CaseId, Cell(caseId)); + fieldMap.assign(riOctavePlugin::caseInfo_CaseName, Cell(std::string(caseName.toLatin1().data()), true)); + fieldMap.assign(riOctavePlugin::caseInfo_CaseType, Cell(std::string(caseType.toLatin1().data()), true)); + fieldMap.assign(riOctavePlugin::caseInfo_CaseGroupId, Cell(caseGroupId)); retval = octave_value(fieldMap); } diff --git a/OctavePlugin/riGetPropertyNames.cpp b/OctavePlugin/riGetPropertyNames.cpp index 1d1309521c..b62add2179 100644 --- a/OctavePlugin/riGetPropertyNames.cpp +++ b/OctavePlugin/riGetPropertyNames.cpp @@ -158,7 +158,7 @@ DEFUN_DLD (riGetPropertyNames, args, nargout, // Build a map between the field name and field cell values - Octave_map m; + octave_map m; m.assign(riOctavePlugin::propertyInfo_PropName, cellValuesB); m.assign(riOctavePlugin::propertyInfo_PropType, cellValuesC); diff --git a/OctavePlugin/riGetSelectedCases.cpp b/OctavePlugin/riGetSelectedCases.cpp index a7379c666d..4ea1227884 100644 --- a/OctavePlugin/riGetSelectedCases.cpp +++ b/OctavePlugin/riGetSelectedCases.cpp @@ -134,7 +134,7 @@ DEFUN_DLD (riGetSelectedCases, args, nargout, // Build a map between the field name and field cell values - Octave_map m; + octave_map m; m.assign(riOctavePlugin::caseInfo_CaseId, cellValuesA); m.assign(riOctavePlugin::caseInfo_CaseName, cellValuesB); diff --git a/OctavePlugin/riGetTimeStepDates.cpp b/OctavePlugin/riGetTimeStepDates.cpp index fbfe5dbf8f..e856a8df87 100644 --- a/OctavePlugin/riGetTimeStepDates.cpp +++ b/OctavePlugin/riGetTimeStepDates.cpp @@ -165,7 +165,7 @@ DEFUN_DLD (riGetTimeStepDates, args, nargout, // Build a map between the field name and field cell values - Octave_map m; + octave_map m; m.assign(riOctavePlugin::timeStepDate_Year, cellValuesA); m.assign(riOctavePlugin::timeStepDate_Month, cellValuesB); diff --git a/OctavePlugin/riGetTimeStepDays.cpp b/OctavePlugin/riGetTimeStepDays.cpp index 03d8e55508..fa72b69236 100644 --- a/OctavePlugin/riGetTimeStepDays.cpp +++ b/OctavePlugin/riGetTimeStepDays.cpp @@ -110,7 +110,7 @@ DEFUN_DLD (riGetTimeStepDays, args, nargout, getTimeStepDates(decimalDays, caseId, "127.0.0.1", 40001); - dim_vector dv(2); + dim_vector dv(2, 1); dv(0) = decimalDays.size(); dv(1) = 1; NDArray oct_decimalDays(dv); diff --git a/OctavePlugin/riGetWellCells.cpp b/OctavePlugin/riGetWellCells.cpp index 3183345d28..09991c404b 100644 --- a/OctavePlugin/riGetWellCells.cpp +++ b/OctavePlugin/riGetWellCells.cpp @@ -249,7 +249,7 @@ DEFUN_DLD (riGetWellCells, args, nargout, // Build a map between the field name and field cell values - Octave_map m; + octave_map m; m.assign(riOctavePlugin::wellCellInfo_I, cellIscv ); m.assign(riOctavePlugin::wellCellInfo_J, cellJscv ); diff --git a/OctavePlugin/riGetWellStatus.cpp b/OctavePlugin/riGetWellStatus.cpp index 55b22d7826..0e779dd108 100644 --- a/OctavePlugin/riGetWellStatus.cpp +++ b/OctavePlugin/riGetWellStatus.cpp @@ -194,7 +194,7 @@ DEFUN_DLD (riGetWellStatus, args, nargout, // Build a map between the field name and field cell values - Octave_map m; + octave_map m; m.assign(riOctavePlugin::wellStatus_WellType, cellValuesB); m.assign(riOctavePlugin::wellStatus_WellStatus, cellValuesC); diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index a39a40aef0..b137de59b1 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,7 +1,7 @@ set(CMAKE_MAJOR_VERSION 1) -set(CMAKE_MINOR_VERSION 3) -set(CMAKE_PATCH_VERSION 1) +set(CMAKE_MINOR_VERSION 4) +set(CMAKE_PATCH_VERSION 0) set(DEV_VERSION "") set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION}) diff --git a/ThirdParty/Ert/.gitignore b/ThirdParty/Ert/.gitignore index b6d4d32cae..43c43a690a 100644 --- a/ThirdParty/Ert/.gitignore +++ b/ThirdParty/Ert/.gitignore @@ -5,31 +5,21 @@ *.pyc *~ *.user - -#pyCharm project +*.user.* .idea - -#to make python tests run in-source devel/python/lib64 - -# /devel/libenkf/src/ /devel/libenkf/src/.faultlist - -# /develbranch/libenkf/src/ /develbranch/libenkf/src/.faultlist - -# Ignore build catalog /build - -# Ignore pdf from tex-test /devel/libert_util/tests/data/latex_OK.pdf -# Ignore Statoil test data /devel/test-data/Statoil - -# Ignore the ert_local python file which is needed to run some python tests /devel/python/python/ert/ecl/ecl_local.py /devel/GPATH /devel/GRTAGS /devel/GTAGS /devel/gtags.sh /cmake.sh +scratch.sparsebundle +*.iml +*.DS_Store + diff --git a/ThirdParty/Ert/devel/CMakeLists.txt b/ThirdParty/Ert/devel/CMakeLists.txt index e2c0cdb6d0..49c1750621 100644 --- a/ThirdParty/Ert/devel/CMakeLists.txt +++ b/ThirdParty/Ert/devel/CMakeLists.txt @@ -5,9 +5,16 @@ if(POLICY CMP0042) cmake_policy(SET CMP0042 OLD) endif() +#----------------------------------------------------------------- + set( ERT_VERSION_MAJOR 1 ) -set( ERT_VERSION_MINOR 7 ) -set( ERT_VERSION_MICRO X ) +set( ERT_VERSION_MINOR 10 ) +set( ERT_VERSION_MICRO git ) + +# If the micro version is not integer, that should be interpreted as a +# development version leading towards version MAJOR.MINOR.0 + +#----------------------------------------------------------------- option( BUILD_ERT "Build the full ERT application - Linux only" OFF) @@ -21,7 +28,7 @@ option( INSTALL_ERT "Should anything be installed when issuing make inst option( ERT_BUILD_GUI "Should the pyQt based gui be compiled and installed" OFF ) option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" OFF) option( ERT_DOC "Build ERT documantation" OFF) - +option( ERT_BUILD_CXX "Build (some) CXX wrappers" ON) include( CheckFunctionExists ) include( CheckTypeSize ) @@ -61,6 +68,7 @@ if (MSVC) add_definitions( -DCOMPILER_MSVC ) elseif (CMAKE_COMPILER_IS_GNUCC) add_definitions( -DCOMPILER_GCC ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x" ) endif() @@ -82,6 +90,24 @@ include(cmake/Modules/UseMultiArch.cmake) include(cmake/ert_link.cmake) +#----------------------------------------------------------------- +# Should we build the block_fs filesystem; this is used extensively +# by the ert application; but if you are only building the support +# eclipse related support libraries you can safely leave this at the +# default OFF value. + +if (BUILD_ERT) + set( ERT_BUILD_BLOCK_FS ON) +else() + if (WITH_PTHREAD) + set( ERT_BUILD_BLOCK_FS OFF CACHE BOOL "Build the block_fs filesystem. Used by ERT application") + else() + set( ERT_BUILD_BLOCK_FS OFF) + endif() +endif() + +#----------------------------------------------------------------- + set(INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group") set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) @@ -136,6 +162,15 @@ endif() include_directories( ${PROJECT_SOURCE_DIR}/libecl/include ) add_subdirectory( libecl ) +if (ERT_BUILD_CXX) + if (HAVE_CXX_SHARED_PTR) + include_directories( ${PROJECT_SOURCE_DIR}/libeclxx/include ) + add_subdirectory( libeclxx ) + else() + message(STATUS "Skipping CXX support - missing Cxx11 features.") + endif() +endif() + include_directories( ${PROJECT_SOURCE_DIR}/libecl_well/include ) add_subdirectory( libecl_well ) @@ -143,6 +178,10 @@ add_subdirectory( libecl_well ) #----------------------------------------------------------------- if (BUILD_ERT) #----------------------------------------------------------------- + if (BUILD_TESTS) + option( ERT_LSF_SUBMIT_TEST "Build and run tests of LSF submit" OFF) + endif() + include(cmake/ert_module_name.cmake) include_directories( ${PROJECT_SOURCE_DIR}/libconfig/include ) diff --git a/ThirdParty/Ert/devel/cmake/Tests/test_have_sigbus.c b/ThirdParty/Ert/devel/cmake/Tests/test_have_sigbus.c new file mode 100644 index 0000000000..e8785a4947 --- /dev/null +++ b/ThirdParty/Ert/devel/cmake/Tests/test_have_sigbus.c @@ -0,0 +1,10 @@ +#include <signal.h> + +void sigbus_handler(int signal) { + +} + + +int main(int argc, char ** argv) { + signal(SIGBUS , sigbus_handler); +} diff --git a/ThirdParty/Ert/devel/cmake/Tests/test_shared_ptr.cpp b/ThirdParty/Ert/devel/cmake/Tests/test_shared_ptr.cpp new file mode 100644 index 0000000000..78ca0bbff4 --- /dev/null +++ b/ThirdParty/Ert/devel/cmake/Tests/test_shared_ptr.cpp @@ -0,0 +1,5 @@ +#include <memory> + +int main( int argc , char ** argv) { + std::shared_ptr<int> ptr = std::make_shared<int>( 10 ); +} diff --git a/ThirdParty/Ert/devel/cmake/cmake_pyc2 b/ThirdParty/Ert/devel/cmake/cmake_pyc2 index b32fd967a7..23170b2c8e 100644 --- a/ThirdParty/Ert/devel/cmake/cmake_pyc2 +++ b/ThirdParty/Ert/devel/cmake/cmake_pyc2 @@ -18,6 +18,7 @@ if not os.path.exists( target_path ): pass shutil.copyfile( src_file , target_file ) +shutil.copystat( src_file , target_file ) try: py_compile.compile( target_file , doraise = True) except Exception,error: diff --git a/ThirdParty/Ert/devel/cmake/create_cmakelists.py b/ThirdParty/Ert/devel/cmake/create_cmakelists.py index 9fec67a46e..2f877df089 100644 --- a/ThirdParty/Ert/devel/cmake/create_cmakelists.py +++ b/ThirdParty/Ert/devel/cmake/create_cmakelists.py @@ -26,11 +26,11 @@ def findRelativeModulePath(directory): index += len("python/") return directory[index:len(directory)] -def createPythonSources(files): +def createPythonSources(files, test_sources=False): result = "" if len(files) > 0: - result = "set(PYTHON_SOURCES\n" + result = "set(%s\n" % ("PYTHON_SOURCES" if not test_sources else "TEST_SOURCES") files = [f for f in files if f.endswith(".py")] @@ -50,11 +50,14 @@ def addSubDirectories(directories): return result -def addPythonPackage(relative_module_path): +def addPythonPackage(relative_module_path, test_sources=False): module_name = ".".join(relative_module_path.split("/")) - template = "add_python_package(\"python.%s\" ${PYTHON_INSTALL_PREFIX}/%s \"${PYTHON_SOURCES}\" True)" + source_type = "PYTHON_SOURCES" if not test_sources else "TEST_SOURCES" + template = "add_python_package(\"python.%s\" ${PYTHON_INSTALL_PREFIX}/%s \"${%s}\" %s)" - return template % (module_name, relative_module_path) + install = "False" if test_sources else "True" + + return template % (module_name, relative_module_path, source_type, install) def addInclude(filename): with open(filename, "r") as include_file: @@ -65,10 +68,11 @@ def addInclude(filename): module_path = findRelativeModulePath(sys.argv[1]) output_file = join(sys.argv[1], "CMakeLists.txt") +test_sources = module_path.startswith("tests") with open(output_file, "w+") as text_file: - text_file.write(createPythonSources(files)) + text_file.write(createPythonSources(files, test_sources=test_sources)) text_file.write("\n\n") - text_file.write(addPythonPackage(module_path)) + text_file.write(addPythonPackage(module_path, test_sources=test_sources)) text_file.write("\n\n") text_file.write(addSubDirectories(directories)) diff --git a/ThirdParty/Ert/devel/cmake/ert_check.cmake b/ThirdParty/Ert/devel/cmake/ert_check.cmake index cb8b7427f4..5950d216a1 100644 --- a/ThirdParty/Ert/devel/cmake/ert_check.cmake +++ b/ThirdParty/Ert/devel/cmake/ert_check.cmake @@ -106,10 +106,22 @@ endif() # underscore to avoid conflict with plplot which defines the # HAVE_USLEEP symbol. check_function_exists( usleep HAVE__USLEEP ) -if (HAVE_OPENDIR) +if (HAVE__USLEEP) add_definitions( -DHAVE__USLEEP ) endif() + +check_function_exists(pthread_yield_np HAVE_YIELD_NP) +if (HAVE_YIELD_NP) + add_definitions(-DHAVE_YIELD_NP) +endif() + +check_function_exists(pthread_yield HAVE_YIELD) +if (HAVE_YIELD) + add_definitions(-DHAVE_YIELD) +endif() + + # Checking based on compiling. Some of the code generates warnings, so we just cut down to bare-bone compiler flags. set( CMAKE_C_FLAGS_main ${CMAKE_C_FLAGS} ) @@ -117,7 +129,7 @@ set( CMAKE_CXX_FLAGS_main ${CMAKE_CXX_FLAGS} ) if (NOT ERT_WINDOWS) set( CMAKE_C_FLAGS "-std=gnu99" ) - set( CMAKE_CXX_FLAGS "") + set( CMAKE_CXX_FLAGS "-std=c++0x") endif() try_compile( HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c ) @@ -146,6 +158,13 @@ if (ISREG_POSIX) add_definitions( -DHAVE_ISREG ) endif() +try_compile( HAVE_SIGBUS ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_sigbus.c ) +if (HAVE_SIGBUS) + add_definitions( -DHAVE_SIGBUS ) +endif() + +try_compile( HAVE_CXX_SHARED_PTR ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_shared_ptr.cpp ) + check_type_size(time_t SIZE_OF_TIME_T) if (${SIZE_OF_TIME_T} EQUAL 8) try_run( RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mktime_before1970.c ) diff --git a/ThirdParty/Ert/devel/debian/control b/ThirdParty/Ert/devel/debian/control index 4712c613ea..8198d32937 100644 --- a/ThirdParty/Ert/devel/debian/control +++ b/ThirdParty/Ert/devel/debian/control @@ -2,7 +2,7 @@ Source: ert.ecl Priority: extra Maintainer: Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Build-Depends: debhelper (>= 8.0.0), cmake, liblapack-dev, libquadmath0, - iputils-ping, zlib1g-dev + iputils-ping, zlib1g-dev, git Standards-Version: 3.9.2 Section: libs Homepage: http://ert.nr.no diff --git a/ThirdParty/Ert/devel/debian/rules b/ThirdParty/Ert/devel/debian/rules index 265d328965..f73eb28cac 100644 --- a/ThirdParty/Ert/devel/debian/rules +++ b/ThirdParty/Ert/devel/debian/rules @@ -13,4 +13,4 @@ dh $@ override_dh_auto_configure: - dh_auto_configure -- -DSHARED_LIB=1 -DBUILD_ECL_SUMMARY=1 -DCMAKE_BUILD_TYPE=Release + dh_auto_configure -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DCMAKE_BUILD_TYPE=Release diff --git a/ThirdParty/Ert/devel/docs/CMakeLists.txt b/ThirdParty/Ert/devel/docs/CMakeLists.txt index b4f119249f..109259a876 100644 --- a/ThirdParty/Ert/devel/docs/CMakeLists.txt +++ b/ThirdParty/Ert/devel/docs/CMakeLists.txt @@ -1,8 +1,23 @@ -set( ERT_DOC_INSTALL_PATH "" CACHE PATH "Absolute path to install documentation *in addition* to $PREFIX/documentation") +set( ERT_DOC_INSTALL_PATH "" CACHE PATH "Absolute path to install documentation *in addition* to $PREFIX/documentation") +set( ERT_DOC_EXTERNAL_ROOT "" CACHE PATH "Path to site local ERT documentation") -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Static DESTINATION ${PROJECT_BINARY_DIR}/tmp_doc/) -add_custom_target(doc_out ALL - COMMAND ${CMAKE_COMMAND} -Dccsd=${CMAKE_CURRENT_SOURCE_DIR} -Dpbd=${PROJECT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/build_doc.cmake +file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/tmp_doc") +EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/user" "${PROJECT_BINARY_DIR}/tmp_doc/user") +EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/code" "${PROJECT_BINARY_DIR}/tmp_doc/code") + +if (ERT_DOC_EXTERNAL_ROOT) + EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${ERT_DOC_EXTERNAL_ROOT}" "${PROJECT_BINARY_DIR}/tmp_doc/external-doc") + message(STATUS "Adding documentation link ${PROJECT_BINARY_DIR}/tmp_doc/external-doc -> ${ERT_DOC_EXTERNAL_ROOT}") + set( ERT_DOC_LINK external-doc/index ) +else() + set( ERT_DOC_LINK "" ) +endif() + +configure_file(index.rst.in ${PROJECT_BINARY_DIR}/tmp_doc/index.rst) +configure_file(conf.py.in ${PROJECT_BINARY_DIR}/conf.py) + +add_custom_target(doc_out ALL + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/run-sphinx.py ${PROJECT_BINARY_DIR}/conf.py ${PROJECT_BINARY_DIR}/python ${PROJECT_BINARY_DIR}/tmp_doc DEPENDS enkf ) INSTALL( DIRECTORY ${PROJECT_BINARY_DIR}/tmp_doc/_build/ DESTINATION ${CMAKE_INSTALL_PREFIX}/documentation ) diff --git a/ThirdParty/Ert/devel/docs/Static/index.rst b/ThirdParty/Ert/devel/docs/Static/index.rst deleted file mode 100644 index 2361929adf..0000000000 --- a/ThirdParty/Ert/devel/docs/Static/index.rst +++ /dev/null @@ -1,6 +0,0 @@ -First page in the static ert's documentation! -=============================== - -Contents: -This is where we need to write the "manual" documentation - diff --git a/ThirdParty/Ert/devel/docs/build_doc.cmake b/ThirdParty/Ert/devel/docs/build_doc.cmake deleted file mode 100644 index 58cea377dc..0000000000 --- a/ThirdParty/Ert/devel/docs/build_doc.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set( ENV{PYTHONPATH} ${pbd}/python) - -execute_process(COMMAND cmake -E copy ${ccsd}/conf.py ${pbd}/tmp_doc/conf.py ) -execute_process(COMMAND cmake -E copy ${ccsd}/index.rst ${pbd}/tmp_doc/index.rst ) -execute_process(COMMAND sphinx-apidoc -e -o python ${pbd}/python WORKING_DIRECTORY ${pbd}/tmp_doc/) -execute_process(COMMAND sphinx-build -b html -d _build/doctrees . _build WORKING_DIRECTORY ${pbd}/tmp_doc/) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/docs/code/C/index.rst b/ThirdParty/Ert/devel/docs/code/C/index.rst new file mode 100644 index 0000000000..60f6a764b1 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/code/C/index.rst @@ -0,0 +1,4 @@ +Low level C libraries +===================== + +How to use the C libraries diff --git a/ThirdParty/Ert/devel/docs/code/index.rst b/ThirdParty/Ert/devel/docs/code/index.rst new file mode 100644 index 0000000000..8ebb5c1196 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/code/index.rst @@ -0,0 +1,11 @@ +Documentation of ert code +========================= + +Contents: + +.. toctree:: + :maxdepth: 1 + + python/index + C/index + diff --git a/ThirdParty/Ert/devel/docs/code/python/eclipse/API/index.rst b/ThirdParty/Ert/devel/docs/code/python/eclipse/API/index.rst new file mode 100644 index 0000000000..4e61a4fb95 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/code/python/eclipse/API/index.rst @@ -0,0 +1,9 @@ +The ert Python API +================== + +.. toctree:: + :maxdepth: 2 + + ../../API/python/ert + ../../API/python/ert_gui + diff --git a/ThirdParty/Ert/devel/docs/code/python/eclipse/index.rst b/ThirdParty/Ert/devel/docs/code/python/eclipse/index.rst new file mode 100644 index 0000000000..6aa6794e19 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/code/python/eclipse/index.rst @@ -0,0 +1,5 @@ +Using the ert.ecl classes for Eclipse manipulation +================================================== + +Using the ert.ecl classes for ECLIPSE binary files + diff --git a/ThirdParty/Ert/devel/docs/code/python/index.rst b/ThirdParty/Ert/devel/docs/code/python/index.rst new file mode 100644 index 0000000000..786c08ae7e --- /dev/null +++ b/ThirdParty/Ert/devel/docs/code/python/index.rst @@ -0,0 +1,10 @@ +Python documentation +==================== + +.. toctree:: + :maxdepth: 1 + + introduction/index + eclipse/index + ../../API/python/ert + ../../API/python/ert_gui diff --git a/ThirdParty/Ert/devel/docs/code/python/introduction/index.rst b/ThirdParty/Ert/devel/docs/code/python/introduction/index.rst new file mode 100644 index 0000000000..06307a123e --- /dev/null +++ b/ThirdParty/Ert/devel/docs/code/python/introduction/index.rst @@ -0,0 +1,4 @@ +Simple introduction to Python +============================= + +An introduction to Python diff --git a/ThirdParty/Ert/devel/docs/conf.py b/ThirdParty/Ert/devel/docs/conf.py.in similarity index 98% rename from ThirdParty/Ert/devel/docs/conf.py rename to ThirdParty/Ert/devel/docs/conf.py.in index 6a5780b6c9..a34d0d4e90 100644 --- a/ThirdParty/Ert/devel/docs/conf.py +++ b/ThirdParty/Ert/devel/docs/conf.py.in @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '1.1' +version = '${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR}' # The full version, including alpha/beta/rc tags. -release = '1.7' +release = '${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR}.${ERT_VERSION_MICRO}' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/ThirdParty/Ert/devel/docs/index.rst b/ThirdParty/Ert/devel/docs/index.rst.in similarity index 85% rename from ThirdParty/Ert/devel/docs/index.rst rename to ThirdParty/Ert/devel/docs/index.rst.in index 0355e90398..47842e6143 100644 --- a/ThirdParty/Ert/devel/docs/index.rst +++ b/ThirdParty/Ert/devel/docs/index.rst.in @@ -9,12 +9,11 @@ Welcome to ert's documentation! Contents: .. toctree:: - :maxdepth: 2 + :maxdepth: 1 - Static/index - - python/ert - python/ert_gui + user/index + code/index + ${ERT_DOC_LINK} Indices and tables diff --git a/ThirdParty/Ert/devel/docs/script/run-sphinx.py b/ThirdParty/Ert/devel/docs/script/run-sphinx.py new file mode 100644 index 0000000000..2a30049661 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/script/run-sphinx.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +import sys +import os +import subprocess +import shutil + +config_file = sys.argv[1] +PYTHONPATH = sys.argv[2] +work_path = sys.argv[3] + +os.environ["PYTHONPATH"] = PYTHONPATH +shutil.copy(config_file , work_path) + +os.chdir( work_path ) +if not os.path.isdir("_static"): + os.mkdir("_static") + +subprocess.call(["sphinx-apidoc" , "-e" , "-o" , "API/python" , PYTHONPATH ]) +subprocess.call(["sphinx-build" , "-b" , "html" , "-d" , "_build/doctrees" , "." , "_build"]) diff --git a/ThirdParty/Ert/devel/docs/user/index.rst b/ThirdParty/Ert/devel/docs/user/index.rst new file mode 100644 index 0000000000..6fcb3255b6 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/user/index.rst @@ -0,0 +1,12 @@ +User documentation for ERT +========================== + +Contents: + +.. toctree:: + :maxdepth: 1 + + tutorial/index + keywords/index + workflows/index + observations/index diff --git a/ThirdParty/Ert/devel/docs/user/keywords/index.rst b/ThirdParty/Ert/devel/docs/user/keywords/index.rst new file mode 100644 index 0000000000..17c5f28ce0 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/user/keywords/index.rst @@ -0,0 +1,2168 @@ +.. _ert_kw_full_doc: + +Keywords for the configuration file +=================================== + +:ref:`Go to main ERT page <index>` + + +General overview +---------------- +The enkf application is started with a single argument, which is the name of the configuration file to be used. The enkf configuration file serves several purposes, which are: + +* Defining which ECLIPSE model to use, i.e. giving a data, grid and schedule file. +* Defining which observation file to use. +* Defining how to run simulations. +* Defining where to store results. +* Creating a parametrization of the ECLIPSE model. + +The configuration file is a plain text file, with one statement per line. The first word on each line is a keyword, which then is followed by a set of arguments that are unique to the particular keyword. Except for the DEFINE keyword, ordering of the keywords is not significant. Similarly to ECLIPSE data files, lines starting with "--" are treated as comments. + +The keywords in the enkf configuration file can roughly be divded into two groups: + +* Basic required keywords not related to parametrization. I.e., keywords giving the data, grid, schedule and observation file, defining how to run simulations and how to store results. These keywords are described in :ref:`Basic required keywords.<basic_required_keywords>` +* Basic optional keywords not related to parametrization. These keywords are described in :ref:`Basic optional keywords <basic_optional_keywords>`. +* Keywords related to parametrization of the ECLIPSE model. These keywords are described in :ref:`Parametrization keywords<parameterization_keywords>`. +* Advanced keywords not related to parametrization. These keywords are described in :ref:`Advanced optional keywords<advanced_optional_keywords>`. + + +List of keywords +---------------- + +===================================================================== ====================================== ============================== ============================================================================================================================================== +Keyword name Required by user? Default value Purpose +===================================================================== ====================================== ============================== ============================================================================================================================================== +:ref:`ADD_FIXED_LENGTH_SCHEDULE_KW <add_fixed_length_schedule_kw>` NO Supporting unknown SCHEDULE keywords. +:ref:`ADD_STATIC_KW <add_Static_kw>` NO Add static ECLIPSE keyword that should be stored +:ref:`ANALYSIS_COPY <analysis_copy>` NO Create new instance of analysis module +:ref:`ANALYSIS_LOAD <analysis_load>` NO Load analysis module +:ref:`ANALYSIS_SET_VAR <analysis_set_var>` NO Set analysis module internal state variable +:ref:`ANALYSIS_SELECT <analysis_select>` NO STD_ENKF Select analysis module to use in update +:ref:`CASE_TABLE <case_table>` NO For running sensitivities you can give the cases descriptive names +:ref:`CONTAINER <container>` NO ... +:ref:`CUSTOM_KW <custom_kw>` NO Ability to load arbitrary values from the forward model. +:ref:`DATA_FILE <data_file>` YES Provide an ECLIPSE data file for the problem. +:ref:`DATA_KW <data_kw>` NO Replace strings in ECLIPSE .DATA files +:ref:`DBASE_TYPE <dbase_type>` NO BLOCK_FS Which 'database' system should be used for storage +:ref:`DEFINE <define>` NO Define keywords with config scope +:ref:`DELETE_RUNPATH <delete_runpath>` NO Explicitly tell ert to delete the runpath when a job is complete +:ref:`ECLBASE <eclbase>` YES Define a name for the ECLIPSE simulations. +:ref:`END_DATE <end_date>` NO You can tell ERT how lon the simulations should be - for error check +:ref:`ENKF_ALPHA <enkf_alpha>` NO 1.50 Parameter controlling outlier behaviour in EnKF algorithm +:ref:`ENKF_BOOTSTRAP <enkf_bootstrap>` NO FALSE Should we bootstrap the Kalman gain estimate +:ref:`ENKF_CROSS_VALIDATION <enkf_cross_validation>` NO ... +:ref:`ENKF_CV_FOLDS <enkf_cv_folds>` NO 10 Number of folds used in the Cross-Validation scheme +:ref:`ENKF_FORCE_NCOMP <enkf_force_ncomp>` NO FALSE Should we want to use a spesific subspace dimension +:ref:`ENKF_KERNEL_REGRESSION <enkf_kernel_regression>` NO FALSE +:ref:`ENKF_KERNEL_FUNCTION <enkf_kernel_function>` NO 1 +:ref:`ENKF_KERNEL_PARAM <enkf_kernel_param>` NO 1 +:ref:`ENKF_LOCAL_CV <enkf_local_cv>` NO FALSE Should we estimate the subspace dimenseion using Cross-Validation +:ref:`ENKF_MERGE_OBSERVATIONS <enkf_merge_observations>` NO FALSE Should observations from many times be merged together +:ref:`ENKF_MODE <enkf_mode>` NO STANDARD Which EnKF should be used +:ref:`ENKF_NCOMP <enkf_ncomp>` NO 1 Dimension of the reduced order subspace (If ENKF_FORCE_NCOMP = TRUE) +:ref:`ENKF_PEN_PRESS <enkf_pen_press>` NO FALSE Should we want to use a penalised PRESS statistic in model selection? +:ref:`ENKF_RERUN <enkf_rerun>` NO FALSE Should the simulations be restarted from time zero after each update. +:ref:`ENKF_SCALING <enkf_scaling>` NO TRUE Do we want to normalize the data ensemble to have unit variance? +:ref:`ENKF_SCHED_FILE <enkf_sched_file>` NO Allows fine-grained control of the time steps in the simulation. +:ref:`ENKF_TRUNCATION <enfk_truncation>` NO 0.99 Cutoff used on singular value spectrum. +:ref:`ENSPATH <enspath>` NO storage Folder used for storage of simulation results. +:ref:`EQUIL_INIT_FILE <equil_init_file>` NO Use INIT_SECTION instead +:ref:`FIELD <field>` NO Ads grid parameters +:ref:`FORWARD_MODEL <forward_model>` NO Add the running of a job to the simulation forward model. +:ref:`GEN_DATA <gen_data>` NO Specify a general type of data created/updated by the forward model. +:ref:`GEN_KW <gen_kw>` NO Add a scalar parameter. +:ref:`GEN_KW_TAG_FORMAT <gen_kw_tag_format>` NO <%s> Format used to add keys in the GEN_KW template files. +:ref:`GEN_KW_EXPORT_FILE <gen_kw_export_file>` NO parameter.txt Name of file to export GEN_KW parameters to. +:ref:`GEN_PARAM <gen_param>` NO Add a general parameter. +:ref:`GRID <grid>` YES Provide an ECLIPSE grid for the reservoir model. +:ref:`HISTORY_SOURCE <history_source>` NO REFCASE_HISTORY Source used for historical values. +:ref:`HOST_TYPE <host_type>` NO +:ref:`IGNORE_SCHEDULE <ignore_schedule>` NO +:ref:`IMAGE_TYPE <image_type>` NO png The type of the images created when plotting. +:ref:`IMAGE_VIEWER <image_viewer>` NO /usr/bin/display External program spawned to view images. +:ref:`INIT_SECTION <init_section>` YES Initialization code for the reservoir model. +:ref:`INSTALL_JOB <install_jobb>` NO Install a job for use in a forward model. +:ref:`ITER_CASE <iter_Case>` NO IES%d Case name format - iterated ensemble smoother +:ref:`ITER_COUNT <iter_count>` NO 4 Number of iterations - iterated ensemble smoother +:ref:`ITER_RETRY_COUNT <iter_retry_count>` NO 4 Number of retries for a iteration - iterated ensemble smoother +:ref:`JOBNAME <jobname>` NO Name used for simulation files. An alternative to ECLBASE. +:ref:`JOB_SCRIPT <job_script>` NO Python script managing the forward model. +:ref:`KEEP_RUNPATH <keep_runpath>` NO Specify realizations that simulations should be kept for. +:ref:`LOAD_SEED <load_seed>` NO Load random seed from given file. +:ref:`LOAD_WORKFLOW <load_workflow>` NO Load a workflow into ERT. +:ref:`LOAD_WORKFLOW_JOB <load_workflow_job>` NO Load a workflow job into ERT. +:ref:`LICENSE_PATH <licence_path>` NO A path where ert-licenses to e.g. RMS are stored. +:ref:`LOCAL_CONFIG <load_config>` NO A file with configuration information for local analysis. +:ref:`LOG_FILE <log_file>` NO log Name of log file +:ref:`LOG_LEVEL <log_level>` NO 1 How much logging? +:ref:`LSF_QUEUE <lsf_queue>` NO normal Name of LSF queue. +:ref:`LSF_RESOURCES <lsf_resources>` NO +:ref:`LSF_SERVER <lsf_server>` NO Set server used when submitting LSF jobs. +:ref:`MAX_ITER_COUNT <max_iter_count>` NO Maximal number of iterations - iterated ensemble smoother. +:ref:`MAX_RESAMPLE <max_resample>` NO 1 How many times should ert resample & retry a simulation. +:ref:`MAX_RUNNING_LOCAL <max_running_local>` NO The maximum number of running jobs when running locally. +:ref:`MAX_RUNNING_LSF <max_running_lsf>` NO The maximum number of simultaneous jobs submitted to LSF. +:ref:`MAX_RUNNING_RSH <max_running_rsh>` NO The maximum number of running jobs when using RSH queue system. +:ref:`MAX_RUNTIME <max_runtime>` NO 0 Set the maximum runtime in seconds for a realization. +:ref:`MAX_SUBMIT <max_submit>` NO 2 How many times should the queue system retry a simulation. +:ref:`MIN_REALIZATIONS <min_realizations>` NO 0 Set the number of minimum reservoir realizations to run before long running realizations are stopped. Keyword STOP_LONG_RUNNING must be set to TRUE when MIN_REALIZATIONS are set. +:ref:`NUM_REALIZATIONS <num_realizations>` YES Set the number of reservoir realizations to use. +:ref:`OBS_CONFIG <obs_config>` NO File specifying observations with uncertainties. +:ref:`PLOT_DRIVER <plot_driver>` NO PLPLOT Which plotting system should be used. +:ref:`PLOT_ERRORBAR <plot_errorbar>` NO FALSE Should errorbars on observations be plotted? +:ref:`PLOT_ERRORBAR_MAX <plot_errorbar_max>` NO 25 Show error bars if less than this number of observations. +:ref:`PLOT_HEIGHT <plot_height>` NO 768 Pixel height of the plots. +:ref:`PLOT_PATH <plot_path>` NO plots Path to where the plots are stored. +:ref:`PLOT_REFCASE <plot_refcase>` NO TRUE TRUE (IF you want to plot the listed reference cases) FALSE if not. +:ref:`PLOT_REFCASE_LIST <plot_refcase_list>` NO Deprecated. Use REFCASE_LIST instead. +:ref:`PLOT_WIDTH <plot_width>` NO 1024 Pixel width of the plots. +:ref:`PRE_CLEAR_RUNPATH <pre_clear_runpath>` NO FALSE Should the runpath be cleared before initializing? +:ref:`QC_PATH <qc_path>` NO QC ... +:ref:`QC_WORKFLOW <qc_workflow>` NO Name of existing workflow to do QC work. +:ref:`QUEUE_SYSTEM <queue_system>` NO System used for running simulation jobs. +:ref:`REFCASE <refcase>` NO (see HISTORY_SOURCE and SUMMARY) Reference case used for observations and plotting. +:ref:`REFCASE_LIST <refcase_list>` NO Full path to Eclipse .DATA files containing completed runs (which you can add to plots) +:ref:`REPORT_CONTEXT <report_context>` NO Values for variables used in report templates. +:ref:`REPORT_GROUP_LIST <report_group_list>` NO Specify list of groups used in report templates. +:ref:`REPORT_LARGE <report_large>` NO FALSE +:ref:`REPORT_LIST <report_list>` NO List of templates used for creating reports. +:ref:`REPORT_PATH <report_path>` NO Reports Directory where final reports are stored. +:ref:`REPORT_SEARCH_PATH <report_search_path>` NO Search path for report templates. +:ref:`REPORT_TIMEOUT <report_timeout>` NO 120 Timeout for running LaTeX. +:ref:`REPORT_WELL_LIST <report_well_list>` NO Specify list of wells used in report templates. +:ref:`RERUN_PATH <rerun_path>` NO ... +:ref:`RERUN_START <rerun_start>` NO 0 ... +:ref:`RFT_CONFIG <rft_config>` NO Config file specifying wellnames and dates for rft-measurments. Used for plotting. The format has to be name day month year (ex. Q-2FI 02 08 1973), with a new entry on a new line. +:ref:`RFTPATH <rftpath>` NO rft Path to where the rft well observations are stored +:ref:`RSH_COMMAND <rsh_command>` NO Command used for remote shell operations. +:ref:`RSH_HOST <rsh_host>` NO Remote host used to run forward model. +:ref:`RUNPATH <runoath>` NO simulations/realization%d Directory to run simulations +:ref:`RUN_TEMPLATE <run_template>` NO Install arbitrary files in the runpath directory. +:ref:`STD_SCALE_CORRELATED_OBS <std_scale_correlated_obs>` NO FALSE Try to estimate the correlations in the data to inflate the observation std. +:ref:`SCHEDULE_FILE <schedule_file>` YES Provide an ECLIPSE schedule file for the problem. +:ref:`SCHEDULE_PREDICTION_FILE <schedule_prediction_file>` NO Schedule prediction file. +:ref:`SELECT_CASE <select_case>` NO The current case / default You can tell ert to select a particular case on bootup. +:ref:`SETENV <setenv>` NO You can modify the UNIX environment with SETENV calls. +:ref:`SINGLE_NODE_UPDATE <single_node_update>` NO FALSE ... +:ref:`STD_CUTOFF <std_cutoff>` NO 1e-6 ... +:ref:`STOP_LONG_RUNNING <stop_long_running>` NO FALSE Stop long running realizations after minimum number of realizations (MIN_REALIZATIONS) have run. +:ref:`STORE_SEED <store_seed>` NO File where the random seed used is stored. +:ref:`SUMMARY <summary>` NO Add summary variables for internalization. +:ref:`SURFACE <surface>` NO Surface parameter read from RMS IRAP file. +:ref:`TORQUE_QUEUE <torque_queue>` NO ... +:ref:`TIME_MAP <time_map>` NO Ability to manually enter a list of dates to establish report step <-> dates mapping. +:ref:`UMASK <umask>` NO ... +:ref:`UPDATE_LOG_PATH <update_log_path>` NO update_log Summary of the EnKF update steps are stored in this directory. +:ref:`UPDATE_PATH <update_path>` NO Modify a UNIX path variable like LD_LIBRARY_PATH. +:ref:`UPDATE_RESULTS <update_results>` NO FALSE ... +:ref:`WORKFLOW_JOB_DIRECTORY <workflow_job_directory>` NO Directory containing workflow jobs. +===================================================================== ====================================== ============================== ============================================================================================================================================== + + +:ref:` <>` + +Basic required keywords +----------------------- +.. _basic_required_keywords: + +These keywords must be set to make the enkf function properly. + +.. _data_file: +.. topic:: DATA_FILE + + | This is the name of ECLIPSE data file used to control the simulations. The data file should be prepared according to the guidelines given in Preparing an ECLIPSE reservoir model for use with enkf. + + *Example:* + + :: + + -- Load the data file called ECLIPSE.DATA + DATA_FILE ECLIPSE.DATA + + + + +.. _eclbase: +.. topic:: ECLBASE + + | The ECLBASE keyword sets the basename used for the ECLIPSE simulations. It can (and should, for your convenience) contain a %d specifier, which will be replaced with the realization numbers when running ECLIPSE. Note that due to limitations in ECLIPSE, the ECLBASE string must be in strictly upper or lower case. + + *Example:* + + :: + + -- Use MY_VERY_OWN_OIL_FIELD-0 etc. as basename. + -- When ECLIPSE is running, the %d will be, + -- replaced with realization number, giving: + -- + -- MY_VERY_OWN_OIL_FIELD-0 + -- MY_VERY_OWN_OIL_FIELD-1 + -- MY_VERY_OWN_OIL_FIELD-2 + -- ... + -- and so on. + ECLBASE MY_VERY_OWN_OIL_FIELD-%d + +.. _jobname: +.. topic:: JOBNAME + + As an alternative to the ECLBASE keyword you can use the JOBNAME keyword; in particular in cases where your forward model does not include ECLIPSE at all that makes more sense. If JOBANME is used instead of ECLBASE the same rules of no-mixed-case apply. + +.. _grid: +.. topic:: GRID + + This is the name of an existing GRID/EGRID file for your ECLIPSE model. If you had to create a new grid file when preparing your ECLIPSE reservoir model for use with enkf, this should point to the new .EGRID file. + + *Example:* + + :: + + -- Load the .EGRID file called MY_GRID.EGRID + GRID MY_GRID.EGRID + + +.. _init_section: +.. topic:: INIT_SECTION + + The INIT_SECTION keyword is used to handle initialization of the ECLIPSE run. See the documentation of the Initialization for more details on why this has to be done. The keyword can be used in two different ways: + + * If it is set to the name of an existing file, the contents of this file will be used for the initialization. + * If it is set to the name of a non-existing file, it will be assumed that a file with this name in the simulation folder will be generated when simulations are submitted, either by the enkf application itself, or by some job installed by the user (see INSTALL_JOB). This generated file will then be used by ECLIPSE for initialization. + + *Example A:* + + :: + + -- Use the contents of the file parameters/EQUIL.INC for initialization + INIT_SECTION params/EQUIL.INC + + *Example B:* + + :: + + -- Use a generated file for the initialization + INIT_SECTION MY_GENERATED_EQUIL_KEYWORD.INC + + +.. _num_realizations: +.. topic:: NUM_REALIZATIONS + + This is just the size of the ensemble, i.e. the number of realizations/members in the ensemble. + + *Example:* + + :: + + -- Use 200 realizations/members + NUM_REALIZATIONS 200 + + +.. _schedule_file: +.. topic:: SCHEDULE_FILE + + This keyword should be the name a text file containing the SCHEDULE section of the ECLIPSE data file. It should be prepared in accordance with the guidelines given in Preparing an ECLIPSE reservoir model for use with enkf. This SCHEDULE section will be used to control the ECLIPSE simulations. You can optionally give a second filename, which is the name of file which will be written into the directories for running ECLIPSE. + + *Example:* + + :: + + -- Parse MY_SCHEDULE.SCH, call the generated file ECLIPSE_SCHEDULE.SCH + SCHEDULE_FILE MY_SCHEDULE.SCH ECLIPSE_SCHEDULE.SCH + + Observe that the SCHEDULE_FILE keyword is only required when you need ERT to stop and restart your simulations; i.e. when you are using the EnKF algorithm. If you are only using ERT to your simulations; or using smoother update it is recommended to leave the SCHEDULE_FILE keyword out. In that case you must make sure that the ECLIPSE datafile correctly includes the SCHEDULE section. + + +Basic optional keywords +----------------------- +.. _basic_optional_keywords: + +These keywords are optional. However, they serve many useful purposes, and it is recommended that you read through this section to get a thorough idea of what's possible to do with the enkf application. + +.. _data_kw: +.. topic:: DATA_KW + + The keyword DATA_KW can be used for inserting strings into placeholders in the ECLIPSE data file. For instance, it can be used to insert include paths. + + *Example:* + + :: + + -- Define the alias MY_PATH using DATA_KW. Any instances of <MY_PATH> (yes, with brackets) + -- in the ECLIPSE data file will now be replaced with /mnt/my_own_disk/my_reservoir_model + -- when running the ECLIPSE jobs. + DATA_KW MY_PATH /mnt/my_own_disk/my_reservoir_model + + The DATA_KW keyword is of course optional. Note also that the enkf has some built in magic strings. + +.. _delete_runpath: +.. topic:: DELETE_RUNPATH + + When the enkf application is running it creates directories for the ECLIPSE simulations, one for each realization. When the simulations are done, the enkf will load the results into it's internal database. If you are using the enkf application as a convenient way to start many simulations, e.g. using the screening experiment option, the default behavior is to not delete these simulation directories. This behavior can be overridden with the DELETE_RUNPATH keyword, which causes enkf to delete the specified simulation directories. When running the EnKF algorithm, the behavior is the opposite. The keyword KEEP_RUNPATH can then be used to override the default behavoir. + + *Example A:* + + :: + + -- Delete simulation directories 0 to 99 + DELETE_RUNPATH 0-99 + + *Example B:* + + :: + + -- Delete simulation directories 0 to 10 as well as 12, 15 and 20. + DELETE_RUNPATH 0 - 10, 12, 15, 20 + + The DELETE_RUNPATH keyword is optional. + +.. _enfk_sched_file: +.. topic:: ENKF_SCHED_FILE + + When the enkf application runs the EnKF algorithm, it will use + ECLIPSE to simulate one report step at a time, and do an + update after each step. However, in some cases it will be + beneficial to turn off the EnKF update for some report steps + or to skip some steps completely. The keyword ENKF_SCHED_FILE + can point to a file with a more advanced schedule for when to + perform the updates. The format of the file pointed to by + ENKF_SCHED_FILE should be plain text, with one entry per + line. Each line should have the following form: + + :: + + REPORT_STEP1 REPORT_STEP2 ON|OFF STRIDE + ... + + Here REPORT_STEP1 and REPORT_STEP2 are the first and last + report steps respectively and ON|OFF determines whether the + EnKF analysis should be ON or OFF, the STRIDE argument is + optional. If the analysis is ON the stride will default to + REPORT_STEP2 minus REPORT_STEP1, thus if you want to perform + analysis at each report step set stride equal to 1. Observe + that whatever value of stride is used, the integration will + always start on REPORT_STEP1 and end on REPORT_STEP2. Example: + + :: + + 0 100 OFF + 100 125 ON 5 + 125 200 ON 1 + + In this example, the enkf application will do the following: + + #. Simulate directly from report step 0 to report step 100. No EnKF update will be performed. + #. From report step 100 to report step 125 it will simulate five report steps at a time, doing EnKF update at report steps 105, 110, 115, 120 and 125. + #. From report step 125 to report step 200 it will simulate one report step at a time, doing EnKF update for every timestep. + + The ENKF_SCHED_FILE keyword is optional. + +.. _end_date: +.. topic:: END_DATE + + When running a set of models from beginning to end ERT does + not now in advance how long the simulation is supposed to be, + it is therefor impossible beforehand to determine which + restart file number should be used as target file, and the + procedure used for EnKF runs can not be used to verify that an + ECLIPSE simulation has run to the end. + + By using the END_DATE keyword you can tell ERT that the + simulation should go at least up to the date given by + END_DATE, otherwise they will be regarded as failed. The + END_DATE does not need to correspond exactly to the end date + of the simulation, it must just be set so that all simulations + which go to or beyond END_DATE are regarded as successfull. + + *Example:* + + :: + END_DATE 10/10/2010 + + With this END_DATE setting all simulations which have gone to + at least 10.th of October 2010 are OK. + + +.. _enspath: +.. topic:: ENSPATH + + The ENSPATH should give the name of a folder that will be used + for storage by the enkf application. Note that the contents of + this folder is not intended for human inspection. By default, + ENSPATH is set to "storage". + + *Example:* + + :: + + -- Use internal storage in /mnt/my_big_enkf_disk + ENSPATH /mnt/my_big_enkf_disk + + The ENSPATH keyword is optional. + +.. _select_case: +.. topic:: SELECT_CASE + + By default ert will remember the selected case from the + previous run, or select the case "default" if this is the + first time you start a project. By using the SELECT_CASE + keyword you can tell ert to start up with a particular + case. If the requested case does not exist ert will ignore the + SELECT_CASE command, the case will not be created + automagically. + +.. _history_source: +.. topic:: HISTORY_SOURCE + + In the observation configuration file you can enter + observations with the keyword HISTORY_OBSERVATION; this means + that ERT will the observed 'true' values from the model + history. Practically the historical values can be fetched + either from the SCHEDULE file or from a reference case. What + source to use for the historical values can be controlled with + the HISTORY_SOURCE keyword. The different possible values for + the HISTORY_SOURCE keyword are: + + + REFCASE_HISTORY + This is the default value for HISTORY_SOURCE, + ERT will fetch the historical values from the *xxxH* + keywords in the refcase summary, e.g. observations of + WGOR:OP_1 is based the WGORH:OP_1 vector from the + refcase summary. + + REFCASE_SIMULATED + In this case the historical values are based on the simulated values from the refcase, this is mostly relevant when a you want compare with another case which serves as 'the truth'. + + SCHEDULE + Load historical values from the WCONHIST and WCONINJE keywords in the Schedule file. + + + When setting HISTORY_SOURCE to either REFCASE_SIMULATED or REFCASE_HISTORY you must also set the REFCASE variable to point to the ECLIPSE data file in an existing reference case (should be created with the same schedule file as you are using now). + + *Example:* + + :: + + -- Use historic data from reference case + HISTORY_SOURCE REFCASE_HISTORY + REFCASE /somefolder/ECLIPSE.DATA + + The HISTORY_SOURCE keyword is optional. + +.. _refcase: +.. topic:: REFCASE + + With the REFCASE key you can supply ert with a reference case which can be used for observations (see HISTORY_SOURCE), if you want to use wildcards with the SUMMARY keyword you also must supply a REFCASE keyword. The REFCASE keyword should just point to an existing ECLIPSE data file; ert will then look up and load the corresponding summary results. + + *Example:* + + :: + + -- The REFCASE keyword points to the datafile of an existing ECLIPSE simulation. + REFCASE /path/to/somewhere/SIM_01_BASE.DATA + + +.. _install_job: +.. topic:: INSTALL_JOB + + The INSTALL_JOB keyword is used to learn the enkf application how to run external applications and scripts, i.e. defining a job. After a job has been defined with INSTALL_JOB, it can be used with the FORWARD_MODEL keyword. For example, if you have a script which generates relative permeability curves from a set of parameters, it can be added as a job, allowing you to do history matching and sensitivity analysis on the parameters defining the relative permeability curves. + + The INSTALL_JOB keyword takes two arguments, a job name and the name of a configuration file for that particular job. + + *Example:* + + :: + + -- Define a Lomeland relative permeabilty job. + -- The file jobs/lomeland.txt contains a detailed + -- specification of the job. + INSTALL_JOB LOMELAND jobs/lomeland.txt + + The configuration file used to specify an external job is easy to use and very flexible. It is documented in Customizing the simulation workflow in enkf. + + The INSTALL_JOB keyword is optional. + +.. _keep_runpath: +.. topic:: KEEP_RUNPATH + + When the enkf application is running it creates directories for the ECLIPSE simulations, one for each realization. If you are using the enkf application to run the EnKF algorithm, the default behavior is to delete these directories after the simulation results have been internalized. This behavior can be overridden with the KEEP_RUNPATH keyword, which causes enkf to keep the specified simulation directories. When running the enkf application as a convenient way to start many simulations, e.g. using the screening experiment option, the behavior is the opposite, and can be overridden with the DELETE_RUNPATH keyword. + + *Example:* + + :: + + -- Keep simulation directories 0 to 15 and 18 and 20 + KEEP_RUNPATH 0-15, 18, 20 + + The KEEP_RUNPATH keyword is optional. + +.. _obs_config: +.. topic:: OBS_CONFIG + + The OBS_CONFIG key should point to a file defining observations and associated uncertainties. The file should be in plain text and formatted according to the guidelines given in Creating an observation file for use with enkf. + + *Example:* + + :: + + -- Use the observations in my_observations.txt + OBS_CONFIG my_observations.txt + + The OBS_CONFIG keyword is optional, but for your own convenience, it is strongly recommended to provide an observation file. + +.. _result_path: +.. topic:: RESULT_PATH + + The enkf application will print some simple tabulated results at each report step. The RESULT_PATH keyword should point to a folder where the tabulated results are to be written. It can contain a %d specifier, which will be replaced with the report step by enkf. The default value for RESULT_PATH is "results/step_%d". + + *Example:* + + :: + + -- Changing RESULT_PATH + RESULT_PATH my_nice_results/step-%d + + The RESULT_PATH keyword is optional. + +.. _runpath: +.. topic:: RUNPATH + + The RUNPATH keyword should give the name of the folders where the ECLIPSE simulations are executed. It should contain at least one %d specifier, which will be replaced by the realization number when the enkf creates the folders. Optionally, it can contain one more %d specifier, which will be replaced by the iteration number. + + By default, RUNPATH is set to "simulations/realization-%d". + + *Example A:* + + :: + -- Giving a RUNPATH with just one %d specifer. + RUNPATH /mnt/my_scratch_disk/realization-%d + + *Example B:* + + :: + + -- Giving a RUNPATH with two %d specifers. + RUNPATH /mnt/my_scratch_disk/realization-%d/iteration-%d + + The RUNPATH keyword is optional. + + +.. _runpath_file: +.. topic:: RUNPATH_FILE + +When running workflows based on external scripts it is necessary to 'tell' the external script in some way or another were all the realisations are located in the filesystem. Since the number of realisations can be quite high this will easily overflow the commandline buffer; the solution which is used is therefor to let ert write a reagular file which looks like this:: + + 0 /path/to/realisation0 CASE0 iter + 1 /path/to/realisation1 CASE1 iter + ... + N /path/to/realisationN CASEN iter + +The path to this file can then be passed to the scripts using the +magic string <RUNPATH_FILE>. The RUNPATH_FILE will by default be +stored as .ert_runpath_list in the same directory as the configuration +file, but you can set it to something else with the RUNPATH_FILE key. + +Keywords controlling the simulations +------------------------------------ +.. _keywords_controlling_the_simulations: + +.. _min_realizations: +.. topic:: MIN_REALIZATIONS + + MIN_REALIZATIONS is the minimum number of realizations that must have succeeded for the simulation to be regarded as a success. + + MIN_REALIZATIONS can also be used in combination with STOP_LONG_RUNNING, see the documentation for STOP_LONG_RUNNING for a description of this. + + *Example:* + + :: + + MIN_REALIZATIONS 20 + + The MIN_REALIZATIONS key can also be set as a percentage of NUM_REALIZATIONS + + :: + + MIN_REALIZATIONS 10% + + The MIN_REALIZATIONS key is optional. + + +.. _stop_long_running: +.. topic:: STOP_LONG_RUNNING + + The STOP_LONG_RUNNING key is used in combination with the MIN_REALIZATIONS key to control the runtime of simulations. When STOP_LONG_RUNNING is set to TRUE, MIN_REALIZATIONS is the minimum number of realizations run before the simulation is stopped. After MIN_REALIZATIONS have succeded successfully, the realizatons left are allowed to run for 25% of the average runtime for successfull realizations, and then killed. + + *Example:* + + :: + + -- Stop long running realizations after 20 realizations have succeeded + MIN_REALIZATIONS 20 + STOP_LONG_RUNNING TRUE + + The STOP_LONG_RUNNING key is optional. The MIN_REALIZATIONS key must be set when STOP_LONG_RUNNING is set to TRUE. + + +.. _max_runtime: +.. topic:: MAX_RUNTIME + + The MAX_RUNTIME keyword is used to control the runtime of simulations. When MAX_RUNTIME is set, a job is only allowed to run for MAX_RUNTIME, given in seconds. A value of 0 means unlimited runtime. + + *Example:* + + :: + + -- Let each realizations run for 50 seconds + MAX_RUNTIME 50 + + The MAX_RUNTIME key is optional. + + +Parameterization keywords +------------------------- +.. _parameterization_keywords: + +The keywords in this section are used to define a parametrization of the ECLIPSE model. I.e., defining which parameters to change in a sensitivity analysis and/or history matching project. For some parameters, it necessary to specify a prior distribution. See Prior distributions available in enkf for a complete list of available priors. + +.. _field: +.. topic:: FIELD + + The FIELD keyword is used to parametrize quantities which have extent over the full grid. Both dynamic properties like pressure, and static properties like porosity, are implemented in terms of FIELD objects. When adding fields in the config file the syntax is a bit different for dynamic fields (typically solution data from ECLIPSE) and parameter fields like permeability and porosity. + + **Dynamic fields** + + To add a dynamic field the entry in the configuration file looks like this: + + :: + FIELD <ID> DYNAMIC MIN:X MAX:Y + + In this case ID is not an arbitrary string; it must coincide with the keyword name found in the ECLIPSE restart file, e.g. PRESSURE. Optionally, you can add a minimum and/or a maximum value with MIN:X and MAX:Y. + + *Example A:* + + :: + + -- Adding pressure field (unbounded) + FIELD PRESSURE DYNAMIC + + *Example B:* + + :: + + -- Adding a bounded water saturation field + FIELD SWAT DYNAMIC MIN:0.2 MAX:0.95 + + **Parameter fields** + + A parameter field (e.g. porosity or permeability) is defined as follows: + + :: + + FIELD ID PARAMETER <ECLIPSE_FILE> INIT_FILES:/path/%d MIN:X MAX:Y OUTPUT_TRANSFORM:FUNC INIT_TRANSFORM:FUNC + + Here ID is again an arbitrary string, ECLIPSE_FILE is the name of the file the enkf will export this field to when running simulations. Note that there should be an IMPORT statement in the ECLIPSE data file corresponding to the name given with ECLIPSE_FILE. INIT_FILES is a filename (with an embedded %d) to load the initial field from. Can be RMS ROFF format, ECLIPSE restart format or ECLIPSE GRDECL format. + + The options MIN, MAX, INIT_TRANSFORM and OUTPUT_TRANSFORM are all optional. MIN and MAX are as for dynamic fields. OUTPUT_TRANSFORM is the name of a mathematical function which will be applied to the field before it is exported, and INIT_TRANSFORM is the name of a function which will be applied to the fields when they are loaded. [Just use INIT_TRANSFORM:XXX to get a list of available functions.] + + Regarding format of ECLIPSE_FILE: The default format for the parameter fields is binary format of the same type as used in the ECLIPSE restart files. This requires that the ECLIPSE datafile contains an IMPORT statement. The advantage with using a binary format is that the files are smaller, and reading/writing is faster than for plain text files. If you give the ECLIPSE_FILE with the extension .grdecl (arbitrary case), enkf will produce ordinary .grdecl files, which are loaded with an INCLUDE statement. This is probably what most users are used to beforehand - but we recomend the IMPORT form. + + **General fields** + + In addition to dynamic and parameter field there is also a general field, where you have fine grained control over input/output. Use of the general field type is only relevant for advanced features. The arguments for the general field type are as follows: + + :: + + FIELD ID GENERAL FILE_GENERATED_BY_ENKF FILE_LOADED_BY_ENKF <OPTIONS> + + The OPTIONS argument is the same as for the parameter field. + +.. _gen_data: +.. topic:: GEN_DATA + + The GEN_DATA keyword is used when estimating data types which enkf does not know anything about. GEN_DATA is very similar to GEN_PARAM, but GEN_DATA is used for data which are updated/created by the forward model like e.g. seismic data. In the main configuration file the input for a GEN_DATA instance is as follows: + + :: + + GEN_DATA ID RESULT_FILE:yyy INPUT_FORMAT:xx REPORT_STEPS:10,20 ECL_FILE:xxx OUTPUT_FORMAT:xx INIT_FILES:/path/files%d TEMPLATE:/template_file TEMPLATE_KEY:magic_string + + The GEN_DATA keyword has many options; in many cases you can leave many of them off. We therefor list the required and the optional options separately: + + **Required GEN_DATA options** + + * RESULT_FILE - This if the name the file generated by the forward model and read by ERT. This filename _must_ have a %d as part of the name, that %d will be replaced by report step when loading. + * INPUT_FORMAT - The format of the file written by the forward model (i.e. RESULT_FILE) and read by ERT, valid values are ASCII, BINARY_DOUBLE and BINARY_FLOAT. + * REPORT_STEPS A list of the report step(s) where you expect the forward model to create a result file. I.e. if the forward model should create a result file for report steps 50 and 100 this setting should be: REPORT_STEPS:50,100. If you have observations of this GEN_DATA data the RESTART setting of the corresponding GENERAL_OBSERVATION must match one of the values given by REPORT_STEPS. + + **Optional GEN_DATA options** + + * ECL_FILE - This is the name of file written by enkf to be read by the forward model. + * OUTPUT_FORMAT - The format of the files written by enkf and read by the forward model, valid values are ASCII, BINARY_DOUBLE, BINARY_FLOAT and ASCII_TEMPLATE. If you use ASCII_TEMPLATE you must also supply values for TEMPLATE and TEMPLATE_KEY. + * INIT_FILES - Format string with '%d' of files to load the initial data from. + + *Example:* + + :: + + GEN_DATA 4DWOC INPUT_FORMAT:ASCII RESULT_FILE:SimulatedWOC%d.txt REPORT_STEPS:10,100 + + Here we introduce a GEN_DATA instance with name 4DWOC. When the forward model has run it should create two files with name SimulatedWOC10.txt and SimulatedWOC100.txt. The result files are in ASCII format, ERT will look for these files and load the content. The files should be pure numbers - without any header. + + **Observe that the GEN_DATA RESULT_FILE setting must have a %d format specifier, that will be replaced with the report step..** + + +.. _custom_kw: +.. topic:: CUSTOM_KW + + The keyword CUSTOM_KW enables custom data key:value pairs + to be stored in ERT storage. Custom KW has many + similarities to Gen KW and Gen Data but is fully defined by + the user and contain only key_value pairs. + + *Example:* + + :: + + CUSTOM_KW GROUP_NAME <input_file> + + --GROUP_NAME + This is similar to Gen KW where every keyword is prefixed with the GROUP_NAME like this: GROUP_NAME:KEYWORD + + --input_file + This is the input file expected to be generated by a forward model. + + --Example + CUSTOM_KW COMPOSITION composition.txt + + With this setup ERT will expect the file composition.txt to be present in the runpath. + This file may look like this + + :: + + oil 0.5 + water 0.2 + gas 0.2 + unknown 0.1 + state good + + Every key-value pair must be a string followed by a space and a value. + The value can either be a number or a string (all numbers are interpreted as floats). + + After a successful run, ERT will store the COMPOSITION + Custom KW in its filesystem and will be available for every + realization. An export will present the values produced as: + + * COMPOSITION:oil + * COMPOSITION:water + * COMPOSITION:gas + * COMPOSITION:unknown + * COMPOSITION:state + + +.. _gen_kw: +.. topic:: GEN_KW + + The GEN_KW (abbreviation of general keyword) parameter is based on a template file and substitution. In the main config file a GEN_KW instance is defined as follows: + + :: + + GEN_KW ID my_template.txt my_eclipse_include.txt my_priors.txt + + Here ID is an (arbitrary) unique string, my_template.txt is the name of a template file, my_eclipse_include.txt is the name of the file which is made for each member based on my_template.txt and my_priors.txt is a file containing a list of parametrized keywords and a prior distribution for each. Note that you must manually edit the ECLIPSE data file so that my_eclipse_include.txt is included. + + Let us consider an example where the GEN_KW parameter type is used to estimate pore volume multipliers. We would then declare a GEN_KW instance in the main enkf configuration file: + + :: + + GEN_KW PAR_MULTPV multpv_template.txt multpv.txt multpv_priors.txt + + In the GRID or EDIT section of the ECLIPSE data file, we would insert the following include statement: + + :: + + INCLUDE + 'multpv.txt' / + + The template file multpv_template.txt would contain some parametrized ECLIPSE statements: + + :: + + BOX + 1 10 1 30 13 13 / + MULTPV + 300*<MULTPV_BOX1> / + ENDBOX + + BOX + 1 10 1 30 14 14 / + MULTPV + 300*<MULTPV_BOX2> / + ENDBOX + + Here, <MULTPV_BOX1> and <MULTPV_BOX2> will act as magic strings. Note that the '<' '>' must be present around the magic strings. In this case, the parameter configuration file multpv_priors.txt could look like this: + + :: + + MULTPV_BOX2 UNIFORM 0.98 1.03 + MULTPV_BOX1 UNIFORM 0.85 1.00 + + In general, the first keyword on each line in the parameter configuration file defines a key, which when found in the template file enclosed in '<' and '>', is replaced with a value. The rest of the line defines a prior distribution for the key. See Prior distributions available in enkf for a list of available prior distributions. + + **Example: Using GEN_KW to estimate fault transmissibility multipliers** + + Previously enkf supported a datatype MULTFLT for estimating fault transmissibility multipliers. This has now been depreceated, as the functionality can be easily achieved with the help of GEN_KW. In th enkf config file: + + :: + + GEN_KW MY-FAULTS MULTFLT.tmpl MULTFLT.INC MULTFLT.txt + + Here MY-FAULTS is the (arbitrary) key assigned to the fault multiplers, MULTFLT.tmpl is the template file, which can look like this: + + :: + + MULTFLT + 'FAULT1' <FAULT1> / + 'FAULT2' <FAULT2> / + / + + and finally the initial distribution of the parameters FAULT1 and FAULT2 are defined in the file MULTFLT.txt: + + :: + + FAULT1 LOGUNIF 0.00001 0.1 + FAULT2 UNIFORM 0.00 1.0 + + Loading GEN_KW values from an external file + + The default use of the GEN_KW keyword is to let the ERT application sample random values for the elements in the GEN_KW instance, but it is also possible to tell ERT to load a precreated set of data files, this can for instance be used as a component in a experimental design based workflow. When using external files to initialize the GEN_KW instances you supply an extra keyword INIT_FILE:/path/to/priors/files%d which tells where the prior files are: + + :: + + GEN_KW MY-FAULTS MULTFLT.tmpl MULTFLT.INC MULTFLT.txt INIT_FILES:priors/multflt/faults%d + + In the example above you must prepare files priors/multflt/faults0, priors/multflt/faults1, ... priors/multflt/faultsn which ert will load when you initialize the case. The format of the GEN_KW input files can be of two varieties: + + 1. The files can be plain ASCII text files with a list of numbers: + + :: + + 1.25 + 2.67 + + The numbers will be assigned to parameters in the order found in the MULTFLT.txt file. + + 2. Alternatively values and keywords can be interleaved as in: + + :: + + FAULT1 1.25 + FAULT2 2.56 + + in this case the ordering can differ in the init files and the parameter file. + + The heritage of the ERT program is based on the EnKF algorithm, and the EnKF algorithm evolves around Gaussian variables - internally the GEN_KW variables are assumed to be samples from the N(0,1) distribution, and the distributions specified in the parameters file are based on transformations starting with a N(0,1) distributed variable. The slightly awkward consequence of this is that to let your sampled values pass through ERT unmodified you must configure the distribution NORMAL 0 1 in the parameter file; alternatively if you do not intend to update the GEN_KW variable you can use the distribution RAW. + + +.. _gen_param: +.. topic:: GEN_PARAM + + The GEN_PARAM parameter type is used to estimate parameters which do not really fit into any of the other categories. As an example, consider the following situation: + + Some external Software (e.g. Cohiba) makes a large vector of random numbers which will serve as input to the forward model. (It is no requirement that the parameter set is large, but if it only consists of a few parameters the GEN_KW type will be easier to use.) + We want to update this parameter with enkf. + In the main configuration file the input for a GEN_PARAM instance is as follows: + + :: + + GEN_PARAM ID ECLIPSE_FILE INPUT_FORMAT:xx OUTPUT_FORMAT:xx INIT_FILES:/path/to/init/files%d (TEMPLATE:/template_file KEY:magic_string) + + here ID is the usual unique string identifying this instance and ECLIPSE_FILE is the name of the file which is written into the run directories. The three arguments GEN_PARAM, ID and ECLIPSE_FILE must be the three first arguments. In addition you must have three additional arguments, INPUT_FORMAT, OUTPUT_FORMAT and INIT_FILES. INPUT_FORMAT is the format of the files enkf should load to initialize, and OUTPUT_FORMAT is the format of the files enkf writes for the forward model. The valid values are: + + * ASCII - This is just text file with formatted numbers. + * ASCII_TEMPLATE - An plain text file with formatted numbers, and an arbitrary header/footer. + * BINARY_FLOAT - A vector of binary float numbers. + * BINARY_DOUBLE - A vector of binary double numbers. + + Regarding the different formats - observe the following: + + #. Except the format ASCII_TEMPLATE the files contain no header information. + #. The format ASCII_TEMPLATE can only be used as output format. + #. If you use the output format ASCII_TEMPLATE you must also supply a TEMPLATE:X and KEY:Y option. See documentation of this below. + #. For the binary formats files generated by Fortran can not be used - can easily be supported on request. + + **Regarding templates:** If you use OUTPUT_FORMAT:ASCII_TEMPLATE you must also supply the arguments TEMPLATE:/template/file and KEY:MaGiCKEY. The template file is an arbitrary existing text file, and KEY is a magic string found in this file. When enkf is running the magic string is replaced with parameter data when the ECLIPSE_FILE is written to the directory where the simulation is run from. Consider for example the follwing configuration: + + :: + + TEMPLATE:/some/file KEY:Magic123 + + The template file can look like this (only the Magic123 is special): + + :: + + Header line1 + Header line2 + ============ + Magic123 + ============ + Footer line1 + Footer line2 + + When enkf is running the string Magic123 is replaced with parameter values, and the resulting file will look like this: + + :: + + Header line1 + Header line2 + ============ + 1.6723 + 5.9731 + 4.8881 + ..... + ============ + Footer line1 + Footer line2 + +.. _surface: +.. topic:: SURFACE + + The SURFACE keyword can be used to work with surface from RMS in the irap format. The surface keyword is configured like this: + + :: + + SURFACE TOP OUTPUT_FILE:surf.irap INIT_FILES:Surfaces/surf%d.irap BASE_SURFACE:Surfaces/surf0.irap + + The first argument, TOP in the example above, is the identifier you want to use for this surface in ert. The OUTPUT_FILE key is the name of surface file which ERT will generate for you, INIT_FILES points to a list of files which are used to initialize, and BASE_SURFACE must point to one existing surface file. When loading the surfaces ERT will check that all the headers are compatible. An example of a surface IRAP file is: + + :: + + -996 511 50.000000 50.000000 + 444229.9688 457179.9688 6809537.0000 6835037.0000 + 260 -30.0000 444229.9688 6809537.0000 + 0 0 0 0 0 0 0 + 2735.7461 2734.8909 2736.9705 2737.4048 2736.2539 2737.0122 + 2740.2644 2738.4014 2735.3770 2735.7327 2733.4944 2731.6448 + 2731.5454 2731.4810 2730.4644 2730.5591 2729.8997 2726.2217 + 2721.0996 2716.5913 2711.4338 2707.7791 2705.4504 2701.9187 + .... + + The surface data will typically be fed into other programs like Cohiba or RMS. The data can be updated using e.g. the Smoother. + + **Initializing from the FORWARD MODEL** + + All the parameter types like FIELD,GEN_KW,GEN_PARAM and SURFACE can be initialized from the forward model. To achieve this you just add the setting FORWARD_INIT:True to the configuration. When using forward init the initialization will work like this: + + #. The explicit initialization from the case menu, or when you start a simulation, will be ignored. + #. When the FORWARD_MODEL is complete ERT will try to initialize the node based on files created by the forward model. If the init fails the job as a whole will fail. + #. If a node has been initialized, it will not be initialized again if you run again. [Should be possible to force this ....] + + When using FORWARD_INIT:True ERT will consider the INIT_FILES setting to find which file to initialize from. If the INIT_FILES setting contains a relative filename, it will be interpreted relativt to the runpath directory. In the example below we assume that RMS has created a file petro.grdecl which contains both the PERMX and the PORO fields in grdecl format; we wish to initialize PERMX and PORO nodes from these files: + + :: + + FIELD PORO PARAMETER poro.grdecl INIT_FILES:petro.grdecl FORWARD_INIT:True + FIELD PERMX PARAMETER permx.grdecl INIT_FILES:petro.grdecl FORWARD_INIT:True + + Observe that forward model has created the file petro.grdecl and the nodes PORO and PERMX create the ECLIPSE input files poro.grdecl and permx.grdecl, to ensure that ECLIPSE finds the input files poro.grdecl and permx.grdecl the forward model should contain a job which will copy/convert petro.grdecl -> (poro.grdecl,permx.grdecl), this job should not overwrite existing versions of permx.grdecl and poro.grdecl. This extra hoops is not strictly needed in all cases, but strongly recommended to ensure that you have control over which data is used, and that everything is consistent in the case where the forward model is run again. + + +.. _summary: +.. topic:: SUMMARY + + The SUMMARY keyword is used to add variables from the ECLIPSE summary file to the parametrization. The keyword expects a string, which should have the format VAR:WGRNAME. Here, VAR should be a quantity, such as WOPR, WGOR, RPR or GWCT. Moreover, WGRNAME should refer to a well, group or region. If it is a field property, such as FOPT, WGRNAME need not be set to FIELD. + + *Example:* + + :: + + -- Using the SUMMARY keyword to add diagnostic variables + SUMMARY WOPR:MY_WELL + SUMMARY RPR:8 + SUMMARY F* -- Use of wildcards requires that you have entered a REFCASE. + + The SUMMARY keyword has limited support for '*' wildcards, if your key contains one or more '*' characters all matching variables from the refcase are selected. Observe that if your summary key contains wildcards you must supply a refcase with the REFCASE key - otherwise it will fail hard. + + **Note:** Properties added using the SUMMARY keyword are only diagnostic. I.e., they have no effect on the sensitivity analysis or history match. + + +Keywords controlling the ES algorithm +----------------------------------------- +.. _keywords_controlling_the_es_algorithm: + +.. _enkf_alpha: +.. topic:: ENKF_ALPHA + + ENKF_ALPHA has some latex letters - need to be handled!! + Scaling factor (double) used in outlier detection. Increasing this factor means that more observations will potentially be included in the assimilation. The default value is 1.50. + + Including outliers in the EnKF algorithm can dramatically increase the coupling between the ensemble members. It is therefore important to filter out these outlier data prior to data assimilation. An observation, \textstyle d^o_i, will be classified as an outlier if + + :: + + |d^o_i - \bar{d}_i| > \mathrm{ENKF\_ALPHA} \left(s_{d_i} + \sigma_{d^o_i}\right), + + where \textstyle\boldsymbol{d}^o is the vector of observed data, \textstyle\boldsymbol{\bar{d}} is the average of the forcasted data ensemble, \textstyle\boldsymbol{s_{d}} is the vector of estimated standard deviations for the forcasted data ensemble, and \textstyle\boldsymbol{s_{d}^o} is the vector standard deviations for the observation error (specified a priori). + + +.. _enkf_bootstrap: +.. topic:: ENKF_BOOTSTRAP + + Boolean specifying if we want to resample the Kalman gain matrix in the update step. The purpose is to avoid that the ensemble covariance collapses. When this keyword is true each ensemble member will be updated based on a Kalman gain matrix estimated from a resampling with replacement of the full ensemble. + + In theory and in practice this has worked well when one uses a small number of ensemble members. + + +.. _enkf_cv_folds: +.. topic:: ENKF_CV_FOLDS + + Integer specifying how many folds we should use in the Cross-Validation (CV) scheme. Possible choices are the integers between 2 and the ensemble size (2-fold CV and leave-one-out CV respectively). However, a robust choice for the number of CV-folds is 5 or 10 (depending on the ensemble size). + + *Example:* + + :: + + -- Setting the number of CV folds equal to 5 + ENKF_CV_FOLDS 5 + + Requires that the ENKF_LOCAL_CV keyword is set to TRUE + + +.. _enkf_force_ncomp: +.. topic:: ENKF_FORCE_NCOMP + + Bool specifying if we want to force the subspace dimension we want to use in the EnKF updating scheme (SVD-based) to a specific integer. This is an alternative to selecting the dimension using ENKF_TRUNCATION or ENKF_LOCAL_CV. + + *Example:* + + :: + + -- Setting the the subspace dimension to 2 + ENKF_FORCE_NCOMP TRUE + ENKF_NCOMP 2 + + + +.. _enkf_local_cv: +.. topic:: ENKF_LOCAL_CV + + Boolean specifying if we want to select the subspace dimension in the SVD-based EnKF algorithm using Cross-Validation (CV) [1]. This is a more robust alternative to selecting the subspace dimension based on the estimated singular values (See ENKF_TRUNCATION), because the predictive power of the estimated Kalman gain matrix is taken into account. + + *Example:* + + :: + + -- Select the subspace dimension using Cross-Validation + ENKF_LOCAL_CV TRUE + + + +.. _enkf_pen_press: +.. topic:: ENKF_PEN_PRESS + + Boolean specifying if we want to select the subspace dimension in the SVD-based EnKF algorithm using Cross-Validation (CV), and a penalised version of the predictive error sum of squares (PRESS) statistic [2]. This is recommended when overfitting is a severe problem (and when the number of ensemble members is small) + + *Example:* + + :: + + -- Select the subspace dimension using Cross-Validation + ENKF_LOCAL_CV TRUE + + -- Using penalised PRESS statistic + ENKF_PEN_PRESS TRUE + + + +.. _enkf_mode: +.. topic:: ENKF_MODE + + The ENKF_MODE keyword is used to select which EnKF algorithm to use. Use the value STANDARD for the original EnKF algorithm, or SQRT for the so-called square root scheme. The default value for ENKF_MODE is STANDARD. + + *Example A:* + + :: + + -- Using the square root update + ENKF_MODE SQRT + + *Example B:* + + :: + + -- Using the standard update + ENKF_MODE STANDARD + + The ENKF_MODE keyword is optional. + + +.. _enkf_merge_observations: +.. topic:: ENKF_MERGE_OBSERVATIONS + + If you use the ENKF_SCHED_FILE option to jump over several dates at a time you can choose whether you want to use all the observations in between, or just the final. If set to TRUE, all observations will be used. If set to FALSE, only the final observation is used. The default value for ENKF_MERGE_OBSERVATIONS is FALSE. + + *Example:* + + :: + + -- Merge observations + ENKF_MERGE_OBSERVATIONS TRUE + + +.. _enkf_ncomp: +.. topic:: ENKF_NCOMP + + Integer specifying the subspace dimension. Requires that ENKF_FORCE_NCOMP is TRUE. + +.. _enkf_rerun: +.. topic:: ENKF_RERUN + + This is a boolean switch - TRUE or FALSE. Should the simulation start from time zero after each update. + + + +.. _enkf_scaling: +.. topic:: ENKF_SCALING + + This is a boolean switch - TRUE (Default) or FALSE. If TRUE, we scale the data ensemble matrix to unit variance. This is generally recommended because the SVD-based EnKF algorithm is not scale invariant. + + +.. _enkf_truncation: +.. topic:: ENKF_TRUNCATION + + Truncation factor for the SVD-based EnKF algorithm (see Evensen, 2007). In this algorithm, the forecasted data will be projected into a low dimensional subspace before assimilation. This can substantially improve on the results obtained with the EnKF, especially if the data ensemble matrix is highly collinear (Saetrom and Omre, 2010). The subspace dimension, p, is selected such that + + :: + + \frac{\sum_{i=1}^{p} s_i^2}{\sum_{i=1}^r s_i^2} \geq \mathrm{ENKF\_TRUNCATION}, + + where si is the ith singular value of the centered data ensemble matrix and r is the rank of this matrix. This criterion is similar to the explained variance criterion used in Principal Component Analysis (see e.g. Mardia et al. 1979). + + The default value of ENKF_TRUNCATION is 0.99. If ensemble collapse is a big problem, a smaller value should be used (e.g 0.90 or smaller). However, this does not guarantee that the problem of ensemble collapse will disappear. Note that setting the truncation factor to 1.00, will recover the Standard-EnKF algorithm if and only if the covariance matrix for the observation errors is proportional to the identity matrix. + + +.. _std_scale_correlated_obs: +.. topic:: STD_SCALE_CORRELATED_OBS + + With this kewyord you can instruct ERT to use the simulated + data to estimate the correlations in the observations, and + then inflate the observation standard deviation as a way to + estimate the real information content in the observations. The + method is based on PCA, the scaling factor is calculated as: + + :: + + \sqrt{\frac{N_{\sigma}}{N_{\mathrm{obs}}} + + where $N_{\sigma}$ is the number of singular components, at + (fixed) truncation 0.95 and $N_{\mathrm{obs}}$ is the number + of observations. The STD_SCALE_CORRELATED_OBS keyword will + flatten all your observations, including temporal and spatial + correlations. For more fine grained control you can use the + STD_CALE_CORRELATED_OBS workflow job, or even write your own + plugins. + + + +.. _update_log_path: +.. topic:: UPDATE_LOG_PATH + + A summary of the data used for updates are stored in this directory. + + +**References** + +* Evensen, G. (2007). "Data Assimilation, the Ensemble Kalman Filter", Springer. +* Mardia, K. V., Kent, J. T. and Bibby, J. M. (1979). "Multivariate Analysis", Academic Press. +* Saetrom, J. and Omre, H. (2010). "Ensemble Kalman filtering with shrinkage regression techniques", Computational Geosciences (online first). + + +Analysis module +--------------- +.. _analysis_module: + +The final EnKF linear algebra is performed in an analysis module. The keywords to load, select and modify the analysis modules are documented here. + +.. _analysis_load: +.. topic:: ANALYSIS_LOAD + + The ANALYSIS_LOAD key is the main key to load an analysis module: + + :: + + ANALYSIS_LOAD ANAME analysis.so + + The first argument ANAME is just an arbitrary unique name which you want to use to refer to the module later. The second argument is the name of the shared library file implementing the module, this can either be an absolute path as /path/to/my/module/ana.so or a relative file name as analysis.so. The module is loaded with dlopen() and the normal shared library search semantics applies. + + +.. _analysis_select: +.. topic:: ANALYSIS_SELECT + + This command is used to select which analysis module to actually use in the updates: + + :: + + ANALYSIS_SELECT ANAME + + Here ANAME is the name you have assigned to the module when loading it with ANALYSIS_LOAD. + + +.. _analysis_set_var: +.. topic:: ANALYSIS_SET_VAR + + The analysis modules can have internal state, like e.g. truncation cutoff values, these values can be manipulated from the config file using the ANALYSIS_SET_VAR keyword: + + :: + + ANALYSIS_SET_VAR ANAME ENKF_TRUNCATION 0.97 + + To use this you must know which variables the module supports setting this way. If you try to set an unknown variable you will get an error message on stderr. + + +.. _analysis_copy: +.. topic:: ANALYSIS_COPY + + With the ANALYSIS_COPY keyword you can create a new instance of a module. This can be convenient if you want to run the same algorithm with the different settings: + + :: + + ANALYSIS_LOAD A1 analysis.so + ANALYISIS_COPY A1 A2 + + We load a module analysis.so and assign the name A1; then we copy A1 -> A2. The module A1 and A2 are now 100% identical. We then set the truncation to two different values: + + :: + + ANALYSIS_SET_VAR A1 ENKF_TRUNCATION 0.95 + ANALYSIS_SET_VAR A2 ENKF_TRUNCATION 0.98 + +**Developing analysis modules** + +In the analysis module the update equations are formulated based on familiar matrix expressions, and no knowledge of the innards of the ERT program are required. Some more details of how modules work can be found here modules.txt. In principle a module is 'just' a shared library following some conventions, and if you are sufficiently savy with gcc you can build them manually, but along with the ert installation you should have utility script ert_module which can be used to build a module; just write ert_module without any arguments to get a brief usage description. + +Advanced optional keywords +-------------------------- +.. _advanced_optional_keywords: + +The keywords in this section, controls advanced features of the enkf application. Insight in the internals of the enkf application and/or ECLIPSE may be required to fully understand their effect. Moreover, many of these keywords are defined in the site configuration, and thus optional to set for the user, but required when installing the enkf application at a new site. + + +.. _add_fixed_length_schedule_kw: +.. topic:: ADD_FIXED_LENGTH_SCHEDULE_KW + + Real low level fix for some SCHEDULE parsing problems. + + +.. _add_static_kw: +.. topic:: ADD_STATIC_KW + + The restart files from ECLIPSE are organized by keywords, which are of three different types: + + #. Keywords containing the dynamic solution, e.g. pressure and saturations. + #. Keywords containing various types of header information which is needed for a restart. + #. Keywords containing various types of diagnostic information which is not needed for a restart. + + Keywords in category 2 and 3 are referred to as static keywords. To be able to restart ECLIPSE, the enkf application has to store the keywords in category 2, whereas keywords in category 3 can safely be dropped. To determine whether a particular keyword is in category 2 or 3 the enkf considers an internal list of keywords. The current list contains the keywords: + + :: + + INTEHEAD LOGIHEAD DOUBHEAD IGRP SGRP XGRP ZGRP IWEL SWEL XWEL ZWEL + ICON SCON XCON HIDDEN STARTSOL PRESSURE SWAT SGAS RS RV ENDSOL ICAQNUM ICAQ IAAQ + SCAQNUM SCAQ SAAQ ACAQNUM ACAQ XAAQ + ISEG ILBS ILBR RSEG ISTHW ISTHG + + By using ADD_STATIC_KW you can dynamically add to this list. The magic string __ALL__ will add all static keywords. Use of the __ALL__ option is strongly discouraged, as it wastes a lot disk space. + + +.. _define: +.. topic:: DEFINE + + With the DEFINE keyword you can define key-value pairs which will be substituted in the rest of the configuration file. The DEFINE keyword expects two arguments: A key and a value to replace for that key. Later instances of the key enclosed in '<' and '>' will be substituted with the value. The value can consist of several strings, in that case they will be joined by one single space. + + *Example:* + + :: + + -- Define ECLIPSE_PATH and ECLIPSE_BASE + DEFINE ECLIPSE_PATH /path/to/eclipse/run + DEFINE ECLIPSE_BASE STATF02 + DEFINE KEY VALUE1 VALUE2 VALUE3 VALUE4 + + -- Set the GRID in terms of the ECLIPSE_PATH + -- and ECLIPSE_BASE keys. + GRID <ECLIPSE_PATH>/<ECLIPSE_BASE>.EGRID + + Observe that when you refer to the keys later in the config file they must be enclosed in '<' and '>'. Furthermore, a key-value pair must be defined in the config file before it can be used. The final key define above KEY, will be replaced with VALUE1 VALUE2 VALUE3 VALUE4 - i.e. the extra spaces will be discarded. + + +.. _time_map: +.. topic:: TIME_MAP + + Normally the mapping between report steps and true dates is + inferred by ERT indirectly by loading the ECLIPSE summary + files. In cases where you do not have any ECLIPSE summary + files you can use the TIME_MAP keyword to specify a file with + dates which are used to establish this mapping: + + *Example:* + + :: + + -- Load a list of dates from external file: "time_map.txt" + TIME_MAP time_map.txt + + The format of the TIME_MAP file should just be a list of dates + formatted as dd/mm/yyyy. The example file below has four dates: + + :: + + 01/01/2000 + 01/07/2000 + 01/01/2001 + 01/07/2001 + + + +.. _schedule_prediction_file: +.. topic:: SCHEDULE_PREDICTION_FILE + + This is the name of a schedule prediction file. It can contain %d to get different files for different members. Observe that the ECLIPSE datafile should include only one schedule file, even if you are doing predictions. + + +Keywords related to running the forward model +--------------------------------------------- +.. _keywords_related_to_running_the_forward_model: + + + +.. _forward_model: +.. topic:: FORWARD_MODEL + + The FORWARD_MODEL keyword is used to define how the simulations are executed. E.g., which version of ECLIPSE to use, which rel.perm script to run, which rock physics model to use etc. Jobs (i.e. programs and scripts) that are to be used in the FORWARD_MODEL keyword must be defined using the INSTALL_JOB keyword. A set of default jobs are available, and by default FORWARD_MODEL takes the value ECLIPSE100. + + The FORWARD_MODEL keyword expects a series of keywords, each defined with INSTALL_JOB. The enkf will execute the jobs in sequentially in the order they are entered. Note that the ENKF_SCHED_FILE keyword can be used to change the FORWARD_MODEL for sub-sequences of the run. + + *Example A:* + + :: + + -- Suppose that "MY_RELPERM_SCRIPT" has been defined with + -- the INSTALL_JOB keyword. This FORWARD_MODEL will execute + -- "MY_RELPERM_SCRIPT" before ECLIPSE100. + FORWARD_MODEL MY_RELPERM_SCRIPT ECLIPSE100 + + *Example B:* + + :: + + -- Suppose that "MY_RELPERM_SCRIPT" and "MY_ROCK_PHYSICS_MODEL" + -- has been defined with the INSTALL_JOB keyword. + -- This FORWARD_MODEL will execute "MY_RELPERM_SCRIPT", then + -- "ECLIPSE100" and in the end "MY_ROCK_PHYSICS_MODEL". + FORWARD_MODEL MY_RELPERM_SCRIPT ECLIPSE100 MY_ROCK_PHYSICS_MODEL + + For advanced jobs you can pass string arguments to the job using a KEY=VALUE based approach, this is further described in: passing arguments. In available jobs in enkf you can see a list of the jobs which are available. + + +.. _job_script: +.. topic:: JOB_SCRIPT + + Running the forward model from enkf is a multi-level process which can be summarized as follows: + + #. A Python module called jobs.py is written and stored in the directory where the forward simulation is run. The jobs.py module contains a list of job-elements, where each element is a Python representation of the code entered when installing the job. + #. The enkf application submits a Python script to the enkf queue system, this script then loads the jobs.py module to find out which programs to run, and how to run them. + #. The job_script starts and monitors the individual jobs in the jobs.py module. + + The JOB_SCRIPT variable should point at the Python script which is managing the forward model. This should normally be set in the site wide configuration file. + + +.. _queue_system: +.. topic:: QUEUE_SYSTEM + + The keyword QUEUE_SYSTEM can be used to control where the + simulation jobs are executed. It can take the values LSF, + TORQUE, RSH and LOCAL. + + The LSF option will submit jobs to the LSF cluster at your + location, and is recommended whenever LSF is available. + + The TORQUE option will submit jobs to the TORQUE a torque + based system, using the commands qsub, qstat etc., if + available. + + If you do not have access to LSF or TORQUE you can submit to + your local workstation using the LOCAL option and to homemade + cluster of workstations using the RSH option. All of the queue + systems can be further configured, see separate sections. + + *Example:* + + :: + + -- Tell ert to use the LSF cluster. + QUEUE_SYSTEM LSF + + The QUEUE_SYSTEM keyword is optional, and usually defaults to + LSF (this is site dependent). + +Configuring LSF access +---------------------- +.. _configuring_lsf_access: + +The LSF system is the most useful of the queue alternatives, and also +the alternative with most options. The most important options are +related to how ert should submit jobs to the LSF system. Essentially +there are two methods ert can use when submitting jobs to the LSF +system: + +#. For workstations which have direct access to LSF ert can submit + directly with no further configuration. This is preferred solution, + but unfortunately not very common. +#. Alternatively ert can issue shell commands to bsub/bjobs/bkill to + submit jobs. These shell commands can be issued on the current + workstation, or alternatively on a remote workstation using ssh. + +The main switch between alternatives 1 and 2 above is the LSF_SERVER +option. + +.. _lsf_server: +.. topic:: LSF_SERVER + + By using the LSF_SERVER option you essentially tell ert two + things about how jobs should be submitted to LSF: + + #. You tell ert that jobs should be submitted using shell + commands. + #. You tell ert which server should be used when submitting + + So when your configuration file has the setting: + + :: + + LSF_SERVER be-grid01 + + ert will use ssh to submit your jobs using shell commands on + the server be-grid01. For this to work you must have + passwordless ssh to the server be-grid01. If you give the + special server name LOCAL ert will submit using shell commands + on the current workstation. + + **bsub/bjobs/bkill options** + + By default ert will use the shell commands bsub,bjobs and + bkill to interact with the queue system, i.e. whatever + binaries are first in your PATH will be used. For fine grained + control of the shell based submission you can tell ert which + programs to use: + + :: + + QUEUE_OPTION LSF BJOBS_CMD /path/to/my/bjobs + QUEUE_OPTION LSF BSUB_CMD /path/to/my/bsub + + *Example 1* + + :: + + LSF_SERVER be-grid01 + QUEUE_OPTION LSF BJOBS_CMD /path/to/my/bjobs + QUEUE_OPTION LSF BSUB_CMD /path/to/my/bsub + + In this example we tell ert to submit jobs from the + workstation be-grid01 using custom binaries for bsub and + bjobs. + + *Example 2* + + :: + + LSF_SERVER LOCAL + + In this example we will submit on the current workstation, + without using ssh first, and we will use the default bsub and + bjobs executables. The remaining LSF options apply + irrespective of which method has been used to submit the jobs. + + +.. _lsf_queue: +.. topic:: LSF_QUEUE + + The name of the LSF queue you are running ECLIPSE simulations in. + + +.. _max_running_lsf: +.. topic:: MAX_RUNNING_LSF + + The keyword MAX_RUNNING_LSF controls the maximum number of + simultaneous jobs submitted to the LSF (Load Sharing Facility) + queue when using the LSF option in QUEUE_SYSTEM. + + *Example:* + + :: + + -- Submit no more than 30 simultaneous jobs + -- to the LSF cluster. + MAX_RUNNING_LSF 30 + + + + +Configuring TORQUE access +------------------------- +.. _configuring_torque_access: + +The TORQUE system is the only available system on some clusters. The +most important options are related to how ert should submit jobs to +the TORQUE system. + +* Currently, the TORQUE option only works when the machine you are + logged into have direct access to the queue system. ert then submit + directly with no further configuration. + +The most basic invocation is in other words: + +:: + + QUEUE_SYSTEM TORQUE + +**qsub/qstat/qdel options** + +By default ert will use the shell commands qsub,qstat and qdel to +interact with the queue system, i.e. whatever binaries are first in +your PATH will be used. For fine grained control of the shell based +submission you can tell ert which programs to use: + +:: + + QUEUE_SYSTEM TORQUE + QUEUE_OPTION TORQUE QSUB_CMD /path/to/my/qsub + QUEUE_OPTION TORQUE QSTAT_CMD /path/to/my/qstat + QUEUE_OPTION TORQUE QDEL_CMD /path/to/my/qdel + +In this example we tell ert to submit jobs using custom binaries for +bsub and bjobs. + +**Name of queue** + +The name of the TORQUE queue you are running ECLIPSE simulations in. + +:: + + QUEUE_OPTION TORQUE QUEUE name_of_queue + +**Name of cluster (label)** + +The name of the TORQUE cluster you are running ECLIPSE simulations +in. This might be a label (serveral clusters), or a single one, as in +this example baloo. + +:: + + QUEUE_OPTION TORQUE CLUSTER_LABEL baloo + +**Max running jobs** + +The queue option MAX_RUNNING controls the maximum number of +simultaneous jobs submitted to the queue when using (in this case) the +TORQUE option in QUEUE_SYSTEM. + +:: + + QUEUE_SYSTEM TORQUE + -- Submit no more than 30 simultaneous jobs + -- to the TORQUE cluster. + QUEUE_OPTION TORQUE MAX_RUNNING 30 + +**Queue options controlling number of nodes and CPUs** + +When using TORQUE, you must specify how many nodes a single job is +should to use, and how many CPUs per node. The default setup in ert +will use one node and one CPU. These options are called NUM_NODES and +NUM_CPUS_PER_NODE. + +If the numbers specified is higher than supported by the cluster +(i.e. use 32 CPUs, but no node has more than 16), the job will not +start. + +If you wish to increase these number, the program running (typically +ECLIPSE) will usually also have to be told to correspondingly use more +processing units (keyword PARALLEL) + +:: + + QUEUE_SYSTEM TORQUE + -- Use more nodes and CPUs + -- in the TORQUE cluster per job submitted + -- This should (in theory) allow for 24 processing + -- units to be used by eg. ECLIPSE + QUEUE_OPTION TORQUE NUM_NODES 3 + QUEUE_OPTION TORQUE NUM_CPUS_PER_NODE 8 + +**Keep output from qsub** + +Sometimes the error messages from qsub can be useful, if something is +seriously wrong with the environment or setup. To keep this output +(stored in your home folder), use this: + +:: + + QUEUE_OPTION TORQUE KEEP_QSUB_OUTPUT 1 + + +** Slow submit to torque ** + +To be more gentle with the torqueue system you can instruct the driver +to sleep for every submit request. The argument to the SUBMIT_SLEEP is +the number of seconds to sleep for every submit, can be a fraction +like 0.5. + +:: + + QUEUE_OPTION TORQUE SUBMIT_SLEEP 0.25 + + +** Torque debug log ** + +You can ask the torqueu driver to store a debug log of the jobs +submitted, and the resulting job id. This is done with the queue +option DEBUG_OUTPUT: + +:: + + QUEUE_OPTION TORQUE DEBUG_OUTPUT torque_log.txt + + + +Configuring the LOCAL queue +--------------------------- +.. _configuring_the_local_queue: + + +.. _max_running_local: +.. topic:: MAX_RUNNING_LOCAL + + The keyword MAX_RUNNING_LOCAL controls the maximum number of simultaneous jobs running when using the LOCAL option in QUEUE_SYSTEM. It is strongly recommended to not let MAX_RUNNING_LOCAL exceed the number of processors on the workstation used. + + *Example:* + + :: + + -- No more than 3 simultaneous jobs + MAX_RUNNING_LOCAL 3 + + +Configuring the RSH queue +------------------------- +.. _configuring_the_rsh_queue: + +.. _rsh_host: +.. topic:: RSH_HOST + + You can run the forward model in enkf on workstations using remote-shell commands. To use the RSH queue system you must first set a list of computers which enkf can use for running jobs: + + :: + + RSH_HOST computer1:2 computer2:2 large_computer:8 + + Here you tell enkf that you can run on three different computers: computer1, computer2 and large_computer. The two first computers can accept two jobs from enkf, and the last can take eight jobs. Observe the following when using RSH: + + You must have passwordless login to the computers listed in RSH_HOST otherwise it will fail hard. enkf will not consider total load on the various computers; if have said it can take two jobs, it will get two jobs, irrespective of the existing load. + +.. _rsh_command: +.. topic:: RSH_COMMAND + + This is the name of the executable used to invoke remote shell operations. Will typically be either rsh or ssh. The command given to RSH_COMMAND must either be in PATH or an absolute path. + + :: + + MAX_RUNNING_RSH + + The keyword MAX_RUNNING_RSH controls the maximum number of simultaneous jobs running when using the RSH option in QUEUE_SYSTEM. It MAX_RUNNING_RSH exceeds the total capacity defined in RSH_HOST, it will automatically be truncated to that capacity. + + *Example:* + + :: + + -- No more than 10 simultaneous jobs + -- running via RSH. + MAX_RUNNING_RSH 10 + + + +Keywords related to plotting +---------------------------- +.. _keywords_related_to_plotting: + + +.. _image_viewer: +.. topic:: IMAGE_VIEWER + + The enkf application has some limited plotting capabilities. The plotting is based on creating a graphics file (currently a png file) and then viewing that file with an external application. The current default image viewer is a program called /usr/bin/display, but you can set IMAGE_VIEWER to point to another binary if that is desired. In particular it can be interesting to set as + + :: + + IMAGE_VIEWER /d/proj/bg/enkf/bin/noplot.sh + + then the plot files will be created, but they will not be flashing in your face (which can be a bit annoying). + + +.. _image_type: +.. topic:: IMAGE_TYPE + + This switch control the type of the plot figures/images created by the PLPLOT plot driver. It is by default set to png which works fine, but you can probably(??) use other popular graphics formats like gif and jpg as well. + + +.. _plot_driver: +.. topic:: PLOT_DRIVER + + This is the name of the sub system used for creating plots. The default system is called 'PLPLOT' - all the other options regarding plotting are sub options which are only relevant when you are using PLPLOT. In addition to PLPLOT you can chose the value 'TEXT'; this will actually not produce any plots, just textfiles which can be used for plotting with your favorite plotting program. This is particularly relevant if you have some special requirements to the plots. + + +.. _plot_errorbar: +.. topic:: PLOT_ERRORBAR + + Should errorbars on the observations be plotted? + + +.. _plot_errorbar_max: +.. topic:: PLOT_ERRORBAR_MAX + + When plotting summary vectors for which observations have been 'installed' with the OBS_CONFIG keyword, ert will plot the observed values. If you have less than PLOT_ERRORBAR_MAX observations ert will use errorbars to show the observed values, otherwise it will use two dashed lines indicating +/- one standard deviation. This option is only meaningful when PLOT_PLOT_ERRORBAR is activated. + + To ensure that you always get errorbars you can set PLOT_ERRORBAR_MAX to a very large value, on the other hand setting PLOT_ERRORBAR_MAX to 0 will ensure that ert always plots observation uncertainty using dashed lines of +/- one standard deviation. + + The setting here will also affect the output when you are using the TEXT driver to plot. + + +.. _plot_height: +.. topic:: PLOT_HEIGHT + + When the PLPLOT driver creates a plot file, it will have the height (in pixels) given by the PLOT_HEIGHT keyword. The default value for PLOT_HEIGHT is 768 pixels. + + +.. _plot_refcase: +.. topic:: PLOT_REFCASE + + Boolean variable which is TRUE if you want to add the refcases to the plots. + + *Example:* + + :: + + PLOT_REFCASE TRUE + + + +.. refcase_list: +.. topic:: REFCASE_LIST + + Provide one or more Eclipse .DATA files for a refcase to be added in the plots. This refcase will be plotted in different colours. The summary files related to the refcase should be in the same folder as the refcase. + + *Example:* + + :: + + REFCASE_LIST /path/to/refcase1/file1.DATA /path/to/refcase2/file2.DATA + + + +.. _plot_path: +.. topic:: PLOT_PATH + + The plotting engine creates 'files' with plots, they are stored in a directory. You can tell what that directory should be. Observe that the current 'casename' will automatically be appended to the plot path. + + +.. plot_width: +.. topic:: PLOT_WIDTH + + When the PLPLOT driver creates a plot file, it will have the width (in pixels) given by the PLOT_WIDTH keyword. The default value for PLOT_WIDTH is 1024 pixels. To create plots of half the size you use: + + :: + + PLOT_HEIGHT 384 + PLOT_WIDTH 512 + + + +.. _rft_config: +.. topic:: RFT_CONFIG + + RFT_CONFIGS argument is a file with the name of the rfts followed by date (day month year) Ex. + + :: + + RFT_CONFIG ../models/wells/rft/WELLNAME_AND_RFT_TIME.txt + + Where the contents of the file is something like + + :: + + be-linapp16(inmyr) -/models/wells/rft 34> more WELLNAME_AND_RFT_TIME.txt + A-1HP 06 05 1993 + A-9HW 31 07 1993 + C-1HP 11 12 2007 + C-5HP 21 12 1999 + C-6HR 09 11 1999 + D-4HP 10 07 2003 + K-3HW 09 02 2003 + K-6HW 08 11 2002 + K-7HW 21 04 2005 + D-6HP 22 04 2006 + + + +.. _rftpath: +.. topic:: RFTPATH + + + RFTPATHs argument is the path to where the rft-files are located + + :: + + RFTPATH ../models/wells/rft/ + + + +Workflows +--------- +.. _workflows: + +The Forward Model in ERT runs in the context of a single realization, i.e. there is no communication between the different processes, and collective gather operations must be performed by the ERT core program after the forward model has completed. As an alternative to the forward model ERT has a system with workflows. Using workflows you can automate cumbersome normal ERT processes, and also invoke external programs. The workflows are run serially on the workstation actually running ERT, and should not be used for computationally heavy tasks. + +Configuring workflows in ERT consists of two steps: installing the jobs which should be available for ERT to use in workflows, and then subsequently assemble one or more jobs, with arguments, in a workflow. + + +**Workflow jobs** + +The workflow jobs are quite similar to the jobs in the forward model, in particular the jobs are described by a configuration file which resembles the one used by the forward model jobs. The workflow jobs can be of two fundamentally different types: + +**INTERNAL** + These jobs invoke a function in the address space of the ERT program itself. The functions are called with the main enkf_main instance as a self argument, and can in principle do anything that ERT can do itself. ERT functions which should be possible to invoke like this must be 'marked as exportable' in the ERT code, but that is a small job. The internal jobs have the following sections in their config file: + + :: + + INTERNAL TRUE -- The job will call an internal function of the current running ERT instance. + FUNCTION enkf_main_plot_all -- Name of the ERT function we are calling; must be marked exportable. + MODULE /name/of/shared/library -- Very optional - to load an extra shared library. + +**EXTERNAL** + These jobs invoke an external program/script to do the job, this is very similar to the jobs of the forward model. Context must be passed between the main ERT process and the script through the use of string substitution, in particular the 'magic' key <RUNPATH_FILE> has been introduced for this purpose. + + :: + + INTERNAL FALSE -- This is the default - not necessary to include. + EXECUTABLE /path/to/a/program -- Path to a program/script which will be invoked by the job. + +In addition to the INTERNAL, FUNCTION, MODULE and EXECUTABLE keys which are used to configure what the job should do there are some keys which can be used to configure the number of arguments and their type. These arguments apply to both internal and external jobs: + +:: + + MIN_ARG 2 -- The job should have at least 2 arguments. + MAX_ARG 3 -- The job should have maximum 3 arguments. + ARG_TYPE 0 INT -- The first argument should be an integer + ARG_TYPE 1 FLOAT -- The second argument should be a float value + ARG_TYPE 2 STRING -- The third argument should be a string - the default. + +The MIN_ARG,MAX_ARG and ARG_TYPE arguments are used to validate workflows. + + +**Example 1 : Plot variables** + +:: + + -- FILE: PLOT -- + INTERNAL TRUE + FUNCTION ert_tui_plot_JOB + MIN_ARG 1 + +This job will use the ERT internal function ert_tui_plot_JOB to plot an ensemble of an arbitrary ERT variable. The job needs at least one argument; there is no upper limit on the number of arguments. + + +**Example 2 : Run external script** + +:: + + -- FILE: ECL_HIST -- + EXECUTABLE Script/ecl_hist.py + MIN_ARG 3 + +This job will invoke the external script Script/ecl_host.py; the script should have at least three commandline arguments. The path to the script, Script/ecl_hist.py is interpreted relative to the location of the configuration file. + + +**Loading workflow jobs into ERT** + +Before the jobs can be used in workflows they must be 'loaded' into ERT. This is done with two different ERT keywords: + +:: + + LOAD_WORKFLOW_JOB jobConfigFile JobName + +The LOAD_WORKFLOW_JOB keyword will load one workflow. The name of the job is optional, if not provided the job will get name from the configuration file. Alternatively you can use the command WORKFLOW_JOB_DIRECTORY which will load all the jobs in a directory. The command: + +:: + + WORKFLOW_JOB_DIRECTORY /path/to/jobs + +will load all the workflow jobs in the /path/to/jobs directory. Observe that all the files in the /path/to/jobs directory should be job configuration files. The jobs loaded in this way will all get the name of the file as the name of the job. + + +**Complete Workflows** + +A workflow is a list of calls to jobs, with additional arguments. The job name should be the first element on each line. Based on the two jobs PLOT and ECL_HIST we can create a small workflow example: + +:: + + PLOT WWCT:OP_1 WWCT:OP_3 PRESSURE:10,10,10 + PLOT FGPT FOPT + ECL_HIST <RUNPATH_FILE> <QC_PATH>/<ERTCASE>/wwct_hist WWCT:OP_1 WWCT:OP_2 + +In this workflow we create plots of the nodes WWCT:OP_1;WWCT:OP_3,PRESSURE:10,10,10,FGPT and FOPT. The plot job we have created in this example is completely general, if we limited ourselves to ECLIPSE summary variables we could get wildcard support. Then we invoke the ECL_HIST example job to create a histogram. See below for documentation of <RUNPATH_FILE>,<QC_PATH> and <ERTCASE>. + + +**Loading workflows** + +Workflows are loaded with the configuration option LOAD_WORKFLOW: + +:: + + LOAD_WORKFLOW /path/to/workflow/WFLOW1 + LOAD_WORKFLOW /path/to/workflow/workflow2 WFLOW2 + +The LOAD_WORKFLOW takes the path to a workflow file as the first argument. By default the workflow will be labeled with the filename internally in ERT, but optionally you can supply a second extra argument which will be used as name for the workflow. Alternatively you can load a workflow interactively. + +**Running workflows** + +Go to workflow menu and type run. + +**Locating the realisations: <RUNPATH_FILE>** + +Many of the external workflow jobs involve looping over all the realisations in a construction like this: + +:: + + for each realisation: + // Do something for realisation + summarize() + +When running an external job in a workflow there is no direct transfer of information between the main ERT process and the external script. We therefor must have a convention for transfering the information of which realisations we have simulated on, and where they are located in the filesystem. This is done through a file which looks like this: + +:: + + 0 /path/to/real0 CASE_0000 + 1 /path/to/real1 CASE_0001 + ... + 9 /path/to/real9 CASE_0009 + +The name and location of this file is available as the magical string <RUNPATH_FILE> and that is typically used as the first argument to external workflow jobs which should iterate over all realisations. The realisations referred to in the <RUNPATH_FILE> are meant to be last simulations you have run; the file is updated every time you run simulations. This implies that it is (currently) not so convenient to alter which directories should be used when running a workflow. + + + +QC keywords +----------- +.. _qc_keywords: + +The QC system is mainly based on workflows. + +.. _qc_workflow: +.. topic:: QC_WORKFLOW + + Name of an existing workflow to do QC work. Will be invoked automatically when a ensemble simulation has been completed, can alternatively be invoked from the QC menu. + + +.. _qc_path: +.. topic:: QC_PATH + + No information on this keyword yet + + +Creating reports +---------------- +.. _creating_reports: + +ERT has a limited capability to create pdf reports based on a LaTeX template and the plots you have created. The process for creating reports works like this: + +#. You select a report template using the REPORT_LIST keyword. +#. ERT will insantiate a LaTeX report file by using your template, and performing some substitutions. The LaTeX report will be stored in a temporary directory /tmp/latex-XXXXXX. +#. pdflatex is used to compile the latex file into a pdf file + +**Format of the template file** + +The template file should mostly be ordinary LaTeX, but when instantiating ERT will search and replace some strings. The most important are: + +**$PLOT_CASE** + This will be replaced with the name of the current case, and that is used to locate the active figures. +**$WELL_LIST** + This will be expanded to a list of well names, REPORT_WELL_LIST below. +**$GROUP_LIST** + This will be expanded to a list of group names, REPORT_GROUP_LIST below. +**$CONFIG_FILE** + The full path of the config file currently in use. +**$USER** + The username of the current user. + +**Template loops** + +The template can have a very simple for loop construction. The syntax of the for loop is as follows: + +:: + + {% for x in [a,b,c,d] %} + %% Do something with x + {% endfor %} + +The whole concept is based on regular expressions and is quite picky on the format. Observe the following: + +#. CaSe MAttErs - i.e. {% For ... %} with a capital 'F' will not work. +#. The loop variable must start with $ or a letter, followed by an arbitrary number of letters and numbers. I.e. $well, x and ab21 are all valid variable names, whereas 5b, __internal and #var are examples of invalid variable names. +#. The behaviour of the matching in the body depends on whether the variable starts with '$' or not: + #. If the variable starts with '$' embedded substrings will be matched - i.e. WWCT$well will be expanded to e.g. WWCTOP-1. + #. If the variable starts with an alphabet character substrings will not be replaced - i.e. the well in wellname will not be touched. +#. All the spaces (underlined here) in {% for x in [a,b,c,d] %} and {% endfor %} must be present; you can have more spaces if you like. +#. A missing {% endfor %} will be detected with a warning; all other errors will go undected, producing something different from what you wanted, it will probably not even compile. + + +**Problems** + +When LaTeX compiling you will get a prompt like this on the screen: + +:: + + Creating report Reports/<Case>/<Name.pdf> [Work-path:/tmp/latex-XXXXXX] ...... + +This means that ERT has created the directory /tmp/latex-XXXXXX and populated that with the file which is compiled. If there are LaTeX problems of some kind you must go to this directory to check out what is wrong, and then fix the source template. When the compilation is finished ERT will print: + +:: + + Creating report Reports/<Case>/<Name.pdf> [Work-path:/tmp/latex-XXXXXX] ...... OK?? + +As indicated by the OK?? it is quite difficult for ERT to assert that the compilation has been successfull, so the pdf file must be opened with e.g. acroread to be certain. + + +.. _report_context: +.. topic:: REPORT_CONTEXT + + With the report context word you can define key,value pairs which will be used in a search-and-replace operation in the template. + + *Example:* + + :: + + REPORT_CONTEXT $FIELD Snorre + REPORT_CONTEXT $MODEL "DG-X sensitivity studies" + + Here every occurence of $FIELD will be replaced with 'Snorre' and every occurence of $MODEL will be replaced with 'DG-X sensitivity studies'. Observe that the config parser expects that the REPORT_CONTEXT keyword gets two space separated arguments, so quoting with "" is necessary when the value consists of several words. The use of a '$' prefix on the keys above is just a suggestion, and not a rule. + + +.. _report_list: +.. topic:: REPORT_LIST + + This should be a list of LaTeX templates which you want to use for creating reports. The arguments in this list should either be the path to an existing file, or alternatively the name of a file which can be found in REPORT_SEARCH_PATH. The search order will be to first look directly in the filesystem, and then subsequently go through the paths listed in REPORT_SEARCH_PATH + + The filename can optionally be followed by a :Name, in that case the created report will be renamed Name.pdf irrespective of the name of the template file. + + *Example:* + + :: + + REPORT_SEARCH_PATH /common/report/path + REPORT_LIST templates/report.tex /some/absolute/path/report.tex:Report2 well_report.tex:snorre_wells.tex + + In the example we specify templates for three different reports: + + #. In the relative path templates/report.tex + #. In the absolute path /some/absolute/path/report.tex + #. Assuming there is no file well_report.tex in your current directory ERT will look in the paths specified by REPORT_SEARCH_PATH. + + Observe the two latter reports will be renamed Report2.pdf and snorre_wells.pdf respectively. + + +.. _report_path: +.. topic:: REPORT_PATH + + The REPORT_PATH keyword is used to tell ERT where you want to store the finished pdf reports. A subdirectory with the current case name will be appended to this path: + + :: + + REPORT_LIST templates/well_report.tex templates/field_report.tex + REPORT_PATH Reports + + Assuming the selected case is called prior you will get the reports Reports/prior/well_report.pdf and Reports/prior/field_report.tex. + + +.. _report_search_path: +.. topic:: REPORT_SEARCH_PATH + + It is possible to install LaTeX templates for reports in a common location, the REPORT_LIST keyword will then search for the templates in these locations. You can use the REPORT_SEARCH_PATH keyword in your config file, but the most relevant use is in the global site configuration file. + + :: + + REPORT_SEARCH_PATH /common/path/well_reports /common/path/group_reports + REPORT_SEARCH_PATH /common/path/field_reports + + +.. _report_well_list: +.. topic:: REPORT_WELL_LIST + + By using the {% for x in [] %} construction in the templates it is possible to have report templates which loop over a list of wells. Unfortunately it is not very interesting to loop over all wells, because ECLIPSE has a limited amount of meta information about the wells, which means that injectors and producers will be treated equally. By using the REPORT_WELL_LIST keyword you can specify which wells you wish to include in the report, these well names will then be assembled into a list which will go into the $WELL_LIST keyword in the report template. + + :: + + REPORT_WELL_LIST C* E1-H -- Must have supplied a REFCASE for the '*' to work properly + REPORT_WELL_LIST OP* + + These well names are then assembled into a list and replace the symbol $WELL_LIST when creating the report. For this to work the report template should contain a section like: + + :: + + {% for $well in $WELL_LIST %} + % Do something with $well + {% endfor %} + + +.. _report_group_list: +.. topic:: REPORT_GROUP_LIST + + This is just like the REPORT_WELL_LIST keyword, but for groups. + + +Manipulating the Unix environment +--------------------------------- +.. _manipulating_the_unix_environment: + +The two keywords SETENV and UPDATE_PATH can be used to manipulate the Unix environment of the ERT process, tha manipulations only apply to the running ERT instance, and are not applied to the shell. + + +.. _setenv: +.. topic:: SETENV + + You can use the SETENV keyword to alter the unix environment enkf is running in. This is probably most relevant for setting up the environment for the external jobs invoked by enkf. + + *Example:* + + :: + + -- Setting up LSF + SETENV LSF_BINDIR /prog/LSF/7.0/linux2.6-glibc2.3-x86_64/bin + SETENV LSF_LIBDIR /prog/LSF/7.0/linux2.6-glibc2.3-x86_64/lib + SETENV LSF_UIDDIR /prog/LSF/7.0/linux2.6-glibc2.3-x86_64/lib/uid + SETENV LSF_SERVERDIR /prog/LSF/7.0/linux2.6-glibc2.3-x86_64/etc + SETENV LSF_ENVDIR /prog/LSF/conf + + Observe that the SETENV command is not as powerful as the corresponding shell utility. In particular you can not use $VAR to refer to the existing value of an environment variable. To add elements to the PATH variable it is easier to use the UPDATE_PATH keyword. + + +.. _update_path: +.. topic:: UPDATE_PATH + + The UPDATE_PATH keyword will prepend a new element to an existing PATH variable. I.e. the config + + :: + + UPDATE_PATH PATH /some/funky/path/bin + + will be equivalent to the shell command: + + :: + + setenv PATH /some/funky/path/bin:$PATH + + The whole thing is just a workaround because we can not use $PATH. diff --git a/ThirdParty/Ert/devel/docs/user/observations/index.rst b/ThirdParty/Ert/devel/docs/user/observations/index.rst new file mode 100644 index 0000000000..47c019dafc --- /dev/null +++ b/ThirdParty/Ert/devel/docs/user/observations/index.rst @@ -0,0 +1,463 @@ +Configuring observations for ERT +================================ + +General overview +---------------- + +When using ERT to condition on dynamic data, it is necessary to +specify which data to condition on. In particular, for a given piece +of data to condition on, the ERT application needs to know: + + - The actual measured value of the data. + - The uncertainty of the measured data. + - The time of measurement. + - How to simulate a response of the data given a parametrized ECLIPSE model. + + +To provide this observation to ERT, an observation file must be +created. The observation file is a plain text file, and is in essence +built around for different classes of observations and has an +associated keyword for each class: + + - Well or group rates from an existing ECLIPSE reference case: The + HISTORY_OBSERVATION keyword. + + - Well logs, RFTS and PLTs: The BLOCK_OBSERVATION keyword. + + - Separator tests, region pressures, etc.: The SUMMARY_OBSERVATION + keyword. + + - Exotic observations (e.g. data from 4D seismic): The + GENERAL_OBSERVATION keyword. + + +The HISTORY_OBSERVATION keyword +------------------------------- + +The keyword HISTORY_OBSERVATION is used to condition on observations +from the WCONHIST and WCONINJH keywords in schedule file provided to +the enkf project (or alternatively an ECLIPSE summary file if you have +changed the HISTORY_SOURCE keyword in the enkf project). The keyword +is typically used to condition on production and injection rates for +groups and wells, as well as bottom hole and tubing head pressures. An +observation entered with the HISTORY_OBSERVATION keyword will be +active at all report steps where data for the observation can be +found. + +In it's simplest form, a history observation is created as follows:: + + HISTORY_OBSERVATION WOPR:P1; + +This will condition on WOPR in well P1 using a default observation +error. The default observation error is a relative error of 10% to the +measurement with a minimum error of 0.10. See below on how explicitly +set the error. + +In general, to condition on variable VAR in well or group WGNAME, one +uses:: + + HISTORY_OBSERVATION VAR:WGNAME; + +Note that there must be a colon ":" between VAR and WGNAME and that +the statement shall end with a semi-colon ";". Thus, to condition on +WOPR, WWCT and WGOR in well C-17, and for the GOPR for the whole +field, one would add the following to the observation configuration:: + + HISTORY_OBSERVATION WOPR:C-17; + HISTORY_OBSERVATION WWCT:C-17; + HISTORY_OBSERVATION WGOR:C-17; + + HISTORY_OBSERVATION GOPR:FIELD; + +By default, the observation error is set to 10% of the observed value, +with a minimum of 0.10. It can be changed as follows:: + + HISTORY_OBSERVATION GOPR:FIELD + { + ERROR = 1000; + ERROR_MODE = ABS; + }; + +This will set the observation error to 1000 for all observations of +GOPR:FIELD. Note that both the items ERROR and ERROR_MODE as well as +the whole definition shall end with a semi-colon. + +The item ERROR_MODE can take three different values: ABS, REL or +RELMIN. If set to REL, all observation errors will be set to the +observed values multiplied by ERROR. Thus, the following will +condition on water injection rate for the whole field with 20% +observation uncertainity:: + + HISTORY_OBSERVATION GWIR:FIELD + { + ERROR = 0.20; + ERROR_MODE = REL; + }; + +If you do not want the observation error to drop below a given +threshold, say 100, you can use RELMIN and the keyword ERROR_MIN:: + + HISTORY_OBSERVATION GWIR:FIELD + { + ERROR = 0.20; + ERROR_MODE = RELMIN; + ERROR_MIN = 100; + }; + +Note that the configuration parser does not threat carriage return +different from space. Thus, the following statement is equivalent to +the previous:: + + HISTORY_OBSERVATION GWIR:FIELD { ERROR = 0.20; ERROR_MODE = RELMIN; ERROR_MIN = 100; }; + + +Also note that the special keyword include can be used to read an +external file. This can be very useful if you want to change the +standard configuration for a lot of observations in one go. For +example, consider the following code:: + + HISTORY_OBSERVATION WOPR:P1 { include "hist_obs_wells.txt"; }; + HISTORY_OBSERVATION WOPR:P2 { include "hist_obs_wells.txt"; }; + HISTORY_OBSERVATION WOPR:P3 { include "hist_obs_wells.txt"; }; + HISTORY_OBSERVATION WOPR:P4 { include "hist_obs_wells.txt"; }; + HISTORY_OBSERVATION WOPR:P5 { include "hist_obs_wells.txt"; }; + +Where the contents of the file hist_obs_wells.txt may be something +like:: + + ERROR_MODE = RELMIN; + ERROR = 0.25; + ERROR_MIN = 100; + +In this case, changing the file hist_obs_wells.txt will affect all of +the observations. + +Note that the keyword include can be used anywhere in the +configuration file. However, nested inclusion (use of include in a +file that has already been included with include) is not allowed. + +By default, an observation entered with the HISTORY_OBSERVATION +keyword will get the observed values, i.e. the 'true' values, from the +WCONHIST and WCONINJH keywords in the schedule file provided to the +ERT project. However it also possible to get the observed values from +a reference case. In that case you must set set HISTORY_SOURCE +variable in the ERT configuration file, see Creating a configuration +file for ERT. + +To change the observation error for a HISTORY_OBSERVATION for one or +more segments of the historic period, you can use the SEGMENT +keyword. For example:: + + HISTORY_OBSERVATION GWIR:FIELD + { + ERROR = 0.20; + ERROR_MODE = RELMIN; + ERROR_MIN = 100; + + SEGMENT FIRST_YEAR + { + START = 0; + STOP = 10; + ERROR = 0.50; + ERROR_MODE = REL; + }; + + SEGMENT SECOND_YEAR + { + START = 11; + STOP = 20; + ERRROR = 1000; + ERROR_MODE = ABS; + }; + }; + +The items START and STOP sets the start and stop of the segment in +terms of ECLIPSE restart steps. The keywords ERROR, ERROR_MODE and +ERROR_MIN behaves like before. If the segments overlap, they are +computed in alphabetical order. Error covariance for "merged" updates + +When merging the historical observations from several report steps +together in one update the different steps are not independent, and it +is beneficial to use a error covariance matrix, by using the keywords +AUTO_CORRF and AUTO_CORRF_PARAM ERT will automatically estimate a +error-covariance matrix based on the auto correlation function +specified by the AUTO_CORRF keyword, with the parameter given by the +AUTO_CORRF_PARAM parameter (i.e. the auto correlation length). The +currently available auto correlation functions are: + + EXP ~ exp(-x) + GAUSS ~ exp(-x*x/2) + +where the parameter x is given as: + + x = (t2 - t1) / AUTO_CORRF_PARAM + + +The SUMMARY_OBSERVATION keyword +------------------------------- + +The keyword SUMMARY_OBSERVATION can be used to condition on any +observation whos simulated value is written to the ECLIPSE summary +file, e.g. well rates, region properties, group and field rates etc. A +quite typical usage of SUMMARY_OBSERVATION is to condition on the +results of a separator test. + +Note: Although it is possible to condition on well and group rates +with SUMMARY_OBSERVATION, it is usually easier to use +HISTORY_OBSERVATION for this. + +In order to create a summary observation, four pieces of information +are needed: The observed value, the observation error, the time of +observation and a summary key. A typical summary observation is +created as follows:: + + SUMMARY_OBSERVATION SEP_TEST_2005 + { + VALUE = 100; + ERROR = 5; + DATE = 21/08/2005; + KEY = GOPR:BRENT; + }; + +This will create an observation of group oil production for the brent +group on 21th of august 2005. The observed value was 100 with a +standard deviation of 5. The name SEP_TEST_2005 will be used as a +label for the observation within the ERT and must be unique. + +Similarly to the name of a HISTORY_OBSERVATION, the item KEY in a +SUMMARY_OBSERVATION is used to look up the simulated value from the +summary file. And again, as when declaring a HISTORY_OBSERVATION, to +condition on VAR in well, group or region WGRNAME, one uses:: + + KEY = VAR:WGRNAME; + +For example, to condition on RPPW in region 8, one uses:: + + KEY = RPPW:8; + +It is also possible to give the observation time as a restart number +using the RESTART item or as time in days from simulation start using +the DAYS item. Here are two examples:: + + -- Giving the observation time in terms of restart number. + SUMMARY_OBSERVATION SEP_TEST_2005 + { + VALUE = 100; + ERROR = 5; + RESTART = 42; + KEY = GOPR:BRENT; + }; + + + -- Giving the observation time in terms of days + -- from simulation start. + SUMMARY_OBSERVATION SEP_TEST_2008 + { + VALUE = 213; + ERROR = 10; + DAYS = 911; + KEY = GOPR:NESS; + }; + + + +The BLOCK_OBSERVATION keyword +------------------------------ + +This is observations of variables in grid blocks/cells. The +observations can be of arbitrary ECLIPSE fields like PRESSURE +(typically for an RFT), PORO or PERM. A block observation is entered +with the BLOCK_OBSERVATION keyword. Here is an example of a typical +block observation:: + + BLOCK_OBSERVATION RFT_2006 + { + FIELD = PRESSURE; + DATE = 22/10/2006; + + OBS P1 { I = 1; J = 1; K = 1; VALUE = 100; ERROR = 5; }; + OBS P2 { I = 2; J = 2; K = 1; VALUE = 101; ERROR = 5; }; + OBS P3 { I = 2; J = 3; K = 1; VALUE = 102; ERROR = 5; }; + }; + +This will condition on observations of the pressure in grid blocks +(1,1,1), (2,2,1) and (2,3,1) on the 22/10/2006. + +By default the BLOCK_OBSERVATION requires that the specific field +which has been observed (e.g. PRESSURE in the example above) must have +been specified in main ERT configuration file using the FIELD keyword, +and ECLIPSE must be configured to produce a restart file for this +particular time. Alternatively it is possible to tell ERT to use the +summary vector as source of the data:: + + BLOCK_OBSERVATION RFT_2006 + { + FIELD = PRESSURE; + DATE = 22/10/2006; + SOURCE = SUMMARY; + + OBS P1 { I = 1; J = 1; K = 1; VALUE = 100; ERROR = 5; }; + OBS P2 { I = 2; J = 2; K = 1; VALUE = 101; ERROR = 5; }; + OBS P3 { I = 2; J = 3; K = 1; VALUE = 102; ERROR = 5; }; + }; + +In this case the data will be loaded from the BPR vectors in the +summary file. + +Note the use of the sub class OBS to specify the actUal observed +values, the observation errors and their grid location. Each OBS shall +have a unique key within the BLOCK_OBSERVATION instance, and is +required to have the items I, J, K, VALUE and ERROR. These are the +grid i,j and k indicies for the observation point, the observed value +and it's standard deviation. + +As with a SUMMARY_OBSERVATION, the observation time can be given as +either a date, days since simulation start or restart number. The +respective keys for setting giving it as date, days or restart number +are DATE, DAYS and RESTART. Note that each BLOCK_OBSERVATION instance +must have an unique global name (RFT_2006 in the example above). + +Block observations can often be quite long. Thus, it is often a good +idea to use the special keyword include in order to store the OBS +structures in a different file. This is done as follows:: + + BLOCK_OBSERVATION RFT_2006 + { + FIELD = PRESSURE; + RESTART = 20; + + include 'RFT_2006_OBS_DATA.txt'; + }; + +Where the file RFT_2006_OBS_DATA.txt contains the OBS instances:: + + OBS P1 { I = 1; J = 1; K = 1; VALUE = 100; ERROR = 5; }; + OBS P2 { I = 2; J = 2; K = 1; VALUE = 101; ERROR = 5; }; + OBS P3 { I = 2; J = 3; K = 1; VALUE = 112; ERROR = 5; }; + OBS P4 { I = 3; J = 3; K = 1; VALUE = 122; ERROR = 5; }; + OBS P5 { I = 4; J = 3; K = 1; VALUE = 112; ERROR = 5; }; + OBS P6 { I = 5; J = 3; K = 1; VALUE = 122; ERROR = 5; }; + + + +The GENERAL_OBSERVATION keyword +-------------------------------- + +The GENERAL_OBSERVATION keyword is used together with the GEN_DATA and +GEN_PARAM type. This pair of observation and data types are typically +used when you want to update something special which does not fit into +any of the predefined enkf types. The ERT application just treats +GENERAL_OBSERVATION (and also GEN_DATA) as a range of number with no +particular structure, this is very flexible, but of course also a bit +more complex to use:: + + GENERAL_OBSERVATION GEN_OBS1{ + DATA = SOME_FIELD; + RESTART = 20; + OBS_FILE = some_file.txt; + }; + +This example a minimum GENERAL_OBSERVATION. The keyword DATA points to +the GEN_DATA instance this observation is 'observing', RESTART gives +the report step when this observation is active. OBS_FILE should be +the name of a file with observation values, and the corresponding +uncertainties. The file with observations should just be a plain text +file with numbers in it, observations and corresponding uncertainties +interleaved. An example of an OBS_FILE:: + + 1.46 0.26 + 25.0 5.0 + 5.00 1.00 + +This OBS_FILE has three observations: 1.46 +/- 0.26, 25.0 +/- 5.0 and +5.00 +/- 1.00. In the example above it is assumed that the DATA +instance we are observing (i.e. comparing with) has the same number of +elements as the observation, i.e. three in this case. By using the +keywords INDEX_LIST or INDEX_FILE you can select the elements of the +GEN_DATA instance you are interested in. Consider for example:: + + GENERAL_OBSERVATION GEN_OBS1{ + DATA = SOME_FIELD; + INDEX_LIST = 0,3,9; + RESTART = 20; + OBS_FILE = some_file.txt; + }; + +Here we use INDEX_LIST to indicate that we are interested in element +0,3 and 9 of the GEN_DATA instance:: + + GEN_DATA GEN_OBS1 + ======== =========== + 1.56 <---------------------> 1.46 0.26 + 23.0 /--------------> 25.0 5.00 + 56.0 | /---------> 5.00 1.00 + 27.0 <------/ | =========== + 0.2 | + 1.56 | + 1.78 | + 6.78 | + 9.00 | + 4.50 <-----------/ + ======== + +In addition to INDEX_LIST it is possible to use INDEX_FILE which +should just point at an plain text file with indexes (without any ',' +or anything). Finally, if your observation only has one value, you can +embed it in the config object with VALUE and ERROR. + +Matching GEN_OBS and GEN_DATA +............................. + +It is important to match up the GEN_OBS observations with the +corresponding GEN_DATA simulation data correctly. The GEN_DATA result +files must have an embedded '%d' to indicate the report step in them - +in the case of smoother based workflows the actual numerical value +here is not important. To ensure that GEN_OBS and corresponding +GEN_DATA values match up correctly only the RESTART method is allowed +for GEN_OBS when specifying the time. So consider a setup like this:: + + -- Config file: + GEN_DATA RFT_BH67 INPUT_FORMAT:ASCII RESULT_FILE:rft_BH67_%d REPORT_STEPS:20 + ... /|\ /|\ + ... | | + -- Observation file: | | + GENERAL_OBSERVATION GEN_OBS1{ +------------------/ + DATA = RFT_BH67; | + RESTART = 20; <------------------------------------/ + OBS_FILE = some_file.txt; + }; + +Here we see that the observation is active at report step 20, and we +expect the forward model to create a file rft_BH67_20 in each +realization directory. Error covariance + +The optional keyword ERROR_COVAR can be used to point to an existing +file, containing an error covariance matrix. The file should contain +the elements of the matrix as formatted numbers; newline formatting is +allowed but not necessary. Since the matrix should by construction be +symmetric there is no difference between column-major and row-major +order! The covariance matrix + + [ 1 0.75 -0.25] +C = [ 0.75 1.25 -0.50] + [-0.25 -0.50 0.85] + +Can be represented by the file:: + + 1 + 0.75 + -0.25 + 0.75 + 1.25 + -0.50 + -0.25 + -0.50 + 0.85 + +without newlines, or alternatively:: + + 1 0.75 -0.25 + 0.75 1.25 -0.50 + -0.25 -0.50 0.85 + +with newlines. diff --git a/ThirdParty/Ert/devel/docs/user/tutorial/index.rst b/ThirdParty/Ert/devel/docs/user/tutorial/index.rst new file mode 100644 index 0000000000..c81644349d --- /dev/null +++ b/ThirdParty/Ert/devel/docs/user/tutorial/index.rst @@ -0,0 +1,3 @@ +ERT Tutorial +============ +Tutorial for ert. diff --git a/ThirdParty/Ert/devel/docs/user/workflows/index.rst b/ThirdParty/Ert/devel/docs/user/workflows/index.rst new file mode 100644 index 0000000000..c3368629b0 --- /dev/null +++ b/ThirdParty/Ert/devel/docs/user/workflows/index.rst @@ -0,0 +1,381 @@ +---------------------- +Built in workflow jobs +---------------------- +.. _built_in_workflow_jobs: + +ERT comes with a list of default workflow jobs which invoke internal ERT functionality. The internal workflows include: + +Jobs related to case management +------------------------------- + +**SELECT_CASE** + +The job SELECT_CASE can be used to change the currently selected case. The SELECT_CASE job should be used as: + +:: + + SELECT_CASE newCase + +if the case newCase does not exist it will be created. + +**CREATE_CASE** + +The job CREATE_CASE can be used to create a new case without selecting it. The CREATE_CASE job should be used as: + +:: + + CREATE_CASE newCase + + +**INIT_CASE_FROM_EXISTING** + +The job INIT_CASE_FROM_EXISTING can be used to initialize a case from an existing case. The argument to the workflow should be the name of the workflow you are initializing from; so to initialize the current case from the existing case "oldCase": + +:: + + INIT_CASE_FROM_EXISTING oldCase + +By default the job will initialize the 'current case', but optionally you can give the name of a second case which should be initialized. In this example we will initialize "newCase" from "oldCase": + +:: + + INIT_CASE_FROM_EXISTING oldCase newCase + +When giving the name of a second case as target for the initialization job the 'current' case will not be affected. + + +Jobs related to export +---------------------- + +**EXPORT_FIELD** + +The EXPORT_FIELD workflow job exports field data to roff or grdecl format dependent on the extension of the export file argument.The job takes the following arguments: + +#. Field to be exported +#. Filename for export file, must contain %d +#. Report_step +#. State +#. Realization range + +The filename must contain a %d. This will be replaced with the realization number. + +The state parameter is either FORECAST or ANALYZED, BOTH is not supported. + +The realization range parameter is optional. Default is all realizations. + + +Example use of this job in a workflow: + +:: + + EXPORT_FIELD PERMZ path_to_export/filename%d.grdecl 0 FORECAST 0,2 + +**EXPORT_FIELD_RMS_ROFF** + +The EXPORT_FIELD_RMS_ROFF workflow job exports field data to roff format. The job takes the following arguments: + +#. Field to be exported +#. Filename for export file, must contain %d +#. Report_step +#. State +#. Realization range + +The filename must contain a %d. This will be replaced with the realization number. + +The state parameter is either FORECAST or ANALYZED, BOTH is not supported. + +The realization range parameter is optional. Default is all realizations. + + +Example uses of this job in a workflow: + +:: + + EXPORT_FIELD_RMS_ROFF PERMZ path_to_export/filename%d.roff 0 FORECAST + EXPORT_FIELD_RMS_ROFF PERMX path_to_export/filename%d 0 FORECAST 0-5 + + +**EXPORT_FIELD_ECL_GRDECL** + +The EXPORT_FIELD_ECL_GRDECL workflow job exports field data to grdecl format. The job takes the following arguments: + +#. Field to be exported +#. Filename for export file, must contain %d +#. Report_step +#. State +#. Realization range + +The filename must contain a %d. This will be replaced with the realization number. + +The state parameter is either FORECAST or ANALYZED, BOTH is not supported. + +The realization range parameter is optional. Default is all realizations. + + +Example uses of this job in a workflow: + +:: + + EXPORT_FIELD_ECL_GRDECL PERMZ path_to_export/filename%d.grdecl 0 ANALYZED + EXPORT_FIELD_ECL_GRDECL PERMX path_to_export/filename%d 0 ANALYZED 0-5 + + +**EXPORT_RUNPATH** + +The EXPORT_RUNPATH workflow job writes the runpath file RUNPATH_FILE for the selected case. + +The job can have no arguments, or one can set a range of realizations and a range of iterations as arguments. + +Example uses of this job in a workflow: + +:: + + EXPORT_RUNPATH + +With no arguments, entries for all realizations are written to the runpath file. If the runpath supports iterations, entries for all realizations in iter0 are written to the runpath file. + +:: + + EXPORT_RUNPATH 0-5 | * + +A range of realizations and a range of iterations can be given. "|" is used as a delimiter to separate realizations and iterations. "*" can be used to select all realizations or iterations. In the example above, entries for realizations 0-5 for all iterations are written to the runpath file. + + +Jobs related to analysis update +------------------------------- + +**ANALYSIS_UPDATE** + +This job will perform a update based on the current case, it is assumed that you have already completed the necessary simulations. By default the job will use all available data in the conditioning and store the updated parameters as the new initial parameters of the current case. However you can use optional argument to control which case the parameters go to, at which report step they are stored and also which report steps are considered when assembling the data. In the simplest form the ANALYSIS_UPDATE job looks like this: + +:: + + ANALYSIS_UPDATE + +In this case the initial parameters in the current case will be updated; using all available data in the conditioning process. In the example below we redirect the updated parameters to the new case NewCase: + +:: + + ANALYSIS_UPDATE NewCase + +Optionally we can decide to update the parameters at a later stage, i.e. for instance at report step 100: + +:: + + ANALYSIS_UPDATE * 100 + +The '*' above means that we should update parameters in the current case. Finally we can limit the report steps used for data: + +:: + + ANALYSIS_UPDATE NewCaseII 0 10,20,30,40,100,120-200 + +In the last example 10,20,30,40,100,120-200 mean the report steps we are considering when updating. Observe that when we use the first argument to specify a new case the will be created if it does not exist, but not selected. + + +**ANALYSIS_ENKF_UPDATE** + +The ANALYSIS_ENKF_UPDATE job will do an EnKF update at the current report step. The job requires the report step as the first argument: + +:: + + ANALYSIS_ENKF_UPDATE 10 + +by default the ENKF_UPDATE will use the observed data at the updatestep, but you can configure it use the report steps you like for data. In the example below the parameters at step 20 will be updated based on the observations at report step 0,5,10,15,16,17,18,19,20: + +:: + + ANALYSIS_ENKF_UPDATE 20 0,5,10,15-20 + +The ANALYSIS_ENKF_UPDATE job is a special case of the ANALYSIS_UPDATE job, in principle the same can be achieved with the ENKF_UPDATE job. + + +Jobs related to running simulations - including updates +------------------------------------------------------- + +**RUN_SMOOTHER** + +The RUN_SMOOTHER job will run a simulation and perform an update. The updated parameters are default stored as the new initial parameters of the current case. Optionally the job can take 1 or 2 parameters. The case to store the updated parameters in can be specified as the first argument. A second argument can be specified to run a simulation with the updated parameters. + + +Run a simulation and an update. The updated parameters are stored as the new initial parameters of the current case: + +:: + + RUN_SMOOTHER + + +Run a simulation and an update. Store the updated parameters in the specified case. This case is created if it does not exist: + +:: + + RUN_SMOOTHER new_case + + +Run a simulation and an update. Store the updated parameters in the specified case, then run a simulation on this case: + +:: + + RUN_SMOOTHER new_case true + + +Run a simulation and an update. Store the updated parameters in the current case, then run a simulation again. Specify "*" to use the current case: + +:: + + RUN_SMOOTHER * true + + +**RUN_SMOOTHER_WITH_ITER** + +This is exactly like the RUN_SMOOTHER job, but it has an additional first argumeent iter which can be used to control the iter number in the RUNPATH. When using the RUN_SMOOTHER job the iter number will be defaultetd to zero, and one in the optional rerun. + +**ENSEMBLE_RUN** + +The ENSEMBLE_RUN job will run a simulation, no update. The job take as optional arguments a range and/or list of which realizations to run. + +:: + + ENSEMBLE_RUN + +:: + + ENSEMBLE_RUN 1-5, 8 + + +**LOAD_RESULTS** + +The LOAD_RESULTS loads result from simulation(s). The job takes as optional arguments a range and/or list of which realizations to load results from. If no realizations are specified, results for all realizations are loaded. + +:: + + LOAD_RESULTS + +:: + + LOAD_RESULTS 1-5, 8 + +In the case of multi iteration jobs, like e.g. the integrated smoother update, the LOAD_RESULTS job will load the results from iter==0. To control which iteration is loaded from you can use the LOAD_RESULTS_ITER job. + + +**LOAD_RESULTS_ITER** + +The LOAD_RESULTS_ITER job is similar to the LOAD_RESULTS job, but it takes an additional first argument which is the iteration number to load from. This should be used when manually loading results from a multi iteration workflow: + +:: + + LOAD_RESULTS_ITER + +:: + + LOAD_RESULTS_ITER 3 1-3, 8-10 + +Will load the realisations 1,2,3 and 8,9,10 from the fourth iteration (counting starts at zero). + + +**MDA_ES** + +This workflow job (plugin) is used to run the *Multiple Data Assimilation Ensemble Smoother* :code:`MDA ES`. +Only two arguments are required to start the MDA ES process; target case format and iteration weights. +The weights implicitly indicate the number of iterations and the normalized global standard deviation scaling applied to the update step. + +:: + + MDA_ES target_case_%d observations/obs.txt + +This command will use the weights specified in the obs.txt file. This file should have a single floating point number per line. +Alternatively the weights can be given as arguments as shown here. + +:: + + MDA_ES target_case_%d 8,4,2,1 + +This command will use the normalized version of the weights 8,4,2,1 and run for four iterations. +The prior will be in *target_case_0* and the results from the last iteration will be in *target_case_4*. +**Note: the weights must be listed with no spaces and separated with commas.** + +If this is run as a plugin from Ertshell or the GUI a convenient user interface can be shown. + + +Jobs for ranking realizations +----------------------------- + +**OBSERVATION_RANKING** + +The OBSERVATION_RANKING job will rank realizations based on the delta between observed and simulated values for selected variables and time steps. The data for selected variables and time steps are summarized for both observed and simulated values, and then the simulated versus observed delta is used for ranking the realizations in increasing order. The job takes a name for the ranking as the first parameter, then the time steps, a "|" character and then variables to rank on. If no time steps and/or no variables are given, all time steps and variables are taken into account. + + +Rank the realizations on observation/simulation delta value for all WOPR data for time steps 0-20: + +:: + + OBSERVATION_RANKING Ranking1 0-20 | WOPR:* + + +Rank the simulations on observation/simulation delta value for all WOPR and WWCT data for time steps 1 and 10-50 + +:: + + OBSERVATION_RANKING Ranking2 1, 10-50 | WOPR:* WWCT:* + + +Rank the realizations on observation/simulation delta value for WOPR:OP-1 data for all time steps + +:: + + OBSERVATION_RANKING Ranking3 | WOPR:OP-1 + +**DATA_RANKING** + +The DATA_RANKING job will rank realizations in increasing or decreasing order on selected data value for a selected time step. The job takes as parameters the name of the ranking, the data key to rank on, increasing order and selected time steps. If no time step is given, the default is the last timestep. + +Rank the realizations on PORO:1,2,3 on time step 0 in decreasing order + +:: + + DATA_RANKING Dataranking1 PORO:1,2,3 false 0 + + +**EXPORT_RANKING** + +The EXPORT_RANKING job exports ranking results to file. The job takes two parameters; the name of the ranking to export and the file to export to. + +:: + + EXPORT_RANKING Dataranking1 /tmp/dataranking1.txt + + +**INIT_MISFIT_TABLE** + +Calculating the misfit for all observations and all timesteps can potentially be a bit timeconsuming, the results are therefor cached internally. If you need to force the recalculation of this cache you can use the INIT_MISFIT_TABLE job to initialize the misfit table that is used in observation ranking. + +:: + + INIT_MISFIT_TABLE + + +**STD_SCALE_CORRELATED_OBS** + +The workflow job :code:`STD_SCALE_CORRELATED_OBS` is used to scale the +observation standard deviation in an attempt to reduce the effect of +correlations in the observed data. The job expects the observation +keys you want to consider as arguments: + +:: + + STD_SCALE_CORRELATED_OBS WWCT:OP_1 WWCT:OP_2 + +In this example the observation uncertainty corresponding to +:code:`WWCT:OP_1` and :code:`WWCT:OP_2` will be scaled. Observe that +the :code:`STD_SCALE_CORRELATED_OBS` keyword will "flatten" in both +time and spatial direction. Wildcards are allow, i.e. + +:: + + STD_SCALE_CORRELATED_OBS W*:OP_1 + +Will scale based on all the observations of well 'OP_1'. For more +advanced selections of observations, where you only want to scale +based on parts of the observation - spatially or temporaly you must +write your own plugin. + diff --git a/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/analysis_module.h b/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/analysis_module.h index 6ee6839e12..782f16a87e 100644 --- a/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/analysis_module.h +++ b/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/analysis_module.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'analysis_module.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'analysis_module.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ANALYSIS_MODULE_H__ @@ -27,7 +27,7 @@ extern "C" { #include <ert/util/bool_vector.h> -/* +/* These are option flag values which are used by the core ert code to query the module of it's needs and capabilities. For instance to to determine whether the data should be scaled prior to analysis the @@ -36,7 +36,7 @@ extern "C" { if (analysis_module_get_option( module, ANALYSIS_SCALE_DATA)) obs_data_scale( obs_data , S , E , D , R , dObs ); - It is the responsability of the module to set the various flags. + It is the responsability of the module to set the various flags. */ @@ -57,54 +57,54 @@ typedef enum { {.value = ANALYSIS_ITERABLE , .name = "ANALYSIS_ITERABLE"} -#define EXTERNAL_MODULE_NAME "analysis_table" +#define EXTERNAL_MODULE_NAME "analysis_table" #define EXTERNAL_MODULE_SYMBOL analysis_table typedef enum { LOAD_OK = 0, - DLOPEN_FAILURE = 1, + DLOPEN_FAILURE = 1, LOAD_SYMBOL_TABLE_NOT_FOUND = 2 } analysis_module_load_status_enum; - - + + typedef struct analysis_module_struct analysis_module_type; - + analysis_module_type * analysis_module_alloc_internal__( rng_type * rng , const char * user_name , const char * symbol_table , bool verbose , analysis_module_load_status_enum * load_status); analysis_module_type * analysis_module_alloc_internal( rng_type * rng , const char * user_name , const char * symbol_table ); - + analysis_module_type * analysis_module_alloc_external__(rng_type * rng , const char * user_name , const char * lib_name , bool verbose , analysis_module_load_status_enum * load_status); analysis_module_type * analysis_module_alloc_external( rng_type * rng , const char * user_name , const char * libname ); - + void analysis_module_free( analysis_module_type * module ); void analysis_module_free__( void * arg); - void analysis_module_initX(analysis_module_type * module , - matrix_type * X , - matrix_type * A , - matrix_type * S , - matrix_type * R , - matrix_type * dObs , - matrix_type * E , + void analysis_module_initX(analysis_module_type * module , + matrix_type * X , + matrix_type * A , + matrix_type * S , + matrix_type * R , + matrix_type * dObs , + matrix_type * E , matrix_type * D); - - - void analysis_module_updateA(analysis_module_type * module , - matrix_type * A , - matrix_type * S , - matrix_type * R , - matrix_type * dObs , - matrix_type * E , + + + void analysis_module_updateA(analysis_module_type * module , + matrix_type * A , + matrix_type * S , + matrix_type * R , + matrix_type * dObs , + matrix_type * E , matrix_type * D ); - - void analysis_module_init_update( analysis_module_type * module , - const bool_vector_type * ens_mask , - const matrix_type * S , - const matrix_type * R , - const matrix_type * dObs , - const matrix_type * E , + + void analysis_module_init_update( analysis_module_type * module , + const bool_vector_type * ens_mask , + const matrix_type * S , + const matrix_type * R , + const matrix_type * dObs , + const matrix_type * E , const matrix_type * D ); - + const char * analysis_module_get_lib_name( const analysis_module_type * module); bool analysis_module_internal( const analysis_module_type * module ); @@ -120,7 +120,7 @@ typedef enum { bool analysis_module_get_bool( const analysis_module_type * module , const char * var); void * analysis_module_get_ptr( const analysis_module_type * module , const char * var); const char * analysis_module_flag_enum_iget( int index, int * value); - + UTIL_IS_INSTANCE_HEADER( analysis_module ); diff --git a/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/enkf_linalg.h b/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/enkf_linalg.h index 966e01d85d..c6aba63329 100644 --- a/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/enkf_linalg.h +++ b/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/enkf_linalg.h @@ -6,7 +6,7 @@ #include <ert/util/double_vector.h> -void enkf_linalg_get_PC( const matrix_type * S0, +int enkf_linalg_get_PC( const matrix_type * S0, const matrix_type * dObs , double truncation, int ncomp, @@ -14,6 +14,8 @@ void enkf_linalg_get_PC( const matrix_type * S0, matrix_type * PC_obs , double_vector_type * singular_values); +int enkf_linalg_num_PC(const matrix_type * S , double truncation ); + void enkf_linalg_init_stdX( matrix_type * X , const matrix_type * S , diff --git a/ThirdParty/Ert/devel/libanalysis/modules/CMakeLists.txt b/ThirdParty/Ert/devel/libanalysis/modules/CMakeLists.txt index 3e9cb584ae..feff7b7236 100644 --- a/ThirdParty/Ert/devel/libanalysis/modules/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libanalysis/modules/CMakeLists.txt @@ -1,6 +1,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set( RML_SOURCE_FILES + rml_enkf_config.c + rml_enkf_log.c rml_enkf.c rml_enkf_common.c ) diff --git a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c index 2b83ece1db..e7558aaa48 100644 --- a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c +++ b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'rml_enkf.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'rml_enkf.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -35,6 +35,8 @@ #include <ert/analysis/std_enkf.h> #include <rml_enkf_common.h> +#include <rml_enkf_config.h> +#include <rml_enkf_log.h> typedef struct rml_enkf_data_struct rml_enkf_data_type; @@ -50,21 +52,11 @@ typedef struct rml_enkf_data_struct rml_enkf_data_type; set_subspace_dimension() routines will set one variable, AND INVALIDATE THE OTHER. For most situations this will be OK, but if you have repeated calls to both of these functions the end result - might be a surprise. + might be a surprise. */ -#define INVALID_SUBSPACE_DIMENSION -1 -#define INVALID_TRUNCATION -1 -#define DEFAULT_SUBSPACE_DIMENSION INVALID_SUBSPACE_DIMENSION -#define DEFAULT_USE_PRIOR true -#define DEFAULT_LAMBDA_INCREASE_FACTOR 4 -#define DEFAULT_LAMBDA_REDUCE_FACTOR 0.1 -#define DEFAULT_LAMBDA0 -1 -#define DEFAULT_LAMBDA_MIN 0.01 -#define DEFAULT_LAMBDA_RECALCULATE false -#define DEFAULT_LOG_FILE "rml_enkf.out" -#define DEFAULT_CLEAR_LOG true - - + + + #define USE_PRIOR_KEY "USE_PRIOR" #define LAMBDA_REDUCE_FACTOR_KEY "LAMBDA_REDUCE" @@ -74,7 +66,7 @@ typedef struct rml_enkf_data_struct rml_enkf_data_type; #define LAMBDA_RECALCULATE_KEY "LAMBDA_RECALCULATE" #define ITER_KEY "ITER" #define LOG_FILE_KEY "LOG_FILE" -#define CLEAR_LOG_KEY "CLEAR_LOG" +#define CLEAR_LOG_KEY "CLEAR_LOG" @@ -103,32 +95,31 @@ typedef struct rml_enkf_data_struct rml_enkf_data_type; destructor or free() function registered with the .freef field of the analysis table. */ + + + + + struct rml_enkf_data_struct { UTIL_TYPE_ID_DECLARATION; - double truncation; // Controlled by config key: ENKF_TRUNCATION_KEY - int subspace_dimension; // Controlled by config key: ENKF_NCOMP_KEY (-1: use Truncation instead) - long option_flags; + int iteration_nr; // Keep track of the outer iteration loop double Sk; // Objective function value double Std; // Standard Deviation of the Objective function + double * Csc; + bool_vector_type * ens_mask; - double * Csc; // Vector with scalings for non-dimensionalizing states matrix_type *Am; // Scaled right singular vectors of ensemble anomalies. - matrix_type *prior; // m_pr - matrix_type *state; // m_l - bool_vector_type * ens_mask; // Tells you which of the realisations are in use. - bool use_prior; // Use exact/approximate scheme? Approximate scheme drops the "prior" term in the LM step. - - double lambda; // parameter to control the setp length in Marquardt levenberg optimization - double lambda0; - double lambda_min; - double lambda_reduce_factor; - double lambda_increase_factor; - bool lambda_recalculate; - - bool clear_log; - char * log_file; - FILE * log_stream; + + matrix_type *global_prior; // m_pr + matrix_type *previous_state; // m_l + + + double lambda; // parameter to control the setp length in Marquardt levenberg optimization + + + rml_enkf_log_type * rml_log; + rml_enkf_config_type * config; }; @@ -144,69 +135,7 @@ static UTIL_SAFE_CAST_FUNCTION_CONST( rml_enkf_data , RML_ENKF_TYPE_ID ) //********************************************** // Set / Get //********************************************** -double rml_enkf_get_truncation( rml_enkf_data_type * data ) { - return data->truncation; -} - -int rml_enkf_get_subspace_dimension( rml_enkf_data_type * data ) { - return data->subspace_dimension; -} - -void rml_enkf_set_truncation( rml_enkf_data_type * data , double truncation ) { - data->truncation = truncation; - if (truncation > 0.0) - data->subspace_dimension = INVALID_SUBSPACE_DIMENSION; -} - -void rml_enkf_set_lambda0( rml_enkf_data_type * data , double lambda0) { - data->lambda0 = lambda0; -} - -double rml_enkf_get_lambda0( const rml_enkf_data_type * data ) { - return data->lambda0; -} - -void rml_enkf_set_lambda_min( rml_enkf_data_type * data , double lambda_min) { - data->lambda_min = lambda_min; -} - -double rml_enkf_get_lambda_min( const rml_enkf_data_type * data ) { - return data->lambda_min; -} -void rml_enkf_set_lambda_increase_factor( rml_enkf_data_type * data , double increase_factor) { - data->lambda_increase_factor = increase_factor; -} - -double rml_enkf_get_lambda_increase_factor( const rml_enkf_data_type * data ) { - return data->lambda_increase_factor; -} - -void rml_enkf_set_lambda_reduce_factor( rml_enkf_data_type * data , double reduce_factor) { - data->lambda_reduce_factor = reduce_factor; -} - -double rml_enkf_get_lambda_reduce_factor( const rml_enkf_data_type * data ) { - return data->lambda_reduce_factor; -} - -bool rml_enkf_get_use_prior( const rml_enkf_data_type * data ) { - return data->use_prior; -} - -void rml_enkf_set_use_prior( rml_enkf_data_type * data , bool use_prior) { - data->use_prior = use_prior; -} - -void rml_enkf_set_lambda_recalculate( rml_enkf_data_type * data , bool lambda_recalculate) { - data->lambda_recalculate = lambda_recalculate; -} - -void rml_enkf_set_subspace_dimension( rml_enkf_data_type * data , int subspace_dimension) { - data->subspace_dimension = subspace_dimension; - if (subspace_dimension > 0) - data->truncation = INVALID_TRUNCATION; -} void rml_enkf_set_iteration_nr( rml_enkf_data_type * data , int iteration_nr) { data->iteration_nr = iteration_nr; @@ -223,113 +152,68 @@ int rml_enkf_get_iteration_nr( const rml_enkf_data_type * data ) { //********************************************** // Log-file related stuff //********************************************** -bool rml_enkf_get_clear_log( const rml_enkf_data_type * data ) { - return data->clear_log; -} -void rml_enkf_set_clear_log( rml_enkf_data_type * data , bool clear_log) { - data->clear_log = clear_log; -} - -void rml_enkf_set_log_file( rml_enkf_data_type * data , const char * log_file ) { - data->log_file = util_realloc_string_copy( data->log_file , log_file ); -} - -const char * rml_enkf_get_log_file( const rml_enkf_data_type * data) { - return data->log_file; -} - -void rml_enkf_log_line( rml_enkf_data_type * data , const char * fmt , ...) { - if (data->log_stream) { - va_list ap; - va_start(ap , fmt); - vfprintf( data->log_stream , fmt , ap ); - va_end( ap ); - } -} static void rml_enkf_write_log_header( rml_enkf_data_type * data, const char * format) { - if (data->log_stream) { + if (rml_enkf_log_is_open( data->rml_log )) { const char * column1 = "Iter#"; const char * column2 = "Lambda"; const char * column3 = "Sk old"; const char * column4 = "Sk_new"; const char * column5 = "std(Sk)"; - - rml_enkf_log_line(data, format, column1, column2, column3, column4, column5); + + rml_enkf_log_line(data->rml_log, format, column1, column2, column3, column4, column5); } } -static void rml_enkf_write_iter_info( rml_enkf_data_type * data , double Sk_new, double Std_new ) { - if (data->log_stream) { +static void rml_enkf_write_iter_info( rml_enkf_data_type * data , double prev_Sk , double Sk_new, double Std_new ) { + if (rml_enkf_log_is_open( data->rml_log )) { const char * format = "\n%2d-->%-2d %-7.3f %-7.3f --> %-7.3f %-7.3f"; const char * format_headers = "\n%-7s %-7s %-7s --> %-7s %-7s"; - - static int has_printed_header = 0; + static bool has_printed_header = false; + if (!has_printed_header) { rml_enkf_write_log_header( data, format_headers ); - has_printed_header = 1; + has_printed_header = true; } - - rml_enkf_log_line( data , format, data->iteration_nr, data->iteration_nr+1, data->lambda, data->Sk, Sk_new, Std_new); - } -} -static void rml_enkf_open_log_file( rml_enkf_data_type * data ) { - data->log_stream = NULL; - if (data->log_file) { - if ( data->iteration_nr == 0) { - if (data->clear_log){ - data->log_stream = util_mkdir_fopen( data->log_file , "w"); - } - else - data->log_stream = util_mkdir_fopen( data->log_file , "a"); - } else - data->log_stream = util_fopen( data->log_file , "a"); + rml_enkf_log_line( data->rml_log , format, data->iteration_nr, data->iteration_nr+1, data->lambda, prev_Sk, Sk_new, Std_new); } } + //********************************************** // Memory //********************************************** void * rml_enkf_data_alloc( rng_type * rng) { rml_enkf_data_type * data = util_malloc( sizeof * data); UTIL_TYPE_ID_INIT( data , RML_ENKF_TYPE_ID ); - - data->log_file = NULL; - - rml_enkf_set_truncation( data , DEFAULT_ENKF_TRUNCATION_ ); - rml_enkf_set_subspace_dimension( data , DEFAULT_SUBSPACE_DIMENSION ); - rml_enkf_set_use_prior( data , DEFAULT_USE_PRIOR ); - rml_enkf_set_lambda0( data , DEFAULT_LAMBDA0 ); - rml_enkf_set_lambda_increase_factor(data , DEFAULT_LAMBDA_INCREASE_FACTOR); - rml_enkf_set_lambda_reduce_factor(data , DEFAULT_LAMBDA_REDUCE_FACTOR); - rml_enkf_set_lambda_min( data , DEFAULT_LAMBDA_MIN ); - rml_enkf_set_log_file( data , DEFAULT_LOG_FILE ); - rml_enkf_set_clear_log( data , DEFAULT_CLEAR_LOG ); - rml_enkf_set_lambda_recalculate( data , DEFAULT_LAMBDA_RECALCULATE ); - - data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE + ANALYSIS_SCALE_DATA; + + data->config = rml_enkf_config_alloc(); + data->rml_log = rml_enkf_log_alloc(); + + data->Csc = NULL; data->iteration_nr = 0; - data->Std = 0; - data->ens_mask = bool_vector_alloc(0,false); - data->state = matrix_alloc(1,1); - data->prior = matrix_alloc(1,1); + data->Std = 0; + data->previous_state = matrix_alloc(1,1); + data->global_prior = NULL; + data->ens_mask = NULL; return data; } -void rml_enkf_data_free( void * arg ) { +void rml_enkf_data_free( void * arg ) { rml_enkf_data_type * data = rml_enkf_data_safe_cast( arg ); - matrix_free( data->state ); - matrix_free( data->prior ); + matrix_free( data->previous_state ); + if (data->global_prior) + matrix_free( data->global_prior ); - util_safe_free( data->log_file ); - bool_vector_free( data->ens_mask ); + rml_enkf_log_free( data->rml_log ); + rml_enkf_config_free( data->config ); free( data ); } @@ -346,11 +230,10 @@ void rml_enkf_data_free( void * arg ) { * Variable name in code <-> D.Oliver notation <-> Description * ------------------------------------------------------------------------------------------------------------- * A <-> m_l <-> Ensemble matrix. Updated in-place by iterations. - * data->state <-> m_(l-1) <-> "A" from the previous iteration. Backs up A in case the update is bad. - * data->prior <-> <-> Previously: "active_prior". Stores A from before iter0, i.e. the actual prior. + * data->previous_state <-> m_(l-1) <-> "A" from the previous iteration. Backs up A in case the update is bad. + * data->global_prior <-> <-> Previously: "active_prior". Stores A from before iter0, i.e. the actual prior. * Acopy <-> <-> Eliminated from code. Copy of A (at each iteration, before acceptance/rejection decision) - * data->prior0 <-> m_pr <-> Eliminated from code. Same as prior, but also includes columns (j) for which ens_mask[j]==false. - * Seems pointless. Only creates confusion. + * * Am <-> A_m <-> Am = Um*Wm^(-1) * Csc <-> C_sc^(1/2) <-> State scalings. Note the square root. @@ -373,28 +256,30 @@ void rml_enkf_data_free( void * arg ) { static void rml_enkf_init1__( rml_enkf_data_type * data) { // Differentiate this routine from init2__, which actually calculates the prior mismatch update. // This routine does not change any ensemble matrix. - // Um*Wm^(-1) are the scaled, truncated, right singular vectors of data->prior - - - int state_size = matrix_get_rows( data->prior ); - int ens_size = matrix_get_columns( data->prior ); - int nrmin = util_int_min( ens_size , state_size); - matrix_type * Dm = matrix_alloc_copy( data->prior ); - matrix_type * Um = matrix_alloc( state_size , nrmin ); /* Left singular vectors. */ - matrix_type * VmT = matrix_alloc( nrmin , ens_size ); /* Right singular vectors. */ - double * Wm = util_calloc( nrmin , sizeof * Wm ); - double nsc = 1/sqrt(ens_size - 1); + // Um*Wm^(-1) are the scaled, truncated, right singular vectors of data->global_prior + + matrix_type * prior = matrix_alloc_column_compressed_copy( data->global_prior , data->ens_mask); + int state_size = matrix_get_rows( prior ); + int ens_size = matrix_get_columns( prior ); + int nrmin = util_int_min( ens_size , state_size); + matrix_type * Dm = matrix_alloc_copy( prior ); + matrix_type * Um = matrix_alloc( state_size , nrmin ); /* Left singular vectors. */ + matrix_type * VmT = matrix_alloc( nrmin , ens_size ); /* Right singular vectors. */ + double * Wm = util_calloc( nrmin , sizeof * Wm ); + double nsc = 1/sqrt(ens_size - 1); matrix_subtract_row_mean(Dm); - - for (int i=0; i < state_size; i++){ - double sc = nsc / (data->Csc[i]); - matrix_scale_row( Dm , i , sc); + { + const double * Csc = data->Csc; + for (int i=0; i < state_size; i++){ + double sc = nsc / (Csc[i]); + matrix_scale_row( Dm , i , sc); + } } // Um Wm VmT = Dm; nsign1 = num of non-zero singular values. - int nsign1 = enkf_linalg_svd_truncation(Dm , data->truncation , -1 , DGESVD_MIN_RETURN , Wm , Um , VmT); - + int nsign1 = enkf_linalg_svd_truncation(Dm , rml_enkf_config_get_truncation( data->config ) , -1 , DGESVD_MIN_RETURN , Wm , Um , VmT); + // Am = Um*Wm^(-1). I.e. scale *columns* of Um enkf_linalg_rml_enkfAm(Um, Wm, nsign1); @@ -402,25 +287,31 @@ static void rml_enkf_init1__( rml_enkf_data_type * data) { matrix_free(Um); matrix_free(VmT); matrix_free(Dm); + matrix_free(prior); free(Wm); } + + // Creates state scaling matrix -void rml_enkf_init_Csc(rml_enkf_data_type * data){ +void rml_enkf_init_Csc(const rml_enkf_data_type * data ){ // This seems a strange choice of scaling matrix. Review? - - int state_size = matrix_get_rows( data->prior ); - int ens_size = matrix_get_columns( data->prior ); + matrix_type * prior = matrix_alloc_column_compressed_copy( data->global_prior , data->ens_mask ); + { + int state_size = matrix_get_rows( prior ); + int ens_size = matrix_get_columns( prior ); - for (int row=0; row < state_size; row++) { - double sumrow = matrix_get_row_sum(data->prior , row); - double tmp = sumrow / ens_size; + for (int row=0; row < state_size; row++) { + double sumrow = matrix_get_row_sum(prior , row); + double tmp = sumrow / ens_size; - if (abs(tmp)< 1) - data->Csc[row] = 0.05; - else - data->Csc[row] = 1.00; + if (abs(tmp)< 1) + data->Csc[row] = 0.05; + else + data->Csc[row] = 1.00; + } + matrix_free( prior ); } } @@ -428,6 +319,7 @@ void rml_enkf_init_Csc(rml_enkf_data_type * data){ static void rml_enkf_initA__(rml_enkf_data_type * data, matrix_type * A, matrix_type * S, matrix_type * Cd, matrix_type * E, matrix_type * D, matrix_type * Udr, double * Wdr, matrix_type * VdTr) { int ens_size = matrix_get_columns( S ); + int state_size = matrix_get_rows( A ); double nsc = 1/sqrt(ens_size-1); int nsign; @@ -440,37 +332,37 @@ static void rml_enkf_initA__(rml_enkf_data_type * data, matrix_type * A, matrix_ matrix_matmul(tmp , Cd , S ); // matrix_scale(tmp , nsc); // - nsign = enkf_linalg_svd_truncation(tmp , data->truncation , -1 , DGESVD_MIN_RETURN , Wdr , Udr , VdTr); + nsign = enkf_linalg_svd_truncation(tmp , rml_enkf_config_get_truncation( data->config ) , -1 , DGESVD_MIN_RETURN , Wdr , Udr , VdTr); matrix_free( tmp ); } - + // Calc X3 { matrix_type * X3 = matrix_alloc( ens_size, ens_size ); { matrix_type * X1 = matrix_alloc( nsign, ens_size); matrix_type * X2 = matrix_alloc( nsign, ens_size ); - - + + // See LM-EnRML algorithm in Oliver'2013 (Comp. Geo.) for meaning enkf_linalg_rml_enkfX1(X1, Udr ,D ,Cd ); // X1 = Ud(T)*Cd(-1/2)*D -- D= -(dk-d0) enkf_linalg_rml_enkfX2(X2, Wdr ,X1 ,data->lambda + 1 , nsign); // X2 = ((a*Ipd)+Wd^2)^-1 * X1 enkf_linalg_rml_enkfX3(X3, VdTr ,Wdr,X2, nsign); // X3 = Vd *Wd*X2 - + matrix_free(X2); matrix_free(X1); } - + // Update A { - matrix_type * dA1 = matrix_alloc( matrix_get_rows(A) , ens_size); - matrix_type * Dm = matrix_alloc_copy( A ); + matrix_type * dA1 = matrix_alloc( state_size , ens_size); + matrix_type * Dm = matrix_alloc_copy( A ); matrix_subtract_row_mean( Dm ); /* Remove the mean from the ensemble of model parameters*/ matrix_scale(Dm, nsc); matrix_matmul(dA1, Dm , X3); - matrix_inplace_add(A,dA1); // dA + matrix_inplace_add(A,dA1); // dA matrix_free(Dm); matrix_free(dA1); @@ -487,15 +379,15 @@ void rml_enkf_init2__( rml_enkf_data_type * data, matrix_type *A, double * Wdr, int state_size = matrix_get_rows( A ); int ens_size = matrix_get_columns( A ); - double nsc = 1/sqrt(ens_size-1); + double nsc = 1/sqrt(ens_size-1); matrix_type *Am = matrix_alloc_copy(data->Am); - matrix_type *Apr = matrix_alloc_copy(data->prior); + matrix_type *Apr = matrix_alloc_column_compressed_copy(data->global_prior , data->ens_mask ); // fprintf(stdout,"\n"); // fprintf(stdout,"A: %d x %d\n", matrix_get_rows(A), matrix_get_columns(A)); - // fprintf(stdout,"prior : %d x %d\n", matrix_get_rows(data->prior), matrix_get_columns(data->prior)); - // fprintf(stdout,"state : %d x %d\n", matrix_get_rows(data->state), matrix_get_columns(data->state)); + // fprintf(stdout,"prior : %d x %d\n", matrix_get_rows(data->global_prior), matrix_get_columns(data->global_prior)); + // fprintf(stdout,"state : %d x %d\n", matrix_get_rows(data->previous_state), matrix_get_columns(data->previous_state)); // fprintf(stdout,"Apr : %d x %d\n", matrix_get_rows(Apr), matrix_get_columns(Apr)); // fprintf(stdout,"Am : %d x %d\n", matrix_get_rows(Am), matrix_get_columns(Am)); // Example: @@ -508,7 +400,7 @@ void rml_enkf_init2__( rml_enkf_data_type * data, matrix_type *A, double * Wdr, int nsign1 = matrix_get_columns(data->Am); - + matrix_type * X4 = matrix_alloc(nsign1,ens_size); matrix_type * X5 = matrix_alloc(state_size,ens_size); @@ -516,13 +408,15 @@ void rml_enkf_init2__( rml_enkf_data_type * data, matrix_type *A, double * Wdr, matrix_type * X7 = matrix_alloc(ens_size,ens_size); matrix_type * dA2 = matrix_alloc(state_size , ens_size); matrix_type * Dk1 = matrix_alloc_copy( A ); - + // Dk = Csc^(-1) * (A - Aprior) // X4 = Am' * Dk { matrix_type * Dk = matrix_alloc_copy( A ); - matrix_inplace_sub(Dk, Apr); + + matrix_inplace_sub( Dk , Apr ); rml_enkf_common_scaleA(Dk , data->Csc , true); + matrix_dgemm(X4 , Am , Dk , true, false, 1.0, 0.0); matrix_free(Dk); } @@ -536,10 +430,10 @@ void rml_enkf_init2__( rml_enkf_data_type * data, matrix_type *A, double * Wdr, // X6 = Dk1' * X5 matrix_dgemm(X6, Dk1, X5, true, false, 1.0, 0.0); - + // X7 enkf_linalg_rml_enkfX7(X7, VdTr , Wdr , data->lambda + 1, X6); - + // delta m_2 rml_enkf_common_scaleA(Dk1 , data->Csc , false); matrix_matmul(dA2 , Dk1 , X7); @@ -547,7 +441,7 @@ void rml_enkf_init2__( rml_enkf_data_type * data, matrix_type *A, double * Wdr, matrix_free(Am); matrix_free(Apr); - matrix_free(X4); + matrix_free(X4); matrix_free(X5); matrix_free(X6); matrix_free(X7); @@ -557,39 +451,45 @@ void rml_enkf_init2__( rml_enkf_data_type * data, matrix_type *A, double * Wdr, // Initialize state and prior from A. Initialize lambda0, lambda. Call initA__, init1__ static void rml_enkf_updateA_iter0(rml_enkf_data_type * data, matrix_type * A, matrix_type * S, matrix_type * R, matrix_type * dObs, matrix_type * E, matrix_type * D, matrix_type * Cd) { - + int ens_size = matrix_get_columns( S ); int nrobs = matrix_get_rows( S ); - int nrmin = util_int_min( ens_size , nrobs); + int nrmin = util_int_min( ens_size , nrobs); int state_size = matrix_get_rows( A ); matrix_type * Skm = matrix_alloc(ens_size, ens_size); // Mismatch matrix_type * Ud = matrix_alloc( nrobs , nrmin ); /* Left singular vectors. */ matrix_type * VdT = matrix_alloc( nrmin , ens_size ); /* Right singular vectors. */ - double * Wd = util_calloc( nrmin , sizeof * Wd ); + double * Wd = util_calloc( nrmin , sizeof * Wd ); data->Csc = util_calloc(state_size , sizeof * data->Csc); - data->Sk = enkf_linalg_data_mismatch(D,Cd,Skm); + data->Sk = enkf_linalg_data_mismatch(D,Cd,Skm); data->Std = matrix_diag_std(Skm,data->Sk); - - if (data->lambda0 < 0) - data->lambda = pow(10 , floor(log10(data->Sk/(2*nrobs))) ); - else - data->lambda = data->lambda0; - - // state = A, prior = A - rml_enkf_common_store_state( data->state , A , data->ens_mask ); - rml_enkf_common_recover_state( A , data->prior , data->ens_mask ); + + { + double lambda0 = rml_enkf_config_get_lambda0( data->config ); + if (lambda0 < 0) + data->lambda = pow(10 , floor(log10(data->Sk/(2*nrobs))) ); + else + data->lambda = lambda0; + } + + + // state = A + rml_enkf_common_store_state( data->previous_state , A , data->ens_mask ); + + // prior = A + data->global_prior = matrix_alloc_copy( data->previous_state ); // Update dependant on data mismatch rml_enkf_initA__(data , A, S , Cd , E , D , Ud , Wd , VdT); // Update dependant on prior mismatch. This should be zero (coz iter0). // Therefore the purpose of init1__ is just to prepare some matrices. - if (data->use_prior) { + if (rml_enkf_config_get_use_prior(data->config)) { rml_enkf_init_Csc( data ); - rml_enkf_init1__(data ); + rml_enkf_init1__( data ); } - rml_enkf_write_iter_info(data, data->Sk, data->Std); + rml_enkf_write_iter_info(data, data->Sk , data->Sk, data->Std); matrix_free( Skm ); matrix_free( Ud ); @@ -597,7 +497,7 @@ static void rml_enkf_updateA_iter0(rml_enkf_data_type * data, matrix_type * A, m free( Wd ); } -// Main routine. Controls the iterations. Called from analysis_module.c: analysis_module_updateA() + void rml_enkf_updateA(void * module_data, matrix_type * A, matrix_type * S, matrix_type * R, matrix_type * dObs, matrix_type * E, matrix_type * D) { // A : ensemble matrix // R : (Inv?) Obs error cov. @@ -616,12 +516,12 @@ void rml_enkf_updateA(void * module_data, matrix_type * A, matrix_type * S, matr double nsc = 1/sqrt(ens_size-1); // Scale factor matrix_type * Cd = matrix_alloc( nrobs, nrobs ); // Cov(E), where E = measurement perturbations? - - // Empirical error covar. R is left unused. Investigate? + + // Empirical error covar. R is left unused. Investigate? enkf_linalg_Covariance(Cd ,E ,nsc, nrobs); // Cd = SampCov(E) (including (N-1) normalization) matrix_inv(Cd); // In-place inversion - rml_enkf_open_log_file(data); + rml_enkf_log_open(data->rml_log , data->iteration_nr); fprintf(stdout,"\nIter %d --> %d", data->iteration_nr, data->iteration_nr + 1); @@ -641,9 +541,9 @@ void rml_enkf_updateA(void * module_data, matrix_type * A, matrix_type * S, matr // Lambda = Normalized data mismatch (rounded) - if (data->lambda_recalculate) + if (rml_enkf_config_get_lambda_recalculate( data->config )) data->lambda = pow(10 , floor(log10(Sk_new / (2*nrobs))) ); - + // Accept/Reject update? Lambda calculation. { bool mismatch_reduced = false; @@ -651,65 +551,70 @@ void rml_enkf_updateA(void * module_data, matrix_type * A, matrix_type * S, matr if (Sk_new < data->Sk) mismatch_reduced = true; - + if (Std_new <= data->Std) std_reduced = true; - fprintf(stdout,"\nWriting iter info to file now. Iter %d --> %d", data->iteration_nr, data->iteration_nr + 1); - rml_enkf_write_iter_info(data, Sk_new, Std_new); + rml_enkf_write_iter_info(data, data->Sk , Sk_new, Std_new); if (mismatch_reduced) { /* Stop check: if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!! */ - + // Reduce Lambda - if (std_reduced) - data->lambda = data->lambda * data->lambda_reduce_factor; - - rml_enkf_common_store_state(data->state , A , data->ens_mask ); + if (std_reduced) + data->lambda = data->lambda * rml_enkf_config_get_lambda_decrease_factor( data->config ); + + rml_enkf_common_store_state(data->previous_state , A , data->ens_mask ); data->Sk = Sk_new; data->Std=Std_new; data->iteration_nr++; } else { // Increase lambda - data->lambda = data->lambda * data->lambda_increase_factor; - // A = data->state - rml_enkf_common_recover_state( data->state , A , data->ens_mask ); + data->lambda = data->lambda * rml_enkf_config_get_lambda_increase_factor( data->config ); + // A = data->previous_state + rml_enkf_common_recover_state( data->previous_state , A , data->ens_mask ); } } // Update dependant on data mismatch (delta m_1) rml_enkf_initA__(data , A , S , Cd , E , D , Ud , Wd , VdT); + // Update dependant on prior mismatch (delta m_2) - if (data->use_prior) { + if (rml_enkf_config_get_use_prior(data->config)) { rml_enkf_init_Csc( data ); rml_enkf_init2__(data , A , Wd , VdT); } - + // Free matrix_free(Skm); matrix_free( Ud ); matrix_free( VdT ); free( Wd ); } - - if (data->lambda < data->lambda_min) - data->lambda = data->lambda_min; + { + double lambda_min = rml_enkf_config_get_lambda_min( data->config ); + if (data->lambda < lambda_min) + data->lambda = lambda_min; + } - if (data->log_stream) - fclose( data->log_stream ); - + + rml_enkf_log_close( data->rml_log ); matrix_free(Cd); } -// Called from analysis_module.c: analysis_module_init_update() -void rml_enkf_init_update(void * arg, const bool_vector_type * ens_mask, const matrix_type * S, const matrix_type * R, const matrix_type * dObs, const matrix_type * E, const matrix_type * D ) { - + + +void rml_enkf_init_update(void * arg, const bool_vector_type * ens_mask, const matrix_type * S, const matrix_type * R, const matrix_type * dObs, const matrix_type * E, const matrix_type * D ) { rml_enkf_data_type * module_data = rml_enkf_data_safe_cast( arg ); - bool_vector_memcpy( module_data->ens_mask , ens_mask ); + + if (module_data->ens_mask) + bool_vector_free( module_data->ens_mask ); + + module_data->ens_mask = bool_vector_alloc_copy( ens_mask ); } @@ -717,6 +622,7 @@ void rml_enkf_init_update(void * arg, const bool_vector_type * ens_mask, const m + //********************************************** // Set / Get basic types //********************************************** @@ -724,9 +630,9 @@ bool rml_enkf_set_int( void * arg , const char * var_name , int value) { rml_enkf_data_type * module_data = rml_enkf_data_safe_cast( arg ); { bool name_recognized = true; - + if (strcmp( var_name , ENKF_NCOMP_KEY_) == 0) - rml_enkf_set_subspace_dimension( module_data , value ); + rml_enkf_config_set_subspace_dimension(module_data->config , value); else if (strcmp( var_name , ITER_KEY) == 0) rml_enkf_set_iteration_nr( module_data , value ); else @@ -750,13 +656,13 @@ bool rml_enkf_set_bool( void * arg , const char * var_name , bool value) { rml_enkf_data_type * module_data = rml_enkf_data_safe_cast( arg ); { bool name_recognized = true; - + if (strcmp( var_name , USE_PRIOR_KEY) == 0) - rml_enkf_set_use_prior( module_data , value ); + rml_enkf_config_set_use_prior( module_data->config , value); else if (strcmp( var_name , CLEAR_LOG_KEY) == 0) - rml_enkf_set_clear_log( module_data , value ); + rml_enkf_log_set_clear_log( module_data->rml_log , value ); else if (strcmp( var_name , LAMBDA_RECALCULATE_KEY) == 0) - rml_enkf_set_lambda_recalculate( module_data , value ); + rml_enkf_config_set_lambda_recalculate( module_data->config , value ); else name_recognized = false; @@ -768,11 +674,11 @@ bool rml_enkf_get_bool( const void * arg, const char * var_name) { const rml_enkf_data_type * module_data = rml_enkf_data_safe_cast_const( arg ); { if (strcmp(var_name , USE_PRIOR_KEY) == 0) - return module_data->use_prior; - else if (strcmp(var_name , CLEAR_LOG_KEY) == 0) - return module_data->clear_log; - else if (strcmp(var_name , LAMBDA_RECALCULATE_KEY) == 0) - return module_data->lambda_recalculate; + return rml_enkf_config_get_use_prior( module_data->config ); + else if (strcmp(var_name , CLEAR_LOG_KEY) == 0) + return rml_enkf_log_get_clear_log( module_data->rml_log ); + else if (strcmp(var_name , LAMBDA_RECALCULATE_KEY) == 0) + return rml_enkf_config_get_lambda_recalculate( module_data->config ); else return false; } @@ -784,15 +690,15 @@ bool rml_enkf_set_double( void * arg , const char * var_name , double value) { bool name_recognized = true; if (strcmp( var_name , ENKF_TRUNCATION_KEY_) == 0) - rml_enkf_set_truncation( module_data , value ); + rml_enkf_config_set_truncation( module_data->config , value ); else if (strcmp( var_name , LAMBDA_INCREASE_FACTOR_KEY) == 0) - rml_enkf_set_lambda_increase_factor( module_data , value ); + rml_enkf_config_set_lambda_increase_factor( module_data->config , value ); else if (strcmp( var_name , LAMBDA_REDUCE_FACTOR_KEY) == 0) - rml_enkf_set_lambda_reduce_factor( module_data , value ); + rml_enkf_config_set_lambda_decrease_factor( module_data->config , value ); else if (strcmp( var_name , LAMBDA0_KEY) == 0) - rml_enkf_set_lambda0( module_data , value ); + rml_enkf_config_set_lambda0( module_data->config , value ); else if (strcmp( var_name , LAMBDA_MIN_KEY) == 0) - rml_enkf_set_lambda_min( module_data , value ); + rml_enkf_config_set_lambda_min( module_data->config , value ); else name_recognized = false; @@ -804,17 +710,21 @@ double rml_enkf_get_double( const void * arg, const char * var_name) { const rml_enkf_data_type * module_data = rml_enkf_data_safe_cast_const( arg ); { if (strcmp(var_name , LAMBDA_REDUCE_FACTOR_KEY) == 0) - return module_data->lambda_reduce_factor; + return rml_enkf_config_get_lambda_decrease_factor(module_data->config); + if (strcmp(var_name , LAMBDA_INCREASE_FACTOR_KEY) == 0) - return module_data->lambda_increase_factor; + return rml_enkf_config_get_lambda_increase_factor(module_data->config); + if (strcmp(var_name , LAMBDA0_KEY) == 0) - return module_data->lambda0; + return rml_enkf_config_get_lambda0(module_data->config); + if (strcmp(var_name , LAMBDA_MIN_KEY) == 0) - return module_data->lambda_min; + return rml_enkf_config_get_lambda_min(module_data->config); + if (strcmp(var_name , ENKF_TRUNCATION_KEY_) == 0) - return module_data->truncation; - else - return -1; + return rml_enkf_config_get_truncation( module_data->config ); + + return -1; } } @@ -823,9 +733,9 @@ bool rml_enkf_set_string( void * arg , const char * var_name , const char * valu rml_enkf_data_type * module_data = rml_enkf_data_safe_cast( arg ); { bool name_recognized = true; - + if (strcmp( var_name , LOG_FILE_KEY) == 0) - rml_enkf_set_log_file( module_data , value ); + rml_enkf_log_set_log_file( module_data->rml_log , value ); else name_recognized = false; @@ -836,7 +746,7 @@ bool rml_enkf_set_string( void * arg , const char * var_name , const char * valu long rml_enkf_get_options( void * arg , long flag ) { rml_enkf_data_type * module_data = rml_enkf_data_safe_cast( arg ); { - return module_data->option_flags; + return rml_enkf_config_get_option_flags( module_data->config ); } } @@ -871,7 +781,7 @@ void * rml_enkf_get_ptr( const void * arg , const char * var_name ) { const rml_enkf_data_type * module_data = rml_enkf_data_safe_cast_const( arg ); { if (strcmp(var_name , LOG_FILE_KEY) == 0) - return module_data->log_file; + return (void *) rml_enkf_log_get_log_file( module_data->rml_log ); else return NULL; } @@ -895,13 +805,13 @@ void * rml_enkf_get_ptr( const void * arg , const char * var_name ) { analysis_table_type SYMBOL_TABLE = { .alloc = rml_enkf_data_alloc, .freef = rml_enkf_data_free, - .set_int = rml_enkf_set_int , - .set_double = rml_enkf_set_double , - .set_bool = rml_enkf_set_bool, + .set_int = rml_enkf_set_int , + .set_double = rml_enkf_set_double , + .set_bool = rml_enkf_set_bool, .set_string = rml_enkf_set_string, - .get_options = rml_enkf_get_options , + .get_options = rml_enkf_get_options , .initX = NULL, - .updateA = rml_enkf_updateA , + .updateA = rml_enkf_updateA , .init_update = rml_enkf_init_update , .complete_update = NULL, .has_var = rml_enkf_has_var, diff --git a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_common.c b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_common.c index 5de985b2bd..fdc541bfbc 100644 --- a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_common.c +++ b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_common.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'rml_enkf.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'rml_enkf.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -38,7 +38,7 @@ // zzz_enkf_common_recover_state(state , A ,ens_mask) assigns state to A. RESIZES A to rows(state)-by-SUM(ens_mask) -void rml_enkf_common_store_state( matrix_type * state , const matrix_type * A , const bool_vector_type * ens_mask ) { +void rml_enkf_common_store_state( matrix_type * state , const matrix_type * A , const bool_vector_type * ens_mask ) { matrix_resize( state , matrix_get_rows( A ) , bool_vector_size( ens_mask ) , false); { const int ens_size = bool_vector_size( ens_mask ); @@ -55,11 +55,11 @@ void rml_enkf_common_store_state( matrix_type * state , const matrix_type * A , -void rml_enkf_common_recover_state( const matrix_type * state , matrix_type * A , const bool_vector_type * ens_mask ) { +void rml_enkf_common_recover_state( const matrix_type * state , matrix_type * A , const bool_vector_type * ens_mask ) { const int ens_size = bool_vector_size( ens_mask ); const int active_size = bool_vector_count_equal( ens_mask , true ); const int rows = matrix_get_rows( state ); - + matrix_resize( A , rows , active_size , false ); { int active_index = 0; diff --git a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_config.c b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_config.c new file mode 100644 index 0000000000..6e9ff18287 --- /dev/null +++ b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_config.c @@ -0,0 +1,168 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'rml_enkf_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#include <ert/util/util.h> +#include <ert/util/type_macros.h> + +#include <ert/analysis/std_enkf.h> +#include <ert/analysis/analysis_module.h> + +#include <rml_enkf_config.h> + + +#define INVALID_SUBSPACE_DIMENSION -1 +#define INVALID_TRUNCATION -1 + +#define DEFAULT_SUBSPACE_DIMENSION INVALID_SUBSPACE_DIMENSION +#define DEFAULT_USE_PRIOR true + +#define DEFAULT_LAMBDA_INCREASE_FACTOR 4 +#define DEFAULT_LAMBDA_REDUCE_FACTOR 0.1 +#define DEFAULT_LAMBDA0 -1 +#define DEFAULT_LAMBDA_MIN 0.01 +#define DEFAULT_LAMBDA_RECALCULATE false + + + +#define RML_ENKF_CONFIG_TYPE_ID 61400061 + +struct rml_enkf_config_struct { + UTIL_TYPE_ID_DECLARATION; + double truncation; // Controlled by config key: ENKF_TRUNCATION_KEY + int subspace_dimension; // Controlled by config key: ENKF_NCOMP_KEY (-1: use Truncation instead) + long option_flags; + bool use_prior; // Use exact/approximate scheme? Approximate scheme drops the "prior" term in the LM step. + + + double lambda0; + double lambda_min; + double lambda_decrease_factor; + double lambda_increase_factor; + bool lambda_recalculate; +}; + + + + + + + +rml_enkf_config_type * rml_enkf_config_alloc() { + rml_enkf_config_type * config = util_malloc( sizeof * config ); + UTIL_TYPE_ID_INIT( config , RML_ENKF_CONFIG_TYPE_ID ); + + rml_enkf_config_set_truncation( config , DEFAULT_ENKF_TRUNCATION_); + rml_enkf_config_set_subspace_dimension( config , DEFAULT_SUBSPACE_DIMENSION); + rml_enkf_config_set_use_prior( config , DEFAULT_USE_PRIOR ); + rml_enkf_config_set_option_flags( config , ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE + ANALYSIS_SCALE_DATA); + + rml_enkf_config_set_lambda_min( config , DEFAULT_LAMBDA_MIN ); + rml_enkf_config_set_lambda0( config , DEFAULT_LAMBDA0 ); + rml_enkf_config_set_lambda_decrease_factor( config , DEFAULT_LAMBDA_REDUCE_FACTOR ); + rml_enkf_config_set_lambda_increase_factor( config , DEFAULT_LAMBDA_INCREASE_FACTOR ); + rml_enkf_config_set_lambda_recalculate( config , DEFAULT_LAMBDA_RECALCULATE ); + + return config; +} + + +bool rml_enkf_config_get_use_prior( const rml_enkf_config_type * config ) { + return config->use_prior; +} + +void rml_enkf_config_set_use_prior( rml_enkf_config_type * config , bool use_prior) { + config->use_prior = use_prior; +} + + +double rml_enkf_config_get_truncation( rml_enkf_config_type * config ) { + return config->truncation; +} + +void rml_enkf_config_set_truncation( rml_enkf_config_type * config , double truncation) { + config->truncation = truncation; + if (truncation > 0.0) + config->subspace_dimension = INVALID_SUBSPACE_DIMENSION; +} + +int rml_enkf_config_get_subspace_dimension( rml_enkf_config_type * config ) { + return config->subspace_dimension; +} + +void rml_enkf_config_set_subspace_dimension( rml_enkf_config_type * config , int subspace_dimension) { + config->subspace_dimension = subspace_dimension; + if (subspace_dimension > 0) + config->truncation = INVALID_TRUNCATION; +} + +void rml_enkf_config_set_option_flags( rml_enkf_config_type * config , long flags) { + config->option_flags = flags; +} + +long rml_enkf_config_get_option_flags( const rml_enkf_config_type * config ) { + return config->option_flags; +} + +double rml_enkf_config_get_lambda0( rml_enkf_config_type * config ) { + return config->lambda0; +} + +void rml_enkf_config_set_lambda0( rml_enkf_config_type * config , double lambda0) { + config->lambda0 = lambda0; +} + + +double rml_enkf_config_get_lambda_min( rml_enkf_config_type * config ) { + return config->lambda_min; +} + +void rml_enkf_config_set_lambda_min( rml_enkf_config_type * config , double lambda_min) { + config->lambda_min = lambda_min; +} + + +double rml_enkf_config_get_lambda_increase_factor( rml_enkf_config_type * config ) { + return config->lambda_increase_factor; +} + +void rml_enkf_config_set_lambda_increase_factor( rml_enkf_config_type * config , double lambda_increase_factor) { + config->lambda_increase_factor = lambda_increase_factor; +} + +double rml_enkf_config_get_lambda_decrease_factor( rml_enkf_config_type * config ) { + return config->lambda_decrease_factor; +} + +void rml_enkf_config_set_lambda_decrease_factor( rml_enkf_config_type * config , double lambda_decrease_factor) { + config->lambda_decrease_factor = lambda_decrease_factor; +} + + +bool rml_enkf_config_get_lambda_recalculate( const rml_enkf_config_type * config ) { + return config->lambda_recalculate; +} + +void rml_enkf_config_set_lambda_recalculate( rml_enkf_config_type * config , bool lambda_recalculate) { + config->lambda_recalculate = lambda_recalculate; +} + + +void rml_enkf_config_free(rml_enkf_config_type * config) { + free( config ); +} diff --git a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_config.h b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_config.h new file mode 100644 index 0000000000..8173b9f7e6 --- /dev/null +++ b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_config.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'rml_enkf_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#ifndef RML_ENKF_CONFIG_H +#define RML_ENKF_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct rml_enkf_config_struct rml_enkf_config_type; + + + rml_enkf_config_type * rml_enkf_config_alloc(); + void rml_enkf_config_free(rml_enkf_config_type * config); + + int rml_enkf_config_get_subspace_dimension( rml_enkf_config_type * config ); + void rml_enkf_config_set_subspace_dimension( rml_enkf_config_type * config , int subspace_dimension); + + double rml_enkf_config_get_truncation( rml_enkf_config_type * config ); + void rml_enkf_config_set_truncation( rml_enkf_config_type * config , double truncation); + + bool rml_enkf_config_get_use_prior( const rml_enkf_config_type * config ); + void rml_enkf_config_set_use_prior( rml_enkf_config_type * config , bool use_prior); + + void rml_enkf_config_set_option_flags( rml_enkf_config_type * config , long flags); + long rml_enkf_config_get_option_flags( const rml_enkf_config_type * config ); + + double rml_enkf_config_get_lambda0( rml_enkf_config_type * config ); + void rml_enkf_config_set_lambda0( rml_enkf_config_type * config , double lambda0); + + double rml_enkf_config_get_lambda_min( rml_enkf_config_type * config ); + void rml_enkf_config_set_lambda_min( rml_enkf_config_type * config , double lambda_min); + + double rml_enkf_config_get_lambda_increase_factor( rml_enkf_config_type * config ); + void rml_enkf_config_set_lambda_increase_factor( rml_enkf_config_type * config , double lambda_increase_factor); + + double rml_enkf_config_get_lambda_decrease_factor( rml_enkf_config_type * config ); + void rml_enkf_config_set_lambda_decrease_factor( rml_enkf_config_type * config , double lambda_decrease_factor); + + bool rml_enkf_config_get_lambda_recalculate( const rml_enkf_config_type * config ); + void rml_enkf_config_set_lambda_recalculate( rml_enkf_config_type * config , bool lambda_recalculate); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_log.c b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_log.c new file mode 100644 index 0000000000..3ee3f7443d --- /dev/null +++ b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_log.c @@ -0,0 +1,108 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'rml_enkf_log.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#include <stdio.h> +#include <stdlib.h> + +#include <ert/util/util.h> + +#include <rml_enkf_log.h> + +#define DEFAULT_LOG_FILE "rml_enkf.out" +#define DEFAULT_CLEAR_LOG true + +struct rml_enkf_log_struct { + bool clear_log; + char * log_file; + FILE * log_stream; +}; + + +rml_enkf_log_type * rml_enkf_log_alloc() { + rml_enkf_log_type * rml_log = util_malloc( sizeof * rml_log ); + rml_log->log_file = NULL; + rml_log->log_stream = NULL; + rml_enkf_log_set_clear_log( rml_log , DEFAULT_CLEAR_LOG ); + return rml_log; +} + +bool rml_enkf_log_get_clear_log( const rml_enkf_log_type * data ) { + return data->clear_log; +} + +void rml_enkf_log_set_clear_log( rml_enkf_log_type * data , bool clear_log) { + data->clear_log = clear_log; +} + +void rml_enkf_log_set_log_file( rml_enkf_log_type * data , const char * log_file ) { + data->log_file = util_realloc_string_copy( data->log_file , log_file ); +} + +const char * rml_enkf_log_get_log_file( const rml_enkf_log_type * data) { + return data->log_file; +} + + +void rml_enkf_log_free(rml_enkf_log_type * rml_log) { + rml_enkf_log_close( rml_log ); + util_safe_free( rml_log->log_file ); + free( rml_log ); +} + + +void rml_enkf_log_open( rml_enkf_log_type * rml_log , int iteration_nr ) { + if (rml_log->log_file) { + if ( iteration_nr == 0) { + + if (rml_log->clear_log) + rml_log->log_stream = util_mkdir_fopen( rml_log->log_file , "w"); + else + rml_log->log_stream = util_mkdir_fopen( rml_log->log_file , "a"); + + } else + rml_log->log_stream = util_fopen( rml_log->log_file , "a"); + } +} + + +bool rml_enkf_log_is_open( const rml_enkf_log_type * rml_log ) { + if (rml_log->log_stream) + return true; + else + return false; +} + + +void rml_enkf_log_close( rml_enkf_log_type * rml_log ) { + if (rml_log->log_stream) + fclose( rml_log->log_stream ); + + rml_log->log_stream = NULL; +} + + +void rml_enkf_log_line( rml_enkf_log_type * rml_log , const char * fmt , ...) { + if (rml_log->log_stream) { + va_list ap; + va_start(ap , fmt); + vfprintf( rml_log->log_stream , fmt , ap ); + va_end( ap ); + } +} + diff --git a/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_log.h b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_log.h new file mode 100644 index 0000000000..2c61d655e7 --- /dev/null +++ b/ThirdParty/Ert/devel/libanalysis/modules/rml_enkf_log.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'rml_enkf_log.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#ifndef RML_ENKF_LOG_H +#define RML_ENKF_LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdbool.h> + + typedef struct rml_enkf_log_struct rml_enkf_log_type; + + rml_enkf_log_type * rml_enkf_log_alloc(); + void rml_enkf_log_free(rml_enkf_log_type * rml_log); + bool rml_enkf_log_get_clear_log( const rml_enkf_log_type * data ); + void rml_enkf_log_set_clear_log( rml_enkf_log_type * data , bool clear_log); + void rml_enkf_log_set_log_file( rml_enkf_log_type * data , const char * log_file ); + const char * rml_enkf_log_get_log_file( const rml_enkf_log_type * data); + void rml_enkf_log_open( rml_enkf_log_type * rml_log , int iteration_nr ); + void rml_enkf_log_close( rml_enkf_log_type * rml_log ); + void rml_enkf_log_line( rml_enkf_log_type * rml_log , const char * fmt , ...); + bool rml_enkf_log_is_open( const rml_enkf_log_type * rml_log ); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/ThirdParty/Ert/devel/libanalysis/src/analysis_module.c b/ThirdParty/Ert/devel/libanalysis/src/analysis_module.c index 4c2ee86281..a711136583 100644 --- a/ThirdParty/Ert/devel/libanalysis/src/analysis_module.c +++ b/ThirdParty/Ert/devel/libanalysis/src/analysis_module.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'analysis_module.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'analysis_module.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -36,7 +36,7 @@ struct analysis_module_struct { UTIL_TYPE_ID_DECLARATION; void * lib_handle; void * module_data; - char * symbol_table; + char * symbol_table; char * lib_name; analysis_free_ftype * freef; @@ -49,17 +49,17 @@ struct analysis_module_struct { analysis_get_options_ftype * get_options; analysis_set_int_ftype * set_int; analysis_set_double_ftype * set_double; - analysis_set_bool_ftype * set_bool; + analysis_set_bool_ftype * set_bool; analysis_set_string_ftype * set_string; - + analysis_has_var_ftype * has_var; analysis_get_int_ftype * get_int; analysis_get_double_ftype * get_double; analysis_get_bool_ftype * get_bool; analysis_get_ptr_ftype * get_ptr; - - bool internal; - char * user_name; /* String used to identify this module for the user; not used in + + bool internal; + char * user_name; /* String used to identify this module for the user; not used in the linking process. */ }; @@ -99,15 +99,15 @@ static bool analysis_module_internal_check( analysis_module_type * module ) { } -static analysis_module_type * analysis_module_alloc__( rng_type * rng , - const analysis_table_type * table , - const char * symbol_table , - const char * lib_name , - const char * user_name , +static analysis_module_type * analysis_module_alloc__( rng_type * rng , + const analysis_table_type * table , + const char * symbol_table , + const char * lib_name , + const char * user_name , void * lib_handle ) { analysis_module_type * module = analysis_module_alloc_empty( user_name , symbol_table , lib_name ); - + module->lib_handle = lib_handle; module->initX = table->initX; module->updateA = table->updateA; @@ -119,7 +119,7 @@ static analysis_module_type * analysis_module_alloc__( rng_type * rng , module->set_bool = table->set_bool; module->alloc = table->alloc; module->freef = table->freef; - module->get_options = table->get_options; + module->get_options = table->get_options; module->has_var = table->has_var; module->get_int = table->get_int; module->get_double = table->get_double; @@ -142,11 +142,11 @@ static analysis_module_type * analysis_module_alloc__( rng_type * rng , -static analysis_module_type * analysis_module_alloc( rng_type * rng , - const char * user_name , - const char * libname , +static analysis_module_type * analysis_module_alloc( rng_type * rng , + const char * user_name , + const char * libname , const char * table_name , - bool verbose, + bool verbose, analysis_module_load_status_enum * load_status) { analysis_module_type * module = NULL; void * lib_handle = dlopen( libname , RTLD_NOW ); @@ -160,15 +160,15 @@ static analysis_module_type * analysis_module_alloc( rng_type * rng , if (verbose) fprintf(stderr , "Failed to load symbol table:%s Error:%s \n",table_name , dlerror()); } - - if (module == NULL) + + if (module == NULL) dlclose( lib_handle ); } else { *load_status = DLOPEN_FAILURE; if (verbose) fprintf(stderr , "Failed to load library:%s Error:%s \n",libname , dlerror()); } - + if (module != NULL) { if (libname == NULL) module->internal = true; @@ -226,7 +226,7 @@ UTIL_IS_INSTANCE_FUNCTION( analysis_module , ANALYSIS_MODULE_TYPE_ID ) void analysis_module_free( analysis_module_type * module ) { if (module->freef != NULL) module->freef( module->module_data ); - + util_safe_free( module->lib_name ); free( module->user_name ); free( module->symbol_table ); @@ -244,26 +244,26 @@ void analysis_module_free__( void * arg) { /* Update functions */ -void analysis_module_initX(analysis_module_type * module , - matrix_type * X , - matrix_type * A , - matrix_type * S , - matrix_type * R , - matrix_type * dObs , - matrix_type * E , +void analysis_module_initX(analysis_module_type * module , + matrix_type * X , + matrix_type * A , + matrix_type * S , + matrix_type * R , + matrix_type * dObs , + matrix_type * E , matrix_type * D ) { - + module->initX(module->module_data , X , A , S , R , dObs , E , D ); } -void analysis_module_updateA(analysis_module_type * module , - matrix_type * A , - matrix_type * S , - matrix_type * R , - matrix_type * dObs , - matrix_type * E , +void analysis_module_updateA(analysis_module_type * module , + matrix_type * A , + matrix_type * S , + matrix_type * R , + matrix_type * dObs , + matrix_type * E , matrix_type * D ) { module->updateA(module->module_data , A , S , R , dObs , E , D ); @@ -272,12 +272,12 @@ void analysis_module_updateA(analysis_module_type * module , -void analysis_module_init_update( analysis_module_type * module , - const bool_vector_type * ens_mask , - const matrix_type * S , - const matrix_type * R , - const matrix_type * dObs , - const matrix_type * E , +void analysis_module_init_update( analysis_module_type * module , + const bool_vector_type * ens_mask , + const matrix_type * S , + const matrix_type * R , + const matrix_type * dObs , + const matrix_type * E , const matrix_type * D ) { if (module->init_update != NULL) module->init_update( module->module_data , ens_mask , S , R , dObs , E , D); @@ -296,7 +296,7 @@ void analysis_module_complete_update( analysis_module_type * module ) { static bool analysis_module_set_int(analysis_module_type * module , const char * flag , int value) { - if (module->set_int != NULL) + if (module->set_int != NULL) return module->set_int( module->module_data , flag , value ); else return false; @@ -327,7 +327,7 @@ static bool analysis_module_set_string(analysis_module_type * module , const cha -/* +/* The input value typically comes from the configuration system and is in terms of a string, irrespective of the fundamental type of the underlying parameter. The algorithm for setting the parameter @@ -346,38 +346,38 @@ bool analysis_module_set_var( analysis_module_type * module , const char * var_n bool set_ok = false; { int int_value; - - if (util_sscanf_int( string_value , &int_value )) + + if (util_sscanf_int( string_value , &int_value )) set_ok = analysis_module_set_int( module , var_name , int_value ); - - + + if (set_ok) return true; } - + { double double_value; - if (util_sscanf_double( string_value , &double_value )) + if (util_sscanf_double( string_value , &double_value )) set_ok = analysis_module_set_double( module , var_name , double_value ); - + if (set_ok) return true; } - + { bool bool_value; - if (util_sscanf_bool( string_value , &bool_value)) + if (util_sscanf_bool( string_value , &bool_value)) set_ok = analysis_module_set_bool( module , var_name , bool_value ); if (set_ok) return true; } - + set_ok = analysis_module_set_string( module , var_name , string_value ); if (!set_ok) fprintf(stderr,"** Warning: failed to set %s=%s for analysis module:%s\n", var_name , string_value , module->user_name); - + return set_ok; } @@ -404,7 +404,7 @@ int analysis_module_get_int( const analysis_module_type * module , const char * return module->get_int( module->module_data , var ); else util_exit("%s: Tried to get integer variable:%s from module:%s - get_int() method not implemented for this module\n" , __func__ , var , module->user_name); - } else + } else util_exit("%s: Tried to get integer variable:%s from module:%s - module does not support this variable \n" , __func__ , var , module->user_name); return 0; @@ -417,7 +417,7 @@ bool analysis_module_get_bool( const analysis_module_type * module , const char return module->get_bool( module->module_data , var ); else util_exit("%s: Tried to get bool variable:%s from module:%s - get_int() method not implemented for this module\n" , __func__ , var , module->user_name); - } else + } else util_exit("%s: Tried to get bool variable:%s from module:%s - module does not support this variable \n" , __func__ , var , module->user_name); return false; @@ -430,7 +430,7 @@ double analysis_module_get_double( const analysis_module_type * module , const c return module->get_double( module->module_data , var ); else util_exit("%s: Tried to get double variable:%s from module:%s - get_double() method not implemented for this module\n" , __func__ , var , module->user_name); - } else + } else util_exit("%s: Tried to get double variable:%s from module:%s - module does not support this variable \n" , __func__ , var , module->user_name); return 0; @@ -443,9 +443,9 @@ void * analysis_module_get_ptr( const analysis_module_type * module , const char return module->get_ptr( module->module_data , var ); else util_exit("%s: Tried to get pointer variable:%s from module:%s - get_ptr() method not implemented for this module\n" , __func__ , var , module->user_name); - } else + } else util_exit("%s: Tried to get pointer variable:%s from module:%s - module does not support this variable \n" , __func__ , var , module->user_name); - + return NULL; } diff --git a/ThirdParty/Ert/devel/libanalysis/src/enkf_linalg.c b/ThirdParty/Ert/devel/libanalysis/src/enkf_linalg.c index a82b1b04bc..5fbac02826 100644 --- a/ThirdParty/Ert/devel/libanalysis/src/enkf_linalg.c +++ b/ThirdParty/Ert/devel/libanalysis/src/enkf_linalg.c @@ -21,10 +21,10 @@ void enkf_linalg_genX3(matrix_type * X3 , const matrix_type * W , const matrix_t for (i=0; i < nrmin; i++) for (j=0; j < nrobs; j++) matrix_iset(X1 , i , j , eig[i] * matrix_iget(W , j , i)); - + matrix_matmul(X2 , X1 , D); /* X2 = X1 * D (Eq. 14.31) */ - matrix_matmul(X3 , W , X2); /* X3 = W * X2 = X1 * X2 (Eq. 14.31) */ - + matrix_matmul(X3 , W , X2); /* X3 = W * X2 = X1 * X2 (Eq. 14.31) */ + matrix_free( X1 ); matrix_free( X2 ); } @@ -34,7 +34,7 @@ void enkf_linalg_genX2(matrix_type * X2 , const matrix_type * S , const matrix_t const int nrens = matrix_get_columns( S ); const int idim = matrix_get_rows( X2 ); matrix_dgemm(X2 , W , S , true , false , 1.0 , 0.0); - { + { int i,j; for (j=0; j < nrens; j++) for (i=0; i < idim; i++) @@ -53,11 +53,11 @@ void enkf_linalg_genX2(matrix_type * X2 , const matrix_type * S , const matrix_t ncomp > 0 , truncation < 0: Use ncomp parameters. ncomp < 0 , truncation > 0: Truncate at level 'truncation'. - + The singular values are returned in the inv_sig0 vector; the values we retain are inverted and the remaining elements in are explicitly set to zero. - + The left-hand singular vectors are returned in the matrix U0. Depending on the value of the flag @store_V0T the right hand singular vectors are stored in the V0T matrix, or just @@ -74,14 +74,14 @@ void enkf_linalg_genX2(matrix_type * X2 , const matrix_type * S , const matrix_t /*This function is similar to enkf_linalg_svdS but it returns the eigen values without its inverse and also give the matrices truncated U VT and Sig0*/ // Trunc.SVD(S) = U0 * Sig0 * V0T -int enkf_linalg_svd_truncation(const matrix_type * S , - double truncation , +int enkf_linalg_svd_truncation(const matrix_type * S , + double truncation , int ncomp , - dgesvd_vector_enum store_V0T , - double * sig0, - matrix_type * U0 , + dgesvd_vector_enum store_V0T , + double * sig0, + matrix_type * U0 , matrix_type * V0T) { - + int num_significant = -1; int nrows = matrix_get_rows(S); int ncolumns= matrix_get_columns(S); @@ -90,9 +90,9 @@ int enkf_linalg_svd_truncation(const matrix_type * S , ((truncation < 0) && (ncomp > 0))) { int num_singular_values = util_int_min( matrix_get_rows( S ) , matrix_get_columns( S )); - { + { matrix_type * workS = matrix_alloc_copy( S ); - matrix_dgesvd(DGESVD_MIN_RETURN , store_V0T , workS , sig0 , U0 , V0T); + matrix_dgesvd(DGESVD_MIN_RETURN , store_V0T , workS , sig0 , U0 , V0T); matrix_free( workS ); } int i; @@ -103,11 +103,11 @@ int enkf_linalg_svd_truncation(const matrix_type * S , double total_sigma2 = 0; for (i=0; i < num_singular_values; i++) total_sigma2 += sig0[i]; - - /* + + /* Determine the number of singular values by enforcing that less than a fraction @truncation of the total variance be - accounted for. + accounted for. */ num_significant = 0; { @@ -116,83 +116,114 @@ int enkf_linalg_svd_truncation(const matrix_type * S , if (running_sigma2 / total_sigma2 < truncation) { /* Include one more singular value ? */ num_significant++; running_sigma2 += sig0[i]; - } else + } else break; } } } - matrix_resize(U0 , nrows , num_significant , true); - matrix_resize(V0T , num_significant , ncolumns , true); + if (num_significant > 0) { + matrix_resize(U0 , nrows , num_significant , true); + matrix_resize(V0T , num_significant , ncolumns , true); + } else + util_abort("%s: zero significant singular values\n",__func__); } - else + else util_abort("%s: truncation:%g ncomp:%d - invalid ambigous input.\n",__func__ , truncation , ncomp ); + return num_significant; } +static int enkf_linalg_num_significant(int num_singular_values , const double * sig0 , double truncation ) { + int num_significant = 0; + double total_sigma2 = 0; + for (int i=0; i < num_singular_values; i++) + total_sigma2 += sig0[i] * sig0[i]; + + /* + Determine the number of singular values by enforcing that + less than a fraction @truncation of the total variance be + accounted for. + */ + { + double running_sigma2 = 0; + for (int i=0; i < num_singular_values; i++) { + if (running_sigma2 / total_sigma2 < truncation) { /* Include one more singular value ? */ + num_significant++; + running_sigma2 += sig0[i] * sig0[i]; + } else + break; + } + } + + return num_significant; +} + +int enkf_linalg_svdS(const matrix_type * S , + double truncation , + int ncomp , + dgesvd_vector_enum store_V0T , + double * inv_sig0, + matrix_type * U0 , + matrix_type * V0T) { -int enkf_linalg_svdS(const matrix_type * S , - double truncation , - int ncomp , - dgesvd_vector_enum store_V0T , - double * inv_sig0, - matrix_type * U0 , - matrix_type * V0T) { - double * sig0 = inv_sig0; int num_significant = 0; - + if (((truncation > 0) && (ncomp < 0)) || ((truncation < 0) && (ncomp > 0))) { int num_singular_values = util_int_min( matrix_get_rows( S ) , matrix_get_columns( S )); - { + { matrix_type * workS = matrix_alloc_copy( S ); - matrix_dgesvd(DGESVD_MIN_RETURN , store_V0T , workS , sig0 , U0 , V0T); + matrix_dgesvd(DGESVD_MIN_RETURN , store_V0T , workS , sig0 , U0 , V0T); matrix_free( workS ); } - int i; if (ncomp > 0) num_significant = ncomp; - else { - double total_sigma2 = 0; - for (i=0; i < num_singular_values; i++) - total_sigma2 += sig0[i] * sig0[i]; - - /* - Determine the number of singular values by enforcing that - less than a fraction @truncation of the total variance be - accounted for. - */ - num_significant = 0; - { - double running_sigma2 = 0; - for (i=0; i < num_singular_values; i++) { - if (running_sigma2 / total_sigma2 < truncation) { /* Include one more singular value ? */ - num_significant++; - running_sigma2 += sig0[i] * sig0[i]; - } else - break; - } - } + else + num_significant = enkf_linalg_num_significant( num_singular_values , sig0 , truncation ); + + { + int i; + /* Inverting the significant singular values */ + for (i = 0; i < num_significant; i++) + inv_sig0[i] = 1.0 / sig0[i]; + + /* Explicitly setting the insignificant singular values to zero. */ + for (i=num_significant; i < num_singular_values; i++) + inv_sig0[i] = 0; } + } else - /* Inverting the significant singular values */ - for (i = 0; i < num_significant; i++) - inv_sig0[i] = 1.0 / sig0[i]; - - /* Explicitly setting the insignificant singular values to zero. */ - for (i=num_significant; i < num_singular_values; i++) - inv_sig0[i] = 0; - - } else util_abort("%s: truncation:%g ncomp:%d - invalid ambigous input.\n",__func__ , truncation , ncomp ); + + return num_significant; +} + + +int enkf_linalg_num_PC(const matrix_type * S , double truncation ) { + int num_singular_values = util_int_min( matrix_get_rows( S ) , matrix_get_columns( S )); + int num_significant; + double * sig0 = util_calloc( num_singular_values , sizeof * sig0); + + { + matrix_type * workS = matrix_alloc_copy( S ); + matrix_dgesvd(DGESVD_NONE , DGESVD_NONE , workS , sig0 , NULL , NULL); + matrix_free( workS ); + } + + num_significant = enkf_linalg_num_significant( num_singular_values , sig0 , truncation ); + free( sig0 ); return num_significant; } + + + void enkf_linalg_Cee(matrix_type * B, int nrens , const matrix_type * R , const matrix_type * U0 , const double * inv_sig0) { const int nrmin = matrix_get_rows( B ); { @@ -200,14 +231,14 @@ void enkf_linalg_Cee(matrix_type * B, int nrens , const matrix_type * R , const matrix_dgemm(X0 , U0 , R , true , false , 1.0 , 0.0); /* X0 = U0^T * R */ matrix_dgemm(B , X0 , U0 , false , false , 1.0 , 0.0); /* B = X0 * U0 */ matrix_free( X0 ); - } - + } + { int i ,j; - /* Funny code ?? + /* Funny code ?? Multiply B with S^(-1)from left and right - BHat = S^(-1) * B * S^(-1) + BHat = S^(-1) * B * S^(-1) */ for (j=0; j < matrix_get_columns( B ) ; j++) for (i=0; i < matrix_get_rows( B ); i++) @@ -217,26 +248,26 @@ void enkf_linalg_Cee(matrix_type * B, int nrens , const matrix_type * R , const for (i=0; i < matrix_get_rows( B ); i++) matrix_imul(B , i , j , inv_sig0[j]); } - + matrix_scale(B , nrens - 1.0); } -void enkf_linalg_lowrankCinv__(const matrix_type * S , - const matrix_type * R , - matrix_type * V0T , - matrix_type * Z, - double * eig , - matrix_type * U0, - double truncation, +void enkf_linalg_lowrankCinv__(const matrix_type * S , + const matrix_type * R , + matrix_type * V0T , + matrix_type * Z, + double * eig , + matrix_type * U0, + double truncation, int ncomp) { - + const int nrobs = matrix_get_rows( S ); const int nrens = matrix_get_columns( S ); const int nrmin = util_int_min( nrobs , nrens ); - + double * inv_sig0 = util_calloc( nrmin , sizeof * inv_sig0); if (V0T != NULL) @@ -246,18 +277,18 @@ void enkf_linalg_lowrankCinv__(const matrix_type * S , { matrix_type * B = matrix_alloc( nrmin , nrmin ); - enkf_linalg_Cee( B , nrens , R , U0 , inv_sig0); /* B = Xo = (N-1) * Sigma0^(+) * U0'* Cee * U0 * Sigma0^(+') (14.26)*/ + enkf_linalg_Cee( B , nrens , R , U0 , inv_sig0); /* B = Xo = (N-1) * Sigma0^(+) * U0'* Cee * U0 * Sigma0^(+') (14.26)*/ matrix_dgesvd(DGESVD_MIN_RETURN , DGESVD_NONE, B , eig, Z , NULL); matrix_free( B ); } - + { int i,j; /* Lambda1 = (I + Lambda)^(-1) */ - for (i=0; i < nrmin; i++) + for (i=0; i < nrmin; i++) eig[i] = 1.0 / (1 + eig[i]); - + for (j=0; j < nrmin; j++) for (i=0; i < nrmin; i++) matrix_imul(Z , i , j , inv_sig0[i]); /* Z2 = Sigma0^(+) * Z; */ @@ -266,20 +297,20 @@ void enkf_linalg_lowrankCinv__(const matrix_type * S , } -void enkf_linalg_lowrankCinv(const matrix_type * S , - const matrix_type * R , +void enkf_linalg_lowrankCinv(const matrix_type * S , + const matrix_type * R , matrix_type * W , /* Corresponding to X1 from Eq. 14.29 */ double * eig , /* Corresponding to 1 / (1 + Lambda_1) (14.29) */ double truncation , int ncomp) { - + const int nrobs = matrix_get_rows( S ); const int nrens = matrix_get_columns( S ); const int nrmin = util_int_min( nrobs , nrens ); matrix_type * U0 = matrix_alloc( nrobs , nrmin ); matrix_type * Z = matrix_alloc( nrmin , nrmin ); - + enkf_linalg_lowrankCinv__( S , R , NULL , Z , eig , U0 , truncation , ncomp); matrix_matmul(W , U0 , Z); /* X1 = W = U0 * Z2 = U0 * Sigma0^(+') * Z */ @@ -288,13 +319,13 @@ void enkf_linalg_lowrankCinv(const matrix_type * S , } -void enkf_linalg_meanX5(const matrix_type * S , - const matrix_type * W , - const double * eig , - const matrix_type * dObs, +void enkf_linalg_meanX5(const matrix_type * S , + const matrix_type * W , + const double * eig , + const matrix_type * dObs, matrix_type * X5) { - + const int nrens = matrix_get_columns( S ); const int nrobs = matrix_get_rows( S ); const int nrmin = util_int_min( nrobs , nrens ); @@ -304,8 +335,8 @@ void enkf_linalg_meanX5(const matrix_type * S , double * y1 = &work[0]; double * y2 = &work[nrmin]; double * y3 = &work[2*nrmin]; - double * y4 = &work[2*nrmin + nrobs]; - + double * y4 = &work[2*nrmin + nrobs]; + if (nrobs == 1) { /* Is this special casing necessary ??? */ y1[0] = matrix_iget(W , 0,0) * matrix_iget( innov , 0 , 0); @@ -317,13 +348,13 @@ void enkf_linalg_meanX5(const matrix_type * S , matrix_dgemv(W , matrix_get_data( innov ) , y1 , true , 1.0, 0.0); /* y1 = Trans(W) * innov */ for (int i= 0; i < nrmin; i++) y2[i] = eig[i] * y1[i]; /* y2 = eig * y1 */ - matrix_dgemv(W , y2 , y3 , false , 1.0 , 0.0); /* y3 = W * y2; */ + matrix_dgemv(W , y2 , y3 , false , 1.0 , 0.0); /* y3 = W * y2; */ matrix_dgemv(S , y3 , y4 , true , 1.0 , 0.0); /* y4 = Trans(S) * y3 */ } - + for (int iens = 0; iens < nrens; iens++) matrix_set_column(X5 , y4 , iens ); - + matrix_shift(X5 , 1.0/nrens); } free( work ); @@ -332,7 +363,7 @@ void enkf_linalg_meanX5(const matrix_type * S , -void enkf_linalg_X5sqrt(matrix_type * X2 , matrix_type * X5 , const matrix_type * randrot, int nrobs) { +void enkf_linalg_X5sqrt(matrix_type * X2 , matrix_type * X5 , const matrix_type * randrot, int nrobs) { const int nrens = matrix_get_columns( X5 ); const int nrmin = util_int_min( nrobs , nrens ); matrix_type * VT = matrix_alloc( nrens , nrens ); @@ -348,24 +379,24 @@ void enkf_linalg_X5sqrt(matrix_type * X2 , matrix_type * X5 , const matrix_type int i,j; for (i = 0; i < nrmin; i++) isig[i] = sqrt( util_double_max( 1.0 - sig[i]*sig[i] ,0.0)); - + for (j = 0; j < nrens; j++) for (i = 0; i < nrens; i++) matrix_iset(X3 , i , j , matrix_iget(VT , j , i)); - + for (j=0; j< nrmin; j++) matrix_scale_column(X3 , j , isig[j]); - + matrix_dgemm(X33 , X3 , VT , false , false , 1.0 , 0.0); /* X33 = X3 * VT */ if (randrot != NULL) - matrix_dgemm(X4 , X33 , randrot , false, false , 1.0 , 0.0); /* X4 = X33 * Randrot */ + matrix_dgemm(X4 , X33 , randrot , false, false , 1.0 , 0.0); /* X4 = X33 * Randrot */ else matrix_assign(X4 , X33); - + matrix_set(IenN , -1.0/ nrens); for (i = 0; i < nrens; i++) matrix_iadd(IenN , i , i , 1.0); - + matrix_dgemm(X5 , IenN , X4 , false , false , 1.0 , 1.0); /* X5 = IenN * X4 + X5 */ matrix_free( X3 ); @@ -383,51 +414,51 @@ void enkf_linalg_X5sqrt(matrix_type * X2 , matrix_type * X5 , const matrix_type matrix_type * enkf_linalg_alloc_innov( const matrix_type * dObs , const matrix_type * S) { matrix_type * innov = matrix_alloc_copy( dObs ); - for (int iobs =0; iobs < matrix_get_row_sum( dObs , iobs); iobs++) + for (int iobs =0; iobs < matrix_get_row_sum( dObs , iobs); iobs++) matrix_isub( innov , iobs , 0 , matrix_get_row_sum( S , iobs )); return innov; } -void enkf_linalg_init_stdX( matrix_type * X , const matrix_type * S , const matrix_type * D , +void enkf_linalg_init_stdX( matrix_type * X , const matrix_type * S , const matrix_type * D , const matrix_type * W , const double * eig , bool bootstrap) { - + int nrobs = matrix_get_rows( W ); int ens_size = matrix_get_rows( X ); - + matrix_type * X3 = matrix_alloc(nrobs , ens_size); enkf_linalg_genX3(X3 , W , D , eig ); /* X2 = diag(eig) * W' * D (Eq. 14.31, Evensen (2007)) */ - /* X3 = W * X2 = X1 * X2 (Eq. 14.31, Evensen (2007)) */ - + /* X3 = W * X2 = X1 * X2 (Eq. 14.31, Evensen (2007)) */ + matrix_dgemm( X , S , X3 , true , false , 1.0 , 0.0); /* X = S' * X3 */ if (!bootstrap) { for (int i = 0; i < ens_size ; i++) matrix_iadd( X , i , i , 1.0); /*X = I + X */ } - + matrix_free( X3 ); } -void enkf_linalg_init_sqrtX(matrix_type * X5 , - const matrix_type * S , - const matrix_type * randrot , - const matrix_type * innov , - const matrix_type * W , - const double * eig , +void enkf_linalg_init_sqrtX(matrix_type * X5 , + const matrix_type * S , + const matrix_type * randrot , + const matrix_type * innov , + const matrix_type * W , + const double * eig , bool bootstrap) { - + const int nrobs = matrix_get_rows( S ); const int nrens = matrix_get_columns( S ); const int nrmin = util_int_min( nrobs , nrens ); - + matrix_type * X2 = matrix_alloc(nrmin , nrens); - + if (bootstrap) util_exit("%s: Sorry bootstrap support not fully implemented for SQRT scheme\n",__func__); - + enkf_linalg_meanX5( S , W , eig , innov , X5 ); enkf_linalg_genX2(X2 , S , W , eig); enkf_linalg_X5sqrt(X2 , X5 , randrot , nrobs); @@ -450,14 +481,14 @@ void enkf_linalg_init_sqrtX(matrix_type * X5 , 2. Then the QR decomposition is computed, and Q will then be a random orthogonal matrix. 3. The diagonal elements of R are extracted and we construct the diagonal matrix X(j,j)=R(j,j)/|R(j,j)| 4. An updated Q'=Q X is computed, and this is now a random orthogonal matrix with a Haar measure. - + The implementation is a plain reimplementation/copy of the old m_randrot.f90 function. */ /** - NB: This should rather use the implementation in m_mean_preserving_rotation.f90. + NB: This should rather use the implementation in m_mean_preserving_rotation.f90. */ void enkf_linalg_set_randrot( matrix_type * Q , rng_type * rng) { @@ -465,8 +496,8 @@ void enkf_linalg_set_randrot( matrix_type * Q , rng_type * rng) { double * tau = util_calloc( ens_size , sizeof * tau ); int * sign = util_calloc( ens_size , sizeof * sign); - for (int i = 0; i < ens_size; i++) - for (int j = 0; j < ens_size; j++) + for (int i = 0; i < ens_size; i++) + for (int j = 0; j < ens_size; j++) matrix_iset(Q , i , j , rng_std_normal( rng )); matrix_dgeqrf( Q , tau ); /* QR factorization */ @@ -482,7 +513,7 @@ void enkf_linalg_set_randrot( matrix_type * Q , rng_type * rng) { } free( sign ); - free( tau ); + free( tau ); } @@ -492,7 +523,7 @@ void enkf_linalg_set_randrot( matrix_type * Q , rng_type * rng) { Generates the mean preserving random rotation for the EnKF SQRT algorithm using the algorithm from Sakov 2006-07. I.e, generate rotation Up such that Up*Up^T=I and Up*1=1 (all rows have sum = 1) see eq 17. - From eq 18, Up=B * Upb * B^T + From eq 18, Up=B * Upb * B^T B is a random orthonormal basis with the elements in the first column equals 1/sqrt(nrens) Upb = | 1 0 | @@ -507,8 +538,8 @@ matrix_type * enkf_linalg_alloc_mp_randrot(int ens_size , rng_type * rng) { matrix_type * B = matrix_alloc( ens_size , ens_size ); matrix_type * Upb = matrix_alloc( ens_size , ens_size ); matrix_type * U = matrix_alloc_shared(Upb , 1 , 1 , ens_size - 1, ens_size - 1); - - + + { int k,j; matrix_type * R = matrix_alloc( ens_size , ens_size ); @@ -517,7 +548,7 @@ matrix_type * enkf_linalg_alloc_mp_randrot(int ens_size , rng_type * rng) { /* modified_gram_schmidt is used to create the orthonormal basis in B.*/ for (k=0; k < ens_size; k++) { - double Rkk = sqrt( matrix_column_column_dot_product( B , k , B , k)); + double Rkk = sqrt( matrix_column_column_dot_product( B , k , B , k)); matrix_iset(R , k , k , Rkk); matrix_scale_column(B , k , 1.0/Rkk); for (j=k+1; j < ens_size; j++) { @@ -535,23 +566,23 @@ matrix_type * enkf_linalg_alloc_mp_randrot(int ens_size , rng_type * rng) { } matrix_free( R ); } - + enkf_linalg_set_randrot( U , rng ); matrix_iset( Upb , 0 , 0 , 1); - - + + { matrix_type * Q = matrix_alloc( ens_size , ens_size ); matrix_dgemm( Q , B , Upb , false , false , 1, 0); /* Q = B * Ubp */ matrix_dgemm( Up , Q , B , false , true , 1, 0); /* Up = Q * T(B) */ matrix_free( Q ); } - + matrix_free( B ); matrix_free( Upb ); matrix_free( U ); } - + return Up; } @@ -561,7 +592,7 @@ matrix_type * enkf_linalg_alloc_mp_randrot(int ens_size , rng_type * rng) { /** Checking that the sum through one row in the X matrix equals @target_sum. @target_sum will be 1 normally, and zero if we are doing - bootstrap. + bootstrap. */ void enkf_linalg_checkX(const matrix_type * X , bool bootstrap) { @@ -572,10 +603,10 @@ void enkf_linalg_checkX(const matrix_type * X , bool bootstrap) { target_sum = 0; else target_sum = 1; - + for (int icol = 0; icol < matrix_get_columns( X ); icol++) { double col_sum = matrix_get_column_sum(X , icol); - if (fabs(col_sum - target_sum) > 0.0001) + if (fabs(col_sum - target_sum) > 0.0001) util_abort("%s: something is seriously broken. col:%d col_sum = %g != %g - ABORTING\n",__func__ , icol , col_sum , target_sum); } } @@ -584,14 +615,14 @@ void enkf_linalg_checkX(const matrix_type * X , bool bootstrap) { /*****************************************************************/ -void enkf_linalg_get_PC( const matrix_type * S0, - const matrix_type * dObs , +int enkf_linalg_get_PC( const matrix_type * S0, + const matrix_type * dObs , double truncation, - int ncomp, + int ncomp, matrix_type * PC, - matrix_type * PC_obs, + matrix_type * PC_obs, double_vector_type * singular_values) { - + const int nrobs = matrix_get_rows( S0 ); const int nrens = matrix_get_columns( S0 ); const int nrmin = util_int_min( nrobs , nrens ); @@ -599,6 +630,7 @@ void enkf_linalg_get_PC( const matrix_type * S0, matrix_type * U0 = matrix_alloc( nrobs , nrens ); matrix_type * S = matrix_alloc_copy( S0 ); double * inv_sig0; + int num_PC; double_vector_iset( singular_values , nrmin - 1 , 0 ); matrix_subtract_row_mean( S ); @@ -606,8 +638,8 @@ void enkf_linalg_get_PC( const matrix_type * S0, inv_sig0 = double_vector_get_ptr( singular_values ); { matrix_type * S_mean = matrix_alloc( nrobs , 1 ); - int num_PC = enkf_linalg_svdS(S , truncation , ncomp, DGESVD_NONE , inv_sig0 , U0 , NULL); - + num_PC = enkf_linalg_svdS(S , truncation , ncomp, DGESVD_NONE , inv_sig0 , U0 , NULL); + matrix_assign( S , S0); // The svd routine will overwrite S - we therefor must pick it up again from S0. matrix_subtract_and_store_row_mean( S , S_mean); @@ -622,7 +654,7 @@ void enkf_linalg_get_PC( const matrix_type * S0, matrix_dgemm( PC , U0 , S , true , false , 1.0 , 0.0 ); } - + /* The observer projections. */ { matrix_scale( S_mean , -1.0); @@ -633,11 +665,13 @@ void enkf_linalg_get_PC( const matrix_type * S0, for (int i=0; i < double_vector_size( singular_values ); i++) inv_sig0[i] = 1.0 / inv_sig0[i]; - + matrix_free( S_mean ); } matrix_free( S ); matrix_free( U0 ); + + return num_PC; } @@ -649,7 +683,7 @@ void enkf_linalg_rml_enkfX1(matrix_type *X1, matrix_type *Udr, matrix_type *D, m here the negative sign cancels with one needed in X3 matrix computation */ matrix_type * tmp = matrix_alloc(matrix_get_columns(Udr),matrix_get_rows(R)); - + matrix_matmul_with_transpose( tmp, Udr, R, true, false); matrix_matmul( X1 , tmp, D); @@ -661,23 +695,23 @@ void enkf_linalg_rml_enkfX1(matrix_type *X1, matrix_type *Udr, matrix_type *D, m void enkf_linalg_rml_enkfX2(matrix_type *X2 , double *Wdr , matrix_type * X1 , double a , int nsign) { /* - This routine computes X2 for RML_EnKF module as X2 = ((a*Ipd)+Wd^2)^-1 * X1 + This routine computes X2 for RML_EnKF module as X2 = ((a*Ipd)+Wd^2)^-1 * X1 Since a+Ipd & Wd are diagonal in nature the computation is reduced to array operations */ - + for (int i=0; i< nsign ; i++) { double scale_factor = 1 / (a + (Wdr[i]*Wdr[i])); matrix_scale_row(X1 , i , scale_factor); } matrix_assign(X2,X1); - + } void enkf_linalg_rml_enkfX3(matrix_type *X3, matrix_type *VdTr, double *Wdr, matrix_type *X2, int nsign) { /* - This routine computes X3 for RML_EnKF module as X3 = Vd *Wd*X2 + This routine computes X3 for RML_EnKF module as X3 = Vd *Wd*X2 */ printf("\nWd: "); @@ -701,9 +735,9 @@ double enkf_linalg_data_mismatch(matrix_type *D , matrix_type *R , matrix_type * double mismatch; matrix_matmul_with_transpose(tmp, D, R,true, false); // tmp = D' * R, i.e. N-by-p matrix_matmul(Sk, tmp, D); // Sk = D' * R * D - // Calculate the mismatch + // Calculate the mismatch mismatch = matrix_trace(Sk)/(matrix_get_columns(D)); - + return mismatch; } @@ -718,7 +752,7 @@ void enkf_linalg_Covariance(matrix_type *Cd, const matrix_type *E, double nsc ,i } } nsc = nsc*nsc; - matrix_scale(Cd,nsc); + matrix_scale(Cd,nsc); } @@ -746,7 +780,7 @@ void enkf_linalg_rml_enkfX7(matrix_type * X7, matrix_type * VdT, double * Wdr, d double scale_factor = 1 / ( a + (Wdr[i]*Wdr[i])); matrix_scale_row( tmp1 , i , scale_factor); } - + matrix_matmul_with_transpose(tmp2, tmp1, VdT, true, false); matrix_matmul(X7, tmp2, X6); diff --git a/ThirdParty/Ert/devel/libconfig/applications/config_test.c b/ThirdParty/Ert/devel/libconfig/applications/config_test.c index d97fee2a54..7a2a14ff77 100644 --- a/ThirdParty/Ert/devel/libconfig/applications/config_test.c +++ b/ThirdParty/Ert/devel/libconfig/applications/config_test.c @@ -24,7 +24,7 @@ int main(void) { const char * config_file = "config_test_input"; - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); config_schema_item_type * item; item = config_add_schema_item(config , "KEY1" , true , true); diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config.h deleted file mode 100644 index 3a816aa70e..0000000000 --- a/ThirdParty/Ert/devel/libconfig/include/ert/config/config.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. -*/ - -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <stdbool.h> - -#include <ert/util/stringlist.h> -#include <ert/util/subst_list.h> -#include <ert/util/hash.h> - -#include <ert/config/config_schema_item.h> -#include <ert/config/config_content_item.h> -#include <ert/config/config_content_node.h> - -#define ECL_COM_KW "--" -#define ENKF_COM_KW "--" - - - - - -typedef struct config_struct config_type; - - - char ** config_alloc_active_list(const config_type *, int *); - void config_free(config_type *); - config_type * config_alloc( ); - char ** config_alloc_active_list(const config_type * , int * ); - bool config_parse(config_type * , const char * , const char * , const char * , const char * , config_schema_unrecognized_enum unrecognized_behaviour , bool ); - bool config_has_schema_item(const config_type * config , const char * kw); - void config_clear(config_type * config); - -/*****************************************************************/ - - config_schema_item_type * config_get_schema_item(const config_type *, const char *); - bool config_item_set(const config_type * , const char * ); - void config_add_alias(config_type * , const char * , const char * ); - void config_install_message(config_type * , const char * , const char * ); - const char * config_safe_get(const config_type * , const char *); - char * config_alloc_joined_string(const config_type * , const char * , const char * ); - - void config_add_define( config_type * config , const char * key , const char * value ); - - /* - bool config_schema_item_is_set(const config_schema_item_type * ); - void config_schema_item_set_argc_minmax(config_schema_item_type * , int , int , int type_map_size , const config_item_types * ); - void config_schema_item_set_common_selection_set(config_schema_item_type * , int argc , const char ** argv); - void config_schema_item_set_indexed_selection_set(config_schema_item_type * item , int , int , const char ** ); - void config_schema_item_set_required_children(config_schema_item_type * , stringlist_type * ); - void config_schema_item_set_required_children_on_value(config_schema_item_type * , const char * , stringlist_type * ); - void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key); - */ - - config_schema_item_type * config_add_schema_item(config_type * config, - const char * kw, - bool required); - - - const char * config_safe_iget(const config_type * config , const char *kw, int occurence , int index); - const char * config_iget(const config_type * , const char * , int occurence , int index); - bool config_iget_as_bool(const config_type * , const char * , int occurence , int index); - double config_iget_as_double(const config_type * , const char * , int occurence , int index); - int config_iget_as_int(const config_type * , const char *, int occurence , int index); - stringlist_type * config_alloc_complete_stringlist(const config_type* , const char * ); - stringlist_type * config_alloc_stringlist(const config_type * config , const char * ); - hash_type * config_alloc_hash(const config_type * , const char * ); - const stringlist_type * config_iget_stringlist_ref(const config_type * , const char * , int ); - - int config_get_occurences(const config_type * , const char * ); - int config_get_occurence_size( const config_type * config , const char * kw , int occurence); - - bool config_has_content_item( const config_type * config , const char * input_kw); - config_content_item_type * config_get_content_item( const config_type * config , const char * input_kw); - config_schema_item_type * config_add_key_value( config_type * config , const char * key , bool required , config_item_types item_type); - bool config_get_value_as_bool(const config_type * config , const char * kw); - int config_get_value_as_int(const config_type * config , const char * kw); - double config_get_value_as_double(const config_type * config , const char * kw); - const char * config_get_value_as_abspath( const config_type * config , const char * kw); - const char * config_get_value_as_relpath( const config_type * config , const char * kw); - const char * config_get_value_as_path( const config_type * config , const char * kw); - const char * config_get_value(const config_type * config , const char * kw); - const char * config_get_config_file( const config_type * config , bool abs_path); - void config_fprintf_errors( const config_type * config , bool add_count , FILE * stream ); - - const subst_list_type * config_get_define_list( const config_type * config); - int config_get_schema_size( const config_type * config ); - int config_get_content_size( const config_type * config ); - const config_content_node_type * config_iget_content_node( const config_type * config , int index ); - config_content_node_type * config_get_value_node( const config_type * config , const char * kw); - config_error_type * config_get_errors( const config_type * config ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content.h new file mode 100644 index 0000000000..63158f77f4 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content.h @@ -0,0 +1,84 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'config_content.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#ifndef __CONFIG_CONTENT_H__ +#define __CONFIG_CONTENT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <ert/util/type_macros.h> +#include <ert/util/stringlist.h> +#include <ert/util/subst_list.h> + +#include <ert/config/config_content_item.h> +#include <ert/config/config_schema_item.h> +#include <ert/config/config_error.h> +#include <ert/config/config_root_path.h> + +typedef struct config_content_struct config_content_type; + + + config_content_type * config_content_alloc(); + void config_content_free( config_content_type * content ); + void config_content_set_valid( config_content_type * content); + bool config_content_is_valid( const config_content_type * content ); + bool config_content_has_item( const config_content_type * content , const char * key); + void config_content_add_item( config_content_type * content , const config_schema_item_type * schema_item , const config_path_elm_type * path_elm); + config_content_item_type * config_content_get_item( const config_content_type * content , const char * key); + void config_content_add_node( config_content_type * content , config_content_node_type * content_node ); + config_error_type * config_content_get_errors( const config_content_type * content); + + const char * config_content_iget( const config_content_type * content , const char * key , int occurence , int index); + int config_content_iget_as_int( const config_content_type * content , const char * key , int occurence , int index); + bool config_content_iget_as_bool( const config_content_type * content , const char * key , int occurence , int index); + double config_content_iget_as_double( const config_content_type * content , const char * key , int occurence , int index); + const char * config_content_safe_iget(const config_content_type * content , const char *kw, int occurence , int index); + int config_content_get_occurences(const config_content_type * content, const char * kw); + + bool config_content_get_value_as_bool(const config_content_type * config , const char * kw); + int config_content_get_value_as_int(const config_content_type * config , const char * kw); + double config_content_get_value_as_double(const config_content_type * config , const char * kw); + const char * config_content_get_value_as_path( const config_content_type * config , const char * kw); + const char * config_content_get_value_as_abspath( const config_content_type * config , const char * kw); + const char * config_content_get_value_as_relpath( const config_content_type * config , const char * kw); + const char * config_content_get_value(const config_content_type * config , const char * kw); + char * config_content_alloc_joined_string(const config_content_type * content , const char * kw, const char * sep); + stringlist_type * config_content_alloc_complete_stringlist(const config_content_type * content , const char * kw); + const stringlist_type * config_content_iget_stringlist_ref(const config_content_type * content , const char * kw, int occurence); + config_content_node_type * config_content_get_value_node( const config_content_type * content , const char * kw); + void config_content_add_define( config_content_type * content , const char * key , const char * value ); + subst_list_type * config_content_get_define_list( config_content_type * content ); + const char * config_content_get_config_file( const config_content_type * content , bool abs_path ); + void config_content_set_config_file( config_content_type * content , const char * config_file ); + int config_content_get_size(const config_content_type * content); + const config_content_node_type * config_content_iget_node( const config_content_type * content , int index); + bool config_content_add_file( config_content_type * content , const char * config_file); + config_root_path_type * config_content_get_invoke_path( config_content_type * content ); + void config_content_set_invoke_path( config_content_type * content); + config_path_elm_type * config_content_add_path_elm( config_content_type * content , const char * path ); + void config_content_pop_path_stack( config_content_type * content ); + + UTIL_IS_INSTANCE_HEADER( config_content ); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h index da4dd393bc..19718ff23f 100644 --- a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'config_content_item.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_content_item.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -26,6 +26,7 @@ extern "C" { #include <ert/util/hash.h> #include <ert/util/stringlist.h> +#include <ert/util/type_macros.h> #include <ert/config/config_error.h> #include <ert/config/config_schema_item.h> @@ -59,6 +60,8 @@ typedef struct config_content_item_struct config_content_item_type; const config_schema_item_type * config_content_item_get_schema( const config_content_item_type * item ); const config_path_elm_type * config_content_item_get_path_elm( const config_content_item_type * item ); + UTIL_IS_INSTANCE_HEADER( config_content_item ); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h index b318bff85b..cd2e9bb95f 100644 --- a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h @@ -31,6 +31,7 @@ define extern "C" { typedef struct config_content_node_struct config_content_node_type; + config_item_types config_content_node_iget_type( const config_content_node_type * node , int index); config_content_node_type * config_content_node_alloc( const config_schema_item_type * schema , const config_path_elm_type * cwd); void config_content_node_add_value(config_content_node_type * node , const char * value); void config_content_node_set(config_content_node_type * node , const stringlist_type * token_list); diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_parser.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_parser.h new file mode 100644 index 0000000000..b156f8012a --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_parser.h @@ -0,0 +1,104 @@ +/* + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <stdbool.h> + +#include <ert/util/stringlist.h> +#include <ert/util/subst_list.h> +#include <ert/util/hash.h> + +#include <ert/config/config_schema_item.h> +#include <ert/config/config_content_item.h> +#include <ert/config/config_content_node.h> +#include <ert/config/config_content.h> + +#define ECL_COM_KW "--" +#define ENKF_COM_KW "--" + + + + + +typedef struct config_parser_struct config_parser_type; + + + void config_free(config_parser_type *); + config_parser_type * config_alloc( ); + char ** config_alloc_active_list(const config_parser_type * , int * ); + config_content_type * config_parse(config_parser_type * , const char * , const char * , const char * , const char * , config_schema_unrecognized_enum unrecognized_behaviour , bool ); + bool config_has_schema_item(const config_parser_type * config , const char * kw); + +/*****************************************************************/ + + config_schema_item_type * config_get_schema_item(const config_parser_type *, const char *); + bool config_item_set(const config_parser_type * , const char * ); + void config_add_alias(config_parser_type * , const char * , const char * ); + void config_install_message(config_parser_type * , const char * , const char * ); + const char * config_safe_get(const config_parser_type * , const char *); + char * config_alloc_joined_string(const config_parser_type * , const char * , const char * ); + + void config_add_define( config_parser_type * config , const char * key , const char * value ); + + /* + bool config_schema_item_is_set(const config_schema_item_type * ); + void config_schema_item_set_argc_minmax(config_schema_item_type * , int , int , int type_map_size , const config_item_types * ); + void config_schema_item_set_common_selection_set(config_schema_item_type * , int argc , const char ** argv); + void config_schema_item_set_indexed_selection_set(config_schema_item_type * item , int , int , const char ** ); + void config_schema_item_set_required_children(config_schema_item_type * , stringlist_type * ); + void config_schema_item_set_required_children_on_value(config_schema_item_type * , const char * , stringlist_type * ); + void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key); + */ + + config_schema_item_type * config_add_schema_item(config_parser_type * config, + const char * kw, + bool required); + + + stringlist_type * config_alloc_complete_stringlist(const config_parser_type * , const char * ); + stringlist_type * config_alloc_stringlist(const config_parser_type * config , const char * ); + hash_type * config_alloc_hash(const config_parser_type * , const char * ); + const stringlist_type * config_iget_stringlist_ref(const config_parser_type * , const char * , int ); + + int config_get_occurences(const config_parser_type * , const char * ); + int config_get_occurence_size( const config_parser_type * config , const char * kw , int occurence); + + bool config_has_content_item( const config_parser_type * config , const char * input_kw); + config_content_item_type * config_get_content_item( const config_parser_type * config , const char * input_kw); + config_schema_item_type * config_add_key_value( config_parser_type * config , const char * key , bool required , config_item_types item_type); +; + const char * config_get_value_as_relpath( const config_parser_type * config , const char * kw); + const char * config_get_value_as_path( const config_parser_type * config , const char * kw); + const char * config_get_value(const config_parser_type * config , const char * kw); + + const subst_list_type * config_get_define_list( const config_parser_type * config); + int config_get_schema_size( const config_parser_type * config ); + config_content_node_type * config_get_value_node( const config_parser_type * config , const char * kw); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h index f9609e1c2c..96243b456d 100644 --- a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'config_schema_item.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_schema_item.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -29,12 +29,12 @@ extern "C" { #include <ert/config/config_error.h> #include <ert/config/config_path_elm.h> -/** +/** Types used for validation of config items. */ typedef enum {CONFIG_STRING = 1, CONFIG_INT = 2, - CONFIG_FLOAT = 4, + CONFIG_FLOAT = 4, CONFIG_PATH = 8, CONFIG_EXISTING_PATH = 16, CONFIG_BOOL = 32, @@ -42,7 +42,7 @@ typedef enum {CONFIG_STRING = 1, CONFIG_BYTESIZE = 128, CONFIG_EXECUTABLE = 256 , CONFIG_INVALID = 512 } config_item_types; - + #define CONFIG_ITEM_TYPE_ENUM_DEFS \ {.value = 1 , .name="CONFIG_STRING"}, \ {.value = 2 , .name="CONFIG_INT"}, \ @@ -53,10 +53,10 @@ typedef enum {CONFIG_STRING = 1, {.value = 64 , .name="CONFIG_CONFIG"}, \ {.value = 128 , .name="CONFIG_BYTESIZE"}, \ {.value = 256 , .name="CONFIG_EXECUTABLE"}, \ -{.value = 512 , .name="CONFIG_INVALID"} +{.value = 512 , .name="CONFIG_INVALID"} #define CONFIG_ITEM_TYPE_ENUM_SIZE 10 - + typedef enum { CONFIG_UNRECOGNIZED_IGNORE = 0, CONFIG_UNRECOGNIZED_WARN = 1, @@ -79,13 +79,13 @@ typedef enum {CONFIG_STRING = 1, typedef struct config_schema_item_struct config_schema_item_type; - - + + config_schema_item_type * config_schema_item_alloc(const char * kw , bool required); - bool config_schema_item_validate_set(const config_schema_item_type * item , - stringlist_type * token_list , - const char * config_file, - const config_path_elm_type * path_elm, + bool config_schema_item_validate_set(const config_schema_item_type * item , + stringlist_type * token_list , + const char * config_file, + const config_path_elm_type * path_elm, config_error_type * error_list); void config_schema_item_free( config_schema_item_type * item); @@ -97,13 +97,13 @@ typedef enum {CONFIG_STRING = 1, void config_schema_item_set_required_children(config_schema_item_type * item , stringlist_type * stringlist); void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key); void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar ); - void config_schema_item_set_argc_minmax(config_schema_item_type * item , - int argc_min , + void config_schema_item_set_argc_minmax(config_schema_item_type * item , + int argc_min , int argc_max); void config_schema_item_assure_type(const config_schema_item_type * item , int index , int type_mask); int config_schema_item_num_required_children(const config_schema_item_type * item); - const char * config_schema_item_iget_required_child( const config_schema_item_type * item , int index); + const char * config_schema_item_iget_required_child( const config_schema_item_type * item , int index); const char * config_schema_item_get_kw( const config_schema_item_type * item ); bool config_schema_item_required( const config_schema_item_type * item ); bool config_schema_item_expand_envvar( const config_schema_item_type * item ); diff --git a/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt b/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt index 6bac305ba7..3c0a76d4a3 100644 --- a/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt @@ -1,5 +1,5 @@ -set( source_files config.c config_error.c config_schema_item.c config_content_item.c config_content_node.c config_root_path.c config_path_elm.c conf.c conf_util.c conf_data.c) -set( header_files config.h config_error.h config_schema_item.h config_content_item.h config_content_node.h config_root_path.h config_path_elm.h conf.h conf_data.h) +set( source_files config_parser.c config_content.c config_error.c config_schema_item.c config_content_item.c config_content_node.c config_root_path.c config_path_elm.c conf.c conf_util.c conf_data.c) +set( header_files config_parser.h config_content.h config_error.h config_schema_item.h config_content_item.h config_content_node.h config_root_path.h config_path_elm.h conf.h conf_data.h) add_library( config ${LIBRARY_TYPE} ${source_files} ) set_target_properties( config PROPERTIES VERSION 1.0 SOVERSION 1.0 ) diff --git a/ThirdParty/Ert/devel/libconfig/src/conf.c b/ThirdParty/Ert/devel/libconfig/src/conf.c index 2f5c5c4d75..7ec931c97e 100644 --- a/ThirdParty/Ert/devel/libconfig/src/conf.c +++ b/ThirdParty/Ert/devel/libconfig/src/conf.c @@ -1190,7 +1190,16 @@ bool conf_instance_has_valid_mutexes( return ok; } - +static bool __instance_has_sub_instance_of_type( + const conf_class_type * __conf_class, int num_sub_instances, conf_class_type ** class_signatures) +{ + for(int sub_instance_nr = 0; sub_instance_nr < num_sub_instances; sub_instance_nr++) + { + if(class_signatures[sub_instance_nr] == __conf_class) + return true; + } + return false; +} static bool conf_instance_has_required_sub_instances( @@ -1218,16 +1227,7 @@ bool conf_instance_has_required_sub_instances( } - bool __instance_has_sub_instance_of_type( - const conf_class_type * __conf_class) - { - for(int sub_instance_nr = 0; sub_instance_nr < num_sub_instances; sub_instance_nr++) - { - if(class_signatures[sub_instance_nr] == __conf_class) - return true; - } - return false; - } + @@ -1243,7 +1243,7 @@ bool conf_instance_has_required_sub_instances( const conf_class_type * sub_conf_class = hash_get(conf_class->sub_classes, sub_class_name); if(sub_conf_class->require_instance) { - if(!__instance_has_sub_instance_of_type(sub_conf_class)) + if(!__instance_has_sub_instance_of_type(sub_conf_class, num_sub_instances, class_signatures)) { printf("ERROR: Missing required instance of sub class \"%s\" in instance \"%s\" of class \"%s\".\n", sub_conf_class->class_name, conf_instance->name, conf_instance->conf_class->class_name); diff --git a/ThirdParty/Ert/devel/libconfig/src/conf_util.c b/ThirdParty/Ert/devel/libconfig/src/conf_util.c index c077fb3a07..f634b784ad 100644 --- a/ThirdParty/Ert/devel/libconfig/src/conf_util.c +++ b/ThirdParty/Ert/devel/libconfig/src/conf_util.c @@ -44,7 +44,7 @@ char * __conf_util_fscanf_alloc_token_buffer( int num_pad_keys, const char ** pad_keys) { - char * buffer_wrk = parser_fread_alloc_file_content( file , NULL /* quote_set */ , NULL /* delete_set */ , "--" /* Comment start*/ , "\n" /* Comment end */); + char * buffer_wrk = basic_parser_fread_alloc_file_content( file , NULL /* quote_set */ , NULL /* delete_set */ , "--" /* Comment start*/ , "\n" /* Comment end */); char ** padded_keys = util_calloc(num_pad_keys , sizeof * padded_keys); for(int key_nr = 0; key_nr < num_pad_keys; key_nr++) { diff --git a/ThirdParty/Ert/devel/libconfig/src/config.c b/ThirdParty/Ert/devel/libconfig/src/config.c deleted file mode 100644 index 5fbf2ef921..0000000000 --- a/ThirdParty/Ert/devel/libconfig/src/config.c +++ /dev/null @@ -1,1040 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. -*/ - -#include <stdlib.h> -#include <stdbool.h> -#include <string.h> -#include <stdio.h> -#include <unistd.h> - -#include <ert/util/type_macros.h> -#include <ert/util/util.h> -#include <ert/util/parser.h> -#include <ert/util/hash.h> -#include <ert/util/stringlist.h> -#include <ert/util/set.h> -#include <ert/util/subst_list.h> -#include <ert/util/vector.h> -#include <ert/util/path_stack.h> - -#include <ert/config/config.h> -#include <ert/config/config_error.h> -#include <ert/config/config_schema_item.h> -#include <ert/config/config_content_node.h> -#include <ert/config/config_content_item.h> -#include <ert/config/config_path_elm.h> -#include <ert/config/config_root_path.h> - -#define CLEAR_STRING "__RESET__" - - - -/** -Structure to parse configuration files of this type: - -KEYWORD1 ARG2 ARG2 ARG3 -KEYWORD2 ARG1-2 -.... -KEYWORDN ARG1 ARG2 - -A keyword can occure many times. - -*/ - - - -/** - - - ============================= - | config_type object | - | | - | Contains 'all' the | - | configuration information.| - | | - ============================= - | | - | \________________________ - | \ - KEY1 KEY2 - | | - \|/ \|/ - ========================= ========================= - | config_item object | | config_item object | - | | | | - | Indexed by a keyword | | Indexed by a keyword | - | which is the first | | which is the first | - | string in the | | string in the | - | config file. | | config file. | - | | | | - ========================= ========================= - | | | - | | | - \|/ \|/ \|/ -============================ ============================ ============================ -| config_item_node object | | config_item_node object | | config_item_node object | -| | | | | | -| Only containing the | | Only containing the | | Only containing the | -| stringlist object | | stringlist object | | stringlist object | -| directly parsed from the | | directly parsed from the | | directly parsed from the | -| file. | | file. | | file. | -|--------------------------| |--------------------------| |--------------------------| -| ARG1 ARG2 ARG3 | | VERBOSE | | DEBUG | -============================ ============================ ============================ - - -The example illustrated above would correspond to the following config -file (invariant under line-permutations): - -KEY1 ARG1 ARG2 ARG3 -KEY1 VERBOSE -KEY2 DEBUG - - -Example config file(2): - -OUTFILE filename -INPUT filename -OPTIONS store -OPTIONS verbose -OPTIONS optimize cache=1 - -In this case the whole config object will contain three items, -corresponding to the keywords OUTFILE, INPUT and OPTIONS. The two -first will again only contain one node each, whereas the OPTIONS item -will contain three nodes, corresponding to the three times the keyword -"OPTIONS" appear in the config file. -*/ - - - - - - - - - - - -struct config_struct { - vector_type * content_list; /* Vector of content_content_node instances. */ - hash_type * content_items; - hash_type * schema_items; - config_error_type * parse_errors; - set_type * parsed_files; /* A set of config files whcih have been parsed - to protect against circular includes. */ - hash_type * messages; /* Can print a (warning) message when a keyword is encountered. */ - subst_list_type * define_list; - char * config_file; /* The last parsed file - NULL if no file is parsed-. */ - char * abs_path; - config_root_path_type * invoke_path; - vector_type * path_elm_storage; - vector_type * path_elm_stack; -}; - - - - - - - - - - -/** - Adds a new node as side-effect ... -*/ -static config_content_node_type * config_get_new_content_node(config_type * config , config_content_item_type * item) { - config_content_node_type * new_node = config_content_item_alloc_node( item , config_content_item_get_path_elm( item )); - vector_append_ref( config->content_list , new_node ); - return new_node; -} - - - - - - - - -/* - The last argument (config_file) is only used for printing - informative error messages, and can be NULL. The config_cwd is - essential if we are looking up a filename, otherwise it can be NULL. - - Returns a string with an error description, or NULL if the supplied - arguments were OK. The string is allocated here, but is assumed that - calling scope will free it. -*/ - -static void config_content_item_set_arg__(config_type * config , config_content_item_type * item , stringlist_type * token_list , - const config_path_elm_type * path_elm , - const char * config_file ) { - - int argc = stringlist_get_size( token_list ) - 1; - - if (argc == 1 && (strcmp(stringlist_iget(token_list , 1) , CLEAR_STRING) == 0)) { - config_content_item_clear(item); - } else { - const config_schema_item_type * schema_item = config_content_item_get_schema( item ); - - /* Filtering based on DEFINE statements */ - if (subst_list_get_size( config->define_list ) > 0) { - int iarg; - for (iarg = 0; iarg < argc; iarg++) { - char * filtered_copy = subst_list_alloc_filtered_string( config->define_list , stringlist_iget(token_list , iarg + 1)); - stringlist_iset_owned_ref( token_list , iarg + 1 , filtered_copy); - } - } - - - /* Filtering based on environment variables */ - if (config_schema_item_expand_envvar( schema_item )) { - int iarg; - for (iarg = 0; iarg < argc; iarg++) { - int env_offset = 0; - char * env_var; - do { - env_var = util_isscanf_alloc_envvar( stringlist_iget(token_list , iarg + 1) , env_offset ); - if (env_var != NULL) { - const char * env_value = getenv( &env_var[1] ); - if (env_value != NULL) { - char * new_value = util_string_replace_alloc( stringlist_iget( token_list , iarg + 1 ) , env_var , env_value ); - stringlist_iset_owned_ref( token_list , iarg + 1 , new_value ); - } else { - env_offset += 1; - fprintf(stderr,"** Warning: environment variable: %s is not defined \n", env_var); - } - } - } while (env_var != NULL); - } - } - - { - if (config_schema_item_validate_set(schema_item , token_list , config_file, path_elm , config->parse_errors)) { - config_content_node_type * node = config_get_new_content_node(config , item); - config_content_node_set(node , token_list); - } - } - } -} - - - - - -/*****************************************************************/ - - - -config_type * config_alloc() { - config_type *config = util_malloc(sizeof * config ); - config->content_list = vector_alloc_new(); - config->path_elm_storage = vector_alloc_new(); - config->path_elm_stack = vector_alloc_new(); - - config->schema_items = hash_alloc(); - config->content_items = hash_alloc(); - config->parse_errors = config_error_alloc(); - config->parsed_files = set_alloc_empty(); - config->messages = hash_alloc(); - config->define_list = subst_list_alloc( NULL ); - config->config_file = NULL; - config->abs_path = NULL; - config->invoke_path = NULL; - return config; -} - - - -const subst_list_type * config_get_define_list( const config_type * config) { - return config->define_list; -} - - -static void config_clear_content_items( config_type * config ) { - hash_free( config->content_items ); - config->content_items = hash_alloc(); - vector_clear( config->content_list ); -} - - -void config_clear(config_type * config) { - config_error_clear(config->parse_errors); - - set_clear(config->parsed_files); - subst_list_clear( config->define_list ); - config_clear_content_items( config ); - vector_clear( config->path_elm_storage ); - vector_clear( config->path_elm_stack ); - - util_safe_free( config->config_file ); - util_safe_free( config->abs_path ); - if (config->invoke_path != NULL) { - config_root_path_free( config->invoke_path ); - config->invoke_path = NULL; - } - config->config_file = NULL; - config->abs_path = NULL; -} - - - -void config_free(config_type * config) { - config_error_free( config->parse_errors ); - set_free(config->parsed_files); - subst_list_free( config->define_list ); - - vector_free( config->path_elm_storage ); - vector_free( config->path_elm_stack ); - vector_free( config->content_list ); - hash_free(config->schema_items); - hash_free(config->content_items); - hash_free(config->messages); - - util_safe_free( config->config_file ); - util_safe_free( config->abs_path ); - if (config->invoke_path != NULL) - config_root_path_free( config->invoke_path ); - - free(config); -} - - - -static void config_insert_schema_item(config_type * config , const char * kw , const config_schema_item_type * item , bool ref) { - if (ref) - hash_insert_ref(config->schema_items , kw , item); - else - hash_insert_hash_owned_ref(config->schema_items , kw , item , config_schema_item_free__); -} - - -/** - This function allocates a simple item with all values - defaulted. The item is added to the config object, and a pointer is - returned to the calling scope. If you want to change the properties - of the item you can do that with config_schema_item_set_xxxx() functions - from the calling scope. -*/ - - -config_schema_item_type * config_add_schema_item(config_type * config , - const char * kw, - bool required) { - - config_schema_item_type * item = config_schema_item_alloc( kw , required ); - config_insert_schema_item(config , kw , item , false); - return item; -} - - - -/** - This is a minor wrapper for adding an item with the properties. - - 1. It has argc_minmax = {1,1} - - The value can than be extracted with config_get_value() and - config_get_value_as_xxxx functions. -*/ - -config_schema_item_type * config_add_key_value( config_type * config , const char * key , bool required , config_item_types item_type) { - config_schema_item_type * item = config_add_schema_item( config , key , required ); - config_schema_item_set_argc_minmax( item , 1 , 1 ); - config_schema_item_iset_type( item , 0 , item_type ); - return item; -} - - - -bool config_has_schema_item(const config_type * config , const char * kw) { - return hash_has_key(config->schema_items , kw); -} - - -config_schema_item_type * config_get_schema_item(const config_type * config , const char * kw) { - return hash_get(config->schema_items , kw); -} - -/* - Due to the possibility of aliases we must go through the canonical - keyword which is internalized in the schema_item. -*/ - - -static config_content_item_type * config_add_content_item( const config_type * config , const char * input_kw, const config_path_elm_type * path_elm) { - config_schema_item_type * schema_item = config_get_schema_item( config , input_kw ); - const char * kw = config_schema_item_get_kw( schema_item ); - config_content_item_type * content_item = config_content_item_alloc( schema_item , path_elm ); - hash_insert_hash_owned_ref( config->content_items , kw , content_item , config_content_item_free__ ); - - return content_item; -} - - -bool config_has_content_item( const config_type * config , const char * input_kw) { - if (config_has_schema_item( config , input_kw )) { - config_schema_item_type * schema_item = config_get_schema_item( config , input_kw ); - const char * kw = config_schema_item_get_kw( schema_item ); - return hash_has_key( config->content_items , kw ); - } else - return false; -} - - -config_content_item_type * config_get_content_item( const config_type * config , const char * input_kw) { - if (config_has_schema_item( config , input_kw )) { - config_schema_item_type * schema_item = config_get_schema_item( config , input_kw ); - const char * kw = config_schema_item_get_kw( schema_item ); - - if (hash_has_key( config->content_items , kw )) - return hash_get( config->content_items , kw ); - else - return NULL; - - } else - return NULL; -} - - - -bool config_item_set(const config_type * config , const char * kw) { - if (config_has_content_item(config , kw)) { - const config_content_item_type * item = config_get_content_item( config , kw ); - if (config_content_item_get_size( item )) - return true; - else - return false; // The item exists - but it has size zero. - } else - return false; -} - - - - - -void config_add_define( config_type * config , const char * key , const char * value ) { - subst_list_append_copy( config->define_list , key , value , NULL ); -} - - - - -char ** config_alloc_active_list(const config_type * config, int * _active_size) { - char ** complete_key_list = hash_alloc_keylist(config->schema_items); - char ** active_key_list = NULL; - int complete_size = hash_get_size(config->schema_items); - int active_size = 0; - int i; - - for( i = 0; i < complete_size; i++) { - if (config_has_content_item( config , complete_key_list[i])) { - active_key_list = util_stringlist_append_copy(active_key_list , active_size , complete_key_list[i]); - active_size++; - } - } - *_active_size = active_size; - util_free_stringlist(complete_key_list , complete_size); - return active_key_list; -} - - - - -static void config_validate_content_item(const config_type * config , const config_content_item_type * item) { - const config_schema_item_type * schema_item = config_content_item_get_schema( item ); - const char * schema_kw = config_schema_item_get_kw( schema_item ); - - { - int i; - for (i = 0; i < config_schema_item_num_required_children(schema_item); i++) { - const char * required_child = config_schema_item_iget_required_child( schema_item , i ); - if (!config_item_set(config , required_child)) { - char * error_message = util_alloc_sprintf("When:%s is set - you also must set:%s.",schema_kw , required_child); - config_error_add( config->parse_errors , error_message ); - } - } - - if (config_schema_item_has_required_children_value( schema_item )) { - int inode; - for (inode = 0; inode < config_content_item_get_size(item); inode++) { - config_content_node_type * node = config_content_item_iget_node(item , inode); - const stringlist_type * values = config_content_node_get_stringlist( node ); - int is; - - for (is = 0; is < stringlist_get_size(values); is++) { - const char * value = stringlist_iget(values , is); - stringlist_type * required_children = config_schema_item_get_required_children_value( schema_item , value ); - - if (required_children != NULL) { - int ic; - for (ic = 0; ic < stringlist_get_size( required_children ); ic++) { - const char * req_child = stringlist_iget( required_children , ic ); - if (!config_item_set(config , req_child )) { - char * error_message = util_alloc_sprintf("When:%s is set to:%s - you also must set:%s.",schema_kw , value , req_child ); - config_error_add( config->parse_errors , error_message ); - } - } - } - } - } - } - } -} - - - -static void config_validate(config_type * config, const char * filename) { - int size = hash_get_size(config->schema_items); - char ** key_list = hash_alloc_keylist(config->schema_items); - int ikey; - for (ikey = 0; ikey < size; ikey++) { - if (config_has_content_item( config , key_list[ikey])) { - const config_content_item_type * item = config_get_content_item(config , key_list[ikey]); - config_validate_content_item(config , item ); - } else { - const config_schema_item_type * schema_item = config_get_schema_item( config , key_list[ikey]); - if (config_schema_item_required( schema_item)) { /* The item is not set ... */ - const char * schema_kw = config_schema_item_get_kw( schema_item ); - char * error_message = util_alloc_sprintf("Item:%s must be set - parsing:%s",schema_kw , config->abs_path); - config_error_add( config->parse_errors , error_message ); - } - } - } - util_free_stringlist(key_list , size); -} - - - - -static config_path_elm_type * config_add_path_elm( config_type * config , const char * path ) { - const config_path_elm_type * current_path_elm; - - if (vector_get_size( config->path_elm_stack ) == 0) - current_path_elm = NULL; - else - current_path_elm = vector_get_last_const(config->path_elm_stack); - - { - config_path_elm_type * new_path_elm; - - { - char * rel_path = NULL; - if (path != NULL) { - if (current_path_elm == NULL) - rel_path = util_alloc_rel_path( config_root_path_get_abs_path(config->invoke_path) , path); - else - rel_path = config_path_elm_alloc_relpath( current_path_elm , path ); - } - new_path_elm = config_path_elm_alloc( config->invoke_path , rel_path ); - util_safe_free( rel_path ); - } - vector_append_owned_ref( config->path_elm_storage , new_path_elm , config_path_elm_free__); - vector_append_ref( config->path_elm_stack , new_path_elm ); - return new_path_elm; - } -} - - - -/** - This function parses the config file 'filename', and updated the - internal state of the config object as parsing proceeds. If - comment_string != NULL everything following 'comment_string' on a - line is discarded. - - include_kw is a string identifier for an include functionality, if - an include is encountered, the included file is parsed immediately - (through a recursive call to config_parse__). if include_kw == NULL, - include files are not supported. - - Observe that use of include, relative paths and all that shit is - quite tricky. The following is currently implemented: - - 1. The front_end function will split the path to the config file - in a path_name component and a file component. - - 2. Recursive calls to config_parse__() will keep control of the - parsers notion of cwd (note that the real OS'wise cwd never - changes), and every item is tagged with the config_cwd - currently active. - - 3. When an item has been entered with type CONFIG_FILE / - CONFIG_DIRECTORY / CONFIG_EXECUTABLE - the item is updated to - reflect to be relative (iff it is relative in the first place) - to the path of the root config file. - - These are not strict rules - it is possible to get other things to - work as well, but the problem is that it very quickly becomes - dependant on 'arbitrariness' in the parsing configuration. - - validate: whether we should validate when complete, that should - typically only be done at the last parsing. - - - define_kw: This a string which can serve as a "#define" for the - parsing. The define_kw keyword should have two arguments - a key - and a value. If the define_kw is present all __subsequent__ - occurences of 'key' are replaced with 'value'. alloc_new_key - is an optinal function (can be NULL) which is used to alloc a new - key, i.e. add leading and trailing 'magic' characters. - - - Example: - -------- - - char * add_angular_brackets(const char * key) { - char * new_key = util_alloc_sprintf("<%s>" , key); - } - - - - config_parse(... , "myDEF" , add_angular_brackets , ...) - - - Config file: - ------------- - myDEF Name BJARNE - myDEF sexual-pref Dogs - ... - ... - PERSON <Name> 28 <sexual-pref> - ... - ------------ - - After parsing we will have an entry: "NAME" , "Bjarne" , "28" , "Dogs". - - The key-value pairs internalized during the config parsing are NOT - returned to the calling scope in any way. -*/ - - -static void config_parse__(config_type * config , - path_stack_type * path_stack , - const char * config_input , - const char * comment_string , - const char * include_kw , - const char * define_kw , - config_schema_unrecognized_enum unrecognized, - bool validate) { - - /* Guard against circular includes. */ - { - char * abs_filename = util_alloc_realpath(config_input); - if (!set_add_key(config->parsed_files , abs_filename)) - util_exit("%s: file:%s already parsed - circular include ? \n",__func__ , abs_filename); - free( abs_filename ); - } - config_path_elm_type * current_path_elm; - - char * config_file; - { - /* Extract the path component of the current input file and chdir() */ - char * config_path; - { - char * config_base; - char * config_ext; - util_alloc_file_components( config_input , &config_path , &config_base , &config_ext); - config_file = util_alloc_filename( NULL , config_base , config_ext ); - free( config_base ); - util_safe_free( config_ext ); - } - current_path_elm = config_add_path_elm( config , config_path ); - path_stack_push_cwd( path_stack ); - if (config_path != NULL) { - util_chdir( config_path ); - free( config_path ); - } - } - - - { - parser_type * parser = parser_alloc(" \t" , "\"", NULL , NULL , "--" , "\n"); - FILE * stream = util_fopen(config_file , "r"); - bool at_eof = false; - - while (!at_eof) { - int active_tokens; - stringlist_type * token_list; - char *line_buffer; - - - line_buffer = util_fscanf_alloc_line(stream , &at_eof); - if (line_buffer != NULL) { - token_list = parser_tokenize_buffer(parser , line_buffer , true); - active_tokens = stringlist_get_size( token_list ); - - /* - util_split_string(line_buffer , " \t" , &tokens , &token_list); - active_tokens = tokens; - for (i = 0; i < tokens; i++) { - char * comment_ptr = NULL; - if(comment_string != NULL) - comment_ptr = strstr(token_list[i] , comment_string); - - if (comment_ptr != NULL) { - if (comment_ptr == token_list[i]) - active_tokens = i; - else - active_tokens = i + 1; - break; - } - } - */ - - if (active_tokens > 0) { - const char * kw = stringlist_iget( token_list , 0 ); - - /*Treating the include keyword. */ - if (include_kw != NULL && (strcmp(include_kw , kw) == 0)) { - if (active_tokens != 2) - util_abort("%s: keyword:%s must have exactly one argument. \n",__func__ ,include_kw); - { - const char *include_file = stringlist_iget( token_list , 1); - if (util_file_exists( include_file )) - config_parse__(config , path_stack , include_file , comment_string , include_kw , define_kw , unrecognized, false); /* Recursive call */ - else - config_error_add(config->parse_errors , util_alloc_sprintf("%s file:%s not found" , include_kw , include_file)); - } - } else if ((define_kw != NULL) && (strcmp(define_kw , kw) == 0)) { - /* Treating the define keyword. */ - if (active_tokens < 3) - util_abort("%s: keyword:%s must have exactly one (or more) arguments. \n",__func__ , define_kw); - { - char * key = util_alloc_string_copy( stringlist_iget(token_list ,1) ); - char * value = stringlist_alloc_joined_substring( token_list , 2 , active_tokens , " "); - - { - char * filtered_value = subst_list_alloc_filtered_string( config->define_list , value); - config_add_define( config , key , filtered_value ); - free( filtered_value ); - } - free(key); - free(value); - } - } else { - if (hash_has_key(config->messages , kw)) - printf("%s \n", (const char *) hash_get(config->messages , kw)); - - if (!config_has_schema_item(config , kw)) { - if (unrecognized == CONFIG_UNRECOGNIZED_WARN) - fprintf(stderr,"** Warning keyword:%s not recognized when parsing:%s --- \n" , kw , config_input); - else if (unrecognized == CONFIG_UNRECOGNIZED_ERROR) - config_error_add(config->parse_errors , util_alloc_sprintf("Keyword:%s is not recognized" , kw)); - - } - - if (config_has_schema_item(config , kw)) { - char * config_cwd; - util_alloc_file_components( config_file , &config_cwd , NULL , NULL ); - - if (!config_has_content_item( config , kw )) - config_add_content_item( config , kw , current_path_elm ); - - { - config_content_item_type * content_item = config_get_content_item( config , kw ); - config_content_item_set_arg__(config , content_item , token_list , current_path_elm , config_file ); - } - } - } - } - stringlist_free(token_list); - free(line_buffer); - } - } - if (validate) - config_validate(config , config_file); - fclose(stream); - parser_free( parser ); - } - free(config_file); - path_stack_pop( path_stack ); - vector_pop_back( config->path_elm_stack ); -} - - - -static void config_set_config_file( config_type * config , const char * config_file ) { - config->config_file = util_realloc_string_copy( config->config_file , config_file ); - util_safe_free(config->abs_path); - config->abs_path = util_alloc_abs_path( config_file ); -} - - -static void config_set_invoke_path( config_type * config ) { - if (config->invoke_path != NULL) - config_root_path_free( config->invoke_path ); - config->invoke_path = config_root_path_alloc( NULL ); -} - - -const char * config_get_config_file( const config_type * config , bool abs_path) { - if (abs_path) - return config->abs_path; - else - return config->config_file; -} - - -void config_fprintf_errors( const config_type * config , bool add_count , FILE * stream ) { - config_error_fprintf( config->parse_errors , add_count , stderr ); -} - - - -bool config_parse(config_type * config , - const char * filename, - const char * comment_string , - const char * include_kw , - const char * define_kw , - config_schema_unrecognized_enum unrecognized_behaviour, - bool validate) { - - if (util_file_readable( filename )) { - path_stack_type * path_stack = path_stack_alloc(); - { - config_set_config_file( config , filename ); - config_set_invoke_path( config ); - config_parse__(config , path_stack , filename , comment_string , include_kw , define_kw , unrecognized_behaviour , validate); - } - path_stack_free( path_stack ); - } else - config_error_add( config->parse_errors , util_alloc_sprintf("Could not open file:%s for parsing" , filename)); - - if (config_error_count( config->parse_errors ) == 0) - return true; // No errors - else - return false; // There were parse errors. -} - - - - -/*****************************************************************/ -/* - Here comes some xxx_get() functions - many of them will fail if - the item has not been added in the right way (this is to ensure that - the xxx_get() request is unambigous. -*/ - - -/** - This function can be used to get the value of a config - parameter. But to ensure that the get is unambigous we set the - following requirements to the item corresponding to 'kw': - - * argc_minmax has been set to 1,1 - - If this is not the case - we die. -*/ - -/** - Assume we installed a key 'KEY' which occurs three times in the final - config file: - - KEY 1 2 3 - KEY 11 22 33 - KEY 111 222 333 - - - Now when accessing these values the occurence variable will - correspond to the linenumber, and the index will index along a line: - - config_iget_as_int( config , "KEY" , 0 , 2) => 3 - config_iget_as_int( config , "KEY" , 2 , 1) => 222 -*/ - - - -bool config_iget_as_bool(const config_type * config , const char * kw, int occurence , int index) { - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_iget_as_bool(item , occurence , index); -} - - -int config_iget_as_int(const config_type * config , const char * kw, int occurence , int index) { - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_iget_as_int(item , occurence , index); -} - - -double config_iget_as_double(const config_type * config , const char * kw, int occurence , int index) { - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_iget_as_double(item , occurence , index); -} - - -/** - As the config_get function, but the argc_minmax requiremnt has been removed. -*/ -const char * config_iget(const config_type * config , const char * kw, int occurence , int index) { - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_iget(item , occurence , index); -} - - - -/** - This function will return NULL is the item has not been set, - however it must be installed with config_add_schema_item(). -*/ -const char * config_safe_iget(const config_type * config , const char *kw, int occurence , int index) { - const char * value = NULL; - - if (config_has_content_item( config , kw )) { - config_content_item_type * item = config_get_content_item(config , kw); - if (occurence < config_content_item_get_size( item )) { - config_content_node_type * node = config_content_item_iget_node( item , occurence ); - value = config_content_node_safe_iget( node , index ); - } - } - return value; -} - - -const stringlist_type * config_iget_stringlist_ref(const config_type * config , const char * kw, int occurence) { - config_content_item_type * item = config_get_content_item(config , kw); - - return config_content_item_iget_stringlist_ref(item , occurence); -} - - -/** - This function allocates a new stringlist containing *ALL* the - arguements for an item. With reference to the illustrated example at - the top the function call: - - config_alloc_complete_strtinglist(config , "KEY1"); - - would produce the list: ("ARG1" "ARG2" "ARG2" "VERBOSE"), i.e. the - arguments for the various occurences of "KEY1" are collapsed to one - stringlist. -*/ - - -stringlist_type * config_alloc_complete_stringlist(const config_type* config , const char * kw) { - bool copy = true; - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_alloc_complete_stringlist(item , copy); -} - - - -/** - In the case the keyword has been mentioned several times the last - occurence will be returned. -*/ -stringlist_type * config_alloc_stringlist(const config_type * config , const char * kw) { - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_alloc_stringlist(item , true); -} - - -/** - Now accepts kw-items which have not been added with append_arg == false. -*/ - -char * config_alloc_joined_string(const config_type * config , const char * kw, const char * sep) { - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_alloc_joined_string(item , sep); -} - - - - - -/** - Return the number of times a keyword has been set - dies on unknown - 'kw'. If the append_arg attribute has been set to false the - function will return 0 or 1 irrespective of how many times the item - has been set in the config file. -*/ - - -int config_get_occurences(const config_type * config, const char * kw) { - if (config_has_content_item( config , kw )) - return config_content_item_get_size(config_get_content_item(config , kw)); - else - return 0; -} - - -int config_get_occurence_size( const config_type * config , const char * kw , int occurence) { - config_content_item_type * item = config_get_content_item(config , kw); - config_content_node_type * node = config_content_item_iget_node( item , occurence ); - return config_content_node_get_size( node ); -} - - - -/** - Allocates a hash table for situations like this: - -ENV PATH /some/path -ENV LD_LIBARRY_PATH /some/other/path -ENV MALLOC STRICT -.... - -the returned hash table will be: {"PATH": "/some/path", "LD_LIBARRY_PATH": "/some/other_path" , "MALLOC": "STRICT"} - -It is enforced that: - - * item is allocated with append_arg = true - * item is allocated with argc_minmax = 2,2 - - The hash takes copy of the values in the hash so the config object - can safefly be freed (opposite if copy == false). -*/ - - -hash_type * config_alloc_hash(const config_type * config , const char * kw) { - bool copy = true; - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_alloc_hash(item , copy); -} - - - - - -/** - This function adds an alias to an existing item; so that the - value+++ of an item can be referred to by two different names. -*/ - - -void config_add_alias(config_type * config , const char * src , const char * alias) { - if (config_has_schema_item(config , src)) { - config_schema_item_type * item = config_get_schema_item(config , src); - config_insert_schema_item(config , alias , item , true); - } else - util_abort("%s: item:%s not recognized \n",__func__ , src); -} - - - -void config_install_message(config_type * config , const char * kw, const char * message) { - hash_insert_hash_owned_ref(config->messages , kw , util_alloc_string_copy(message) , free); -} - - - - -#include "config_get.c" - - diff --git a/ThirdParty/Ert/devel/libconfig/src/config_content.c b/ThirdParty/Ert/devel/libconfig/src/config_content.c new file mode 100644 index 0000000000..507456aa54 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_content.c @@ -0,0 +1,409 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'config_content.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> + +#include <ert/util/type_macros.h> +#include <ert/util/hash.h> +#include <ert/util/set.h> +#include <ert/util/vector.h> +#include <ert/util/subst_list.h> + +#include <ert/config/config_root_path.h> +#include <ert/config/config_path_elm.h> +#include <ert/config/config_content.h> +#include <ert/config/config_content_item.h> +#include <ert/config/config_schema_item.h> +#include <ert/config/config_error.h> + + +#define CONFIG_CONTENT_TYPE_ID 6612520 + +struct config_content_struct { + UTIL_TYPE_ID_DECLARATION; + set_type * parsed_files; /* A set of config files whcih have been parsed - to protect against circular includes. */ + vector_type * nodes; + hash_type * items; + config_error_type * parse_errors; + subst_list_type * define_list; + char * config_file; + char * abs_path; + + config_root_path_type * invoke_path; + vector_type * path_elm_storage; + vector_type * path_elm_stack; + bool valid; +}; + + +UTIL_IS_INSTANCE_FUNCTION( config_content , CONFIG_CONTENT_TYPE_ID ) + +config_content_type * config_content_alloc() { + config_content_type * content = util_malloc( sizeof * content ); + UTIL_TYPE_ID_INIT( content , CONFIG_CONTENT_TYPE_ID ); + content->valid = false; + content->items = hash_alloc(); + content->nodes = vector_alloc_new(); + content->parse_errors = config_error_alloc(); + content->define_list = subst_list_alloc( NULL ); + content->parsed_files = set_alloc_empty(); + + content->path_elm_storage = vector_alloc_new(); + content->path_elm_stack = vector_alloc_new(); + + content->invoke_path = NULL; + content->config_file = NULL; + content->abs_path = NULL; + return content; +} + + +bool config_content_has_item( const config_content_type * content , const char * key) { + return hash_has_key( content->items , key ); +} + + +config_content_item_type * config_content_get_item( const config_content_type * content , const char * key) { + return hash_get( content->items , key ); +} + + +void config_content_add_item( config_content_type * content , const config_schema_item_type * schema_item , const config_path_elm_type * path_elm) { + + const char * kw = config_schema_item_get_kw( schema_item ); + config_content_item_type * content_item = config_content_item_alloc( schema_item , path_elm ); + hash_insert_hash_owned_ref( content->items , kw , content_item , config_content_item_free__ ); + +} + +void config_content_add_node( config_content_type * content , config_content_node_type * content_node ) { + vector_append_ref( content->nodes , content_node ); +} + + +void config_content_set_valid( config_content_type * content) { + content->valid = true; +} + +bool config_content_is_valid( const config_content_type * content ) { + return content->valid; +} + + +config_error_type * config_content_get_errors( const config_content_type * content) { + return content->parse_errors; +} + +void config_content_free( config_content_type * content ) { + vector_free( content->nodes ); + hash_free( content->items ); + config_error_free( content->parse_errors ); + subst_list_free( content->define_list ); + util_safe_free( content->config_file ); + util_safe_free( content->abs_path ); + set_free( content->parsed_files ); + if (content->invoke_path != NULL) + config_root_path_free( content->invoke_path ); + + free( content ); +} + +bool config_content_add_file( config_content_type * content , const char * config_file) { + return set_add_key( content->parsed_files , config_file); +} + +config_root_path_type * config_content_get_invoke_path( config_content_type * content ) { + return content->invoke_path; +} + + +void config_content_set_invoke_path( config_content_type * content) { + if (content->invoke_path != NULL) + config_root_path_free( content->invoke_path ); + content->invoke_path = config_root_path_alloc( NULL ); +} + + + +/*****************************************************************/ + +/* + Here comes some xxx_get() functions - many of them will fail if + the item has not been added in the right way (this is to ensure that + the xxx_get() request is unambigous. +*/ + + +/** + This function can be used to get the value of a config + parameter. But to ensure that the get is unambigous we set the + following requirements to the item corresponding to 'kw': + + * argc_minmax has been set to 1,1 + + If this is not the case - we die. +*/ + +/** + Assume we installed a key 'KEY' which occurs three times in the final + config file: + + KEY 1 2 3 + KEY 11 22 33 + KEY 111 222 333 + + + Now when accessing these values the occurence variable will + correspond to the linenumber, and the index will index along a line: + + config_iget_as_int( config , "KEY" , 0 , 2) => 3 + config_iget_as_int( config , "KEY" , 2 , 1) => 222 +*/ + +const char * config_content_iget( const config_content_type * content , const char * key , int occurence , int index) { + config_content_item_type * item = config_content_get_item(content , key); + return config_content_item_iget(item , occurence , index); +} + + +int config_content_iget_as_int( const config_content_type * content , const char * key , int occurence , int index) { + config_content_item_type * item = config_content_get_item(content , key); + return config_content_item_iget_as_int(item , occurence , index); +} + + +bool config_content_iget_as_bool( const config_content_type * content , const char * key , int occurence , int index) { + config_content_item_type * item = config_content_get_item(content , key); + return config_content_item_iget_as_bool(item , occurence , index); +} + + +double config_content_iget_as_double( const config_content_type * content , const char * key , int occurence , int index) { + config_content_item_type * item = config_content_get_item(content , key); + return config_content_item_iget_as_double(item , occurence , index); +} + + +/** + This function will return NULL is the item has not been set, + however it must be installed with config_add_schema_item(). +*/ + +const char * config_content_safe_iget(const config_content_type * content , const char *kw, int occurence , int index) { + const char * value = NULL; + + if (config_content_has_item( content , kw )) { + config_content_item_type * item = config_content_get_item(content , kw); + if (occurence < config_content_item_get_size( item )) { + config_content_node_type * node = config_content_item_iget_node( item , occurence ); + value = config_content_node_safe_iget( node , index ); + } + } + return value; +} + + +/** + Return the number of times a keyword has been set - dies on unknown + 'kw'. If the append_arg attribute has been set to false the + function will return 0 or 1 irrespective of how many times the item + has been set in the config file. +*/ + + +int config_content_get_occurences(const config_content_type * content, const char * kw) { + if (config_content_has_item( content , kw )) + return config_content_item_get_size( config_content_get_item(content , kw) ); + else + return 0; +} + + + +const config_content_node_type * config_content_iget_node( const config_content_type * content , int index) { + const config_content_node_type * node = vector_iget_const(content->nodes , index ); + return node; +} + + +int config_content_get_size(const config_content_type * content) { + return vector_get_size( content->nodes ); +} + +/*****************************************************************/ +/* All the get_value functions will operate on the last item which has + been set with a particular key value. So assuming the config file + looks like: + + KEY VALUE1 + KEY VALUE2 OPTIONAL + KEY 100 VALUE3 OPTIONAL ERROR + + these functions will all operate on the last line in the config file: + + KEY 100 VALUE3 OPTIONAL ERROR +*/ + + + +static config_content_node_type * config_content_get_value_node__( const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node( config , kw ); + if (node == NULL) + util_abort("Tried to get value node from unset kw:%s \n",__func__ , kw ); + + return node; +} + +config_content_node_type * config_content_get_value_node( const config_content_type * content , const char * kw) { + config_content_item_type * item = config_content_get_item(content , kw); + config_content_node_type * node = config_content_item_get_last_node( item ); + config_content_node_assert_key_value( node ); + return node; +} + + +bool config_content_get_value_as_bool(const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node__( config , kw ); + return config_content_node_iget_as_bool(node , 0); +} + +int config_content_get_value_as_int(const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node__( config , kw ); + return config_content_node_iget_as_int(node , 0); +} + +double config_content_get_value_as_double(const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node__( config , kw ); + return config_content_node_iget_as_double(node , 0); +} + +const char * config_content_get_value_as_path( const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node__( config , kw ); + return config_content_node_iget_as_path(node , 0); +} + +const char * config_content_get_value_as_abspath( const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node__( config , kw ); + return config_content_node_iget_as_abspath(node , 0); +} + +const char * config_content_get_value_as_relpath( const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node__( config , kw ); + return config_content_node_iget_as_relpath(node , 0); +} + + +const char * config_content_get_value(const config_content_type * config , const char * kw) { + config_content_node_type * node = config_content_get_value_node__( config , kw ); + return config_content_node_iget(node , 0); +} + +/*****************************************************************/ + +char * config_content_alloc_joined_string(const config_content_type * content , const char * kw, const char * sep) { + config_content_item_type * item = config_content_get_item(content , kw); + return config_content_item_alloc_joined_string(item , sep); +} + + +/** + This function allocates a new stringlist containing *ALL* the + arguements for an item. With reference to the illustrated example at + the top the function call: + + config_alloc_complete_strtinglist(config , "KEY1"); + + would produce the list: ("ARG1" "ARG2" "ARG2" "VERBOSE"), i.e. the + arguments for the various occurences of "KEY1" are collapsed to one + stringlist. +*/ + + +stringlist_type * config_content_alloc_complete_stringlist(const config_content_type * content , const char * kw) { + bool copy = true; + config_content_item_type * item = config_content_get_item(content , kw); + return config_content_item_alloc_complete_stringlist(item , copy); +} + + + +const stringlist_type * config_content_iget_stringlist_ref(const config_content_type * content , const char * kw, int occurence) { + config_content_item_type * item = config_content_get_item(content , kw); + + return config_content_item_iget_stringlist_ref(item , occurence); +} + +void config_content_add_define( config_content_type * content , const char * key , const char * value ) { + subst_list_append_copy( content->define_list , key , value , NULL ); +} + +subst_list_type * config_content_get_define_list( config_content_type * content ) { + return content->define_list; +} + + +/*****************************************************************/ + +void config_content_set_config_file( config_content_type * content , const char * config_file ) { + content->config_file = util_realloc_string_copy( content->config_file , config_file ); + + util_safe_free(content->abs_path); + content->abs_path = util_alloc_abs_path( config_file ); +} + + + +const char * config_content_get_config_file( const config_content_type * content , bool abs_path ) { + if (abs_path) + return content->abs_path; + else + return content->config_file; +} + + +config_path_elm_type * config_content_add_path_elm( config_content_type * content , const char * path ) { + const config_path_elm_type * current_path_elm; + + if (vector_get_size( content->path_elm_stack ) == 0) + current_path_elm = NULL; + else + current_path_elm = vector_get_last_const(content->path_elm_stack); + + { + config_path_elm_type * new_path_elm; + + { + char * rel_path = NULL; + config_root_path_type * invoke_path = config_content_get_invoke_path( content ); + if (path != NULL) { + if (current_path_elm == NULL) + rel_path = util_alloc_rel_path( config_root_path_get_abs_path(invoke_path) , path); + else + rel_path = config_path_elm_alloc_relpath( current_path_elm , path ); + } + new_path_elm = config_path_elm_alloc( invoke_path , rel_path ); + util_safe_free( rel_path ); + } + vector_append_owned_ref( content->path_elm_storage , new_path_elm , config_path_elm_free__); + vector_append_ref( content->path_elm_stack , new_path_elm ); + return new_path_elm; + } +} + +void config_content_pop_path_stack( config_content_type * content ) { + vector_pop_back( content->path_elm_stack ); +} diff --git a/ThirdParty/Ert/devel/libconfig/src/config_content_item.c b/ThirdParty/Ert/devel/libconfig/src/config_content_item.c index f07c1da2de..b6d4873f30 100644 --- a/ThirdParty/Ert/devel/libconfig/src/config_content_item.c +++ b/ThirdParty/Ert/devel/libconfig/src/config_content_item.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'config_content_item.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_content_item.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -53,7 +53,7 @@ struct config_content_item_struct { config_content_item_get_occurences( "KEY1" ) - will return 2. + will return 2. */ @@ -81,7 +81,7 @@ const config_content_node_type * config_content_item_iget_node_const(const confi char * config_content_item_ialloc_joined_string(const config_content_item_type * item , const char * sep , int occurence) { - const config_content_node_type * node = config_content_item_iget_node(item , occurence); + const config_content_node_type * node = config_content_item_iget_node(item , occurence); return config_content_node_alloc_joined_string(node , sep); } @@ -90,7 +90,7 @@ char * config_content_item_ialloc_joined_string(const config_content_item_type * char * config_content_item_alloc_joined_string(const config_content_item_type * item , const char * sep) { const int occurences = config_content_item_get_size( item ); char * joined_string = NULL; - + for (int i =0; i < occurences ; i++) { char * element = config_content_item_ialloc_joined_string(item , sep , i); joined_string = util_strcat_realloc( joined_string , element); @@ -98,18 +98,18 @@ char * config_content_item_alloc_joined_string(const config_content_item_type * joined_string = util_strcat_realloc( joined_string , sep ); free( element ); } - + return joined_string; } const stringlist_type * config_content_item_iget_stringlist_ref(const config_content_item_type * item, int occurence) { - const config_content_node_type * node = config_content_item_iget_node(item , occurence); + const config_content_node_type * node = config_content_item_iget_node(item , occurence); return config_content_node_get_stringlist( node ); } const stringlist_type * config_content_item_get_stringlist_ref(const config_content_item_type * item) { - const config_content_node_type * node = config_content_item_get_last_node( item ); + const config_content_node_type * node = config_content_item_get_last_node( item ); return config_content_node_get_stringlist( node ); } @@ -125,12 +125,12 @@ stringlist_type * config_content_item_alloc_complete_stringlist(const config_con for (inode = 0; inode < vector_get_size( item->nodes ); inode++) { const config_content_node_type * node = config_content_item_iget_node(item , inode); const stringlist_type * src_list = config_content_node_get_stringlist( node ); - + if (copy) stringlist_append_stringlist_copy( stringlist , src_list ); else - stringlist_append_stringlist_ref( stringlist , src_list ); - + stringlist_append_stringlist_ref( stringlist , src_list ); + } return stringlist; @@ -146,12 +146,12 @@ stringlist_type * config_content_item_alloc_stringlist(const config_content_item const config_content_node_type * node = config_content_item_get_last_node( item ); stringlist_type * stringlist = stringlist_alloc_new(); const stringlist_type * src_list = config_content_node_get_stringlist( node ); - + if (copy) stringlist_append_stringlist_copy( stringlist , src_list ); else - stringlist_append_stringlist_ref( stringlist , src_list ); - + stringlist_append_stringlist_ref( stringlist , src_list ); + return stringlist; } @@ -170,15 +170,15 @@ hash_type * config_content_item_alloc_hash(const config_content_item_type * item const stringlist_type * src_list = config_content_node_get_stringlist( node ); const char * key = stringlist_iget(src_list , 0); const char * value = stringlist_iget(src_list , 1); - + if (copy) { - hash_insert_hash_owned_ref(hash , + hash_insert_hash_owned_ref(hash , key , - util_alloc_string_copy(value) , + util_alloc_string_copy(value) , free); } else hash_insert_ref(hash , key , value ); - + } } return hash; @@ -191,7 +191,7 @@ hash_type * config_content_item_alloc_hash(const config_content_item_type * item const char * config_content_item_iget(const config_content_item_type * item , int occurence , int index) { - const config_content_node_type * node = config_content_item_iget_node(item , occurence); + const config_content_node_type * node = config_content_item_iget_node(item , occurence); const stringlist_type * src_list = config_content_node_get_stringlist( node ); return stringlist_iget( src_list , index ); } @@ -228,7 +228,7 @@ double config_content_item_iget_as_double(const config_content_item_type * item OPTION V1 OPTION V2 V3 V4 - OPTION __RESET__ + OPTION __RESET__ OPTION V6 In this case OPTION will get the value 'V6'. The example given @@ -250,8 +250,8 @@ void config_content_item_free( config_content_item_type * item ) { -UTIL_SAFE_CAST_FUNCTION( config_content_item , CONFIG_CONTENT_ITEM_ID); - +UTIL_SAFE_CAST_FUNCTION( config_content_item , CONFIG_CONTENT_ITEM_ID) +UTIL_IS_INSTANCE_FUNCTION( config_content_item , CONFIG_CONTENT_ITEM_ID) void config_content_item_free__( void * arg ) { diff --git a/ThirdParty/Ert/devel/libconfig/src/config_content_node.c b/ThirdParty/Ert/devel/libconfig/src/config_content_node.c index d7015802bc..5966a6120f 100644 --- a/ThirdParty/Ert/devel/libconfig/src/config_content_node.c +++ b/ThirdParty/Ert/devel/libconfig/src/config_content_node.c @@ -111,6 +111,11 @@ const char * config_content_node_safe_iget(const config_content_node_type * node } +config_item_types config_content_node_iget_type( const config_content_node_type * node , int index) { + return config_schema_item_iget_type( node->schema , index ); +} + + bool config_content_node_iget_as_bool(const config_content_node_type * node , int index) { bool value; config_schema_item_assure_type(node->schema , index , CONFIG_BOOL); diff --git a/ThirdParty/Ert/devel/libconfig/src/config_error.c b/ThirdParty/Ert/devel/libconfig/src/config_error.c index 2bd344ff96..9924e94b62 100644 --- a/ThirdParty/Ert/devel/libconfig/src/config_error.c +++ b/ThirdParty/Ert/devel/libconfig/src/config_error.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'config_error.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_error.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdio.h> @@ -54,7 +54,7 @@ void config_error_free( config_error_type * error ) { void config_error_add( config_error_type * error , char * new_error) { - stringlist_append_owned_ref( error->error_list , new_error ); + stringlist_append_copy( error->error_list , new_error ); } @@ -78,9 +78,9 @@ void config_error_fprintf( const config_error_type * error , bool add_count , FI int error_nr; for (error_nr = 0; error_nr < stringlist_get_size( error->error_list ); error_nr++) { - if (add_count) + if (add_count) fprintf(stream , " %02d: " , error_nr); - + fprintf( stream , "%s\n" , stringlist_iget( error->error_list , error_nr)); } } diff --git a/ThirdParty/Ert/devel/libconfig/src/config_get.c b/ThirdParty/Ert/devel/libconfig/src/config_get.c index 6c18e882e1..ea331b7c06 100644 --- a/ThirdParty/Ert/devel/libconfig/src/config_get.c +++ b/ThirdParty/Ert/devel/libconfig/src/config_get.c @@ -32,7 +32,7 @@ */ -config_content_node_type * config_get_value_node( const config_type * config , const char * kw) { +/*config_content_node_type * config_get_value_node( const config_parser_type * config , const char * kw) { config_content_item_type * item = config_get_content_item(config , kw); if (item != NULL) { config_content_node_type * node = config_content_item_get_last_node( item ); @@ -42,7 +42,7 @@ config_content_node_type * config_get_value_node( const config_type * config , c return NULL; // Will return NULL on unset keywords - must check NULL return value?! } -static config_content_node_type * config_get_value_node__( const config_type * config , const char * kw) { +static config_content_node_type * config_get_value_node__( const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node( config , kw ); if (node == NULL) util_abort("Tried to get value node from unset kw:%s \n",__func__ , kw ); @@ -50,65 +50,54 @@ static config_content_node_type * config_get_value_node__( const config_type * c return node; } -bool config_get_value_as_bool(const config_type * config , const char * kw) { +bool config_get_value_as_bool(const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node__( config , kw ); return config_content_node_iget_as_bool(node , 0); } -int config_get_value_as_int(const config_type * config , const char * kw) { +int config_get_value_as_int(const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node__( config , kw ); return config_content_node_iget_as_int(node , 0); } -double config_get_value_as_double(const config_type * config , const char * kw) { +double config_get_value_as_double(const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node__( config , kw ); return config_content_node_iget_as_double(node , 0); } -const char * config_get_value_as_path( const config_type * config , const char * kw) { +const char * config_get_value_as_path( const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node__( config , kw ); return config_content_node_iget_as_path(node , 0); } -const char * config_get_value_as_abspath( const config_type * config , const char * kw) { +const char * config_get_value_as_abspath( const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node__( config , kw ); return config_content_node_iget_as_abspath(node , 0); } -const char * config_get_value_as_relpath( const config_type * config , const char * kw) { +const char * config_get_value_as_relpath( const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node__( config , kw ); return config_content_node_iget_as_relpath(node , 0); } -const char * config_get_value(const config_type * config , const char * kw) { +const char * config_get_value(const config_parser_type * config , const char * kw) { config_content_node_type * node = config_get_value_node__( config , kw ); return config_content_node_iget(node , 0); } - +*/ /*****************************************************************/ -int config_get_content_size( const config_type * config ) { - return vector_get_size(config->content_list); -} -const config_content_node_type * config_iget_content_node( const config_type * config , int index) { - return vector_iget_const( config->content_list , index ); -} - - -int config_get_schema_size( const config_type * config ) { +int config_get_schema_size( const config_parser_type * config ) { return hash_get_size( config->schema_items ); } -config_error_type * config_get_errors( const config_type * config ) { - return config->parse_errors; -} diff --git a/ThirdParty/Ert/devel/libconfig/src/config_parser.c b/ThirdParty/Ert/devel/libconfig/src/config_parser.c new file mode 100644 index 0000000000..fce75df223 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_parser.c @@ -0,0 +1,698 @@ +/* + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> +#include <stdio.h> +#include <unistd.h> + +#include <ert/util/type_macros.h> +#include <ert/util/util.h> +#include <ert/util/parser.h> +#include <ert/util/hash.h> +#include <ert/util/stringlist.h> +#include <ert/util/subst_list.h> +#include <ert/util/vector.h> +#include <ert/util/path_stack.h> + +#include <ert/config/config_parser.h> +#include <ert/config/config_error.h> +#include <ert/config/config_schema_item.h> +#include <ert/config/config_content_node.h> +#include <ert/config/config_content_item.h> +#include <ert/config/config_path_elm.h> +#include <ert/config/config_root_path.h> + +#define CLEAR_STRING "__RESET__" + + + +/** +Structure to parse configuration files of this type: + +KEYWORD1 ARG2 ARG2 ARG3 +KEYWORD2 ARG1-2 +.... +KEYWORDN ARG1 ARG2 + +A keyword can occure many times. + +*/ + + + +/** + + + ============================= + | config_type object | + | | + | Contains 'all' the | + | configuration information.| + | | + ============================= + | | + | \________________________ + | \ + KEY1 KEY2 + | | + \|/ \|/ + ========================= ========================= + | config_item object | | config_item object | + | | | | + | Indexed by a keyword | | Indexed by a keyword | + | which is the first | | which is the first | + | string in the | | string in the | + | config file. | | config file. | + | | | | + ========================= ========================= + | | | + | | | + \|/ \|/ \|/ +============================ ============================ ============================ +| config_item_node object | | config_item_node object | | config_item_node object | +| | | | | | +| Only containing the | | Only containing the | | Only containing the | +| stringlist object | | stringlist object | | stringlist object | +| directly parsed from the | | directly parsed from the | | directly parsed from the | +| file. | | file. | | file. | +|--------------------------| |--------------------------| |--------------------------| +| ARG1 ARG2 ARG3 | | VERBOSE | | DEBUG | +============================ ============================ ============================ + + +The example illustrated above would correspond to the following config +file (invariant under line-permutations): + +KEY1 ARG1 ARG2 ARG3 +KEY1 VERBOSE +KEY2 DEBUG + + +Example config file(2): + +OUTFILE filename +INPUT filename +OPTIONS store +OPTIONS verbose +OPTIONS optimize cache=1 + +In this case the whole config object will contain three items, +corresponding to the keywords OUTFILE, INPUT and OPTIONS. The two +first will again only contain one node each, whereas the OPTIONS item +will contain three nodes, corresponding to the three times the keyword +"OPTIONS" appear in the config file. +*/ + + + + + + + + + + + +struct config_parser_struct { + hash_type * schema_items; + hash_type * messages; /* Can print a (warning) message when a keyword is encountered. */ +}; + + + + + + + + + + + + + + + + + + +/* + The last argument (config_file) is only used for printing + informative error messages, and can be NULL. The config_cwd is + essential if we are looking up a filename, otherwise it can be NULL. + + Returns a string with an error description, or NULL if the supplied + arguments were OK. The string is allocated here, but is assumed that + calling scope will free it. +*/ + +static config_content_node_type * config_content_item_set_arg__(subst_list_type * define_list , + config_error_type * parse_errors , + config_content_item_type * item , + stringlist_type * token_list , + const config_path_elm_type * path_elm , + const char * config_file ) { + + config_content_node_type * new_node = NULL; + int argc = stringlist_get_size( token_list ) - 1; + + if (argc == 1 && (strcmp(stringlist_iget(token_list , 1) , CLEAR_STRING) == 0)) { + config_content_item_clear(item); + } else { + const config_schema_item_type * schema_item = config_content_item_get_schema( item ); + + /* Filtering based on DEFINE statements */ + if (subst_list_get_size( define_list ) > 0) { + int iarg; + for (iarg = 0; iarg < argc; iarg++) { + char * filtered_copy = subst_list_alloc_filtered_string( define_list , stringlist_iget(token_list , iarg + 1)); + stringlist_iset_owned_ref( token_list , iarg + 1 , filtered_copy); + } + } + + + /* Filtering based on environment variables */ + if (config_schema_item_expand_envvar( schema_item )) { + int iarg; + for (iarg = 0; iarg < argc; iarg++) { + int env_offset = 0; + char * env_var; + do { + env_var = util_isscanf_alloc_envvar( stringlist_iget(token_list , iarg + 1) , env_offset ); + if (env_var != NULL) { + const char * env_value = getenv( &env_var[1] ); + if (env_value != NULL) { + char * new_value = util_string_replace_alloc( stringlist_iget( token_list , iarg + 1 ) , env_var , env_value ); + stringlist_iset_owned_ref( token_list , iarg + 1 , new_value ); + } else { + env_offset += 1; + fprintf(stderr,"** Warning: environment variable: %s is not defined \n", env_var); + } + } + } while (env_var != NULL); + } + } + + { + if (config_schema_item_validate_set(schema_item , token_list , config_file, path_elm , parse_errors)) { + new_node = config_content_item_alloc_node( item , config_content_item_get_path_elm( item )); + config_content_node_set(new_node , token_list); + } + } + } + return new_node; +} + + + + + +/*****************************************************************/ + + + +config_parser_type * config_alloc() { + config_parser_type *config = util_malloc(sizeof * config ); + config->schema_items = hash_alloc(); + config->messages = hash_alloc(); + return config; +} + + + + + + + + + + +void config_free(config_parser_type * config) { + + hash_free(config->schema_items); + hash_free(config->messages); + + free(config); +} + + + +static void config_insert_schema_item(config_parser_type * config , const char * kw , const config_schema_item_type * item , bool ref) { + if (ref) + hash_insert_ref(config->schema_items , kw , item); + else + hash_insert_hash_owned_ref(config->schema_items , kw , item , config_schema_item_free__); +} + + +/** + This function allocates a simple item with all values + defaulted. The item is added to the config object, and a pointer is + returned to the calling scope. If you want to change the properties + of the item you can do that with config_schema_item_set_xxxx() functions + from the calling scope. +*/ + + +config_schema_item_type * config_add_schema_item(config_parser_type * config , + const char * kw, + bool required) { + + config_schema_item_type * item = config_schema_item_alloc( kw , required ); + config_insert_schema_item(config , kw , item , false); + return item; +} + + + +/** + This is a minor wrapper for adding an item with the properties. + + 1. It has argc_minmax = {1,1} + + The value can than be extracted with config_get_value() and + config_get_value_as_xxxx functions. +*/ + +config_schema_item_type * config_add_key_value( config_parser_type * config , const char * key , bool required , config_item_types item_type) { + config_schema_item_type * item = config_add_schema_item( config , key , required ); + config_schema_item_set_argc_minmax( item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , item_type ); + return item; +} + + + +bool config_has_schema_item(const config_parser_type * config , const char * kw) { + return hash_has_key(config->schema_items , kw); +} + + +config_schema_item_type * config_get_schema_item(const config_parser_type * config , const char * kw) { + return hash_get(config->schema_items , kw); +} + +/* + Due to the possibility of aliases we must go through the canonical + keyword which is internalized in the schema_item. +*/ + + + + + + + + + +static void config_validate_content_item(const config_parser_type * config , config_content_type * content , const config_content_item_type * item) { + const config_schema_item_type * schema_item = config_content_item_get_schema( item ); + const char * schema_kw = config_schema_item_get_kw( schema_item ); + + { + int i; + for (i = 0; i < config_schema_item_num_required_children(schema_item); i++) { + const char * required_child = config_schema_item_iget_required_child( schema_item , i ); + if (!config_content_has_item(content , required_child)) { + char * error_message = util_alloc_sprintf("When:%s is set - you also must set:%s.",schema_kw , required_child); + config_error_add( config_content_get_errors( content ) , error_message ); + free( error_message ); + } + } + + if (config_schema_item_has_required_children_value( schema_item )) { + int inode; + for (inode = 0; inode < config_content_item_get_size(item); inode++) { + config_content_node_type * node = config_content_item_iget_node(item , inode); + const stringlist_type * values = config_content_node_get_stringlist( node ); + int is; + + for (is = 0; is < stringlist_get_size(values); is++) { + const char * value = stringlist_iget(values , is); + stringlist_type * required_children = config_schema_item_get_required_children_value( schema_item , value ); + + if (required_children != NULL) { + int ic; + for (ic = 0; ic < stringlist_get_size( required_children ); ic++) { + const char * req_child = stringlist_iget( required_children , ic ); + if (!config_content_has_item(content , req_child )) { + char * error_message = util_alloc_sprintf("When:%s is set to:%s - you also must set:%s.",schema_kw , value , req_child ); + config_error_add( config_content_get_errors( content ) , error_message ); + free( error_message ); + } + } + } + } + } + } + } +} + + + +static void config_validate(config_parser_type * config, config_content_type * content , const char * filename) { + int size = hash_get_size(config->schema_items); + char ** key_list = hash_alloc_keylist(config->schema_items); + int ikey; + for (ikey = 0; ikey < size; ikey++) { + const config_schema_item_type * schema_item = config_get_schema_item( config , key_list[ikey]); + const char * content_key = config_schema_item_get_kw( schema_item ); + if (config_content_has_item( content , content_key)) { + const config_content_item_type * item = config_content_get_item(content , content_key); + config_validate_content_item(config , content , item ); + } else { + if (config_schema_item_required( schema_item)) { /* The item is not set ... */ + char * error_message = util_alloc_sprintf("Item:%s must be set - parsing:%s",content_key , config_content_get_config_file( content , true )); + config_error_add( config_content_get_errors( content ) , error_message ); + free( error_message ); + } + } + } + util_free_stringlist(key_list , size); +} + + + + + + + +/** + This function parses the config file 'filename', and updated the + internal state of the config object as parsing proceeds. If + comment_string != NULL everything following 'comment_string' on a + line is discarded. + + include_kw is a string identifier for an include functionality, if + an include is encountered, the included file is parsed immediately + (through a recursive call to config_parse__). if include_kw == NULL, + include files are not supported. + + Observe that use of include, relative paths and all that shit is + quite tricky. The following is currently implemented: + + 1. The front_end function will split the path to the config file + in a path_name component and a file component. + + 2. Recursive calls to config_parse__() will keep control of the + parsers notion of cwd (note that the real OS'wise cwd never + changes), and every item is tagged with the config_cwd + currently active. + + 3. When an item has been entered with type CONFIG_FILE / + CONFIG_DIRECTORY / CONFIG_EXECUTABLE - the item is updated to + reflect to be relative (iff it is relative in the first place) + to the path of the root config file. + + These are not strict rules - it is possible to get other things to + work as well, but the problem is that it very quickly becomes + dependant on 'arbitrariness' in the parsing configuration. + + validate: whether we should validate when complete, that should + typically only be done at the last parsing. + + + define_kw: This a string which can serve as a "#define" for the + parsing. The define_kw keyword should have two arguments - a key + and a value. If the define_kw is present all __subsequent__ + occurences of 'key' are replaced with 'value'. alloc_new_key + is an optinal function (can be NULL) which is used to alloc a new + key, i.e. add leading and trailing 'magic' characters. + + + Example: + -------- + + char * add_angular_brackets(const char * key) { + char * new_key = util_alloc_sprintf("<%s>" , key); + } + + + + config_parse(... , "myDEF" , add_angular_brackets , ...) + + + Config file: + ------------- + myDEF Name BJARNE + myDEF sexual-pref Dogs + ... + ... + PERSON <Name> 28 <sexual-pref> + ... + ------------ + + After parsing we will have an entry: "NAME" , "Bjarne" , "28" , "Dogs". + + The key-value pairs internalized during the config parsing are NOT + returned to the calling scope in any way. +*/ + + +static void config_parse__(config_parser_type * config , + config_content_type * content , + path_stack_type * path_stack , + const char * config_input , + const char * comment_string , + const char * include_kw , + const char * define_kw , + config_schema_unrecognized_enum unrecognized, + bool validate) { + + /* Guard against circular includes. */ + { + char * abs_filename = util_alloc_realpath(config_input); + if (!config_content_add_file( content , abs_filename )) + util_exit("%s: file:%s already parsed - circular include ? \n",__func__ , abs_filename); + free( abs_filename ); + } + config_path_elm_type * current_path_elm; + + char * config_file; + { + /* Extract the path component of the current input file and chdir() */ + char * config_path; + { + char * config_base; + char * config_ext; + util_alloc_file_components( config_input , &config_path , &config_base , &config_ext); + config_file = util_alloc_filename( NULL , config_base , config_ext ); + free( config_base ); + util_safe_free( config_ext ); + } + current_path_elm = config_content_add_path_elm( content , config_path ); + path_stack_push_cwd( path_stack ); + if (config_path != NULL) { + util_chdir( config_path ); + free( config_path ); + } + } + + + { + const char * comment_end = comment_string ? "\n" : NULL; + basic_parser_type * parser = basic_parser_alloc(" \t" , "\"", NULL , NULL , comment_string , comment_end); + FILE * stream = util_fopen(config_file , "r"); + bool at_eof = false; + + while (!at_eof) { + int active_tokens; + stringlist_type * token_list; + char *line_buffer; + + + line_buffer = util_fscanf_alloc_line(stream , &at_eof); + if (line_buffer != NULL) { + token_list = basic_parser_tokenize_buffer(parser , line_buffer , true); + active_tokens = stringlist_get_size( token_list ); + + /* + util_split_string(line_buffer , " \t" , &tokens , &token_list); + active_tokens = tokens; + for (i = 0; i < tokens; i++) { + char * comment_ptr = NULL; + if(comment_string != NULL) + comment_ptr = strstr(token_list[i] , comment_string); + + if (comment_ptr != NULL) { + if (comment_ptr == token_list[i]) + active_tokens = i; + else + active_tokens = i + 1; + break; + } + } + */ + + if (active_tokens > 0) { + const char * kw = stringlist_iget( token_list , 0 ); + + /*Treating the include keyword. */ + if (include_kw != NULL && (strcmp(include_kw , kw) == 0)) { + if (active_tokens != 2) + util_abort("%s: keyword:%s must have exactly one argument. \n",__func__ ,include_kw); + { + const char *include_file = stringlist_iget( token_list , 1); + if (util_file_exists( include_file )) + config_parse__(config , content , path_stack , include_file , comment_string , include_kw , define_kw , unrecognized, false); /* Recursive call */ + else { + char * error_message = util_alloc_sprintf("%s file:%s not found" , include_kw , include_file); + config_error_add( config_content_get_errors( content ) , error_message ); + free( error_message ); + } + } + } else if ((define_kw != NULL) && (strcmp(define_kw , kw) == 0)) { + /* Treating the define keyword. */ + if (active_tokens < 3) + util_abort("%s: keyword:%s must have exactly one (or more) arguments. \n",__func__ , define_kw); + { + char * key = util_alloc_string_copy( stringlist_iget(token_list ,1) ); + char * value = stringlist_alloc_joined_substring( token_list , 2 , active_tokens , " "); + + { + char * filtered_value = subst_list_alloc_filtered_string( config_content_get_define_list( content ) , value); + config_content_add_define( content , key , filtered_value ); + free( filtered_value ); + } + free(key); + free(value); + } + } else { + if (hash_has_key(config->messages , kw)) + printf("%s \n", (const char *) hash_get(config->messages , kw)); + + if (!config_has_schema_item(config , kw)) { + if (unrecognized == CONFIG_UNRECOGNIZED_WARN) + fprintf(stderr,"** Warning keyword:%s not recognized when parsing:%s --- \n" , kw , config_input); + else if (unrecognized == CONFIG_UNRECOGNIZED_ERROR) { + char * error_message = util_alloc_sprintf("Keyword:%s is not recognized" , kw); + config_error_add( config_content_get_errors( content ) , error_message ); + free( error_message ); + } + } + + if (config_has_schema_item(config , kw)) { + config_schema_item_type * schema_item = config_get_schema_item( config , kw ); + char * config_cwd; + util_alloc_file_components( config_file , &config_cwd , NULL , NULL ); + + if (!config_content_has_item( content , kw )) + config_content_add_item( content , schema_item , current_path_elm); + + + { + subst_list_type * define_list = config_content_get_define_list( content ); + config_content_item_type * content_item = config_content_get_item( content , config_schema_item_get_kw( schema_item ) ); + config_content_node_type * new_node = config_content_item_set_arg__(define_list , config_content_get_errors( content ) , content_item , token_list , current_path_elm , config_file ); + if (new_node) + config_content_add_node( content , new_node ); + + } + } + } + } + stringlist_free(token_list); + free(line_buffer); + } + } + if (validate) + config_validate(config , content , config_file); + fclose(stream); + basic_parser_free( parser ); + } + free(config_file); + path_stack_pop( path_stack ); + config_content_pop_path_stack( content ); +} + + + + + + + + + + + + +config_content_type * config_parse(config_parser_type * config , + const char * filename, + const char * comment_string , + const char * include_kw , + const char * define_kw , + config_schema_unrecognized_enum unrecognized_behaviour, + bool validate) { + + config_content_type * content = config_content_alloc( ); + + if (util_file_readable( filename )) { + path_stack_type * path_stack = path_stack_alloc(); + { + config_content_set_config_file( content , filename ); + config_content_set_invoke_path( content ); + config_parse__(config , content , path_stack , filename , comment_string , include_kw , define_kw , unrecognized_behaviour , validate); + } + path_stack_free( path_stack ); + } else { + char * error_message = util_alloc_sprintf("Could not open file:%s for parsing" , filename); + config_error_add( config_content_get_errors( content ) , error_message ); + free( error_message ); + } + + if (config_error_count( config_content_get_errors( content ) ) == 0) + config_content_set_valid( content ); + + return content; +} + + + + +/*****************************************************************/ + + + + +/** + This function adds an alias to an existing item; so that the + value+++ of an item can be referred to by two different names. +*/ + + +void config_add_alias(config_parser_type * config , const char * src , const char * alias) { + if (config_has_schema_item(config , src)) { + config_schema_item_type * item = config_get_schema_item(config , src); + config_insert_schema_item(config , alias , item , true); + } else + util_abort("%s: item:%s not recognized \n",__func__ , src); +} + + + +void config_install_message(config_parser_type * config , const char * kw, const char * message) { + hash_insert_hash_owned_ref(config->messages , kw , util_alloc_string_copy(message) , free); +} + + + + +#include "config_get.c" + + diff --git a/ThirdParty/Ert/devel/libconfig/src/config_schema_item.c b/ThirdParty/Ert/devel/libconfig/src/config_schema_item.c index 9970967fb5..2934d8a498 100644 --- a/ThirdParty/Ert/devel/libconfig/src/config_schema_item.c +++ b/ThirdParty/Ert/devel/libconfig/src/config_schema_item.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'config_schema_item.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_schema_item.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -36,7 +36,7 @@ typedef struct validate_struct validate_type; -/** +/** This is a 'support-struct' holding various pieces of information needed during the validation process. Observe the following about validation: @@ -51,10 +51,10 @@ typedef struct validate_struct validate_type; 2. Validation is a two-step process, the first step is run when an item is parsed. This includes checking: - o The number of argument. + o The number of argument. o That the arguments have the right type. o That the values match the selection set. - + The second validation step is done when the pasing is complete, in this pass we check dependencies - i.e. required_children and required_children_on_value. @@ -69,11 +69,11 @@ typedef struct validate_struct validate_type; argc_max first. */ - + struct validate_struct { int argc_min; /* The minimum number of arguments: -1 means no lower limit. */ - int argc_max; /* The maximum number of arguments: -1 means no upper limit. */ - set_type * common_selection_set; /* A selection set which will apply uniformly to all the arguments. */ + int argc_max; /* The maximum number of arguments: -1 means no upper limit. */ + set_type * common_selection_set; /* A selection set which will apply uniformly to all the arguments. */ set_type ** indexed_selection_set; /* A selection set which will apply for specifi (indexed) arguments. */ int_vector_type * type_map; /* A list of types for the items. Set along with argc_minmax(); */ stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */ @@ -88,13 +88,13 @@ struct validate_struct { struct config_schema_item_struct { UTIL_TYPE_ID_DECLARATION; char * kw; /* The kw which identifies this item· */ - - bool required_set; + + bool required_set; stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */ hash_type * required_children_value; /* A list of item's which must also be set - depending on the value of this item. (can be NULL) */ - validate_type * validate; /* Information need during validation. */ - bool expand_envvar; /* Should environment variables like $HOME be expanded?*/ + validate_type * validate; /* Information need during validation. */ + bool expand_envvar; /* Should environment variables like $HOME be expanded?*/ }; @@ -114,7 +114,7 @@ static validate_type * validate_alloc() { validate->indexed_selection_set = NULL; validate->required_children = NULL; validate->required_children_value = NULL; - validate->type_map = int_vector_alloc(0 , 0); + validate->type_map = int_vector_alloc(0 , 0); validate_set_default_type( validate , CONFIG_STRING ); return validate; } @@ -128,7 +128,7 @@ static void validate_free(validate_type * validate) { set_free(validate->indexed_selection_set[i]); free(validate->indexed_selection_set); } - + int_vector_free( validate->type_map ); if (validate->required_children != NULL) stringlist_free(validate->required_children); if (validate->required_children_value != NULL) hash_free(validate->required_children_value); @@ -142,27 +142,27 @@ static void validate_iset_type( validate_type * validate , int index , config_it static config_item_types validate_iget_type( const validate_type * validate , int index) { - return int_vector_safe_iget( validate->type_map , index ); + return int_vector_safe_iget( validate->type_map , index ); } static void validate_set_argc_minmax(validate_type * validate , int argc_min , int argc_max) { if (validate->argc_min != CONFIG_DEFAULT_ARG_MIN) util_abort("%s: sorry - current implementation does not allow repeated calls to: %s \n",__func__ , __func__); - + if (argc_min == CONFIG_DEFAULT_ARG_MIN) argc_min = 0; validate->argc_min = argc_min; validate->argc_max = argc_max; - + if ((argc_max != CONFIG_DEFAULT_ARG_MAX) && (argc_max < argc_min)) util_abort("%s invalid arg min/max values. argc_min:%d argc_max:%d \n",__func__ , argc_min , argc_max); - + { int internal_type_size = 0; /* Should end up in the range [argc_min,argc_max] */ - if (argc_max > 0) + if (argc_max > 0) internal_type_size = argc_max; else internal_type_size = argc_min; @@ -185,16 +185,16 @@ static void validate_set_common_selection_set(validate_type * validate , int arg static void validate_set_indexed_selection_set(validate_type * validate , int index , int argc , const char ** argv) { - + if (validate->indexed_selection_set == NULL) util_abort("%s: must call xxx_set_argc_minmax() first - aborting \n",__func__); - + if (index >= validate->argc_min) util_abort("%s: When not not setting argc_max selection set can only be applied to indices up to argc_min\n",__func__); - + if (validate->indexed_selection_set[index] != NULL) set_free(validate->indexed_selection_set[index]); - + validate->indexed_selection_set[index] = set_alloc(argc , argv); } @@ -206,10 +206,10 @@ static UTIL_SAFE_CAST_FUNCTION( config_schema_item , CONFIG_SCHEMA_ITEM_ID) void config_schema_item_assure_type(const config_schema_item_type * item , int index , int type_mask) { bool OK = false; - + if (int_vector_safe_iget( item->validate->type_map , index) & type_mask) OK = true; - + if (!OK) util_abort("%s: failed - wrong installed type \n" , __func__); } @@ -233,7 +233,7 @@ config_schema_item_type * config_schema_item_alloc(const char * kw , bool requir static char * __alloc_relocated__(const config_path_elm_type * path_elm , const char * value) { char * file; - + if (util_is_abs_path(value)) file = util_alloc_string_copy( value ); else @@ -251,11 +251,11 @@ bool config_schema_item_validate_set(const config_schema_item_type * item , stri OK = false; { char * error_message; - if (config_file != NULL) + if (config_file != NULL) error_message = util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have at least %d arguments.",config_file , item->kw , item->validate->argc_min); else error_message = util_alloc_sprintf("Error:: Keyword:%s must have at least %d arguments.",item->kw , item->validate->argc_min); - + config_error_add( error_list , error_message ); } } @@ -266,22 +266,22 @@ bool config_schema_item_validate_set(const config_schema_item_type * item , stri OK = false; { char * error_message; - + if (config_file != NULL) error_message = util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have maximum %d arguments.",config_file , item->kw , item->validate->argc_max); else error_message = util_alloc_sprintf("Error:: Keyword:%s must have maximum %d arguments.",item->kw , item->validate->argc_max); - + config_error_add( error_list , error_message ); } } } - /* + /* OK - now we have verified that the number of arguments is correct. Then - we start actually looking at the values. + we start actually looking at the values. */ - if (OK) { + if (OK) { /* Validating selection set - first common, then indexed */ if (item->validate->common_selection_set) { for (int iarg = 0; iarg < argc; iarg++) { @@ -344,14 +344,14 @@ bool config_schema_item_validate_set(const config_schema_item_type * item , stri /* 1. If the supplied value is an abolute path - do nothing. 2. If the supplied is _not_ an absolute path: - + a. Try if the relocated exists - then use that. b. Else - try if the util_alloc_PATH_executable() exists. */ if (!util_is_abs_path( value )) { char * relocated = __alloc_relocated__(path_elm , value); char * path_exe = util_alloc_PATH_executable( value ); - + if (util_file_exists(relocated)) { if (util_is_executable(relocated)) stringlist_iset_copy( token_list , iarg , relocated); @@ -359,7 +359,7 @@ bool config_schema_item_validate_set(const config_schema_item_type * item , stri stringlist_iset_copy( token_list , iarg , path_exe); else config_error_add( error_list , util_alloc_sprintf("Could not locate executable:%s ", value)); - + free(relocated); util_safe_free(path_exe); } else { @@ -384,7 +384,7 @@ bool config_schema_item_validate_set(const config_schema_item_type * item , stri util_abort("%s: config_item_type:%d not recognized \n",__func__ , validate_iget_type(item->validate , iarg)); } } - } + } } return OK; } @@ -393,7 +393,7 @@ bool config_schema_item_validate_set(const config_schema_item_type * item , stri void config_schema_item_free( config_schema_item_type * item) { free(item->kw); if (item->required_children != NULL) stringlist_free(item->required_children); - if (item->required_children_value != NULL) hash_free(item->required_children_value); + if (item->required_children_value != NULL) hash_free(item->required_children_value); validate_free(item->validate); free(item); } @@ -423,10 +423,10 @@ void config_schema_item_set_required_children_on_value(config_schema_item_type * */ -void config_schema_item_set_argc_minmax(config_schema_item_type * item , - int argc_min , +void config_schema_item_set_argc_minmax(config_schema_item_type * item , + int argc_min , int argc_max) { - + validate_set_argc_minmax(item->validate , argc_min , argc_max); } @@ -444,7 +444,7 @@ config_item_types config_schema_item_iget_type(const config_schema_item_type * i return validate_iget_type( item->validate , index ); } - + void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar ) { @@ -469,7 +469,7 @@ void config_schema_item_set_required_children(config_schema_item_type * item , s void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key) { if (item->required_children == NULL) item->required_children = stringlist_alloc_new(); - + stringlist_append_copy( item->required_children , child_key ); } diff --git a/ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt index 03477b9423..456b59144b 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt @@ -35,6 +35,10 @@ add_executable( config_error config_error.c) target_link_libraries( config_error config test_util ) add_test( config_error ${EXECUTABLE_OUTPUT_PATH}/config_error ) +add_executable( config_content config_content.c) +target_link_libraries( config_content config test_util ) +add_test( config_content ${EXECUTABLE_OUTPUT_PATH}/config_content ) + add_executable( config_config config_config.c) target_link_libraries( config_config config test_util ) diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_append_test.c b/ThirdParty/Ert/devel/libconfig/tests/config_append_test.c index 3e24d6245c..e2eeaa0803 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_append_test.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_append_test.c @@ -20,27 +20,36 @@ #include <ert/util/test_util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> int main(int argc , char ** argv) { const char * config_file = argv[1]; - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); config_schema_item_type * item = config_add_schema_item(config , "APPEND" , false ); config_schema_item_set_argc_minmax( item , 1 , 1); - test_assert_true(config_parse(config , config_file , "--" , NULL , NULL , false , true )); - { - test_assert_int_equal( config_get_occurences( config , "APPEND" ) , 3); + config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true ); + test_assert_true(config_content_is_instance( content )); + test_assert_true(config_content_is_valid( content )); + test_assert_int_equal( config_content_get_occurences( content , "APPEND" ) , 3); + { - const char * value = config_get_value( config , "APPEND"); + const char * value = config_content_get_value( content , "APPEND"); test_assert_string_equal( value , "VALUE3"); } - } - test_assert_false( config_parse( config , "DoesNotExist" , "--" , NULL , NULL , false , true)); + config_content_free( content ); + } + + { + config_content_type * content = config_parse( config , "DoesNotExist" , "--" , NULL , NULL , false , true); + test_assert_false( config_content_is_valid( content )); + config_content_free( content ); + } exit(0); } diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_argc.c b/ThirdParty/Ert/devel/libconfig/tests/config_argc.c index bc065fb83e..da32176017 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_argc.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_argc.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'config_argc.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_argc.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -24,14 +24,14 @@ #include <ert/util/test_util.h> #include <ert/util/util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_schema_item.h> #include <ert/config/config_error.h> void install_SIGNALS(void) { signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ signal(SIGINT , util_abort_signal); /* Control C */ - signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. + signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ } @@ -43,38 +43,48 @@ int main(int argc , char ** argv) { const char * argc_OK = argv[1]; const char * argc_less = argv[2]; const char * argc_more = argv[3]; - - config_type * config = config_alloc(); + + config_parser_type * config = config_alloc(); config_schema_item_type * schema_item = config_add_schema_item( config , "ITEM" , false ); config_schema_item_set_argc_minmax( schema_item , 2 , 2 ); - - test_assert_true( config_parse( config , argc_OK , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true)); - config_clear( config ); - test_assert_false( config_parse( config , argc_less , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true)); { - const config_error_type * config_error = config_get_errors( config ); - const char * error_msg = "Error when parsing config_file:\"argc_less\" Keyword:ITEM must have at least 2 arguments."; - - test_assert_int_equal( config_error_count( config_error ) , 1); - test_assert_string_equal( config_error_iget( config_error , 0 ) , error_msg); + config_content_type * content = config_parse( config , argc_OK , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true); + test_assert_true( config_content_is_instance( content )); + test_assert_true(config_content_is_valid( content )); + config_content_free( content ); } - config_clear( config ); + { + config_content_type * content = config_parse( config , argc_less , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true); + test_assert_true( config_content_is_instance( content )); + test_assert_false( config_content_is_valid( content )); + + { + const config_error_type * config_error = config_content_get_errors( content ); + const char * error_msg = "Error when parsing config_file:\"argc_less\" Keyword:ITEM must have at least 2 arguments."; + + test_assert_int_equal( config_error_count( config_error ) , 1); + test_assert_string_equal( config_error_iget( config_error , 0 ) , error_msg); + } + config_content_free( content ); + } - test_assert_false( config_parse( config , argc_more , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true)); { - const config_error_type * config_error = config_get_errors( config ); - const char * error_msg = "Error when parsing config_file:\"argc_more\" Keyword:ITEM must have maximum 2 arguments."; - - test_assert_int_equal( config_error_count( config_error ) , 1); - test_assert_string_equal( config_error_iget( config_error , 0 ) , error_msg); + config_content_type * content = config_parse( config , argc_more , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true); + test_assert_true( config_content_is_instance( content )); + test_assert_false( config_content_is_valid( content )); + { + const config_error_type * config_error = config_content_get_errors( content ); + const char * error_msg = "Error when parsing config_file:\"argc_more\" Keyword:ITEM must have maximum 2 arguments."; + + test_assert_int_equal( config_error_count( config_error ) , 1); + test_assert_string_equal( config_error_iget( config_error , 0 ) , error_msg); + } + config_content_free( content ); } - config_clear( config ); - config_free( config ); exit(0); } } - diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_config.c b/ThirdParty/Ert/devel/libconfig/tests/config_config.c index cb76348631..8d10c89cf5 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_config.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_config.c @@ -23,12 +23,12 @@ #include <ert/util/test_util.h> #include <ert/util/util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_schema_item.h> int main(int argc , char ** argv) { - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); config_add_schema_item( config , "KEYWORD" , false ); config_free( config ); exit(0); diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_content.c b/ThirdParty/Ert/devel/libconfig/tests/config_content.c new file mode 100644 index 0000000000..6ce29004ed --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_content.c @@ -0,0 +1,37 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'config_content.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#include <ert/util/test_util.h> + +#include <ert/config/config_content.h> + + +void test_create() { + config_content_type * content = config_content_alloc( ); + test_assert_true( config_content_is_instance( content ) ); + config_content_free( content ); +} + + + + + + +int main( int argc , char ** argv) { + test_create(); +} diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_content_item.c b/ThirdParty/Ert/devel/libconfig/tests/config_content_item.c index ee0be46be8..f79a0ca601 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_content_item.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_content_item.c @@ -23,7 +23,7 @@ #include <ert/util/util.h> #include <ert/util/hash.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_content_node.h> #include <ert/config/config_schema_item.h> #include <ert/config/config_path_elm.h> @@ -31,28 +31,27 @@ int main(int argc , char ** argv) { const char * config_file = argv[1]; - config_type * config = config_alloc(); - + config_parser_type * config = config_alloc(); + config_add_schema_item( config , "SET" , true ); config_add_schema_item( config , "NOTSET" , false ); - test_assert_true( config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true )); + { + config_content_type * content = config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true ); + test_assert_true( config_content_is_instance( content )); + test_assert_true(config_content_is_valid( content )); - test_assert_not_NULL( config_get_content_item( config , "SET" )); - test_assert_NULL( config_get_content_item( config , "NOTSET" ) ); - test_assert_NULL( config_get_content_item( config , "UNKNOWN" ) ); + test_assert_true( config_content_has_item( content , "SET" )); + test_assert_false( config_content_has_item( content , "NOTSET" ) ); + test_assert_false( config_content_has_item( content , "UNKNOWN" ) ); - test_assert_true( config_has_schema_item( config , "SET" )); - test_assert_true( config_has_schema_item( config , "NOTSET" )); - test_assert_false( config_has_schema_item( config , "UNKNOWN" )); + test_assert_true( config_has_schema_item( config , "SET" )); + test_assert_true( config_has_schema_item( config , "NOTSET" )); + test_assert_false( config_has_schema_item( config , "UNKNOWN" )); - test_assert_true( config_has_content_item( config , "SET" )); - test_assert_false( config_has_content_item( config , "NOTSET" )); - test_assert_false( config_has_content_item( config , "UNKNOWN" )); - - + config_content_free( content ); + } - exit(0); } diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_define.c b/ThirdParty/Ert/devel/libconfig/tests/config_define.c index d93dab6a8f..c10eb27f86 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_define.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_define.c @@ -23,16 +23,18 @@ #include <ert/util/util.h> #include <ert/util/subst_list.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_content_node.h> #include <ert/config/config_schema_item.h> #include <ert/config/config_path_elm.h> -void test_define(config_type * config , const char * config_file) { - test_assert_true( config_parse( config , config_file , NULL , NULL , "DEFINE" , CONFIG_UNRECOGNIZED_IGNORE , true )); +void test_define(config_parser_type * config , const char * config_file) { + config_content_type * content = config_parse( config , config_file , NULL , NULL , "DEFINE" , CONFIG_UNRECOGNIZED_IGNORE , true ); + test_assert_true( config_content_is_instance( content )); + test_assert_true(config_content_is_valid( content )); { - const subst_list_type * define_list = config_get_define_list( config ); + const subst_list_type * define_list = config_content_get_define_list( content ); test_assert_true( subst_list_has_key( define_list , "VAR1")); test_assert_true( subst_list_has_key( define_list , "VAR2")); test_assert_true( subst_list_has_key( define_list , "VARX")); @@ -43,12 +45,13 @@ void test_define(config_type * config , const char * config_file) { test_assert_string_equal( subst_list_get_value( define_list , "VAR2") , "10"); test_assert_string_equal( subst_list_get_value( define_list , "VARX") , "1"); } + config_content_free( content ); } -config_type * config_create_schema() { - config_type * config = config_alloc(); +config_parser_type * config_create_schema() { + config_parser_type * config = config_alloc(); config_add_schema_item( config , "SET" , true ); config_add_schema_item( config , "NOTSET" , false ); @@ -58,12 +61,15 @@ config_type * config_create_schema() { int main(int argc , char ** argv) { - const char * config_file = argv[1]; - config_type * config = config_create_schema(); - - test_define( config , config_file ); - - config_free( config ); - exit(0); + util_install_signals(); + { + const char * config_file = argv[1]; + config_parser_type * config = config_create_schema(); + + test_define( config , config_file ); + + config_free( config ); + exit(0); + } } diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_include_test.c b/ThirdParty/Ert/devel/libconfig/tests/config_include_test.c index c2eb86c4a1..d310e580a0 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_include_test.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_include_test.c @@ -24,10 +24,11 @@ #include <ert/util/util.h> #include <ert/util/path_stack.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_schema_item.h> +#include <ert/config/config_content.h> -void parse_test(config_type * config , +void parse_test(config_parser_type * config , const char * root_path , // The new working directory - the test will start by chdir() here. const char * config_file ) { // The config_file, either as an absolute path - or relative from root_path @@ -52,9 +53,9 @@ void parse_test(config_type * config , config_rel_path = util_alloc_rel_path( NULL , config_abs_path); { - config_clear( config ); - if (config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true )) { - + config_content_type * content = config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true ); + if (config_content_is_valid( content )) { + char * relpath0 = util_alloc_filename( config_rel_path , path0, NULL); char * relpath1 = util_alloc_filename( config_rel_path , path1, NULL); char * relpath2 = util_alloc_filename( config_rel_path , path2, NULL); @@ -66,24 +67,25 @@ void parse_test(config_type * config , char * abspath2 = util_alloc_filename( config_abs_path , path2, NULL); char * abspath3 = util_alloc_filename( config_abs_path , path3, NULL); char * abspath4 = util_alloc_filename( config_abs_path , path4, NULL); - - test_assert_string_equal(config_get_value_as_relpath(config , "PATH0") , relpath0 ); - test_assert_string_equal(config_get_value_as_relpath(config , "PATH1") , relpath1 ); - test_assert_string_equal(config_get_value_as_relpath(config , "PATH2") , relpath2 ); - test_assert_string_equal(config_get_value_as_relpath(config , "PATH3") , relpath3 ); - test_assert_string_equal(config_get_value_as_relpath(config , "PATH4") , relpath4 ); - - test_assert_string_equal(config_get_value_as_abspath(config , "PATH0") , abspath0 ); - test_assert_string_equal(config_get_value_as_abspath(config , "PATH1") , abspath1 ); - test_assert_string_equal(config_get_value_as_abspath(config , "PATH2") , abspath2 ); - test_assert_string_equal(config_get_value_as_abspath(config , "PATH3") , abspath3 ); - test_assert_string_equal(config_get_value_as_abspath(config , "PATH4") , abspath4 ); - + + test_assert_string_equal(config_content_get_value_as_relpath(content , "PATH0") , relpath0 ); + test_assert_string_equal(config_content_get_value_as_relpath(content , "PATH1") , relpath1 ); + test_assert_string_equal(config_content_get_value_as_relpath(content , "PATH2") , relpath2 ); + test_assert_string_equal(config_content_get_value_as_relpath(content , "PATH3") , relpath3 ); + test_assert_string_equal(config_content_get_value_as_relpath(content , "PATH4") , relpath4 ); + + test_assert_string_equal(config_content_get_value_as_abspath(content , "PATH0") , abspath0 ); + test_assert_string_equal(config_content_get_value_as_abspath(content , "PATH1") , abspath1 ); + test_assert_string_equal(config_content_get_value_as_abspath(content , "PATH2") , abspath2 ); + test_assert_string_equal(config_content_get_value_as_abspath(content , "PATH3") , abspath3 ); + test_assert_string_equal(config_content_get_value_as_abspath(content , "PATH4") , abspath4 ); + } else { - config_error_type * error = config_get_errors( config ); + const config_error_type * error = config_content_get_errors( content ); config_error_fprintf( error , true , stdout ); test_error_exit("Hmm - parsing %s failed \n", config_file ); } + config_content_free( content ); } path_stack_pop( path_stack ); } @@ -93,7 +95,7 @@ int main(int argc , char ** argv) { const char * abs_path = argv[1]; const char * config_file = argv[2]; char * abs_config_file = util_alloc_filename( abs_path , config_file , NULL); - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); { config_schema_item_type * schema_item; diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_node_test.c b/ThirdParty/Ert/devel/libconfig/tests/config_node_test.c index 75c3c2dccd..699aeeb69c 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_node_test.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_node_test.c @@ -18,30 +18,31 @@ #include <stdlib.h> #include <stdbool.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> int main(int argc , char ** argv) { const char * config_file = argv[1]; - config_type * config = config_alloc(); - bool OK; + config_parser_type * config = config_alloc(); { config_schema_item_type * item = config_add_schema_item(config , "APPEND" , false ); config_schema_item_set_argc_minmax( item , 1 , 1); } config_add_schema_item(config , "NEXT" , false ); - - OK = config_parse(config , config_file , "--" , NULL , NULL , false , true ); - - if (OK) { - if (config_get_content_size( config ) == 4) { - const config_content_node_type * node0 = config_iget_content_node( config , 0 ); + + config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true ); + + if (config_content_is_valid( content )) { + if (config_content_get_size( content ) == 4) { + const config_content_node_type * node0 = config_content_iget_node( content , 0 ); if (strcmp( config_content_node_get_kw( node0 ) , "APPEND") == 0) { if (config_content_node_get_size(node0) == 1) { - const config_content_node_type * node3 = config_iget_content_node( config , 3 ); + const config_content_node_type * node3 = config_content_iget_node( content , 3 ); if (strcmp( config_content_node_get_kw( node3 ) , "NEXT") == 0) { if (config_content_node_get_size(node3) == 2) { + config_content_free( content ); exit(0); } else printf("Size error node3\n"); } else printf("kw error node3 \n"); @@ -49,7 +50,8 @@ int main(int argc , char ** argv) { } else printf("kw error node0 kw:%s \n", config_content_node_get_kw( node0 )); } else printf("Size error \n"); } else printf("Parse error"); - + + config_content_free( content ); exit(1); } diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c b/ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c index 6b1217ae04..e6b4ea50f1 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c @@ -24,7 +24,7 @@ #include <ert/util/util.h> #include <ert/util/test_work_area.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_path_elm.h> #include <ert/config/config_root_path.h> diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_root_path.c b/ThirdParty/Ert/devel/libconfig/tests/config_root_path.c index c23af67b29..60bbe9be69 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_root_path.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_root_path.c @@ -22,7 +22,7 @@ #include <ert/util/test_util.h> #include <ert/util/util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_root_path.h> diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c b/ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c index 5514dd94a0..bfedc12d38 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c @@ -1,25 +1,28 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'config_typeFail.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_parser_typeFail.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> +#include <ert/util/test_util.h> + #include <ert/config/config_error.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> void error(char * msg) { @@ -30,36 +33,37 @@ void error(char * msg) { int main(int argc , char ** argv) { const char * config_file = argv[1]; - config_type * config = config_alloc(); - bool OK; + config_parser_type * config = config_alloc(); { config_schema_item_type * item = config_add_schema_item(config , "TYPES_KEY" , false ); - config_schema_item_set_argc_minmax( item , 4 , 4 ); + config_schema_item_set_argc_minmax( item , 4 , 4 ); config_schema_item_iset_type( item , 0 , CONFIG_INT ); config_schema_item_iset_type( item , 1 , CONFIG_FLOAT ); config_schema_item_iset_type( item , 2 , CONFIG_BOOL ); - + item = config_add_schema_item( config , "SHORT_KEY" , false ); config_schema_item_set_argc_minmax( item , 1 , 1 ); - + item = config_add_schema_item( config , "LONG_KEY" , false ); config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX); } - OK = config_parse(config , config_file , "--" , NULL , NULL , false , true ); - - if (OK) { - error("Parse error\n"); - } else { - config_error_type * cerror = config_get_errors( config ); - if (config_error_count( cerror ) > 0) { - int i; - for (i=0; i < config_error_count( cerror ); i++) { - printf("Error %d: %s \n",i , config_error_iget( cerror , i )); + + { + config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true ); + + if (config_content_is_valid( content )) { + error("Parse error\n"); + } else { + const config_error_type * cerror = config_content_get_errors( content ); + if (config_error_count( cerror ) > 0) { + int i; + for (i=0; i < config_error_count( cerror ); i++) { + printf("Error %d: %s \n",i , config_error_iget( cerror , i )); + } } + test_assert_int_equal( 5 , config_error_count( cerror )); } - printf("Error count:%d \n",config_error_count( cerror )); - if (config_error_count( cerror ) != 5) - error("Wrong error count\n"); + config_content_free( content ); } printf("OK \n"); exit(0); diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c b/ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c index 83aded9a60..7dc4bc59fb 100644 --- a/ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c +++ b/ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c @@ -1,36 +1,33 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'config_typeOK.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_parser_typeOK.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> -#include <ert/config/config.h> +#include <ert/util/test_util.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> -void error(char * msg) { - fprintf(stderr , msg); - exit(1); -} int main(int argc , char ** argv) { const char * config_file = argv[1]; - config_type * config = config_alloc(); - bool OK; + config_parser_type * config = config_alloc(); { config_schema_item_type * item = config_add_schema_item(config , "TYPE_KEY" , false ); config_schema_item_set_argc_minmax( item , 4 , 4 ); @@ -40,16 +37,17 @@ int main(int argc , char ** argv) { item = config_add_schema_item( config , "SHORT_KEY" , false ); config_schema_item_set_argc_minmax( item , 1 , 1 ); - + item = config_add_schema_item( config , "LONG_KEY" , false ); config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX ); } - OK = config_parse(config , config_file , "--" , NULL , NULL , false , true ); - - if (OK) { - - } else error("Parse error\n"); - + { + config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true ); + test_assert_true( config_content_is_valid( content )); + config_content_free( content ); + } + + exit(0); } diff --git a/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt index 131e33900d..f69cef80dd 100644 --- a/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt @@ -32,6 +32,13 @@ if (BUILD_APPLICATIONS) set(program_list summary2csv2 summary2csv kw_extract grdecl_grid make_grid sum_write load_test grdecl_test grid_dump_ascii select_test grid_dump convert kw_list grid_info summary) endif() + if (BUILD_ERT) + add_executable( ecl_quantile ecl_quantile.c ) + include_directories( ../../libconfig/include ) + target_link_libraries( ecl_quantile config ) + list( APPEND program_list ecl_quantile ) + endif() + foreach(prog ${program_list}) target_link_libraries( ${prog} ecl ert_util ) diff --git a/ThirdParty/Ert/devel/libecl/applications/convert.c b/ThirdParty/Ert/devel/libecl/applications/convert.c index 1160e9ceaa..104a432b3f 100644 --- a/ThirdParty/Ert/devel/libecl/applications/convert.c +++ b/ThirdParty/Ert/devel/libecl/applications/convert.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'convert.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'convert.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -31,40 +31,43 @@ void file_convert(const char * src_file , const char * target_file, ecl_file_enum file_type , bool fmt_src) { fortio_type *src , *target; - ecl_kw_type * ecl_kw; bool formatted_src; printf("Converting %s -> %s \n",src_file , target_file); if (file_type != ECL_OTHER_FILE) formatted_src = fmt_src; else { - if (util_fmt_bit8(src_file)) + if (util_fmt_bit8(src_file)) formatted_src = true; else formatted_src = false; } - + target = fortio_open_writer(target_file , !formatted_src , ECL_ENDIAN_FLIP ); src = fortio_open_reader(src_file , formatted_src , ECL_ENDIAN_FLIP); - ecl_kw = ecl_kw_fread_alloc(src); - if (ecl_kw == NULL) { - fprintf(stderr,"Loading: %s failed - maybe you forgot the header? \n", src_file); - abort(); - } - while (ecl_kw != NULL) { - ecl_kw_fwrite(ecl_kw , target); - - ecl_kw_free(ecl_kw); - ecl_kw = ecl_kw_fread_alloc(src); + while (true) { + if (fortio_read_at_eof( src )) + break; + + { + ecl_kw_type * ecl_kw = ecl_kw_fread_alloc( src ); + if (ecl_kw) { + ecl_kw_fwrite(ecl_kw , target); + ecl_kw_free(ecl_kw); + } else { + fprintf(stderr, "Reading keyword failed \n"); + break; + } + } } - if (ecl_kw != NULL) ecl_kw_free(ecl_kw); + fortio_fclose(src); fortio_fclose(target); } -int main (int argc , char **argv) { +int main (int argc , char **argv) { if (argc == 1) { fprintf(stderr,"Usage: convert.x <filename1> <filename2> <filename3> ...\n"); exit(1); @@ -72,12 +75,12 @@ int main (int argc , char **argv) { char *src_file = argv[1]; char *target_file; - + int report_nr; ecl_file_enum file_type; bool fmt_file; file_type = ecl_util_get_file_type(src_file , &fmt_file , &report_nr); - + if (file_type == ECL_OTHER_FILE) { if (argc != 3) { fprintf(stderr,"When the file can not be recognized on the name as an ECLIPSE file you must give output_file as second (and final) argument \n"); @@ -99,10 +102,10 @@ int main (int argc , char **argv) { exit(1); } util_alloc_file_components(src_file , &path , &basename , &extension); - + target_file = ecl_util_alloc_filename(path, basename , file_type , !fmt_file , report_nr); file_convert(src_file , target_file , file_type , fmt_file); - + free(path); free(basename); free(extension); diff --git a/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c b/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c index e52b704b2f..8bfe042f7c 100644 --- a/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c +++ b/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_quantile.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_quantile.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ @@ -32,7 +32,9 @@ #include <ert/util/arg_pack.h> #include <ert/util/thread_pool.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> +#include <ert/config/config_error.h> #include <ert/config/config_content_item.h> #include <ert/config/config_content_node.h> @@ -41,7 +43,7 @@ #define DEFAULT_NUM_INTERP 50 #define SUMMARY_JOIN ":" #define MIN_SIZE 10 -#define LOAD_THREADS 4 +#define LOAD_THREADS 4 typedef enum { @@ -62,7 +64,7 @@ typedef struct { /** Microscopic data structure representing one column of data; - i.e. one ECLIPSE summary key and one accompanying quantile value. + i.e. one ECLIPSE summary key and one accompanying quantile value. */ typedef struct { @@ -124,7 +126,7 @@ sum_case_type * sum_case_fread_alloc( const char * data_file , const time_t_vect sum_case->ecl_sum = ecl_sum_fread_alloc_case( data_file , SUMMARY_JOIN ); sum_case->interp_data = double_vector_alloc(0 , 0); - sum_case->interp_time = interp_time; + sum_case->interp_time = interp_time; sum_case->start_time = ecl_sum_get_start_time( sum_case->ecl_sum ); sum_case->end_time = ecl_sum_get_end_time( sum_case->ecl_sum ); return sum_case; @@ -148,7 +150,7 @@ void sum_case_free__( void * sum_case) { void ensemble_add_case( ensemble_type * ensemble , const char * data_file ) { sum_case_type * sum_case = sum_case_fread_alloc( data_file , ensemble->interp_time ); - + pthread_rwlock_wrlock( &ensemble->rwlock ); { printf("Loading case: %s \n", data_file ); @@ -157,7 +159,7 @@ void ensemble_add_case( ensemble_type * ensemble , const char * data_file ) { ensemble->start_time = util_time_t_min( ensemble->start_time , sum_case->start_time); else ensemble->start_time = ecl_sum_get_start_time( sum_case->ecl_sum ); - + ensemble->end_time = util_time_t_max( ensemble->end_time , sum_case->end_time); } pthread_rwlock_unlock( &ensemble->rwlock ); @@ -216,7 +218,7 @@ ensemble_type * ensemble_alloc( ) { } -void ensemble_init( ensemble_type * ensemble , config_type * config) { +void ensemble_init( ensemble_type * ensemble , config_content_type * config) { /*1 : Loading ensembles and settings from the config instance */ /*1a: Loading the eclipse summary cases. */ @@ -224,33 +226,32 @@ void ensemble_init( ensemble_type * ensemble , config_type * config) { thread_pool_type * tp = thread_pool_alloc( LOAD_THREADS , true ); { int i,j; - const config_content_item_type * case_item = config_get_content_item( config , "CASE_LIST" ); - - if (case_item != NULL) { - for (j=0; j < config_content_node_get_size( case_item ); j++) { - const config_content_node_type * case_node = config_content_item_iget_node( case_item ); - for (i=0; i < config_content_node_get_size( case_node ) i++) { + if (config_content_has_item( config , "CASE_LIST")) { + const config_content_item_type * case_item = config_content_get_item( config , "CASE_LIST" ); + for (j=0; j < config_content_item_get_size( case_item ); j++) { + const config_content_node_type * case_node = config_content_item_iget_node( case_item , j ); + for (i=0; i < config_content_node_get_size( case_node ); i++) { const char * case_glob = config_content_node_iget( case_node , i ); ensemble_load_from_glob( ensemble , case_glob , tp); } } } - + } thread_pool_join( tp ); thread_pool_free( tp ); } - + { const sum_case_type * tmp = vector_iget_const( ensemble->data , 0 ); ensemble->refcase = tmp->ecl_sum; } - + /*1b: Other config settings */ - if (config_item_set( config , "NUM_INTERP" )) - ensemble->num_interp = config_iget_as_int( config , "NUM_INTERP" , 0 , 0 ); - - + if (config_content_has_item( config , "NUM_INTERP" )) + ensemble->num_interp = config_content_iget_as_int( config , "NUM_INTERP" , 0 , 0 ); + + /*2: Remaining initialization */ ensemble_init_time_interp( ensemble ); if (vector_get_size( ensemble->data ) < MIN_SIZE ) @@ -269,7 +270,7 @@ void ensemble_free( ensemble_type * ensemble ) { } /*****************************************************************/ - + static output_type * output_alloc( const char * file , const char * format_string) { output_type * output = util_malloc( sizeof * output ); output->keys = vector_alloc_new(); @@ -289,7 +290,7 @@ static output_type * output_alloc( const char * file , const char * format_strin } output->format = format; } - + return output; } @@ -322,26 +323,26 @@ static void output_add_key( const ecl_sum_type * refcase , output_type * output util_split_string( qkey , SUMMARY_JOIN , &tokens , &tmp); if (tokens == 1) util_exit("Hmmm - the key:%s is malformed - must be of the form SUMMARY_KEY:QUANTILE.\n",qkey); - + if (!util_sscanf_double( tmp[tokens - 1] , &quantile)) util_exit("Hmmmm - failed to interpret:%s as a quantile - must be a number (0,1).\n",tmp[tokens-1]); - + if (quantile <= 0 || quantile >= 1.0) util_exit("Invalid quantile value:%g - must be in interval (0,1)\n", quantile); - + sum_key = util_alloc_joined_string( (const char **) tmp , tokens - 1 , SUMMARY_JOIN); { stringlist_type * matching_keys = stringlist_alloc_new(); int i; ecl_sum_select_matching_general_var_list( refcase , sum_key , matching_keys ); - for (i=0; i < stringlist_get_size( matching_keys ); i++) + for (i=0; i < stringlist_get_size( matching_keys ); i++) vector_append_owned_ref( output->keys , quant_key_alloc( stringlist_iget( matching_keys , i ) , quantile) , quant_key_free__ ); - + if (stringlist_get_size( matching_keys ) == 0) fprintf(stderr,"** Warning: No summary vectors matching:\'%s\' found?? \n", sum_key); stringlist_free( matching_keys ); } - + util_free_stringlist( tmp, tokens ); } @@ -354,21 +355,21 @@ static void output_add_key( const ecl_sum_type * refcase , output_type * output OUTPUT output_file key.q key.q key.q key.q ... */ -void output_table_init( const ecl_sum_type * refcase, hash_type * output_table , const config_type * config ) { +void output_table_init( const ecl_sum_type * refcase, hash_type * output_table , const config_content_type * config ) { int i,j; - const config_content_item_type * output_item = config_get_content_item( config , "OUTPUT"); - if (output_item != NULL) { + if (config_content_has_item( config , "OUTPUT")) { + const config_content_item_type * output_item = config_content_get_item( config , "OUTPUT"); for (i = 0; i < config_content_item_get_size( output_item ); i++) { const config_content_node_type * output_node = config_content_item_iget_node( output_item , i ); - + const char * file = config_content_node_iget( output_node , 0 ); const char * format_string = config_content_node_iget( output_node , 1 ); output_type * output = output_alloc( file , format_string ); - + /* All the keys are just added - without any check. */ for (j = 2; j < config_content_node_get_size( output_node ); j++) output_add_key( refcase , output , config_content_node_iget( output_node , j)); - + hash_insert_hash_owned_ref( output_table , file , output , output_free__ ); } } @@ -390,9 +391,9 @@ static void print_var( FILE * stream , const char * var , double q , const char -/* +/* ** The columns are <TAB> separated! ** - + An ECLIPSE summary variable is generally characterized by three variable values from SMSPEC vectors; the three vectors are KEYWORDS, WGNAMES and NUMS. @@ -403,7 +404,7 @@ static void print_var( FILE * stream , const char * var , double q , const char additional information from one, or both of WGNAMES and NUMS. For instance for a well variable or group variable we will need the well name from WGNAMES and for a block property we will need the - block number (as i + j*nx + k*nx*ny) from the NUMS vector. + block number (as i + j*nx + k*nx*ny) from the NUMS vector. When writing the S3Graph header I don't understand how to enter the different parts of header information. The current implementation, @@ -412,7 +413,7 @@ static void print_var( FILE * stream , const char * var , double q , const char 1. Write a line like this: DATE TIME KEYWORD1:xxx KEYWORD2:xxx KEYWORD3:xxxx - + Here KEYWORD is an eclipse variable memnonic from the KEYWORDS array, i.e. FOPT or WWCT. The :xxx part is the quantile we are looking at, i.e. 0.10 or 0.90. It seems adding the quantile @@ -420,16 +421,16 @@ static void print_var( FILE * stream , const char * var , double q , const char 2. Write a line with units: - DATE TIME KEYWORD1:xxx KEYWORD2:xxx KEYWORD3:xxxx + DATE TIME KEYWORD1:xxx KEYWORD2:xxx KEYWORD3:xxxx DAYS UNIT1 UNIT2 UNIT2 <---- New line 3. Write a line with keyword qualifiers, i.e. extra information: DATE TIME WOPR:xxx FOPT:xxxx BPR - DAYS UNIT1 UNIT2 UNIT2 - OP1 1000 <---- New line - + DAYS UNIT1 UNIT2 UNIT2 + OP1 1000 <---- New line + Now - the totally confusing part is that it is not clear what S3Graph expects on this third line, in the case of well/group variables it is a well/group name from the WGNAMES array, @@ -443,14 +444,14 @@ static void print_var( FILE * stream , const char * var , double q , const char [*] : I do not really understand why it seems to work. - + */ void output_save_S3Graph( const output_type * output, ensemble_type * ensemble , const double ** data ) { - FILE * stream = util_mkdir_fopen( output->file , "w"); + FILE * stream = util_mkdir_fopen( output->file , "w"); const char * kw_fmt = "\t%s"; const char * unit_fmt = "\t%s"; const char * wgname_fmt = "\t%s"; @@ -466,14 +467,14 @@ void output_save_S3Graph( const output_type * output, ensemble_type * ensemble , const int data_columns = vector_get_size( output->keys ); const int data_rows = time_t_vector_size( ensemble->interp_time ); int row_nr,column_nr; - + { - char * origin; + char * origin; util_alloc_file_components( output->file , NULL ,&origin , NULL); fprintf(stream , "ORIGIN %s\n", origin ); free( origin ); } - + /* 1: Writing first header line with variables. */ fprintf(stream , time_header ); for (column_nr = 0; column_nr < data_columns; column_nr++) { @@ -489,20 +490,20 @@ void output_save_S3Graph( const output_type * output, ensemble_type * ensemble , fprintf(stream , unit_fmt , ecl_sum_get_unit( ensemble->refcase , qkey->sum_key ) ); } fprintf(stream , "\n"); - - /*3: Writing third header line with WGNAMES / NUMS - extra information - + + /*3: Writing third header line with WGNAMES / NUMS - extra information - breaks completely down with LGR information. */ fprintf(stream , time_blank ); { for (column_nr = 0; column_nr < data_columns; column_nr++) { const quant_key_type * qkey = vector_iget( output->keys , column_nr ); const char * ecl_key = qkey->sum_key; - const char * wgname = ecl_sum_get_wgname( ensemble->refcase , ecl_key ); + const char * wgname = ecl_sum_get_wgname( ensemble->refcase , ecl_key ); int num = ecl_sum_get_num( ensemble->refcase , ecl_key ); ecl_smspec_var_type var_type = ecl_sum_get_var_type( ensemble->refcase , ecl_key); bool need_num = ecl_smspec_needs_num( var_type ); - bool need_wgname = ecl_smspec_needs_wgname( var_type ); - + bool need_wgname = ecl_smspec_needs_wgname( var_type ); + if (need_num && need_wgname) { /** Do not know how to include both - will just create a mangled name as a combination. */ @@ -511,7 +512,7 @@ void output_save_S3Graph( const output_type * output, ensemble_type * ensemble , free( wgname_num ); } else if (need_num) fprintf(stream , num_fmt , num); - else if (need_wgname) + else if (need_wgname) fprintf(stream , wgname_fmt , wgname); else fprintf(stream , empty_fmt ); @@ -528,7 +529,7 @@ void output_save_S3Graph( const output_type * output, ensemble_type * ensemble , fprintf(stream , date_fmt , mday , month , year); } fprintf(stream , days_fmt , 1.0*(interp_time - ensemble->start_time) / 86400); - + for (column_nr = 0; column_nr < data_columns; column_nr++) { fprintf(stream , float_fmt , data[row_nr][column_nr]); } @@ -539,7 +540,7 @@ void output_save_S3Graph( const output_type * output, ensemble_type * ensemble , void output_save_plain__( const output_type * output , ensemble_type * ensemble , const double ** data , bool add_header) { - FILE * stream = util_mkdir_fopen( output->file , "w"); + FILE * stream = util_mkdir_fopen( output->file , "w"); const char * key_fmt = " %18s:%4.2f "; const char * time_header = "-- DAYS DATE "; const char * time_dash = "------------------------"; @@ -560,7 +561,7 @@ void output_save_plain__( const output_type * output , ensemble_type * ensemble fprintf(stream , "\n"); fprintf( stream , time_dash ); - for (int i=0; i < vector_get_size( output->keys ); i++) + for (int i=0; i < vector_get_size( output->keys ); i++) fprintf(stream , key_dash ); fprintf(stream , "\n"); } @@ -574,7 +575,7 @@ void output_save_plain__( const output_type * output , ensemble_type * ensemble util_set_datetime_values(interp_time , NULL , NULL , NULL , &mday , &month , &year); fprintf(stream , date_fmt , mday , month , year); } - + for (column_nr = 0; column_nr < data_columns; column_nr++) { fprintf(stream , float_fmt , data[row_nr][column_nr]); } @@ -600,13 +601,13 @@ void output_save( const output_type * output , ensemble_type * ensemble , const util_exit("Sorry: output_format:%d not supported \n", output->format ); } } - + void output_run_line( const output_type * output , ensemble_type * ensemble) { - + const int data_columns = vector_get_size( output->keys ); const int data_rows = time_t_vector_size( ensemble->interp_time ); double ** data; @@ -615,15 +616,15 @@ void output_run_line( const output_type * output , ensemble_type * ensemble) { data = util_calloc( data_rows , sizeof * data ); /* time-direction, i.e. the row index is the first index and the - column number (i.e. the different keys) is the second index. + column number (i.e. the different keys) is the second index. */ for (row_nr=0; row_nr < data_rows; row_nr++) data[row_nr] = util_calloc( data_columns , sizeof * data[row_nr] ); - + printf("Creating output file: %s \n",output->file ); - - /* + + /* Go through all the cases and check that they have this key; exit if missing. Could also ignore the missing keys and just continue; and even defer the checking to the inner loop. @@ -632,35 +633,35 @@ void output_run_line( const output_type * output , ensemble_type * ensemble) { const quant_key_type * qkey = vector_iget( output->keys , column_nr ); { bool OK = true; - + for (int iens = 0; iens < vector_get_size( ensemble->data ); iens++) { const sum_case_type * sum_case = vector_iget_const( ensemble->data , iens ); - + if (!ecl_sum_has_general_var(sum_case->ecl_sum , qkey->sum_key)) { OK = false; fprintf(stderr,"** Sorry: the case:%s does not have the summary key:%s \n", ecl_sum_get_case( sum_case->ecl_sum ), qkey->sum_key); } } - if (!OK) + if (!OK) util_exit("Exiting due to missing summary vector(s).\n"); } } - - + + /* The main loop - outer loop is running over time. */ { /** In the quite typical case that we are asking for several quantiles of the quantity, i.e. - WWCT:OP_1:0.10 WWCT:OP_1:0.50 WWCT:OP_1:0.90 + WWCT:OP_1:0.10 WWCT:OP_1:0.50 WWCT:OP_1:0.90 the interp_data_cache construction will ensure that the underlying ecl_sum object is only queried once; and also the sorting will be performed once. */ - + hash_type * interp_data_cache = hash_alloc(); for (row_nr = 0; row_nr < data_rows; row_nr++) { @@ -680,10 +681,10 @@ void output_run_line( const output_type * output , ensemble_type * ensemble) { if (double_vector_size( interp_data ) == 0) { for (int iens = 0; iens < vector_get_size( ensemble->data ); iens++) { const sum_case_type * sum_case = vector_iget_const( ensemble->data , iens ); - + if ((interp_time >= sum_case->start_time) && (interp_time <= sum_case->end_time)) /* We allow the different simulations to have differing length */ double_vector_append( interp_data , ecl_sum_get_general_var_from_sim_time( sum_case->ecl_sum , interp_time , qkey->sum_key)) ; - + double_vector_sort( interp_data ); } } @@ -693,7 +694,7 @@ void output_run_line( const output_type * output , ensemble_type * ensemble) { } hash_free( interp_data_cache ); } - + output_save( output , ensemble , (const double **) data); for (row_nr=0; row_nr < data_rows; row_nr++) free( data[row_nr] ); @@ -717,19 +718,19 @@ void output_table_run( hash_type * output_table , ensemble_type * ensemble ) { /*****************************************************************/ -void config_init( config_type * config ) { +void config_init( config_parser_type * config ) { - config_add_schema_item( config , "CASE_LIST" , true , true ); + config_add_schema_item( config , "CASE_LIST" , true ); config_add_key_value( config , "NUM_INTERP" , false , CONFIG_INT); - + { config_schema_item_type * item; - item = config_add_schema_item( config , "OUTPUT" , true , true ); - config_schema_item_set_argc_minmax( item , 2 , CONFIG_DEFAULT_ARG_MAX , 0 , NULL ); + item = config_add_schema_item( config , "OUTPUT" , true ); + config_schema_item_set_argc_minmax( item , 2 , CONFIG_DEFAULT_ARG_MAX ); config_schema_item_set_indexed_selection_set( item , 1 , 3 , (const char *[3]) { S3GRAPH_STRING , HEADER_STRING , PLAIN_STRING }); } - + } @@ -737,7 +738,7 @@ void config_init( config_type * config ) { void usage() { fprintf(stderr, "\nUse:\n\n ecl_quantile config_file\n\n"); - + printf("Help\n"); printf("----\n"); printf("\n"); @@ -786,7 +787,7 @@ void usage() { printf("\n"); printf(" Q: The quantile we are interested in, e.g 0.10 to get the P10\n"); printf(" quantile and 0.90 to get the P90 quantile.\n"); - printf("\n"); + printf("\n"); printf(" For the 'VAR' and 'WG?' parts of the keys you can use shell-style\n"); printf(" wildcards to get all summary vectors matching a criteria, i.e. \n"); printf(" 'WOPR:A-*:0.50' will give the P50 quantile of WOPR for all wells \n"); @@ -824,11 +825,14 @@ int main( int argc , char ** argv ) { hash_type * output_table = hash_alloc(); ensemble_type * ensemble = ensemble_alloc(); { - config_type * config = config_alloc( ); + config_parser_type * config = config_alloc( ); + config_content_type * content; const char * config_arg = argv[1]; - + config_init( config ); - if (config_parse( config , config_arg , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN, true )) { + content = config_parse( config , config_arg , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN, true ); + + if (config_content_is_valid( content )) { char * config_path; util_alloc_file_components( config_arg , &config_path , NULL , NULL); if (config_path != NULL) { @@ -836,17 +840,18 @@ int main( int argc , char ** argv ) { free( config_path ); } } else { - config_fprintf_errors( config , stderr ); + config_error_type * error = config_content_get_errors( content ); + config_error_fprintf( error , true , stderr ); exit(1); } - - - ensemble_init( ensemble , config ); - output_table_init( ensemble_get_refcase( ensemble ) , output_table , config); - config_free( config ); - } + + ensemble_init( ensemble , content ); + output_table_init( ensemble_get_refcase( ensemble ) , output_table , content ); + config_content_free( content ); + config_free( config ); + } output_table_run( output_table , ensemble ); ensemble_free( ensemble ); hash_free( output_table ); diff --git a/ThirdParty/Ert/devel/libecl/applications/ens_plot.c b/ThirdParty/Ert/devel/libecl/applications/ens_plot.c index fd8c4a33c8..87be8abb1b 100644 --- a/ThirdParty/Ert/devel/libecl/applications/ens_plot.c +++ b/ThirdParty/Ert/devel/libecl/applications/ens_plot.c @@ -1886,8 +1886,7 @@ int main(int argc , char ** argv) { install_SIGNALS(); //setvbuf(stdout, NULL, _IOFBF, 0); - - + setenv( "PLPLOT_LIB" , "/project/res/x86_64_RH_5/plplot/plplot-5.10.0/share/plplot5.10.0" , 1); if(argc > 1){ if(strcmp(argv[1], "-b") == 0 || strcmp(argv[1], "-s") == 0) { diff --git a/ThirdParty/Ert/devel/libecl/applications/grid_info.c b/ThirdParty/Ert/devel/libecl/applications/grid_info.c index ad19535881..239de99862 100644 --- a/ThirdParty/Ert/devel/libecl/applications/grid_info.c +++ b/ThirdParty/Ert/devel/libecl/applications/grid_info.c @@ -60,7 +60,7 @@ int main(int argc, char ** argv) { } printf("----\n"); */ - ecl_grid_fwrite_EGRID( ecl_grid , "/tmp/INFO.EGRID"); + ecl_grid_fwrite_EGRID( ecl_grid , "/tmp/INFO.EGRID", true); ecl_grid_free(ecl_grid); } } diff --git a/ThirdParty/Ert/devel/libecl/applications/kw_list.c b/ThirdParty/Ert/devel/libecl/applications/kw_list.c index b98a27dd34..482c3c096c 100644 --- a/ThirdParty/Ert/devel/libecl/applications/kw_list.c +++ b/ThirdParty/Ert/devel/libecl/applications/kw_list.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'kw_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'kw_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -32,14 +32,14 @@ void kw_list(const char *filename) { ecl_kw_type * ecl_kw = ecl_kw_alloc_empty(); bool fmt_file; if (ecl_util_fmt_file(filename , &fmt_file)) { - + printf("-----------------------------------------------------------------\n"); - printf("%s: \n",filename); - fortio = fortio_open_reader(filename , fmt_file , ECL_ENDIAN_FLIP); - while( ecl_kw_fread_realloc(ecl_kw , fortio) ) + printf("%s: \n",filename); + fortio = fortio_open_reader(filename , fmt_file , ECL_ENDIAN_FLIP); + while( ecl_kw_fread_realloc(ecl_kw , fortio) ) ecl_kw_summarize(ecl_kw); printf("-----------------------------------------------------------------\n"); - + ecl_kw_free(ecl_kw); fortio_fclose(fortio); } else diff --git a/ThirdParty/Ert/devel/libecl/applications/make_grid.c b/ThirdParty/Ert/devel/libecl/applications/make_grid.c index ec9d1f4784..f3ba89450b 100644 --- a/ThirdParty/Ert/devel/libecl/applications/make_grid.c +++ b/ThirdParty/Ert/devel/libecl/applications/make_grid.c @@ -48,7 +48,7 @@ int main(int argc, char ** argv) { char * EGRID_file = util_alloc_filename( path , basename , "EGRID"); printf("Writing file: %s ...",EGRID_file); fflush(stdout); - ecl_grid_fwrite_EGRID( ecl_grid , EGRID_file ); + ecl_grid_fwrite_EGRID( ecl_grid , EGRID_file, true ); free( EGRID_file ); } diff --git a/ThirdParty/Ert/devel/libecl/applications/sum_write.c b/ThirdParty/Ert/devel/libecl/applications/sum_write.c index 9495586b15..aee72cdf26 100644 --- a/ThirdParty/Ert/devel/libecl/applications/sum_write.c +++ b/ThirdParty/Ert/devel/libecl/applications/sum_write.c @@ -1,18 +1,18 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - The file 'sum_write' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + The file 'sum_write' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -58,7 +58,7 @@ CASE.SMSPEC CASE.S0001 CASE.S0002 - ------------------------------ -------------------------- --------------------------------------- + ------------------------------ -------------------------- --------------------------------------- | KEYWORD | WGNAMES | NUMS | | MINISTEP 1| MINISTEP 2| | MINISTEP 3| MINISTEP 4| MINISTEP 5| +----------------------------+ +------------------------+ +-------------------------------------+ | TIME | | | --> | | | --> | | | | @@ -106,7 +106,8 @@ 5. The header contains a "TIME" variable; to some extent this looks like just any other variable, but it must be present in the SMSPEC header. In the example above the first element in every - data block is the current time (in days) for that datablock. + data block is the current time (in days) for that datablock; if + labunits is used the stored value is the elapsed time in hours. 6. In the ecl_sum library the concept of a 'gen_key' is used quite extensively. The gen_key is a string combination of the KEYWORD, @@ -114,7 +115,7 @@ relevant elements are combined when forming a gen_key; i.e. for the example above we will have: - ------------------------------ + ------------------------------ | KEYWORD | WGNAMES | NUMS | General key +----------------------------+ ------------ | TIME | | | --> TIME @@ -122,7 +123,7 @@ | GOPR | P-North | | --> GOPR:P-North | BPR | | 5423 | --> BPR:5423 , BPR:i,j,k | WGPR | GasW | | --> WGPR:GasW - +----------------------------+ + +----------------------------+ Note the following: @@ -132,7 +133,7 @@ never inverted, so the join string can be arbitrary. o For the block quantities, like the BPR in the example above - the NUMS value is the cell number in (i,j,k) ordering: + the NUMS value is the cell number in (i,j,k) ordering: NUMS = i + (j - 1)*nx + (k-1)*nx*ny @@ -148,11 +149,11 @@ 2. Use your simulator to step forward in time, and add timesteps with ecl_sum_add_tstep(). - + Now - the important thing is that steps 1 and 2 two can not be - interchanged, that will lead to crash and burn. + interchanged, that will lead to crash and burn. */ - + int main( int argc , char ** argv) { @@ -160,7 +161,7 @@ int main( int argc , char ** argv) { int nx = 10; int ny = 10; int nz = 10; - + smspec_node_type * wwct_wellx; smspec_node_type * wopr_wellx; @@ -173,7 +174,7 @@ int main( int argc , char ** argv) { 1: The case - this an ECLIPSE basename, with an optional leading path component. Can later be modified with ecl_sum_set_case(). - + 2: Should formatted files be used? Can be modified with ecl_sum_set_fmt_output(). @@ -190,18 +191,19 @@ int main( int argc , char ** argv) { 6-8: Grid dimensions. */ - ecl_sum_type * ecl_sum = ecl_sum_alloc_writer( "/tmp/CASE" , false , true , ":" , start_time , nx , ny , nz ); + bool time_in_days = true; + ecl_sum_type * ecl_sum = ecl_sum_alloc_writer( "/tmp/CASE" , false , true , ":" , start_time , time_in_days , nx , ny , nz ); /* We add the variables we wish to measure. Due to the rather inflexible nature of the format we must add all the variables we - are interested in before we start adding data. - + are interested in before we start adding data. + The arguments to this function are: 1. self / this - + 2. The KEYWORD value for the variable we are considering; the function ecl_smspec_identify_var_type() will be called with this string - i.e. you must follow the ECLIPSE rules (see @@ -216,7 +218,7 @@ int main( int argc , char ** argv) { 4. The NUMS value for this variable. 5. The unit for this variable. - + 6. A defualt value for this variable. Observe that as an alternative to ecl_sum_add_var() you can use @@ -229,11 +231,11 @@ int main( int argc , char ** argv) { This is an alternative when e.g. the name of wells is not known in advance. */ - ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); + ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); ecl_sum_add_var( ecl_sum , "WWCT" , "OP-1" , 0 , "(1)" , 0.0 ); ecl_sum_add_var( ecl_sum , "WOPR" , "OP-1" , 0 , "Barrels" , 0.0 ); - + /* The return value from the ecl_sum_add_var() function is an @@ -246,15 +248,15 @@ int main( int argc , char ** argv) { 1. You can just ignore it - that is not very clean; in this case you must make an assumption of gen_key format at a later stage. - + 2. You can use the smspec_node_get_gen_key1() or smspec_node_get_params_index() and hold on to the gen_key or params_index values. You will need these later. 3. You can hold on to the complete smspec_node instance, and then later on call one of the smspec_node_get_params_index() - or smspec_node_get_gen_key1() functions. - + or smspec_node_get_gen_key1() functions. + If you wish to change the WGNAME value with ecl_sum_update_wgname() a later stage you must hold on to the smspec_node instance. @@ -277,7 +279,7 @@ int main( int argc , char ** argv) { Here we add a collection of ten variables which are not initialized. Before they can be actually used you must initialize them with: - + ecl_sum_init_var( ecl_sum , node , keyword , wgname , num , unit ); If you do not init them at all they will appear in the SMSPEC file @@ -291,9 +293,9 @@ int main( int argc , char ** argv) { vector_append_ref( blank_nodes , blank_node ); } } - - - + + + { int num_dates = 10; int num_step = 10; @@ -325,7 +327,7 @@ int main( int argc , char ** argv) { */ ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum , report_step + 1 , sim_days ); - + /* We can just set a value by it's index using the ecl_sum_tstep_iset() function. The index value should come diff --git a/ThirdParty/Ert/devel/libecl/applications/view_summary.c b/ThirdParty/Ert/devel/libecl/applications/view_summary.c index f01eef1c53..9300550a5b 100644 --- a/ThirdParty/Ert/devel/libecl/applications/view_summary.c +++ b/ThirdParty/Ert/devel/libecl/applications/view_summary.c @@ -1,18 +1,18 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - The file 'view_summary.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + The file 'view_summary.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -34,7 +34,7 @@ void install_SIGNALS(void) { signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ signal(SIGINT , util_abort_signal); /* Control C */ - signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. + signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ } @@ -144,23 +144,22 @@ int main(int argc , char ** argv) { bool report_only = false; bool list_mode = false; bool include_restart = true; - ecl_sum_fmt_type fmt; - int arg_offset = 1; + bool print_header = true; + int arg_offset = 1; - ecl_sum_fmt_init_summary_x( &fmt ); #ifdef HAVE_GETOPT if (argc == 1) print_help_and_exit(); else { - + static struct option long_options[] = { {"no-restart" , 0 , 0 , 'n'} , {"list" , 0 , 0 , 'l'} , {"report-only" , 0 , 0 , 'r'} , - {"no-header" , 0 , 0 , 'x'} , + {"no-header" , 0 , 0 , 'x'} , {"help" , 0 , 0 , 'h'} , { 0 , 0 , 0 , 0} }; - + while (1) { int c; int option_index = 0; @@ -180,7 +179,7 @@ int main(int argc , char ** argv) { list_mode = true; break; case 'x': - fmt.print_header = false; + print_header = false; break; case 'h': print_help_and_exit(); @@ -193,38 +192,38 @@ int main(int argc , char ** argv) { arg_offset = optind; /* External static variable in the getopt scope*/ } #endif - + if (arg_offset >= argc) print_help_and_exit(); { char * data_file = argv[arg_offset]; ecl_sum_type * ecl_sum; - int num_keys = argc - arg_offset - 1; + int num_keys = argc - arg_offset - 1; const char ** arg_list = (const char **) &argv[arg_offset + 1]; - - + + ecl_sum = ecl_sum_fread_alloc_case__( data_file , ":" , include_restart); /** If no keys have been presented the function will list available keys. */ if (num_keys == 0) list_mode = true; - + if (ecl_sum != NULL) { if (list_mode) { - /* + /* The program is called in list mode, we only print the (matching) keys in a table on stdout. If no arguments have been given on the commandline, all internalized keys - will be printed. + will be printed. */ - + stringlist_type * keys = stringlist_alloc_new(); if (num_keys == 0) { ecl_sum_select_matching_general_var_list( ecl_sum , "*" , keys); stringlist_sort(keys , NULL ); - } else + } else build_key_list( ecl_sum , keys , num_keys , arg_list); - + { int columns = 5; int i; @@ -238,14 +237,21 @@ int main(int argc , char ** argv) { stringlist_free( keys ); } else { /* Normal operation print results for the various keys on stdout. */ + ecl_sum_fmt_type fmt; stringlist_type * key_list = stringlist_alloc_new( ); build_key_list( ecl_sum , key_list , num_keys , arg_list); + + if (print_header) + ecl_sum_fmt_init_summary_x(ecl_sum , &fmt ); + else + fmt.print_header = false; + ecl_sum_fprintf(ecl_sum , stdout , key_list , report_only , &fmt); stringlist_free( key_list ); } ecl_sum_free(ecl_sum); - } else + } else fprintf(stderr,"summary.x: No summary data found for case:%s\n", data_file ); } } diff --git a/ThirdParty/Ert/devel/libecl/cxx/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/cxx/CMakeLists.txt deleted file mode 100644 index d98fb2f07d..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/src ) -add_subdirectory( src ) diff --git a/ThirdParty/Ert/devel/libecl/cxx/applications/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/cxx/applications/CMakeLists.txt deleted file mode 100644 index abba5dd4f8..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/applications/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -find_package(VTK REQUIRED) -include(${VTK_USE_FILE}) - -add_executable(vtu2ecl vtu2ecl.cxx) -if (VTK_LIBRARIES) - target_link_libraries(vtu2ecl ${VTK_LIBRARIES} eclxx_static ) -else() - target_link_libraries(vtu2ecl vtkHybrid eclxx_static ) -endif() - diff --git a/ThirdParty/Ert/devel/libecl/cxx/applications/vtu2ecl.cxx b/ThirdParty/Ert/devel/libecl/cxx/applications/vtu2ecl.cxx deleted file mode 100644 index 0accea6ed2..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/applications/vtu2ecl.cxx +++ /dev/null @@ -1,110 +0,0 @@ -#include <vtkXMLUnstructuredGridReader.h> -#include <vtkSmartPointer.h> -#include <vtkDataSetMapper.h> -#include <vtkActor.h> -#include <vtkRenderWindow.h> -#include <vtkRenderer.h> -#include <vtkRenderWindowInteractor.h> -#include <vtkUnstructuredGrid.h> -#include <vtkCellData.h> -#include <vtkDataArray.h> -#include <vtkFloatArray.h> -#include <vtkIntArray.h> - -#include <ecl_kw.hpp> -#include <fortio.hpp> - - - -EclKW getKW(vtkCellData * cellData , std::string sourceName , std::string targetName , ecl_type_enum type) { - vtkDataArray * dataArray = cellData->GetArray( sourceName.c_str() ); - if (dataArray) { - vtkFloatArray * floatArray = vtkFloatArray::SafeDownCast( dataArray ); - - return EclKW::create( targetName.c_str() , floatArray->GetSize() , type , floatArray->GetPointer(0)); - } -} - - - - - -int main ( int argc, char *argv[] ) -{ - //parse command line arguments - if(argc != 2) - { - std::cerr << "Usage: " << argv[0] - << " Filename(.vtu)" << std::endl; - return EXIT_FAILURE; - } - - vtkDataSet * dataSet; - std::string filename = argv[1]; - - //read all the data from the file - vtkSmartPointer<vtkXMLUnstructuredGridReader> reader = vtkSmartPointer<vtkXMLUnstructuredGridReader>::New(); - reader->SetFileName(filename.c_str()); - reader->Update(); - reader->GetOutput()->Register(reader); - - dataSet = vtkDataSet::SafeDownCast(reader->GetOutput()); - - std::cout << "Number of cells: " << dataSet->GetNumberOfCells() << std::endl; - std::cout << "Classname: " << dataSet->GetClassName() << std::endl; - - // Now check for cell data - - vtkCellData *cd = dataSet->GetCellData(); - if (cd) - { - FortIO writer = FortIO::writer("/tmp/file" , true); - std::cout << " contains cell data with " - << cd->GetNumberOfArrays() - << " arrays." << std::endl; - - { - EclKW poro = getKW( cd , "PORO" , "PORO" , ECL_FLOAT_TYPE ); - EclKW permx = getKW( cd , "PERMX" , "PERMX" , ECL_FLOAT_TYPE ); - EclKW permy = getKW( cd , "PERMY" , "PERMY" , ECL_FLOAT_TYPE ); - EclKW permz = getKW( cd , "PERMZ" , "PERMZ" , ECL_FLOAT_TYPE ); - } - - for (int i = 0; i < cd->GetNumberOfArrays(); i++) - { - vtkFloatArray * array = vtkFloatArray::SafeDownCast( cd->GetArray(i)); - float * data; - - if (!array) - std::cout << "SafeDownCast() failed" << std::endl; - - std::cout << "\tArray " << i - << " is named " - << (cd->GetArrayName(i) ? cd->GetArrayName(i) : "NULL") - << "Value: " - << array->GetTuple1( 0 ); - - - array->SetTuple1( 0 , 0.25 ); - std::cout << " Updated value: " << array->GetTuple1( 0 ) << std::endl; - - data = array->GetPointer( 0 ); - { - int i; - for (i=0; i < 10; i++) - std::cout << " data[" << i << "] = " << data[i] << std::endl; - } - { - EclKW kw = EclKW::wrap_data("KJELL" , array->GetSize( ) , ECL_FLOAT_TYPE , data); - - - kw.fwrite( writer ); - } - } - writer.close(); - } - - return EXIT_SUCCESS; -} - - diff --git a/ThirdParty/Ert/devel/libecl/cxx/include/ecl_kw.hpp b/ThirdParty/Ert/devel/libecl/cxx/include/ecl_kw.hpp deleted file mode 100644 index e5495a8c76..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/include/ecl_kw.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __ECL_KW_HPP__ -#define __ECL_KW_HPP__ -#include <iostream> - -#include <ecl_util.h> -#include <ecl_kw.h> - -#include <fortio.hpp> - - -class EclKW { -private: - ecl_kw_type * c_ptr; - bool owner; - - EclKW(ecl_kw_type * c_ptr , bool owner) { - this->c_ptr = c_ptr; - this->owner = owner; - std::cout << "Have created: " << ecl_kw_get_header( c_ptr ) << "\n"; - } - - -public: - ecl_kw_type * C_PTR( ) { return c_ptr; } - - //EclKW( const std::string& name , size_t size , ecl_type_enum type , void * data = NULL); - - static EclKW create (const char * name , int size , ecl_type_enum type , void * data = NULL); - static EclKW wrap (ecl_kw_type * c_ptr , bool owner = false); - static EclKW wrap_data(const char * name , int size , ecl_type_enum type, void * data); - - - //EclKW( EclKW& src); - ~EclKW(); - void fwrite( FortIO& fortio ); - - int size( ) { return ecl_kw_get_size( c_ptr ); } - ecl_type_enum type() { return ecl_kw_get_type( c_ptr ); } - - - template <typename T> void set_data( const T * data ) { - ecl_kw_set_memcpy_data( c_ptr , data ); - } - - template <typename T> void iset(int i , T value) { - ecl_kw_iset( c_ptr , i , &value); - } - - template <typename T> T iget(int i ) { - T value; - ecl_kw_iget( c_ptr , i , &value); - return value; - } - -}; - -#endif diff --git a/ThirdParty/Ert/devel/libecl/cxx/include/fortio.hpp b/ThirdParty/Ert/devel/libecl/cxx/include/fortio.hpp deleted file mode 100644 index b63c70ef90..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/include/fortio.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __FORTIO_HPP__ -#define __FORTIO_HPP__ -#include <string> - -#include <fortio.h> - -#ifndef BYTE_ORDER -#define BYTE_ORDER __LITTLE_ENDIAN -#endif -#include <ecl_endian_flip.h> - -class FortIO { - -private: - fortio_type * c_ptr; - - FortIO(fortio_type * c_ptr) { - this->c_ptr = c_ptr; - } - - -public: - ~FortIO() { close(); } - - fortio_type * C_PTR( ) { return c_ptr; } - - static FortIO writer(const std::string & filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP ); - static FortIO reader(const char * filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP ); - static FortIO readwrite( const char * filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP ); - void close(); -}; - -#endif diff --git a/ThirdParty/Ert/devel/libecl/cxx/src/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/cxx/src/CMakeLists.txt deleted file mode 100644 index 857f9b18d1..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/src/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -set( source_files fortio.cxx ecl_kw.cxx ) -set( header_files fortio.hpp ecl_kw.hpp ) - -add_library( eclxx_static STATIC ${source_files}) -add_library( eclxx_shared SHARED ${source_files}) - -set_target_properties( eclxx_static PROPERTIES OUTPUT_NAME eclxx ) -set_target_properties( eclxx_shared PROPERTIES OUTPUT_NAME eclxx ) - -target_link_libraries( eclxx_static ecl_static ) -target_link_libraries( eclxx_shared ecl_shared ) - -if (ECL_INSTALL_PREFIX) - install(TARGETS eclxx_static eclxx_shared DESTINATION ${ECL_INSTALL_PREFIX}/lib) - install(FILES ${header_files} DESTINATION ${ECL_INSTALL_PREFIX}/include) -else() - # - install(TARGETS eclxx_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(FILES ${header_files} DESTINATION include) -endif() diff --git a/ThirdParty/Ert/devel/libecl/cxx/src/ecl_kw.cxx b/ThirdParty/Ert/devel/libecl/cxx/src/ecl_kw.cxx deleted file mode 100644 index 457ab428c4..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/src/ecl_kw.cxx +++ /dev/null @@ -1,58 +0,0 @@ -#include <iostream> - -#include <ecl_kw.h> -#include <ecl_kw.hpp> - - -EclKW EclKW::wrap( ecl_kw_type * c_ptr , bool owner) { - return EclKW( c_ptr , owner ); -} - - -EclKW EclKW::wrap_data(const char * name , int size , ecl_type_enum type, void * data) { - ecl_kw_type * c_ptr = ecl_kw_alloc_new_shared( name , size , type , data ); - return EclKW( c_ptr , true ); -} - - -EclKW EclKW::create( const char * name , int size , ecl_type_enum type , void * data) { - ecl_kw_type * c_ptr = ecl_kw_alloc( name , size , type ); - if (data != NULL) - ecl_kw_set_memcpy_data( c_ptr , data ); - return EclKW( c_ptr , true ); -} - -/*EclKW::EclKW( const std::string& name , size_t size , ecl_type_enum type , void * data) { - c_ptr = ecl_kw_alloc( name.c_str() , (int) size , type ); - if (data != NULL) - ecl_kw_set_memcpy_data( c_ptr , data ); -} -*/ - -EclKW::~EclKW() { - std::cout << "Calling destructor: " << ecl_kw_get_header( c_ptr ) << "\n"; - if (owner) - ecl_kw_free( c_ptr ); -} - -/*EclKW::EclKW( EclKW & src ) { - owner = src.owner; - src.owner = false; - - c_ptr = src.c_ptr; -} -*/ - -/*EclKW::EclKW( EclKW src ) { - owner = sr.>owner; - src.owner = false; - - c_ptr = src.c_ptr; -} -*/ - -void EclKW::fwrite(FortIO& fortio) { - ecl_kw_fwrite( c_ptr , fortio.C_PTR()); -} - - diff --git a/ThirdParty/Ert/devel/libecl/cxx/src/ecl_kw.hpp b/ThirdParty/Ert/devel/libecl/cxx/src/ecl_kw.hpp deleted file mode 100644 index e5495a8c76..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/src/ecl_kw.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __ECL_KW_HPP__ -#define __ECL_KW_HPP__ -#include <iostream> - -#include <ecl_util.h> -#include <ecl_kw.h> - -#include <fortio.hpp> - - -class EclKW { -private: - ecl_kw_type * c_ptr; - bool owner; - - EclKW(ecl_kw_type * c_ptr , bool owner) { - this->c_ptr = c_ptr; - this->owner = owner; - std::cout << "Have created: " << ecl_kw_get_header( c_ptr ) << "\n"; - } - - -public: - ecl_kw_type * C_PTR( ) { return c_ptr; } - - //EclKW( const std::string& name , size_t size , ecl_type_enum type , void * data = NULL); - - static EclKW create (const char * name , int size , ecl_type_enum type , void * data = NULL); - static EclKW wrap (ecl_kw_type * c_ptr , bool owner = false); - static EclKW wrap_data(const char * name , int size , ecl_type_enum type, void * data); - - - //EclKW( EclKW& src); - ~EclKW(); - void fwrite( FortIO& fortio ); - - int size( ) { return ecl_kw_get_size( c_ptr ); } - ecl_type_enum type() { return ecl_kw_get_type( c_ptr ); } - - - template <typename T> void set_data( const T * data ) { - ecl_kw_set_memcpy_data( c_ptr , data ); - } - - template <typename T> void iset(int i , T value) { - ecl_kw_iset( c_ptr , i , &value); - } - - template <typename T> T iget(int i ) { - T value; - ecl_kw_iget( c_ptr , i , &value); - return value; - } - -}; - -#endif diff --git a/ThirdParty/Ert/devel/libecl/cxx/src/fortio.cpp b/ThirdParty/Ert/devel/libecl/cxx/src/fortio.cpp deleted file mode 100644 index 713368ba76..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/src/fortio.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include <string.h> -#include <fortio.hpp> - -static FortIO reader( const char * filename , bool endian_flip_header , bool fmt_file) { - c_ptr = fortio_open_reader( filename , endian_flip_header , fmt_file ); -} - - -static FortIO writer( const std::string & filename , bool endian_flip_header , bool fmt_file) { - c_ptr = fortio_open_reader( filename.c_str() , endian_flip_header , fmt_file ); -} diff --git a/ThirdParty/Ert/devel/libecl/cxx/src/fortio.cxx b/ThirdParty/Ert/devel/libecl/cxx/src/fortio.cxx deleted file mode 100644 index 45cfc7e77a..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/src/fortio.cxx +++ /dev/null @@ -1,27 +0,0 @@ -#include <fortio.hpp> - - -void FortIO::close() { - if (c_ptr) - fortio_fclose( c_ptr ); - c_ptr = NULL; -} - - -FortIO FortIO::reader( const char * filename , bool fmt_file , bool endian_flip_header) { - fortio_type * c_ptr = fortio_open_reader( filename , fmt_file , endian_flip_header); - return FortIO( c_ptr ); -} - - -FortIO FortIO::writer( const std::string & filename , bool fmt_file , bool endian_flip_header ) { - fortio_type * c_ptr = fortio_open_writer( filename.c_str() , fmt_file , endian_flip_header); - return FortIO( c_ptr ); -} - - -FortIO FortIO::readwrite( const char * filename , bool fmt_file , bool endian_flip_header) { - fortio_type * c_ptr = fortio_open_readwrite( filename , fmt_file , endian_flip_header); - return FortIO( c_ptr ); -} - diff --git a/ThirdParty/Ert/devel/libecl/cxx/src/fortio.hpp b/ThirdParty/Ert/devel/libecl/cxx/src/fortio.hpp deleted file mode 100644 index b63c70ef90..0000000000 --- a/ThirdParty/Ert/devel/libecl/cxx/src/fortio.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __FORTIO_HPP__ -#define __FORTIO_HPP__ -#include <string> - -#include <fortio.h> - -#ifndef BYTE_ORDER -#define BYTE_ORDER __LITTLE_ENDIAN -#endif -#include <ecl_endian_flip.h> - -class FortIO { - -private: - fortio_type * c_ptr; - - FortIO(fortio_type * c_ptr) { - this->c_ptr = c_ptr; - } - - -public: - ~FortIO() { close(); } - - fortio_type * C_PTR( ) { return c_ptr; } - - static FortIO writer(const std::string & filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP ); - static FortIO reader(const char * filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP ); - static FortIO readwrite( const char * filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP ); - void close(); -}; - -#endif diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file.h index 905b99d2ec..a2d1b28340 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_file.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_file.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_FILE_H__ @@ -33,7 +33,7 @@ extern "C" { #include <ert/ecl/ecl_util.h> typedef enum { - ECL_FILE_CLOSE_STREAM = 1 , /* + ECL_FILE_CLOSE_STREAM = 1 , /* This flag will close the underlying FILE object between each access; this is mainly to save filedescriptors in cases where many ecl_file instances are open at the same time. */ @@ -60,7 +60,6 @@ extern "C" { void ecl_file_push_block( ecl_file_type * ecl_file ); void ecl_file_pop_block( ecl_file_type * ecl_file ); ecl_file_type * ecl_file_open( const char * filename , int flags); - ecl_file_type * ecl_file_try_open( const char * filename , int flags); void ecl_file_close( ecl_file_type * ecl_file ); void ecl_file_fortio_detach( ecl_file_type * ecl_file ); void ecl_file_free__(void * arg); @@ -76,18 +75,18 @@ extern "C" { ecl_version_enum ecl_file_get_ecl_version( const ecl_file_type * file ); void ecl_file_fwrite_fortio(const ecl_file_type * ec_file , fortio_type * fortio , int offset); void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * , bool fmt_file ); - + void ecl_file_replace_kw( ecl_file_type * ecl_file , ecl_kw_type * old_kw , ecl_kw_type * new_kw , bool insert_copy); int ecl_file_get_phases( const ecl_file_type * init_file ); void ecl_file_fprintf_kw_list( const ecl_file_type * ecl_file , FILE * stream ); - + bool ecl_file_writable( const ecl_file_type * ecl_file ); int ecl_file_get_flags( const ecl_file_type * ecl_file ); void ecl_file_set_flags( ecl_file_type * ecl_file, int new_flags ); bool ecl_file_flags_set( const ecl_file_type * ecl_file , int flags); - - + + ecl_file_kw_type * ecl_file_iget_file_kw( const ecl_file_type * file , int global_index); ecl_file_kw_type * ecl_file_iget_named_file_kw( const ecl_file_type * file , const char * kw, int ith); ecl_kw_type * ecl_file_iget_kw( const ecl_file_type * file , int global_index); @@ -99,7 +98,7 @@ extern "C" { int ecl_file_iget_named_size( const ecl_file_type * file , const char * kw , int ith); void ecl_file_indexed_read(const ecl_file_type * file , const char * kw, int index, const int_vector_type * index_map, char* buffer); - + bool ecl_file_subselect_block( ecl_file_type * ecl_file , const char * kw , int occurence); bool ecl_file_select_block( ecl_file_type * ecl_file , const char * kw , int occurence); void ecl_file_select_global( ecl_file_type * ecl_file ); @@ -124,13 +123,13 @@ extern "C" { void ecl_file_close_fortio_stream(ecl_file_type * ecl_file); ecl_file_type * ecl_file_open_rstblock_report_step( const char * filename , int report_step , int flags); - ecl_file_type * ecl_file_open_rstblock_sim_time( const char * filename , time_t sim_time , int flags); + ecl_file_type * ecl_file_open_rstblock_sim_time( const char * filename , time_t sim_time , int flags); ecl_file_type * ecl_file_iopen_rstblock( const char * filename , int seqnum_index , int flags); - + /*****************************************************************/ /* SUMMARY FILES */ - + bool ecl_file_select_smryblock( ecl_file_type * ecl_file , int ministep_nr ); ecl_file_type * ecl_file_open_smryblock( const char * filename , int ministep_nr , int flags); @@ -139,5 +138,5 @@ extern "C" { #ifdef __cplusplus } -#endif +#endif #endif diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file_kw.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file_kw.h index 3f5c1d2142..f8b810b2b5 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file_kw.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_file_kw.h @@ -49,7 +49,7 @@ typedef struct inv_map_struct inv_map_type; offset_type ecl_file_kw_get_offset(const ecl_file_kw_type * file_kw); bool ecl_file_kw_ptr_eq( const ecl_file_kw_type * file_kw , const ecl_kw_type * ecl_kw); void ecl_file_kw_replace_kw( ecl_file_kw_type * file_kw , fortio_type * target , ecl_kw_type * new_kw ); - void ecl_file_kw_fskip_data( const ecl_file_kw_type * file_kw , fortio_type * fortio); + bool ecl_file_kw_fskip_data( const ecl_file_kw_type * file_kw , fortio_type * fortio); void ecl_file_kw_inplace_fwrite( ecl_file_kw_type * file_kw , fortio_type * fortio); #ifdef __cplusplus diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h index 76a690111f..3c89292906 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_grid.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_grid.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_GRID_H__ @@ -28,24 +28,24 @@ extern "C" { #include <ert/util/stringlist.h> #include <ert/ecl/ecl_coarse_cell.h> -#include <ert/ecl/ecl_kw.h> +#include <ert/ecl/ecl_kw.h> #include <ert/ecl/grid_dims.h> #include <ert/ecl/nnc_info.h> #define ECL_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids. #define ECL_GRID_MAINGRID_LGR_NR 0 - typedef double (block_function_ftype) ( const double_vector_type *); + typedef double (block_function_ftype) ( const double_vector_type *); typedef struct ecl_grid_struct ecl_grid_type; bool ecl_grid_have_coarse_cells( const ecl_grid_type * main_grid ); - bool ecl_grid_cell_in_coarse_group1( const ecl_grid_type * main_grid , int global_index ); - bool ecl_grid_cell_in_coarse_group3( const ecl_grid_type * main_grid , int i , int j , int k); + bool ecl_grid_cell_in_coarse_group1( const ecl_grid_type * main_grid , int global_index ); + bool ecl_grid_cell_in_coarse_group3( const ecl_grid_type * main_grid , int i , int j , int k); int ecl_grid_get_num_coarse_groups( const ecl_grid_type * main_grid ); ecl_coarse_cell_type * ecl_grid_iget_coarse_group( const ecl_grid_type * ecl_grid , int coarse_nr ); ecl_coarse_cell_type * ecl_grid_get_cell_coarse_group1( const ecl_grid_type * ecl_grid , int global_index); ecl_coarse_cell_type * ecl_grid_get_cell_coarse_group3( const ecl_grid_type * ecl_grid , int i , int j , int k); - + void ecl_grid_get_column_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j, double_vector_type * column); int ecl_grid_get_global_index_from_xy_top( const ecl_grid_type * ecl_grid , double x , double y); @@ -55,7 +55,7 @@ extern "C" { void ecl_grid_get_cell_corner_xyz3(const ecl_grid_type * grid , int i , int j , int k, int corner_nr , double * xpos , double * ypos , double * zpos ); void ecl_grid_get_cell_corner_xyz1(const ecl_grid_type * grid , int global_index , int corner_nr , double * xpos , double * ypos , double * zpos ); void ecl_grid_get_corner_xyz(const ecl_grid_type * grid , int i , int j , int k, double * xpos , double * ypos , double * zpos ); - + double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j , int k); double ecl_grid_get_cell_thickness1( const ecl_grid_type * grid , int global_index ); double ecl_grid_get_cdepth1(const ecl_grid_type * grid , int global_index); @@ -70,6 +70,7 @@ extern "C" { bool ecl_grid_cell_contains1(const ecl_grid_type * grid , int global_index , double x , double y , double z); bool ecl_grid_cell_contains3(const ecl_grid_type * grid , int i , int j ,int k , double x , double y , double z); int ecl_grid_get_global_index_from_xyz(ecl_grid_type * grid , double x , double y , double z , int start_index); + bool ecl_grid_get_ij_from_xy( const ecl_grid_type * grid , double x , double y , int k , int* i, int* j); const char * ecl_grid_get_name( const ecl_grid_type * ); int ecl_grid_get_active_index3(const ecl_grid_type * ecl_grid , int i , int j , int k); int ecl_grid_get_active_index1(const ecl_grid_type * ecl_grid , int global_index); @@ -77,14 +78,14 @@ extern "C" { int ecl_grid_get_active_fracture_index1(const ecl_grid_type * ecl_grid , int global_index); bool ecl_grid_cell_active3(const ecl_grid_type * , int , int , int ); bool ecl_grid_cell_active1(const ecl_grid_type * , int); - bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); + bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int ); int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index); int ecl_grid_get_global_index1F(const ecl_grid_type * ecl_grid , int active_fracture_index); - const nnc_info_type * ecl_grid_get_cell_nnc_info3( const ecl_grid_type * grid , int i , int j , int k); - const nnc_info_type * ecl_grid_get_cell_nnc_info1( const ecl_grid_type * grid , int global_index); - + const nnc_info_type * ecl_grid_get_cell_nnc_info3( const ecl_grid_type * grid , int i , int j , int k); + const nnc_info_type * ecl_grid_get_cell_nnc_info1( const ecl_grid_type * grid , int global_index); + ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw ); ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); @@ -94,10 +95,10 @@ extern "C" { ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum); ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const int * actnum); ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const double * depthz , const int * actnum); - + bool ecl_grid_exists( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input ); - + void ecl_grid_free(ecl_grid_type * ); void ecl_grid_free__( void * arg ); grid_dims_type ecl_grid_iget_dims( const ecl_grid_type * grid , int grid_nr); @@ -118,7 +119,7 @@ extern "C" { int ecl_grid_get_global_size( const ecl_grid_type * ecl_grid ); bool ecl_grid_compare(const ecl_grid_type * g1 , const ecl_grid_type * g2 , bool include_lgr, bool include_nnc , bool verbose); int ecl_grid_get_active_size( const ecl_grid_type * ecl_grid ); - + double ecl_grid_get_bottom1(const ecl_grid_type * grid , int global_index); double ecl_grid_get_bottom3(const ecl_grid_type * grid , int i, int j , int k); double ecl_grid_get_bottom1A(const ecl_grid_type * grid , int active_index); @@ -128,17 +129,17 @@ extern "C" { double ecl_grid_get_top2(const ecl_grid_type * grid , int i, int j); double ecl_grid_get_bottom2(const ecl_grid_type * grid , int i, int j); int ecl_grid_locate_depth( const ecl_grid_type * grid , double depth , int i , int j ); - + void ecl_grid_alloc_blocking_variables(ecl_grid_type * , int ); void ecl_grid_init_blocking(ecl_grid_type * ); double ecl_grid_block_eval3d(ecl_grid_type * grid , int i, int j , int k ,block_function_ftype * blockf ); int ecl_grid_get_block_count3d(const ecl_grid_type * ecl_grid , int i , int j, int k); bool ecl_grid_block_value_3d(ecl_grid_type * , double , double ,double , double); - + bool ecl_grid_cell_invalid1(const ecl_grid_type * ecl_grid , int global_index); bool ecl_grid_cell_invalid3(const ecl_grid_type * ecl_grid , int i , int j , int k); double ecl_grid_cell_invalid1A(const ecl_grid_type * grid , int active_index); - + void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream); void ecl_grid_dump_ascii(ecl_grid_type * grid , bool active_only , FILE * stream); void ecl_grid_dump_ascii_cell1(ecl_grid_type * grid , int global_index , FILE * stream, const double * offset); @@ -151,7 +152,7 @@ extern "C" { int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid ); int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid ); int ecl_grid_get_lgr_nr_from_name( const ecl_grid_type * grid , const char * name); - ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_index); + ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_index); ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, int lgr_nr); ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * __lgr_name); bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name); @@ -162,21 +163,21 @@ extern "C" { int ecl_grid_get_parent_cell3( const ecl_grid_type * grid , int i , int j , int k); const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ); bool ecl_grid_is_lgr( const ecl_grid_type * ecl_grid ); - + double ecl_grid_get_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k); float ecl_grid_get_float_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k); double ecl_grid_get_double_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k); int ecl_grid_get_int_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k); - + void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream , double double_default); bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ); - - void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename); + + void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename, bool metric_output); void ecl_grid_fwrite_GRID( const ecl_grid_type * grid , const char * filename); void ecl_grid_fprintf_grdecl( ecl_grid_type * grid , FILE * stream ); void ecl_grid_fwrite_EGRID_header__( int dims[3] , const float mapaxes[6], int dualp_flag , fortio_type * fortio); void ecl_grid_fwrite_EGRID_header( int dims[3] , const float mapaxes[6], fortio_type * fortio); - + float * ecl_grid_alloc_zcorn_data( const ecl_grid_type * grid ); ecl_kw_type * ecl_grid_alloc_zcorn_kw( const ecl_grid_type * grid ); int * ecl_grid_alloc_actnum_data( const ecl_grid_type * grid ); @@ -197,7 +198,7 @@ extern "C" { void ecl_grid_init_zcorn_data( const ecl_grid_type * grid , float * zcorn ); void ecl_grid_init_zcorn_data_double( const ecl_grid_type * grid , double * zcorn ); int ecl_grid_get_zcorn_size( const ecl_grid_type * grid ); - + void ecl_grid_init_coord_data( const ecl_grid_type * grid , float * coord ); void ecl_grid_init_coord_data_double( const ecl_grid_type * grid , double * coord ); int ecl_grid_get_coord_size( const ecl_grid_type * ecl_grid); @@ -206,10 +207,12 @@ extern "C" { bool ecl_grid_use_mapaxes( const ecl_grid_type * grid ); void ecl_grid_init_mapaxes_data_double( const ecl_grid_type * grid , double * mapaxes); void ecl_grid_reset_actnum( ecl_grid_type * grid , const int * actnum ); + void ecl_grid_compressed_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw); + void ecl_grid_global_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw); UTIL_IS_INSTANCE_HEADER( ecl_grid ); UTIL_SAFE_CAST_HEADER( ecl_grid ); - + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h index d84f514653..809a126ee2 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_kw.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_kw.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_KW_H__ @@ -36,15 +36,14 @@ extern "C" { typedef struct ecl_kw_struct ecl_kw_type; - #define ECL_KW_FORTIO_HEADER_SIZE 4 + ECL_STRING_LENGTH + 4 + ECL_TYPE_LENGTH + 4 - + size_t ecl_kw_fortio_size( const ecl_kw_type * ecl_kw ); void * ecl_kw_get_ptr(const ecl_kw_type *ecl_kw); void ecl_kw_set_data_ptr(ecl_kw_type * ecl_kw , void * data); void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio); - void ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio); + bool ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio); ecl_type_enum ecl_kw_get_type(const ecl_kw_type *); - const char * ecl_kw_get_header8(const ecl_kw_type *); + const char * ecl_kw_get_header8(const ecl_kw_type *); const char * ecl_kw_get_header(const ecl_kw_type * ecl_kw ); ecl_kw_type * ecl_kw_alloc_empty(); bool ecl_kw_fread_header(ecl_kw_type *, fortio_type *); @@ -104,31 +103,31 @@ extern "C" { bool ecl_kw_block_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , int cmp_elements); bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data); bool ecl_kw_content_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2); - void ecl_kw_fskip_data__( ecl_type_enum ecl_type , int size , fortio_type * fortio); - void ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio); - void ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio); + bool ecl_kw_fskip_data__( ecl_type_enum ecl_type , int size , fortio_type * fortio); + bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio); + bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio); void ecl_kw_fskip_header( fortio_type * fortio); bool ecl_kw_is_grdecl_file(FILE * ); - bool ecl_kw_is_kw_file(FILE * , bool ); - + bool ecl_kw_is_kw_file(fortio_type * fortio); + int ecl_kw_element_sum_int( const ecl_kw_type * ecl_kw ); double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ); void ecl_kw_inplace_inv(ecl_kw_type * my_kw); void ecl_kw_element_sum(const ecl_kw_type * , void * ); void ecl_kw_max_min(const ecl_kw_type * , void * , void *); void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw); - + ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer); void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer); - + void ecl_kw_fprintf_data( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream); void ecl_kw_memcpy_data( ecl_kw_type * target , const ecl_kw_type * src); - + bool ecl_kw_assert_numeric( const ecl_kw_type * kw ); bool ecl_kw_assert_binary( const ecl_kw_type * kw1, const ecl_kw_type * kw2); - + void ecl_kw_scalar_set_bool( ecl_kw_type * ecl_kw , bool bool_value); void ecl_kw_scalar_set__(ecl_kw_type * ecl_kw , const void * value); void ecl_kw_scalar_set_float_or_double( ecl_kw_type * ecl_kw , double value ); @@ -139,9 +138,9 @@ extern "C" { ECL_KW_SCALAR_SET_TYPED_HEADER( float ) ECL_KW_SCALAR_SET_TYPED_HEADER( double ) #undef ECL_KW_SCALAR_SET_TYPED_HEADER - + ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target_size , const int * mapping, void * def_value); - + void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw); void ecl_kw_inplace_sub( ecl_kw_type * target_kw , const ecl_kw_type * sub_kw); void ecl_kw_inplace_div( ecl_kw_type * target_kw , const ecl_kw_type * div_kw); @@ -152,68 +151,68 @@ extern "C" { void ecl_kw_inplace_mul_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * mul_kw); void ecl_kw_inplace_div_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * div_kw); void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_kw); - + bool ecl_kw_assert_binary_numeric( const ecl_kw_type * kw1, const ecl_kw_type * kw2); #define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2) ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int ); ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float ); ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double ); #undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER - + #define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor) ECL_KW_SCALE_TYPED_HEADER( int ); ECL_KW_SCALE_TYPED_HEADER( float ); ECL_KW_SCALE_TYPED_HEADER( double ); #undef ECL_KW_SCALE_TYPED_HEADER void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor ); - - + + #define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor) ECL_KW_SHIFT_TYPED_HEADER( int ); ECL_KW_SHIFT_TYPED_HEADER( float ); ECL_KW_SHIFT_TYPED_HEADER( double ); #undef ECL_KW_SHIFT_TYPED_HEADER void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ); - - + + #define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int) ECL_KW_IGET_TYPED_HEADER(double); ECL_KW_IGET_TYPED_HEADER(float); ECL_KW_IGET_TYPED_HEADER(int); #undef ECL_KW_IGET_TYPED_HEADER bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i ); - - + + #define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type ) ECL_KW_ISET_TYPED_HEADER(double); ECL_KW_ISET_TYPED_HEADER(float); ECL_KW_ISET_TYPED_HEADER(int); #undef ECL_KW_ISET_TYPED_HEADER void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value); - - + + #define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *) ECL_KW_GET_TYPED_PTR_HEADER(double); ECL_KW_GET_TYPED_PTR_HEADER(float); ECL_KW_GET_TYPED_PTR_HEADER(int); ECL_KW_GET_TYPED_PTR_HEADER(bool); #undef ECL_KW_GET_TYPED_PTR_HEADER - + #define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value) ECL_KW_SET_INDEXED_HEADER( double ); ECL_KW_SET_INDEXED_HEADER( float ); ECL_KW_SET_INDEXED_HEADER( int ); #undef ECL_KW_SET_INDEXED_HEADER - - + + #define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift) ECL_KW_SHIFT_INDEXED_HEADER( int ); ECL_KW_SHIFT_INDEXED_HEADER( float ); ECL_KW_SHIFT_INDEXED_HEADER( double ); #undef ECL_KW_SHIFT_INDEXED_HEADER - - + + #define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale) ECL_KW_SCALE_INDEXED_HEADER( int ); ECL_KW_SCALE_INDEXED_HEADER( float ); @@ -226,9 +225,11 @@ extern "C" { ECL_KW_MAX_MIN_HEADER( float ); ECL_KW_MAX_MIN_HEADER( double ); #undef ECL_KW_MAX_MIN_HEADER - + + void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, const int * actnum); + #include <ert/ecl/ecl_kw_grdecl.h> - + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_magic.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_magic.h index 200e1b7df6..4d064e69fa 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_magic.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_magic.h @@ -5,7 +5,7 @@ extern "C" { #endif -/* +/* This header file contains names and indices of ECLIPSE keywords which have special significance in various files. Observe that many of the keywords like e.g. INTEHEAD occur in many different file @@ -24,37 +24,37 @@ extern "C" { #define DOUBHEAD_KW "DOUBHEAD" #define RPORV_KW "RPORV" #define PORV_KW "PORV" -#define PORMOD_KW "PORV_MOD" +#define PORMOD_KW "PORV_MOD" #define PVTNUM_KW "PVTNUM" #define LGRHEADI_KW "LGRHEADI" #define LGRHEADI_LGR_NR_INDEX 0 -#define LGRJOIN_KW "LGRJOIN" +#define LGRJOIN_KW "LGRJOIN" -/* +/* Observe that many of the elements in the INTEHEAD keyword is shared between the restart and init files. The ones listed below here are in both the INIT and the restart files. In addition the restart files have many well related items which are only in the restart files. */ - - -#define INTEHEAD_UNIT_INDEX 2 -#define INTEHEAD_NX_INDEX 8 -#define INTEHEAD_NY_INDEX 9 -#define INTEHEAD_NZ_INDEX 10 -#define INTEHEAD_NACTIVE_INDEX 11 -#define INTEHEAD_PHASE_INDEX 14 -#define INTEHEAD_DAY_INDEX 64 -#define INTEHEAD_MONTH_INDEX 65 -#define INTEHEAD_YEAR_INDEX 66 -#define INTEHEAD_IPROG_INDEX 94 + + +#define INTEHEAD_UNIT_INDEX 2 +#define INTEHEAD_NX_INDEX 8 +#define INTEHEAD_NY_INDEX 9 +#define INTEHEAD_NZ_INDEX 10 +#define INTEHEAD_NACTIVE_INDEX 11 +#define INTEHEAD_PHASE_INDEX 14 +#define INTEHEAD_DAY_INDEX 64 +#define INTEHEAD_MONTH_INDEX 65 +#define INTEHEAD_YEAR_INDEX 66 +#define INTEHEAD_IPROG_INDEX 94 #define INTEHEAD_METRIC_VALUE 1 #define INTEHEAD_ECLIPSE100_VALUE 100 -#define INTEHEAD_ECLIPSE300_VALUE 300 +#define INTEHEAD_ECLIPSE300_VALUE 300 #define INTEHEAD_ECLIPSE300THERMAL_VALUE 500 #define INTEHEAD_INIT_SIZE 95 @@ -63,18 +63,18 @@ extern "C" { #define LOGIHEAD_ECLIPSE300_RADIAL_INDEX 3 #define LOGIHEAD_ECLIPSE100_RADIAL_INDEX 4 #define LOGIHEAD_DUALP_INDEX 14 -#define LOGIHEAD_INIT_SIZE 80 +#define LOGIHEAD_INIT_SIZE 80 #define LOGIHEAD_RESTART_SIZE 15 -#define LOGIHEAD_RS_INDEX 0 +#define LOGIHEAD_RS_INDEX 0 #define LOGIHEAD_RV_INDEX 1 -#define LOGIHEAD_DIR_RELPERM_INDEX 2 +#define LOGIHEAD_DIR_RELPERM_INDEX 2 /*-----------------------------------------------------------------*/ #define LOGIHEAD_REV_RELPERM100_INDEX 3 /* The indices for reversible relperm and */ #define LOGIHEAD_RADIAL100_INDEX 4 /* use of radial grids is interchanged between */ #define LOGIHEAD_REV_RELPERM300_INDEX 4 /* ECLIPSE100 and ECLIPSE300. */ -#define LOGIHEAD_RADIAL300_INDEX 3 +#define LOGIHEAD_RADIAL300_INDEX 3 /*-----------------------------------------------------------------*/ #define LOGIHEAD_HYSTERISIS_INDEX 6 #define LOGIHEAD_DUALP_INDEX 14 @@ -82,7 +82,7 @@ extern "C" { #define LOGIHEAD_DIR_ENDPOINT_SCALING_INDEX 17 #define LOGIHEAD_REV_ENDPOINT_SCALING_INDEX 18 #define LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX 19 -#define LOGIHEAD_MISC_DISPLACEMENT_INDEX 35 +#define LOGIHEAD_MISC_DISPLACEMENT_INDEX 35 #define LOGIHEAD_SCALE_WATER_PC_AT_MAX_SAT_INDEX 55 #define LOGIHEAD_SCALE_GAS_PC_AT_MAX_SAT_INDEX 56 @@ -101,7 +101,7 @@ extern "C" { present in non-unified files, where the report step must be inferred from the filename. */ #define STARTSOL_KW "STARTSOL" -#define ENDSOL_KW "ENDSOL" +#define ENDSOL_KW "ENDSOL" #define IWEL_KW "IWEL" #define ZWEL_KW "ZWEL" @@ -120,12 +120,12 @@ extern "C" { #define FIPGAS_KW "FIPGAS" #define FIPWAT_KW "FIPWAT" -#define FIPOIL_KW "FIPOIL" +#define FIPOIL_KW "FIPOIL" #define RFIPGAS_KW "RFIPGAS" #define RFIPWAT_KW "RFIPWAT" -#define RFIPOIL_KW "RFIPOIL" +#define RFIPOIL_KW "RFIPOIL" + - #define INTEHEAD_NWELLS_INDEX 16 // Number of wells #define INTEHEAD_NIWELZ_INDEX 24 // Number of elements pr. well in the IWEL array. #define INTEHEAD_NZWELZ_INDEX 27 // Number of 8 character words pr. well @@ -193,7 +193,7 @@ extern "C" { #define RESTART_KW "RESTART" #define SUMMARY_RESTART_SIZE 8 -/* +/* There are no magic indices in the summary data files, for all interesting data the table created from the ecl_smspec file must be consulted. @@ -210,7 +210,7 @@ extern "C" { special information for SEGMENT data is not internalized at all, and there are also several additional keywords for the PLTs which are not internalized. */ - + /* Common keywords */ #define TIME_KW "TIME" /* The days since simulation start when @@ -223,6 +223,7 @@ extern "C" { #define CONIPOS_KW "CONIPOS" /* The i-index of the connections in the well. */ #define CONJPOS_KW "CONJPOS" /* The j-index ... */ #define CONKPOS_KW "CONKPOS" /* The k-index ... */ +#define HOSTGRID_KW "HOSTGRID" /* RFT keywords */ #define SWAT_KW "SWAT" /* The kewyord containing SWAT. */ @@ -236,12 +237,12 @@ extern "C" { #define CONGRAT_KW "CONGRAT" /* Gas ... */ #define CONORAT_KW "CONORAT" /* Oil ... */ #define CONPRES_KW "CONPRES" /* Pressure ... */ -#define CONLENST_KW "CONLENST" /* Length along MSW well */ -#define CONLENEN_KW "CONLENEN" /* Length to connection end for MSW well */ -#define CONVTUB_KW "CONVTUB" /* Volumetric flow at tubing head conditions. */ -#define CONOTUB_KW "CONOTUB" /* Volumetric oil flow at tubing head conditions. */ -#define CONGTUB_KW "CONGTUB" /* Volumetric gas flow at tubing head conditions. */ -#define CONWTUB_KW "CONWTUB" /* Volumetric water flow at tubing head conditions. */ +#define CONLENST_KW "CONLENST" /* Length along MSW well */ +#define CONLENEN_KW "CONLENEN" /* Length to connection end for MSW well */ +#define CONVTUB_KW "CONVTUB" /* Volumetric flow at tubing head conditions. */ +#define CONOTUB_KW "CONOTUB" /* Volumetric oil flow at tubing head conditions. */ +#define CONGTUB_KW "CONGTUB" /* Volumetric gas flow at tubing head conditions. */ +#define CONWTUB_KW "CONWTUB" /* Volumetric water flow at tubing head conditions. */ #define WELLETC_TYPE_INDEX 5 /* At this keyword the WELLETC keyword contains a string @@ -263,32 +264,32 @@ extern "C" { /* GRID and EGRID files have very different structure, and only a few keywords are shared. */ - + /* Common keywords */ #define SPECGRID_KW "SPECGRID" -#define SPECGRID_NX_INDEX 0 -#define SPECGRID_NY_INDEX 1 -#define SPECGRID_NZ_INDEX 2 +#define SPECGRID_NX_INDEX 0 +#define SPECGRID_NY_INDEX 1 +#define SPECGRID_NZ_INDEX 2 #define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to world coordinates. */ -#define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, +#define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements, the second element will be the name of the parent. */ #define MAPUNITS_KW "MAPUNITS" #define GRIDUNIT_KW "GRIDUNIT" - -#define NNCHEAD_KW "NNCHEAD" /*Non-neighbour connection header*/ -#define NNC1_KW "NNC1" /*Upstream cell numbers for non-neighbour connections*/ -#define NNC2_KW "NNC2" /*Downstream cell numbers for non-neighbour connections*/ -#define NNCL_KW "NNCL" /*Cell numbers for LGR cells that are connected to global grid cells*/ -#define NNCG_KW "NNCG" /*Cell numbers for global cells connected to LGR cells*/ + +#define NNCHEAD_KW "NNCHEAD" /*Non-neighbour connection header*/ +#define NNC1_KW "NNC1" /*Upstream cell numbers for non-neighbour connections*/ +#define NNC2_KW "NNC2" /*Downstream cell numbers for non-neighbour connections*/ +#define NNCL_KW "NNCL" /*Cell numbers for LGR cells that are connected to global grid cells*/ +#define NNCG_KW "NNCG" /*Cell numbers for global cells connected to LGR cells*/ #define NNCHEAD_NUMNNC_INDEX 0 /*Item 1 in non-neighbour connection header: number of NNCs. Only present for main grid*/ #define NNCHEAD_LGR_INDEX 1 /*Item 2 in non-neighbour connection header: LGR number (0 for global grid)*/ #define NNCHEADA_KW "NNCHEADA" /*Header for NNC's between two amalgamated LGRs*/ -#define NNA1_KW "NNA1" /*Cell numbers in connecting local grid ILOC1*/ +#define NNA1_KW "NNA1" /*Cell numbers in connecting local grid ILOC1*/ #define NNA2_KW "NNA2" /*Cell numbers in connecting local grid ILOC2*/ #define NNCHEADA_ILOC1_INDEX 0 /*ILOC1: Index of first LGR*/ #define NNCHEADA_ILOC2_INDEX 1 /*ILOC2: Index of second LGR*/ -#define NNA_NUMNNC_INDEX 0 /*Item 1 in NNA1 or NNA2 is number of NNCs*/ +#define NNA_NUMNNC_INDEX 0 /*Item 1 in NNA1 or NNA2 is number of NNCs*/ #define TRANNNC_KW "TRANNNC" #define TRANGL_KW "TRANGL" @@ -305,7 +306,7 @@ extern "C" { #define ENDGRID_KW "ENDGRID" #define ENDLGR_KW "ENDLGR" #define CORSNUM_KW "CORSNUM" - + /* GRID keywords */ #define GRIDHEAD_KW "GRIDHEAD" /* Header information for GRID files. */ #define COORD_KW "COORD" /* Header information for one cell in GRID file. */ @@ -321,7 +322,7 @@ extern "C" { #define GRIDHEAD_NZ_INDEX 3 #define GRIDHEAD_LGR_INDEX 4 #define GRIDHEAD_SIZE 100 - + /* Observe that these indices are one value lower than the values used in the ecl_smspec file. */ #define DIMENS_NX_INDEX 0 @@ -340,15 +341,15 @@ extern "C" { #define FILEHEAD_GRIDTYPE_CORNERPOINT 0 /* <----/ */ #define FILEHEAD_ORGTYPE_CORNERPOINT 1 -#define FILEHEAD_SINGLE_POROSITY 0 -#define FILEHEAD_DUAL_POROSITY 1 -#define FILEHEAD_DUAL_PERMEABILITY 2 +#define FILEHEAD_SINGLE_POROSITY 0 +#define FILEHEAD_DUAL_POROSITY 1 +#define FILEHEAD_DUAL_PERMEABILITY 2 -#define CELL_NOT_ACTIVE 0 +#define CELL_NOT_ACTIVE 0 #define CELL_ACTIVE_MATRIX 1 -#define CELL_ACTIVE CELL_ACTIVE_MATRIX -#define CELL_ACTIVE_FRACTURE 2 +#define CELL_ACTIVE CELL_ACTIVE_MATRIX +#define CELL_ACTIVE_FRACTURE 2 diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_nnc_export.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_nnc_export.h index ffb2d806d5..322fc99950 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_nnc_export.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_nnc_export.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_nnc_export.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_nnc_export.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -24,10 +24,14 @@ extern "C" { #endif +#include <math.h> + #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_file.h> #include <ert/ecl/ecl_kw.h> +#define ERT_ECL_DEFAULT_NNC_TRANS HUGE_VAL + typedef struct { int grid_nr1; int global_index1; @@ -39,8 +43,8 @@ typedef struct { int ecl_nnc_export_get_size( const ecl_grid_type * grid ); - void ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data); - + int ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data); + ecl_kw_type * ecl_nnc_export_get_tranx_kw( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1, int lgr_nr2 ); ecl_kw_type * ecl_nnc_export_get_tranll_kw( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1, int lgr_nr2 ); ecl_kw_type * ecl_nnc_export_get_tran_kw( const ecl_file_type * init_file , const char * kw , int lgr_nr ); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_region.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_region.h index 8c790909e9..8b7e0988d4 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_region.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_region.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_region.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_region.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_REGION_H__ @@ -29,29 +29,30 @@ extern "C" { #include <ert/ecl/ecl_box.h> #include <ert/ecl/ecl_grid.h> +#include <ert/ecl/layer.h> + - typedef enum { SELECT_ALL = 0, - DESELECT_ALL = 1, + DESELECT_ALL = 1, SELECT_FROM_IJK = 2, DESELECT_FROM_IJK = 3, - SELECT_FROM_I = 4, - DSELECT_FROM_I = 5, - SELECT_FROM_J = 6, - DSELECT_FROM_J = 7, - SELECT_FROM_K = 8, - DSELECT_FROM_K = 9, + SELECT_FROM_I = 4, + DSELECT_FROM_I = 5, + SELECT_FROM_J = 6, + DSELECT_FROM_J = 7, + SELECT_FROM_K = 8, + DSELECT_FROM_K = 9, SELECT_EQUAL = 10, DESELECT_EQUAL = 11, - SELECT_IN_INTERVAL = 12, + SELECT_IN_INTERVAL = 12, DESELECT_IN_INTERVAL = 13, INVERT_SELECTION = 14 } ecl_region_select_cmd; -typedef struct ecl_region_struct ecl_region_type; +typedef struct ecl_region_struct ecl_region_type; void ecl_region_unlock( ecl_region_type * region ); void ecl_region_lock( ecl_region_type * region ); @@ -60,34 +61,34 @@ typedef struct ecl_region_struct ecl_region_type; ecl_region_type * ecl_region_alloc( const ecl_grid_type * ecl_grid , bool preselect); void ecl_region_free( ecl_region_type * region ); void ecl_region_free__( void * __region ); - + const int_vector_type * ecl_region_get_active_list( ecl_region_type * region ); const int_vector_type * ecl_region_get_global_list( ecl_region_type * region ); const int_vector_type * ecl_region_get_global_active_list( ecl_region_type * region ); - + bool ecl_region_contains_ijk( const ecl_region_type * ecl_region , int i , int j , int k); bool ecl_region_contains_global( const ecl_region_type * ecl_region , int global_index); bool ecl_region_contains_active( const ecl_region_type * ecl_region , int active_index); - + void ecl_region_invert_selection( ecl_region_type * region ); void ecl_region_select_all( ecl_region_type * region); void ecl_region_deselect_all( ecl_region_type * region ); - + void ecl_region_select_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value); void ecl_region_deselect_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value); - + void ecl_region_select_equal( ecl_region_type * region , const ecl_kw_type * ecl_kw, int value); void ecl_region_deselect_equal( ecl_region_type * region , const ecl_kw_type * ecl_kw, int value); - + void ecl_region_select_inactive_cells( ecl_region_type * region ); void ecl_region_deselect_inactive_cells( ecl_region_type * region ); void ecl_region_select_active_cells( ecl_region_type * region ); void ecl_region_deselect_active_cells( ecl_region_type * region ); - + void ecl_region_select_from_box( ecl_region_type * region , const ecl_box_type * ecl_box ); void ecl_region_deselect_from_box( ecl_region_type * region , const ecl_box_type * ecl_box ); - + void ecl_region_select_from_ijkbox( ecl_region_type * region , int i1 , int i2 , int j1 , int j2 , int k1 , int k2); void ecl_region_deselect_from_ijkbox( ecl_region_type * region , int i1 , int i2 , int j1 , int j2 , int k1 , int k2); @@ -97,58 +98,62 @@ typedef struct ecl_region_struct ecl_region_type; void ecl_region_deselect_j1j2( ecl_region_type * region , int j1 , int i2); void ecl_region_select_k1k2( ecl_region_type * region , int k1 , int k2); void ecl_region_deselect_k1k2( ecl_region_type * region , int k1 , int i2); - + void ecl_region_select_shallow_cells( ecl_region_type * region , double depth_limit ); void ecl_region_deselect_shallow_cells( ecl_region_type * region , double depth_limit ); void ecl_region_select_deep_cells( ecl_region_type * region , double depth_limit ); void ecl_region_deselect_deep_cells( ecl_region_type * region , double depth_limit ); - + void ecl_region_select_thin_cells( ecl_region_type * ecl_region , double dz_limit ); void ecl_region_deselect_thin_cells( ecl_region_type * ecl_region , double dz_limit ); void ecl_region_select_thick_cells( ecl_region_type * ecl_region , double dz_limit ); void ecl_region_deselect_thick_cells( ecl_region_type * ecl_region , double dz_limit ); - + void ecl_region_select_small_cells( ecl_region_type * ecl_region , double volum_limit ); void ecl_region_deselect_small_cells( ecl_region_type * ecl_region , double volum_limit ); void ecl_region_select_large_cells( ecl_region_type * ecl_region , double volum_limit ); void ecl_region_deselect_large_cells( ecl_region_type * ecl_region , double volum_limit ); - + void ecl_region_select_global_index( ecl_region_type * ecl_region , int global_index); void ecl_region_deselect_global_index( ecl_region_type * ecl_region , int global_index); - + void ecl_region_select_active_index( ecl_region_type * ecl_region , int active_index); void ecl_region_deselect_active_index( ecl_region_type * ecl_region , int active_index); - + void ecl_region_intersection( ecl_region_type * region , const ecl_region_type * new_region ); void ecl_region_union( ecl_region_type * region , const ecl_region_type * new_region ); void ecl_region_subtract( ecl_region_type * region , const ecl_region_type * new_region); void ecl_region_xor( ecl_region_type * region , const ecl_region_type * new_region); - + void ecl_region_select_smaller( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit); void ecl_region_deselect_smaller( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit); void ecl_region_select_larger( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit); void ecl_region_deselect_larger( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit); - + void ecl_region_cmp_select_less( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2); void ecl_region_cmp_deselect_less( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2); void ecl_region_cmp_select_more( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2); void ecl_region_cmp_deselect_more( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2); - + void ecl_region_select_in_cylinder( ecl_region_type * region , double x0 , double y0, double R); void ecl_region_deselect_in_cylinder( ecl_region_type * region , double x0 , double y0, double R); void ecl_region_select_in_zcylinder( ecl_region_type * region , double x0 , double y0, double R , double z1 , double z2); void ecl_region_deselect_in_zcylinder( ecl_region_type * region , double x0 , double y0, double R, double z1 , double z2); - + void ecl_region_select_above_plane( ecl_region_type * region, const double n[3] , const double p[3]); void ecl_region_select_below_plane( ecl_region_type * region, const double n[3] , const double p[3]); void ecl_region_deselect_above_plane( ecl_region_type * region, const double n[3] , const double p[3]); void ecl_region_deselect_below_plane( ecl_region_type * region, const double n[3] , const double p[3]); - + void ecl_region_select_inside_polygon( ecl_region_type * region , const geo_polygon_type * polygon); void ecl_region_deselect_inside_polygon( ecl_region_type * region , const geo_polygon_type * polygon); void ecl_region_select_outside_polygon( ecl_region_type * region , const geo_polygon_type * polygon); void ecl_region_deselect_outside_polygon( ecl_region_type * region , const geo_polygon_type * polygon); + void ecl_region_select_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value); + void ecl_region_deselect_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value); + + /*****************************************************************/ /* Functions to manipulate ecl_kw instances . */ @@ -172,11 +177,11 @@ typedef struct ecl_region_struct ecl_region_type; /*****************************************************************/ /* Stupid cpp compat/legacy/cruft functions. */ - int ecl_region_get_active_size_cpp( ecl_region_type * region ); + int ecl_region_get_active_size_cpp( ecl_region_type * region ); int ecl_region_get_global_size_cpp( ecl_region_type * region ); const int * ecl_region_get_active_list_cpp( ecl_region_type * region ); const int * ecl_region_get_global_list_cpp( ecl_region_type * region ); - + /*****************************************************************/ diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_file.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_file.h index 1118fdd011..63e421bc48 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_file.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_file.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_rft_file.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rft_file.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_RFT_FILE_H__ @@ -26,13 +26,15 @@ extern "C" { #include <ert/util/stringlist.h> #include <ert/ecl/ecl_rft_node.h> +#include <ert/util/vector.h> +#include <ert/util/int_vector.h> typedef struct ecl_rft_file_struct ecl_rft_file_type; char * ecl_rft_file_alloc_case_filename(const char * case_input ); const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ); -ecl_rft_file_type * ecl_rft_file_alloc_case(const char * case_input ); -bool ecl_rft_file_case_has_rft(const char * case_input ); +ecl_rft_file_type * ecl_rft_file_alloc_case(const char * case_input ); +bool ecl_rft_file_case_has_rft(const char * case_input ); bool ecl_rft_file_case_has_rft( const char * case_input ); ecl_rft_file_type * ecl_rft_file_alloc(const char * ); void ecl_rft_file_free(ecl_rft_file_type * ); @@ -51,6 +53,7 @@ int ecl_rft_file_get_well_occurences( const ecl_rft_file_t stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_file ); int ecl_rft_file_get_num_wells( const ecl_rft_file_type * rft_file ); void ecl_rft_file_free__( void * arg); +void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes,int num_nodes, ert_ecl_unit_enum unit_set); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_node.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_node.h index 1a4f9fed27..94b3ff97d1 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_node.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rft_node.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_rft_node.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rft_node.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_RFT_NODE_H__ @@ -26,8 +26,8 @@ extern "C" { #include <ert/ecl/ecl_file.h> #include <ert/ecl/ecl_rft_cell.h> -typedef enum { RFT = 1 , - PLT = 2 , +typedef enum { RFT = 1 , + PLT = 2 , SEGMENT = 3 /* Not really implemented */ } ecl_rft_enum; typedef struct ecl_rft_node_struct ecl_rft_node_type; @@ -38,7 +38,6 @@ const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_ const ecl_rft_cell_type * ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k); void ecl_rft_node_fprintf_rft_obs(const ecl_rft_node_type * , double , const char * , const char * , double ); ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * file_map ); -const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * ); void ecl_rft_node_free(ecl_rft_node_type * ); void ecl_rft_node_free__(void * ); time_t ecl_rft_node_get_date(const ecl_rft_node_type * ); @@ -60,6 +59,12 @@ double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index); double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index); double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index); double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index); +void ecl_rft_node_fwrite(const ecl_rft_node_type * rft_node, fortio_type * fortio, ert_ecl_unit_enum unit_set); +double ecl_rft_node_get_days(const ecl_rft_node_type * rft_node ); +int ecl_rft_node_cmp( const ecl_rft_node_type * n1 , const ecl_rft_node_type * n2); + +void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell); +ecl_rft_node_type * ecl_rft_node_alloc_new(const char * well_name, const char * data_type_string, const time_t recording_date, const double days); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rst_file.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rst_file.h index df4998486b..c94f764b04 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rst_file.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rst_file.h @@ -20,12 +20,15 @@ #ifndef __ECL_RST_FILE_H__ #define __ECL_RST_FILE_H__ +#include <ert/ecl/ecl_rsthead.h> + #ifdef __cplusplus extern "C" { #endif - typedef struct ecl_rst_file_struct ecl_rst_file_type; +typedef struct ecl_rst_file_struct ecl_rst_file_type; + ecl_rst_file_type * ecl_rst_file_open_read( const char * filename ); ecl_rst_file_type * ecl_rst_file_open_write( const char * filename ); @@ -34,9 +37,10 @@ extern "C" { void ecl_rst_file_start_solution( ecl_rst_file_type * rst_file ); void ecl_rst_file_end_solution( ecl_rst_file_type * rst_file ); - void ecl_rst_file_fwrite_header( ecl_rst_file_type * rst_file , int seqnum , time_t date , double days , int nx , int ny ,int nz , int nactive , int phases); + void ecl_rst_file_fwrite_header( ecl_rst_file_type * rst_file , int seqnum, ecl_rsthead_type * rsthead_data ); void ecl_rst_file_add_kw(ecl_rst_file_type * rst_file , const ecl_kw_type * ecl_kw ); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rsthead.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rsthead.h index 75f12f5037..b4f68af660 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rsthead.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rsthead.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_RSTHEAD.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_RSTHEAD.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_RSTHEAD_H__ @@ -36,7 +36,7 @@ extern "C" { time_t sim_time; int version; // 100, 300, 500 (Eclipse300-Thermal) int phase_sum; // Oil = 1 Gas = 2 Water = 4 - + int nx; int ny; int nz; @@ -50,26 +50,26 @@ extern "C" { // Pure well properties int nwells; // Number of wells - int niwelz; // Number of elements pr well in IWEL array - int nzwelz; // Number of 8 character words pr well in ZWEL array + int niwelz; // Number of elements pr well in IWEL array + int nzwelz; // Number of 8 character words pr well in ZWEL array // Connection properties - int niconz; // Number of elements per completion in ICON array + int niconz; // Number of elements per completion in ICON array int ncwmax; // Maximum number of completions per well int nsconz; // Number of elements per completion in SCON array // Segment properties - int nisegz; // Number of entries pr segment in the ISEG array - int nsegmx; // The maximum number of segments pr well - int nswlmx; // The maximum number of segmented wells + int nisegz; // Number of entries pr segment in the ISEG array + int nsegmx; // The maximum number of segments pr well + int nswlmx; // The maximum number of segmented wells int nlbrmx; // The maximum number of lateral branches pr well - int nilbrz; // The number of entries pr segment in ILBR array + int nilbrz; // The number of entries pr segment in ILBR array int nrsegz; // The number of entries pr segment in RSEG array // Properteies from the LOGIHEAD keyword: bool dualp; - + // Properties from the DOUBHEAD keyword: double sim_days; } ecl_rsthead_type; @@ -79,10 +79,12 @@ extern "C" { void ecl_rsthead_free( ecl_rsthead_type * rsthead ); ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence); ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_type * rst_file ); + ecl_rsthead_type * ecl_rsthead_alloc_empty(); time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw ); void ecl_rsthead_fprintf( const ecl_rsthead_type * header , FILE * stream); void ecl_rsthead_fprintf_struct( const ecl_rsthead_type * header , FILE * stream); bool ecl_rsthead_equal( const ecl_rsthead_type * header1 , const ecl_rsthead_type * header2); + double ecl_rsthead_get_sim_days( const ecl_rsthead_type * header ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_smspec.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_smspec.h index bf32c70799..1323029046 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_smspec.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_smspec.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_smspec.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_smspec.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_SMSPEC__ @@ -31,7 +31,7 @@ extern "C" { #include <ert/ecl/smspec_node.h> -typedef struct ecl_smspec_struct ecl_smspec_type; +typedef struct ecl_smspec_struct ecl_smspec_type; /** @@ -45,20 +45,19 @@ typedef struct ecl_smspec_struct ecl_smspec_type; */ const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node); - void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); - void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node ); + void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); + void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node ); ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index ); bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ); bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ); const char * ecl_smspec_get_var_type_name( ecl_smspec_var_type var_type ); ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var); - ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , time_t sim_start , int nx , int ny , int nz); + ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz); void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , bool fmt_file ); - + ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * key_join_string , bool include_restart); void ecl_smspec_free( ecl_smspec_type *); - - int ecl_smspec_get_sim_days_index( const ecl_smspec_type * smspec ); + int ecl_smspec_get_date_day_index( const ecl_smspec_type * smspec ); int ecl_smspec_get_date_month_index( const ecl_smspec_type * smspec ); int ecl_smspec_get_date_year_index( const ecl_smspec_type * smspec ); @@ -79,7 +78,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; const smspec_node_type * ecl_smspec_get_region_var_node(const ecl_smspec_type * ecl_smspec , const char *region_var , int region_nr); int ecl_smspec_get_region_var_params_index(const ecl_smspec_type * ecl_smspec , const char * region_var , int region_nr); bool ecl_smspec_has_region_var(const ecl_smspec_type * ecl_smspec , const char * region_var , int region_nr); - + const smspec_node_type * ecl_smspec_get_misc_var_node(const ecl_smspec_type * ecl_smspec , const char *var); int ecl_smspec_get_misc_var_params_index(const ecl_smspec_type * ecl_smspec , const char *var); bool ecl_smspec_has_misc_var(const ecl_smspec_type * ecl_smspec , const char *var); @@ -87,21 +86,21 @@ typedef struct ecl_smspec_struct ecl_smspec_type; const smspec_node_type * ecl_smspec_get_block_var_node(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr); int ecl_smspec_get_block_var_params_index(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr); bool ecl_smspec_has_block_var(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr); - + const smspec_node_type * ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k); int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k); bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k); - + const smspec_node_type * ecl_smspec_get_well_completion_var_node(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr); int ecl_smspec_get_well_completion_var_params_index(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr); bool ecl_smspec_has_well_completion_var(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr); - + const smspec_node_type * ecl_smspec_get_general_var_node( const ecl_smspec_type * smspec , const char * lookup_kw ); int ecl_smspec_get_general_var_params_index(const ecl_smspec_type * ecl_smspec , const char * lookup_kw); bool ecl_smspec_has_general_var(const ecl_smspec_type * ecl_smspec , const char * lookup_kw); const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec , const char * lookup_kw); - + //bool ecl_smspec_general_is_total(const ecl_smspec_type * ecl_smspec , const char * gen_key); //bool ecl_smspec_is_rate(const ecl_smspec_type * smspec , int kw_index); //ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index ); @@ -109,14 +108,15 @@ typedef struct ecl_smspec_struct ecl_smspec_type; //int ecl_smspec_iget_num( const ecl_smspec_type * smspec , int index ); //const char * ecl_smspec_iget_wgname( const ecl_smspec_type * smspec , int index ); //const char * ecl_smspec_iget_keyword( const ecl_smspec_type * smspec , int index ); - - void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit ); + + void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit ); void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern); + int ecl_smspec_get_time_seconds( const ecl_smspec_type * ecl_smspec ); int ecl_smspec_get_time_index( const ecl_smspec_type * ecl_smspec ); time_t ecl_smspec_get_start_time(const ecl_smspec_type * ); /*****************************************************************/ @@ -133,6 +133,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; const int * ecl_smspec_get_grid_dims( const ecl_smspec_type * smspec ); int ecl_smspec_get_params_size( const ecl_smspec_type * smspec ); + int ecl_smspec_num_nodes( const ecl_smspec_type * smspec); const smspec_node_type * ecl_smspec_iget_node( const ecl_smspec_type * smspec , int index ); void ecl_smspec_lock( ecl_smspec_type * smspec ); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h index 41ada81092..9ecf59114f 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_sum.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_sum.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_SUM_H__ @@ -51,17 +51,18 @@ extern "C" { char * date_dash; char * value_dash; } ecl_sum_fmt_type; - + void ecl_sum_fmt_init_csv( ecl_sum_fmt_type * fmt ); - void ecl_sum_fmt_init_summary_x( ecl_sum_fmt_type * fmt ); + /*****************************************************************/ typedef struct ecl_sum_struct ecl_sum_type; + void ecl_sum_fmt_init_summary_x( const ecl_sum_type * ecl_sum , ecl_sum_fmt_type * fmt ); double ecl_sum_get_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const smspec_node_type * node); double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const smspec_node_type * node); double ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time); - + void ecl_sum_set_unified( ecl_sum_type * ecl_sum , bool unified ); void ecl_sum_set_fmt_case( ecl_sum_type * ecl_sum , bool fmt_case ); @@ -93,39 +94,39 @@ typedef struct ecl_sum_struct ecl_sum_type; ecl_sum_type * ecl_sum_fread_alloc_case(const char * , const char * key_join_string); ecl_sum_type * ecl_sum_fread_alloc_case__(const char * , const char * key_join_string , bool include_restart); bool ecl_sum_case_exists( const char * input_file ); - + /* Accessor functions : */ double ecl_sum_get_well_var(const ecl_sum_type * ecl_sum , int time_index , const char * well , const char *var); bool ecl_sum_has_well_var(const ecl_sum_type * ecl_sum , const char * well , const char *var); double ecl_sum_get_well_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * well , const char * var); double ecl_sum_get_well_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * well , const char * var); - + double ecl_sum_get_group_var(const ecl_sum_type * ecl_sum , int time_index , const char * group , const char *var); bool ecl_sum_has_group_var(const ecl_sum_type * ecl_sum , const char * group , const char *var); - + double ecl_sum_get_field_var(const ecl_sum_type * ecl_sum , int time_index , const char *var); bool ecl_sum_has_field_var(const ecl_sum_type * ecl_sum , const char *var); double ecl_sum_get_field_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var); double ecl_sum_get_field_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var); - + double ecl_sum_get_block_var(const ecl_sum_type * ecl_sum , int time_index , const char * block_var , int block_nr); int ecl_sum_get_block_var_index(const ecl_sum_type * ecl_sum , const char * block_var , int block_nr); bool ecl_sum_has_block_var(const ecl_sum_type * ecl_sum , const char * block_var , int block_nr); double ecl_sum_get_block_var_ijk(const ecl_sum_type * ecl_sum , int time_index , const char * block_var , int i , int j , int k); int ecl_sum_get_block_var_index_ijk(const ecl_sum_type * ecl_sum , const char * block_var , int i , int j , int k); bool ecl_sum_has_block_var_ijk(const ecl_sum_type * ecl_sum , const char * block_var , int i , int j , int k); - + double ecl_sum_get_region_var(const ecl_sum_type * ecl_sum , int time_index , const char *var , int region_nr); bool ecl_sum_has_region_var(const ecl_sum_type * ecl_sum , const char *var , int region_nr); - + double ecl_sum_get_misc_var(const ecl_sum_type * ecl_sum , int time_index , const char *var); int ecl_sum_get_misc_var_index(const ecl_sum_type * ecl_sum , const char *var); bool ecl_sum_has_misc_var(const ecl_sum_type * ecl_sum , const char *var); - + double ecl_sum_get_well_completion_var(const ecl_sum_type * ecl_sum , int time_index , const char * well , const char *var, int cell_nr); int ecl_sum_get_well_completion_var_index(const ecl_sum_type * ecl_sum , const char * well , const char *var, int cell_nr); bool ecl_sum_has_well_completion_var(const ecl_sum_type * ecl_sum , const char * well , const char *var, int cell_nr); - + double ecl_sum_get_general_var(const ecl_sum_type * ecl_sum , int time_index , const char * lookup_kw); int ecl_sum_get_general_var_params_index(const ecl_sum_type * ecl_sum , const char * lookup_kw); const smspec_node_type * ecl_sum_get_general_var_node(const ecl_sum_type * ecl_sum , const char * lookup_kw); @@ -136,12 +137,12 @@ typedef struct ecl_sum_struct ecl_sum_type; const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const char * var); /***************/ void ecl_sum_fprintf(const ecl_sum_type * , FILE * , const stringlist_type * , bool report_only , const ecl_sum_fmt_type * fmt); - - - - + + + + /* Time related functions */ - int ecl_sum_get_first_gt( const ecl_sum_type * ecl_sum , int param_index , double limit); + int ecl_sum_get_first_gt( const ecl_sum_type * ecl_sum , int param_index , double limit); int ecl_sum_get_first_lt( const ecl_sum_type * ecl_sum , int param_index , double limit); int ecl_sum_get_last_report_step( const ecl_sum_type * ecl_sum ); int ecl_sum_get_first_report_step( const ecl_sum_type * ecl_sum ); @@ -152,8 +153,8 @@ typedef struct ecl_sum_struct ecl_sum_type; int ecl_sum_iget_report_step( const ecl_sum_type * ecl_sum , int internal_index ); int ecl_sum_iget_mini_step( const ecl_sum_type * ecl_sum , int internal_index ); double ecl_sum_iget_general_var(const ecl_sum_type * ecl_sum , int internal_index , const char * lookup_kw); - - + + void ecl_sum_init_data_vector( const ecl_sum_type * ecl_sum , double_vector_type * data_vector , int data_index , bool report_only ); double_vector_type * ecl_sum_alloc_data_vector( const ecl_sum_type * ecl_sum , int data_index , bool report_only); time_t_vector_type * ecl_sum_alloc_time_vector( const ecl_sum_type * ecl_sum , bool report_only); @@ -167,7 +168,7 @@ typedef struct ecl_sum_struct ecl_sum_type; const char * ecl_sum_get_abs_path(const ecl_sum_type * ecl_sum ); const char * ecl_sum_get_case(const ecl_sum_type * ); bool ecl_sum_same_case( const ecl_sum_type * ecl_sum , const char * input_file ); - + void ecl_sum_resample_from_sim_days( const ecl_sum_type * ecl_sum , const double_vector_type * sim_days , double_vector_type * value , const char * gen_key); void ecl_sum_resample_from_sim_time( const ecl_sum_type * ecl_sum , const time_t_vector_type * sim_time , double_vector_type * value , const char * gen_key); time_t ecl_sum_time_from_days( const ecl_sum_type * ecl_sum , double sim_days ); @@ -179,25 +180,25 @@ typedef struct ecl_sum_struct ecl_sum_type; stringlist_type * ecl_sum_alloc_well_list( const ecl_sum_type * ecl_sum , const char * pattern); stringlist_type * ecl_sum_alloc_group_list( const ecl_sum_type * ecl_sum , const char * pattern); stringlist_type * ecl_sum_alloc_well_var_list( const ecl_sum_type * ecl_sum ); - stringlist_type * ecl_sum_alloc_matching_general_var_list(const ecl_sum_type * ecl_sum , const char * pattern); + stringlist_type * ecl_sum_alloc_matching_general_var_list(const ecl_sum_type * ecl_sum , const char * pattern); void ecl_sum_select_matching_general_var_list( const ecl_sum_type * ecl_sum , const char * pattern , stringlist_type * keys); const ecl_smspec_type * ecl_sum_get_smspec( const ecl_sum_type * ecl_sum ); ecl_smspec_var_type ecl_sum_identify_var_type(const char * var); ecl_smspec_var_type ecl_sum_get_var_type( const ecl_sum_type * ecl_sum , const char * gen_key); bool ecl_sum_var_is_rate( const ecl_sum_type * ecl_sum , const char * gen_key); bool ecl_sum_var_is_total( const ecl_sum_type * ecl_sum , const char * gen_key); - + int ecl_sum_iget_report_end( const ecl_sum_type * ecl_sum , int report_step ); int ecl_sum_iget_report_start( const ecl_sum_type * ecl_sum , int report_step ); - ecl_sum_type * ecl_sum_alloc_writer( const char * ecl_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , int nx , int ny , int nz); + ecl_sum_type * ecl_sum_alloc_writer( const char * ecl_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz); void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case); void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value); smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value); void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit); - ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days); + ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_seconds); void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname ); bool ecl_sum_is_oil_producer( const ecl_sum_type * ecl_sum , const char * well); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h index 047800dc1c..6bc5603c3e 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_sum_data.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_sum_data.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_SUM_DATA_H__ @@ -33,11 +33,12 @@ extern "C" { #include <ert/ecl/ecl_sum_tstep.h> #include <ert/ecl/smspec_node.h> +#include <ert/ecl/ecl_sum_vector.h> -typedef struct ecl_sum_data_struct ecl_sum_data_type ; +typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_fwrite_step( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified, int report_step); void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified); - void ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist); + bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist); void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist); ecl_sum_data_type * ecl_sum_data_alloc_writer( ecl_smspec_type * smspec ); ecl_sum_data_type * ecl_sum_data_alloc( ecl_smspec_type * smspec); @@ -51,41 +52,42 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_init_data_vector( const ecl_sum_data_type * data , double_vector_type * data_vector , int data_index , bool report_only); void ecl_sum_data_init_time_vector( const ecl_sum_data_type * data , time_t_vector_type * time_vector , bool report_only); time_t_vector_type * ecl_sum_data_alloc_time_vector( const ecl_sum_data_type * data , bool report_only); - time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data ); + time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data ); time_t ecl_sum_data_get_report_time( const ecl_sum_data_type * data , int report_step); double ecl_sum_data_get_first_day( const ecl_sum_data_type * data); const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data); - time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data ); - time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data ); - double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ); + time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data ); + time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data ); + double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ); void ecl_sum_data_summarize(const ecl_sum_data_type * data , FILE * stream); double ecl_sum_data_iget( const ecl_sum_data_type * data , int internal_index , int params_index ); - + double ecl_sum_data_iget_sim_days( const ecl_sum_data_type * , int ); time_t ecl_sum_data_iget_sim_time( const ecl_sum_data_type * , int ); - - + + bool ecl_sum_data_has_report_step(const ecl_sum_data_type * , int ); - + ecl_sum_data_type * ecl_sum_data_fread_alloc( ecl_smspec_type * , const stringlist_type * filelist , bool include_restart); void ecl_sum_data_free( ecl_sum_data_type * ); int ecl_sum_data_get_last_report_step( const ecl_sum_data_type * data ); int ecl_sum_data_get_first_report_step( const ecl_sum_data_type * data ); int ecl_sum_data_get_first_ministep( const ecl_sum_data_type * data ); int ecl_sum_data_get_last_ministep( const ecl_sum_data_type * data ); - + double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node); double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node); - + int ecl_sum_data_get_length( const ecl_sum_data_type * data ); int ecl_sum_data_iget_report_step(const ecl_sum_data_type * data , int internal_index); int ecl_sum_data_iget_mini_step(const ecl_sum_data_type * data , int internal_index); int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_step ); int ecl_sum_data_iget_report_start( const ecl_sum_data_type * data , int report_step ); - ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_days); + ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_seconds); bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2); bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2); - + void ecl_sum_data_write_csv_file(const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, FILE *fp); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_tstep.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_tstep.h index 94dc7e32e4..c0f285e49f 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_tstep.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_tstep.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ecl_sum_tstep.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ecl_sum_tstep.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_SUM_TSTEP_H__ @@ -35,15 +35,17 @@ typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type; void ecl_sum_tstep_free__( void * __ministep); ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file(int report_step , int ministep_nr , - const ecl_kw_type * params_kw , - const char * src_file , + const ecl_kw_type * params_kw , + const char * src_file , const ecl_smspec_type * smspec); - - ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , float sim_days , const ecl_smspec_type * smspec ); - + + ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , float sim_seconds , const ecl_smspec_type * smspec ); + double ecl_sum_tstep_iget(const ecl_sum_tstep_type * ministep , int index); time_t ecl_sum_tstep_get_sim_time(const ecl_sum_tstep_type * ministep); double ecl_sum_tstep_get_sim_days(const ecl_sum_tstep_type * ministep); + double ecl_sum_tstep_get_sim_seconds(const ecl_sum_tstep_type * ministep); + int ecl_sum_tstep_get_report(const ecl_sum_tstep_type * ministep); int ecl_sum_tstep_get_ministep(const ecl_sum_tstep_type * ministep); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_vector.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_vector.h new file mode 100644 index 0000000000..4e265d383f --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_vector.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ecl_sum_vector.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#ifndef __ECL_SUM_VECTOR_H__ +#define __ECL_SUM_VECTOR_H__ + +#ifdef __cplusplus +extern "C" { +#endif +#include <ert/ecl/ecl_sum.h> + +typedef struct ecl_sum_vector_struct ecl_sum_vector_type; + + void ecl_sum_vector_free( ecl_sum_vector_type * keylist ); + ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum); + + bool ecl_sum_vector_add_key( ecl_sum_vector_type * keylist, const char * key); + void ecl_sum_vector_add_keys( ecl_sum_vector_type * keylist, const char * pattern); + + bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index); + int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index); + int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h index 92c8454e4d..df304122ab 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_util.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_util.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_UTIL_H__ @@ -27,19 +27,19 @@ extern "C" { #include <ert/util/stringlist.h> #include <ert/util/time_t_vector.h> #include <ert/util/parser.h> - - -typedef enum { ECL_OTHER_FILE = 0 , - ECL_RESTART_FILE = 1 , - ECL_UNIFIED_RESTART_FILE = 2 , - ECL_SUMMARY_FILE = 4 , - ECL_UNIFIED_SUMMARY_FILE = 8 , - ECL_SUMMARY_HEADER_FILE = 16 , - ECL_GRID_FILE = 32 , - ECL_EGRID_FILE = 64 , + + +typedef enum { ECL_OTHER_FILE = 0 , + ECL_RESTART_FILE = 1 , + ECL_UNIFIED_RESTART_FILE = 2 , + ECL_SUMMARY_FILE = 4 , + ECL_UNIFIED_SUMMARY_FILE = 8 , + ECL_SUMMARY_HEADER_FILE = 16 , + ECL_GRID_FILE = 32 , + ECL_EGRID_FILE = 64 , ECL_INIT_FILE = 128 , ECL_RFT_FILE = 256 , - ECL_DATA_FILE = 512 } ecl_file_enum; + ECL_DATA_FILE = 512 } ecl_file_enum; #define ECL_FILE_ENUM_DEFS {.value = 0 , .name="ECL_OTHER_FILE"}, \ @@ -62,7 +62,7 @@ typedef enum { ECL_OTHER_FILE = 0 , can be stored. */ - + typedef enum { ECL_INVALID_STORAGE = 0, ECL_BINARY_UNIFIED = 1, ECL_FORMATTED_UNIFIED = 2, @@ -75,24 +75,23 @@ typedef enum { ECL_OTHER_FILE = 0 , i.e. 'REAL', 'INTE', ... , come as 4 character strings. */ - #define ECL_STRING_LENGTH 8 #define ECL_TYPE_LENGTH 4 - - +#define ECL_KW_HEADER_DATA_SIZE ECL_STRING_LENGTH + ECL_TYPE_LENGTH + 4 +#define ECL_KW_HEADER_FORTIO_SIZE ECL_KW_HEADER_DATA_SIZE + 8 /*****************************************************************/ -/* +/* Observe that these type identidiers are (ab)used in both the rms and ert/enkf libraries in situations where ECLIPSE is not at all involved. */ typedef enum { - ECL_CHAR_TYPE = 0, - ECL_FLOAT_TYPE = 1, - ECL_DOUBLE_TYPE = 2, - ECL_INT_TYPE = 3, - ECL_BOOL_TYPE = 4, + ECL_CHAR_TYPE = 0, + ECL_FLOAT_TYPE = 1, + ECL_DOUBLE_TYPE = 2, + ECL_INT_TYPE = 3, + ECL_BOOL_TYPE = 4, ECL_MESS_TYPE = 5 } ecl_type_enum; @@ -111,12 +110,12 @@ typedef enum { The libecl library has been built and tested 99.5% with ECLIPSE100 as context, but in thye gravity code there is some very limited functionality related to ECLIPSE100 versus ECLIPSE300 functionality. -*/ +*/ typedef enum { ECLIPSE_UNDEFINED = 0, ECLIPSE100 = 1, - ECLIPSE300 = 2 + ECLIPSE300 = 2 } ecl_version_enum; /* @@ -126,7 +125,7 @@ typedef enum { The function ecl_util_get_phase_name() can be used to lookup a string name from an enum value. - + The phases in a simulation will typically be a sum of these fundamental phases, and represented as an integer. */ @@ -142,10 +141,10 @@ typedef enum { typedef enum { - ECL_METRIC_UNITS = 0, - ECL_FIELD_UNITS = 1, - ECL_LAB_UNITS = 2 -} ecl_unit_enum; + ERT_ECL_METRIC_UNITS = 0, + ERT_ECL_FIELD_UNITS = 1, + ERT_ECL_LAB_UNITS = 2 +} ert_ecl_unit_enum; #define ECL_UNIT_ENUM_DEFS {.value = 0 , .name = "ECL_METRIC_UNITS"}, {.value = 1 , .name = "ECL_FIELD_UNITS"} , {.value = 2 , .name = "ECL_LAB_UNITS"} #define ECL_UNIT_ENUM_SIZE 3 @@ -153,7 +152,7 @@ typedef enum { // For unformatted files: #define ECL_BOOL_TRUE_INT -1 // Binary representation: 11111111 11111111 11111111 1111111 -#define ECL_BOOL_FALSE_INT 0 // Binary representation: 00000000 00000000 00000000 0000000 +#define ECL_BOOL_FALSE_INT 0 // Binary representation: 00000000 00000000 00000000 0000000 #define ECL_COMMENT_STRING "--" #define ECL_COMMENT_CHAR '-' // Need to consecutive to make an ECLIPSE comment #define ECL_DATA_TERMINATION "/" @@ -185,7 +184,7 @@ int ecl_util_get_month_nr(const char * month_name); int ecl_util_fname_report_cmp(const void *f1, const void *f2); time_t ecl_util_make_date(int mday , int month , int year); time_t ecl_util_make_date__(int mday , int month , int year, int * year_offset); -ecl_unit_enum ecl_util_get_unit_set(const char * data_file); +ert_ecl_unit_enum ecl_util_get_unit_set(const char * data_file); bool ecl_util_valid_basename_fmt( const char * basename_fmt ); bool ecl_util_valid_basename( const char * basename ); @@ -195,6 +194,7 @@ const char * ecl_util_file_enum_iget( int index, int * value); int ecl_util_select_filelist( const char * path , const char * base , ecl_file_enum file_type , bool fmt_file , stringlist_type * filelist); void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end); void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date); +void ecl_util_set_date_values(time_t t , int * mday , int * month , int * year); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/fault_block.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/fault_block.h index c5f8a2ba05..fbbc32cbb0 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/fault_block.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/fault_block.h @@ -26,6 +26,8 @@ extern "C" { #include <ert/util/double_vector.h> #include <ert/util/type_macros.h> +#include <ert/geometry/geo_polygon_collection.h> + #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_kw.h> @@ -49,7 +51,7 @@ extern "C" { bool fault_block_trace_edge( const fault_block_type * block , double_vector_type * x_list , double_vector_type * y_list, int_vector_type * cell_list); const int_vector_type * fault_block_get_global_index_list( const fault_block_type * fault_block); void fault_block_copy_content(fault_block_type * target_block , const fault_block_type * src_block ); - void fault_block_list_neighbours( const fault_block_type * block, int_vector_type * neighbour_list); + void fault_block_list_neighbours( const fault_block_type * block , bool connected_only , const geo_polygon_collection_type * polylines , int_vector_type * neighbour_list); UTIL_IS_INSTANCE_HEADER(fault_block); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/fortio.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/fortio.h index cecd64cc79..754e6c76e5 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/fortio.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/fortio.h @@ -43,35 +43,32 @@ typedef struct fortio_struct fortio_type; fortio_status_type fortio_check_buffer( FILE * stream , bool endian_flip , size_t buffer_size ); fortio_status_type fortio_check_file( const char * filename , bool endian_flip); - bool fortio_guess_endian_flip(const char * , bool *); - bool fortio_is_fortran_file(const char * , bool * ); + bool fortio_looks_like_fortran_file(const char * , bool ); void fortio_copy_record(fortio_type * , fortio_type * , int , void * , bool *); - fortio_type * fortio_alloc_FILE_wrapper(const char * , bool , bool , FILE * ); fortio_type * fortio_open_reader(const char *, bool fmt_file , bool endian_flip_header); fortio_type * fortio_open_writer(const char *, bool fmt_file , bool endian_flip_header); fortio_type * fortio_open_readwrite(const char *, bool fmt_file , bool endian_flip_header); fortio_type * fortio_open_append(const char *filename , bool fmt_file , bool endian_flip_header); + fortio_type * fortio_alloc_FILE_wrapper(const char * , bool , bool , bool , FILE * ); void fortio_free_FILE_wrapper(fortio_type *); void fortio_fclose(fortio_type *); int fortio_init_read(fortio_type *); - void fortio_complete_read(fortio_type *); + bool fortio_complete_read(fortio_type *, int record_size); void fortio_init_write(fortio_type * , int); - void fortio_complete_write(fortio_type *); + void fortio_complete_write(fortio_type * , int record_size); void fortio_fskip_buffer(fortio_type *, int ); int fortio_fskip_record(fortio_type *); - int fortio_fread_record(fortio_type * , char *buffer); - void fortio_fread_buffer(fortio_type * , char * , int ); - void fortio_fwrite_record(fortio_type * , const char *, int); + bool fortio_fread_buffer(fortio_type * , char * buffer, int buffer_size); + void fortio_fwrite_record(fortio_type * , const char * buffer, int buffer_size); FILE * fortio_get_FILE(const fortio_type *); void fortio_fflush(fortio_type * ) ; - int fortio_get_record_size(const fortio_type *); bool fortio_is_fortio_file(fortio_type * ); void fortio_rewind(const fortio_type *fortio); const char * fortio_filename_ref(const fortio_type * ); bool fortio_fmt_file(const fortio_type *); offset_type fortio_ftell( const fortio_type * fortio ); - int fortio_fseek( fortio_type * fortio , offset_type offset , int whence); - void fortio_data_fskip(fortio_type* fortio, const int element_size, const int element_count, const int block_count); + bool fortio_fseek( fortio_type * fortio , offset_type offset , int whence); + bool fortio_data_fskip(fortio_type* fortio, const int element_size, const int element_count, const int block_count); void fortio_data_fseek(fortio_type* fortio, offset_type data_offset, size_t data_element, const int element_size, const int element_count, const int block_size); int fortio_fileno( fortio_type * fortio ); @@ -79,7 +76,7 @@ typedef struct fortio_struct fortio_type; bool fortio_fopen_stream( fortio_type * fortio ); bool fortio_stream_is_open( const fortio_type * fortio ); bool fortio_assert_stream_open( fortio_type * fortio ); - + bool fortio_read_at_eof( fortio_type * fortio ); UTIL_IS_INSTANCE_HEADER( fortio ); UTIL_SAFE_CAST_HEADER( fortio ); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/layer.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/layer.h index 4aaad8260a..fae3e71479 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/layer.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/layer.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'layer.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'layer.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __LAYER_H__ @@ -27,10 +27,11 @@ extern "C" { #include <ert/util/struct_vector.h> #include <ert/util/type_macros.h> +#include <ert/ecl/ecl_grid.h> -/* +/* The elements in this enum are (ab)used as indexes into a int[] vector; - i.e. the must span the values 0..3. + i.e. the must span the values 0..3. */ typedef enum { @@ -46,9 +47,11 @@ extern "C" { } int_point2d_type; - + typedef struct layer_struct layer_type; + bool layer_iget_left_barrier( const layer_type * layer, int i , int j); + bool layer_iget_bottom_barrier( const layer_type * layer, int i , int j); int layer_get_nx( const layer_type * layer ); int layer_get_ny( const layer_type * layer ); void layer_fprintf_cell( const layer_type * layer , int i , int j , FILE * stream); @@ -57,6 +60,7 @@ extern "C" { layer_type * layer_alloc(int nx , int ny); void layer_free( layer_type * layer ); int layer_replace_cell_values( layer_type * layer , int old_value , int new_value); + bool layer_iget_active( const layer_type * layer, int i , int j); int layer_iget_cell_value( const layer_type * layer, int i , int j); void layer_iset_cell_value( layer_type * layer , int i , int j , int value); int layer_iget_edge_value( const layer_type * layer , int i , int j , edge_dir_enum dir); @@ -66,8 +70,15 @@ extern "C" { int layer_get_cell_sum( const layer_type * layer ); bool layer_trace_block_content( layer_type * layer , bool erase , int start_i , int start_j , int value , int_vector_type * i_list , int_vector_type * j_list); bool layer_trace_block_edge( const layer_type * layer , int i , int j , int value , struct_vector_type * corner_list , int_vector_type * cell_list); - - + bool layer_cell_contact( const layer_type * layer , int i1 , int j1 , int i2 , int j2); + void layer_add_interp_barrier( layer_type * layer , int c1 , int c2); + void layer_add_ijbarrier( layer_type * layer , int i1 , int j1 , int i2 , int j2 ); + void layer_add_barrier( layer_type * layer , int c1 , int c2); + void layer_memcpy(layer_type * target_layer , const layer_type * src_layer); + void layer_update_active( layer_type * layer , const ecl_grid_type * grid , int k); + + void layer_cells_equal( const layer_type * layer , int value , int_vector_type * i_list , int_vector_type * j_list); + UTIL_IS_INSTANCE_HEADER( layer ); UTIL_SAFE_CAST_HEADER( layer ); diff --git a/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt index d3d79e2c17..0258867d02 100644 --- a/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt @@ -17,7 +17,8 @@ set( source_files ecl_sum_data.c ecl_util.c ecl_kw.c - ecl_sum.c + ecl_sum.c + ecl_sum_vector.c fortio.c ecl_rft_file.c ecl_rft_node.c @@ -57,7 +58,8 @@ set( header_files ecl_sum_data.h ecl_util.h ecl_kw.h - ecl_sum.h + ecl_sum.h + ecl_sum_vector.h fortio.h ecl_rft_file.h ecl_rft_node.h diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_file.c b/ThirdParty/Ert/devel/libecl/src/ecl_file.c index 092bb68b3f..4894d490fa 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_file.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_file.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdio.h> @@ -49,12 +49,12 @@ with a collection of ecl_kw instances and has various query functions, however it does not utilize knowledge of the structure/content of the files in the way e.g. ecl_grid.c does[1]. - + The main datatype here is the ecl_file type, but in addition each ecl_kw instance is wrapped in an ecl_file_kw (implemented in ecl_file_kw.c) structure and all the indexing is implemented with the file_map type. The file_map type is not used outside this file. - + When the file is opened an index of all the keywords is created and stored in the field global_map, and the field active_map is set to point to global_map, i.e. all query/get operations on the ecl_file @@ -67,9 +67,9 @@ a keyword from name and occurence number, and then including all keywords up to the next occurence of the same keyword: - SEQHDR ---\ - MINISTEP 0 | - PARAMS ..... | + SEQHDR ---\ + MINISTEP 0 | + PARAMS ..... | MINISTEP 1 | Block 0 PARAMS ..... | MINISTEP 2 | @@ -83,14 +83,14 @@ SEQHDR ---+ MINISTEP 6 | Block 2 PARAMS .... | - SEQHDR ---+ - MINISTEP 7 | + SEQHDR ---+ + MINISTEP 7 | PARAMS .... | Block 3 MINISTEP 8 | PARAMS .... | - + For the unified summary file depicted here e.g. the call - + ecl_file_get_blockmap( ecl_file , "SEQHDR" , 2 ) Will create a sub-index consisting of the (three) keywords in what @@ -99,7 +99,7 @@ of functionality is required to get from natural time coordinates (i.e. simulation time or report step) to the occurence number (see ecl_rstfile for more details). - + To select a subindex as the active index you use the ecl_file_select_block() function, or alternatively you can use ecl_file_open_block() to directly select the relevant block @@ -109,8 +109,8 @@ calls to create a new sub index will also use the global_map index - i.e. the indexing is not recursive, a sub index is always created based on the global_map, and not on the currently active map. - - + + [1]: This is not entirely true - in the file ecl_rstfile.c; which is included from this file are several specialized function for working with restart files. However the restart files are @@ -128,7 +128,7 @@ typedef struct file_map_struct file_map_type; struct file_map_struct { vector_type * kw_list; /* This is a vector of ecl_file_kw instances corresponding to the content of the file. */ hash_type * kw_index; /* A hash table with integer vectors of indices - see comment below. */ - stringlist_type * distinct_kw; /* A stringlist of the keywords occuring in the file - each string occurs ONLY ONCE. */ + stringlist_type * distinct_kw; /* A stringlist of the keywords occuring in the file - each string occurs ONLY ONCE. */ fortio_type * fortio; /* The same fortio instance pointer as in the ecl_file styructure. */ bool owner; /* Is this map the owner of the ecl_file_kw instances; only true for the global_map. */ inv_map_type * inv_map; /* Shared reference owned by the ecl_file structure. */ @@ -158,10 +158,10 @@ struct ecl_file_struct { with entries 'SEQHDR', 'MINISTEP' and 'PARAMS'. Each entry in the hash table is an integer vector which again contains the internal index of the various occurences: - + ------------------ SEQHDR \ - MINISTEP 0 | + MINISTEP 0 | PARAMS ..... | MINISTEP 1 | PARAMS ..... | @@ -172,7 +172,7 @@ struct ecl_file_struct { kw_index = {"SEQHDR": [0], "MINISTEP": [1,3,5], "PARAMS": [2,4,6]} <== This is hash table. kw_list = [SEQHDR , MINISTEP , PARAMS , MINISTEP , PARAMS , MINISTEP , PARAMS] distinct_kw = [SEQHDR , MINISTEP , PARAMS] - + */ @@ -208,7 +208,7 @@ static int file_map_get_global_index( const file_map_type * file_map , const cha int global_index = int_vector_iget( index_vector , ith); return global_index; } - + /** @@ -216,7 +216,7 @@ static int file_map_get_global_index( const file_map_type * file_map , const cha internal index fields 'kw_index' and 'distinct_kw'. This function must be called every time the content of the kw_list vector is modified (otherwise the ecl_file instance will be in an - inconsistent state). + inconsistent state). */ @@ -233,7 +233,7 @@ static void file_map_make_index( file_map_type * file_map ) { hash_insert_hash_owned_ref( file_map->kw_index , header , index_vector , int_vector_free__); stringlist_append_copy( file_map->distinct_kw , header); } - + { int_vector_type * index_vector = hash_get( file_map->kw_index , header); int_vector_append( index_vector , i); @@ -244,7 +244,7 @@ static void file_map_make_index( file_map_type * file_map ) { static bool file_map_has_kw( const file_map_type * file_map, const char * kw) { return hash_has_key( file_map->kw_index , kw ); -} +} static ecl_file_kw_type * file_map_iget_file_kw( const file_map_type * file_map , int global_index) { @@ -265,7 +265,7 @@ static ecl_kw_type * file_map_iget_kw( const file_map_type * file_map , int inde ecl_kw_type * ecl_kw = ecl_file_kw_get_kw_ptr( file_kw , file_map->fortio , file_map->inv_map); if (!ecl_kw) { if (fortio_assert_stream_open( file_map->fortio )) { - + ecl_kw = ecl_file_kw_get_kw( file_kw , file_map->fortio , file_map->inv_map); if (FILE_FLAGS_SET( file_map->flags[0] , ECL_FILE_CLOSE_STREAM)) @@ -283,7 +283,7 @@ static void file_map_index_fload_kw(const file_map_type * file_map, const char* ecl_type_enum ecl_type = ecl_file_kw_get_type(file_kw); int element_count = ecl_file_kw_get_size(file_kw); - ecl_kw_fread_indexed_data(file_map->fortio, offset + ECL_KW_FORTIO_HEADER_SIZE, ecl_type, element_count, index_map, buffer); + ecl_kw_fread_indexed_data(file_map->fortio, offset + ECL_KW_HEADER_FORTIO_SIZE, ecl_type, element_count, index_map, buffer); } } @@ -339,9 +339,9 @@ static ecl_kw_type * file_map_iget_named_kw( const file_map_type * file_map , co ecl_kw_type * ecl_kw = ecl_file_kw_get_kw_ptr( file_kw , file_map->fortio , file_map->inv_map ); if (!ecl_kw) { if (fortio_assert_stream_open( file_map->fortio )) { - + ecl_kw = ecl_file_kw_get_kw( file_kw , file_map->fortio , file_map->inv_map); - + if (FILE_FLAGS_SET( file_map->flags[0] , ECL_FILE_CLOSE_STREAM)) fortio_fclose_stream( file_map->fortio ); } @@ -365,16 +365,16 @@ static void file_map_replace_kw( file_map_type * file_map , ecl_kw_type * old_kw while (index < vector_get_size( file_map->kw_list )) { ecl_file_kw_type * ikw = vector_iget( file_map->kw_list , index ); if (ecl_file_kw_ptr_eq( ikw , old_kw)) { - /* + /* Found it; observe that the vector_iset() function will - automatically invoke the destructor on the old_kw. + automatically invoke the destructor on the old_kw. */ ecl_kw_type * insert_kw = new_kw; - + if (insert_copy) insert_kw = ecl_kw_alloc_copy( new_kw ); ecl_file_kw_replace_kw( ikw , file_map->fortio , insert_kw ); - + file_map_make_index( file_map ); return; } @@ -386,7 +386,7 @@ static void file_map_replace_kw( file_map_type * file_map , ecl_kw_type * old_kw static bool file_map_load_all( file_map_type * file_map ) { bool loadOK = false; - + if (fortio_assert_stream_open( file_map->fortio )) { int index; for (index = 0; index < vector_get_size( file_map->kw_list); index++) { @@ -409,9 +409,9 @@ static bool file_map_load_all( file_map_type * file_map ) { static void file_map_add_kw( file_map_type * file_map , ecl_file_kw_type * file_kw) { if (file_map->owner) - vector_append_owned_ref( file_map->kw_list , file_kw , ecl_file_kw_free__ ); + vector_append_owned_ref( file_map->kw_list , file_kw , ecl_file_kw_free__ ); else - vector_append_ref( file_map->kw_list , file_kw); + vector_append_ref( file_map->kw_list , file_kw); } static void file_map_free( file_map_type * file_map ) { @@ -451,7 +451,7 @@ static int file_map_iget_occurence( const file_map_type * file_map , int global_ const char * header = ecl_file_kw_get_header( file_kw ); const int_vector_type * index_vector = hash_get( file_map->kw_index , header ); const int * index_data = int_vector_get_const_ptr( index_vector ); - + int occurence = -1; { /* Manual reverse lookup. */ @@ -471,8 +471,8 @@ static void file_map_fprintf_kw_list(const file_map_type * file_map , FILE * str for (i=0; i < vector_get_size( file_map->kw_list ); i++) { const ecl_file_kw_type * file_kw = vector_iget_const( file_map->kw_list , i ); fprintf(stream , "%-8s %7d:%s\n", - ecl_file_kw_get_header( file_kw ) , - ecl_file_kw_get_size( file_kw ) , + ecl_file_kw_get_header( file_kw ) , + ecl_file_kw_get_size( file_kw ) , ecl_util_get_type_name( ecl_file_kw_get_type( file_kw ))); } } @@ -486,20 +486,20 @@ static file_map_type * file_map_alloc_blockmap(const file_map_type * file_map , if (file_map_has_kw( file_map , header )) { int kw_index = file_map_get_global_index( file_map , header , occurence ); ecl_file_kw_type * file_kw = vector_iget( file_map->kw_list , kw_index ); - + while (true) { file_map_add_kw( block_map , file_kw ); - + kw_index++; if (kw_index == vector_get_size( file_map->kw_list )) - break; + break; else { file_kw = vector_iget(file_map->kw_list , kw_index); if (strcmp( header , ecl_file_kw_get_header( file_kw )) == 0) break; } } - } + } file_map_make_index( block_map ); return block_map; } else @@ -536,7 +536,7 @@ void ecl_file_fwrite_fortio(const ecl_file_type * ecl_file , fortio_type * targe -/* +/* Observe : if the filename is a standard filename which can be used to infer formatted/unformatted automagically the fmt_file variable is NOT consulted. @@ -545,11 +545,11 @@ void ecl_file_fwrite_fortio(const ecl_file_type * ecl_file , fortio_type * targe void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * filename, bool fmt_file) { bool __fmt_file; ecl_file_enum file_type; - + file_type = ecl_util_get_file_type( filename , &__fmt_file , NULL); if (file_type == ECL_OTHER_FILE) __fmt_file = fmt_file; - + { fortio_type * target = fortio_open_writer( filename , __fmt_file , ECL_ENDIAN_FLIP); ecl_file_fwrite_fortio( ecl_file , target , 0); @@ -591,7 +591,7 @@ void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * filename, boo .... for (ikw = 0; ikw < ecl_file_get_num_distinct_kw(ecl_file); ikw++) { const char * kw = ecl_file_iget_distinct_kw(ecl_file , ikw); - + printf("The file contains: %d occurences of \'%s\' \n",ecl_file_get_num_named_kw( ecl_file , kw) , kw); } .... @@ -601,7 +601,7 @@ void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * filename, boo The file contains 1 occurences of 'SEQHDR' The file contains 3 occurences of 'MINISTEP' The file contains 3 occurences of 'PARAMS' - + */ @@ -623,7 +623,7 @@ void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * filename, boo @old_kw can not be found the function will fail hard - to verify that @new_kw is indeed in the ecl_file instance you should use ecl_file_has_kw_ptr() first. - + The ecl_file function typically gives out references to the internal ecl_kw instances via the ecl_file_iget_kw() function. Use of ecl_file_replace_kw() might lead to invalidating ecl_kw @@ -634,22 +634,22 @@ void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * filename, boo ecl_file_type * restart_file = ecl_file_fread_alloc( "ECLIPSE.UNRST" ); ecl_kw_type * initial_pressure = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , 0); ecl_kw_type * faked_pressure = ecl_kw_alloc_copy( initial_pressure ); - + ecl_kw_scale( faked_pressure , 1.25 ); ecl_file_replace_kw( restart_file , initial_pressure , faked_pressure , false ); <--- This call will invalidate the inital_pressure reference .... .... - // This will fail horribly: + // This will fail horribly: printf("The initial pressure in cell(0) was:%g \n",ecl_kw_iget_double( initial_pressure , 0 )); /|\ | - +---------> Using initial_pressure => Crash and burn! - + +---------> Using initial_pressure => Crash and burn! + The ecl_file structure takes ownership of all the keywords, and will also take ownership of the newly instered @new_kw instance; if the boolean @insert_copy is set to true the function will insert a - copy of @new_kw, leaving the original reference untouched. -*/ + copy of @new_kw, leaving the original reference untouched. +*/ @@ -665,7 +665,7 @@ ecl_kw_type * ecl_file_icopy_named_kw( const ecl_file_type * ecl_file , const ch return ecl_kw_alloc_copy( ecl_file_iget_named_kw( ecl_file , kw , ith )); } - + /* Will return the number of times a particular keyword occurs in a ecl_file instance. Will return 0 if the keyword can not be found. @@ -692,7 +692,7 @@ int ecl_file_get_num_named_kw(const ecl_file_type * ecl_file , const char * kw) ecl_file_iget_occurence(ecl_file , 2) -> 0; Global index 2 will look up the first occurence of PARAMS. - + ecl_file_iget_occurence(ecl_file , 5) -> 2; Global index 5 will look up th third occurence of MINISTEP. @@ -705,7 +705,7 @@ int ecl_file_iget_occurence( const ecl_file_type * ecl_file , int index) { } -/** +/** Returns the total number of ecl_kw instances in the ecl_file instance. */ @@ -778,10 +778,10 @@ const char * ecl_file_iget_header( const ecl_file_type * file , int global_index /* ---------- */ -/* +/* This function will return the ith occurence of 'kw' in ecl_file. Will abort hard if the request can not be satisifed - use - query functions if you can not take that. + query functions if you can not take that. */ ecl_kw_type * ecl_file_iget_named_kw( const ecl_file_type * file , const char * kw, int ith) { @@ -815,7 +815,7 @@ static file_map_type * ecl_file_get_blockmap( ecl_file_type * ecl_file , const c blockmap = file_map_alloc_blockmap( ecl_file->global_map , kw , occurence ); else blockmap = file_map_alloc_blockmap( ecl_file->active_map , kw , occurence ); - + if (blockmap != NULL) ecl_file_add_map( ecl_file , blockmap ); return blockmap; @@ -824,7 +824,7 @@ static file_map_type * ecl_file_get_blockmap( ecl_file_type * ecl_file , const c /*****************************************************************/ /* - Different functions to open and close a file. + Different functions to open and close a file. */ /** @@ -835,23 +835,37 @@ static file_map_type * ecl_file_get_blockmap( ecl_file_type * ecl_file , const c map. */ -static void ecl_file_scan( ecl_file_type * ecl_file ) { +static bool ecl_file_scan( ecl_file_type * ecl_file ) { + bool scan_ok = false; fortio_fseek( ecl_file->fortio , 0 , SEEK_SET ); { ecl_kw_type * work_kw = ecl_kw_alloc_new("WORK-KW" , 0 , ECL_INT_TYPE , NULL); - offset_type current_offset; + while (true) { - current_offset = fortio_ftell( ecl_file->fortio ); - if (ecl_kw_fread_header( work_kw , ecl_file->fortio )) { - ecl_file_kw_type * file_kw = ecl_file_kw_alloc( work_kw , current_offset); - file_map_add_kw( ecl_file->global_map , file_kw ); - ecl_file_kw_fskip_data( file_kw , ecl_file->fortio ); - } else + if (fortio_read_at_eof(ecl_file->fortio)) { + scan_ok = true; break; + } + + { + offset_type current_offset = fortio_ftell( ecl_file->fortio ); + if (ecl_kw_fread_header( work_kw , ecl_file->fortio)) { + ecl_file_kw_type * file_kw = ecl_file_kw_alloc( work_kw , current_offset); + if (ecl_file_kw_fskip_data( file_kw , ecl_file->fortio )) + file_map_add_kw( ecl_file->global_map , file_kw ); + else + break; + } else + break; + } } + ecl_kw_free( work_kw ); } - file_map_make_index( ecl_file->global_map ); + if (scan_ok) + file_map_make_index( ecl_file->global_map ); + + return scan_ok; } @@ -868,54 +882,44 @@ void ecl_file_select_global( ecl_file_type * ecl_file ) { structure. No keyword data will be loaded from the file. The ecl_file instance will retain an open fortio reference to the - file until ecl_file_close() is called. + file until ecl_file_close() is called. */ -static ecl_file_type * ecl_file_open__( const char * filename , int flags) { +ecl_file_type * ecl_file_open( const char * filename , int flags) { fortio_type * fortio; bool fmt_file; ecl_util_fmt_file( filename , &fmt_file); //flags |= ECL_FILE_CLOSE_STREAM; // DEBUG DEBUG DEBUG - + if (FILE_FLAGS_SET(flags , ECL_FILE_WRITABLE)) fortio = fortio_open_readwrite( filename , fmt_file , ECL_ENDIAN_FLIP); - else - fortio = fortio_open_reader( filename , fmt_file , ECL_ENDIAN_FLIP); + else + fortio = fortio_open_reader( filename , fmt_file , ECL_ENDIAN_FLIP); if (fortio) { ecl_file_type * ecl_file = ecl_file_alloc_empty( flags ); ecl_file->fortio = fortio; ecl_file->global_map = file_map_alloc( ecl_file->fortio , &ecl_file->flags , ecl_file->inv_map , true ); - + ecl_file_add_map( ecl_file , ecl_file->global_map ); - ecl_file_scan( ecl_file ); - ecl_file_select_global( ecl_file ); - - if (FILE_FLAGS_SET( ecl_file->flags , ECL_FILE_CLOSE_STREAM)) - fortio_fclose_stream( ecl_file->fortio ); - - return ecl_file; - } else - return NULL; -} + if (ecl_file_scan( ecl_file )) { + ecl_file_select_global( ecl_file ); + if (FILE_FLAGS_SET( ecl_file->flags , ECL_FILE_CLOSE_STREAM)) + fortio_fclose_stream( ecl_file->fortio ); -ecl_file_type * ecl_file_open( const char * filename , int flags) { - ecl_file_type * ecl_file = ecl_file_open__(filename , flags ); - if (ecl_file) - return ecl_file; - else { - util_abort("%s: failed to open ECLIPSE file:%s \n",__func__ , filename); + return ecl_file; + } else { + ecl_file_close( ecl_file ); + return NULL; + } + } else return NULL; - } } -ecl_file_type * ecl_file_try_open( const char * filename, int flags) { - return ecl_file_open__(filename , flags ); -} @@ -974,7 +978,7 @@ bool ecl_file_select_block( ecl_file_type * ecl_file , const char * kw , int occ void ecl_file_close(ecl_file_type * ecl_file) { if (ecl_file->fortio != NULL) fortio_fclose( ecl_file->fortio ); - + inv_map_free( ecl_file->inv_map ); vector_free( ecl_file->map_list ); vector_free( ecl_file->map_stack ); @@ -1019,7 +1023,7 @@ void ecl_file_free__(void * arg) { /* Here we include two files with functions specialized to work with restart and summary files. Observe that the files ecl_rstfile.c and ecl_smryfile are compiled as part of the same compilation unit as - ecl_file.c + ecl_file.c */ #include "ecl_rstfile.c" @@ -1033,10 +1037,10 @@ void ecl_file_free__(void * arg) { The input @file must be either an INIT file or a restart file. Will fail hard if an INTEHEAD kw can not be found - or if the INTEHEAD keyword is not sufficiently large. - + The eclipse files can distinguish between ECLIPSE300 ( value == 300) and ECLIPSE300-Thermal option (value == 500). This function will - return ECLIPSE300 in both those cases. + return ECLIPSE300 in both those cases. */ ecl_version_enum ecl_file_get_ecl_version( const ecl_file_type * file ) { @@ -1079,14 +1083,14 @@ bool ecl_file_writable( const ecl_file_type * ecl_file ) { /** Checks if the ecl_file contains ecl_kw; this check is based on pointer equality - i.e. we check if the ecl_file contains exactly - this keyword - not an arbitrary equivalent keyword. + this keyword - not an arbitrary equivalent keyword. This function can be called as a safeguard before calling - ecl_file_save_kw(). + ecl_file_save_kw(). */ bool ecl_file_has_kw_ptr( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_kw) { - ecl_file_kw_type * file_kw = inv_map_get_file_kw( ecl_file->inv_map , ecl_kw ); + ecl_file_kw_type * file_kw = inv_map_get_file_kw( ecl_file->inv_map , ecl_kw ); if (file_kw == NULL) return false; else @@ -1108,19 +1112,19 @@ bool ecl_file_has_kw_ptr( const ecl_file_type * ecl_file , const ecl_kw_type * e will ensue if this is not satisfied. 3. The ecl_file must have been opened with one of the _writable() - open functions. + open functions. */ bool ecl_file_save_kw( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_kw) { - ecl_file_kw_type * file_kw = inv_map_get_file_kw( ecl_file->inv_map , ecl_kw ); // We just verify that the input ecl_kw points to an ecl_kw + ecl_file_kw_type * file_kw = inv_map_get_file_kw( ecl_file->inv_map , ecl_kw ); // We just verify that the input ecl_kw points to an ecl_kw if (file_kw != NULL) { // we manage; from then on we use the reference contained in - if (fortio_assert_stream_open( ecl_file->fortio )) { // the corresponding ecl_file_kw instance. - - ecl_file_kw_inplace_fwrite( file_kw , ecl_file->fortio ); - + if (fortio_assert_stream_open( ecl_file->fortio )) { // the corresponding ecl_file_kw instance. + + ecl_file_kw_inplace_fwrite( file_kw , ecl_file->fortio ); + if (FILE_FLAGS_SET( ecl_file->flags , ECL_FILE_CLOSE_STREAM)) fortio_fclose_stream( ecl_file->fortio ); - + return true; } else return false; diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_file_kw.c b/ThirdParty/Ert/devel/libecl/src/ecl_file_kw.c index 1dcd0dcf79..2fffa1ff0c 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_file_kw.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_file_kw.c @@ -297,8 +297,8 @@ offset_type ecl_file_kw_get_offset(const ecl_file_kw_type * file_kw) { return file_kw->file_offset; } -void ecl_file_kw_fskip_data( const ecl_file_kw_type * file_kw , fortio_type * fortio) { - ecl_kw_fskip_data__( file_kw->ecl_type , file_kw->kw_size , fortio ); +bool ecl_file_kw_fskip_data( const ecl_file_kw_type * file_kw , fortio_type * fortio) { + return ecl_kw_fskip_data__( file_kw->ecl_type , file_kw->kw_size , fortio ); } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_grid.c b/ThirdParty/Ert/devel/libecl/src/ecl_grid.c index 10941aaad0..9edcf66382 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_grid.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_grid.c @@ -1,21 +1,19 @@ -// Fauilure Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-A3.EGRID - /* - Copyright (c) 2011 statoil asa, norway. - - The file 'ecl_grid.c' is part of ert - ensemble based reservoir tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (c) 2011 statoil asa, norway. + + The file 'ecl_grid.c' is part of ert - ensemble based reservoir tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -32,6 +30,7 @@ #include <ert/util/stringlist.h> #include <ert/geometry/geo_util.h> +#include <ert/geometry/geo_polygon.h> #include <ert/ecl/ecl_util.h> #include <ert/ecl/ecl_kw.h> @@ -71,7 +70,7 @@ ecl_grid_get_pos3() - 3: this function expects i,j,k ecl_grid_get_pos1() - 1: this function expects a global index ecl_grid_get_pos1a() - 1a: this function expects an active index. - + */ @@ -136,15 +135,15 @@ corners | coords | corners | - coords | - corners | - coords | - corners __/________________________________________________________ + coords | + corners | + coords | + corners __/________________________________________________________ lgr \ - lgrilg | - dimens | + lgrilg | + dimens | coords | - corners | first lgr, with some header information, + corners | first lgr, with some header information, coords | and then normal coords/corners keywords for corners | the four refined cells. coords | @@ -163,34 +162,34 @@ coords | corners __/ - + for egrid files it is essentially the same, except for replacing the keywords coords/corners with coord/zcorn/actnum. also the lgr - headers are somewhat different. + headers are somewhat different. solution data in restart files comes in a similar way, a restart file with lgr can typically look like this: ..... __ - ..... \ + ..... \ startsol | all restart data for the ordinary pressure | grid. swat | sgas | .... | - endsol __/____________________________ + endsol __/____________________________ lgr \ .... | - startsol | restart data for + startsol | restart data for pressure | the first lgr. sgas | swat | ... | endsol | - endlgr __/ - lgr \ + endlgr __/ + lgr \ .... | - startsol | restart data for + startsol | restart data for pressure | the second lgr. sgas | swat | @@ -203,7 +202,7 @@ 1. when loading a egrid/grid file one ecl_grid_type instance will be allocated; this grid will contain the main grid, and all the - lgr grids. + lgr grids. 2. only one datatype (ecl_grid_type) is used both for the main grid and the lgr grids. @@ -222,7 +221,7 @@ ecl_file_type * restart_data = ecl_file_fread_alloc(restart_filename , true); // load some restart info to inspect ecl_grid_type * grid = ecl_grid_alloc(grid_filename , true); // bootstrap ecl_grid instance stringlist_type * lgr_names = ecl_grid_alloc_name_list( grid ); // get a list of all the lgr names. - + printf("grid:%s has %d a total of %d lgr's \n", grid_filename , stringlist_get_size( lgr_names )); for (int lgr_nr = 0; lgr_nr < stringlist_get_size( lgr_names); lgr_nr++) { ecl_grid_type * lgr_grid = ecl_grid_get_lgr( grid , stringlist_iget( lgr_names , lgr_nr )); // get the ecl_grid instance of the lgr - by name. @@ -235,7 +234,7 @@ pressure_kw = ecl_file_iget_named_kw( ecl_file , "pressure" , ecl_grid_get_grid_nr( lgr_grid )); /|\ | - | + | we query the lgr_grid instance to find which occurence of the solution data we should look up in the ecl_file instance with restart data. puuhh!! @@ -269,7 +268,7 @@ 3. The ecl_grid structure contains a list of ecl_coarse_cell instances in the coarse_cells vector. - + 4. The introduction of coarse groups makes the concept of active cells slightly more complex: @@ -282,7 +281,7 @@ and active index will no longer be unique - there will be several different global indices mapping to the same active index. - + The api for coarse related tasks is briefly: - int ecl_grid_get_num_coarse_groups( const ecl_grid_type * main_grid ) @@ -304,7 +303,7 @@ from the grid files: - The active property of the cells is an integer which is a sum of - the flag values ACTIVE_MATRIX and ACTIVE_FRACTURE. + the flag values ACTIVE_MATRIX and ACTIVE_FRACTURE. - All functions operating on fracture properties have 'fracture' as part of the name. The functions operating on the matrix do @@ -320,8 +319,8 @@ - For the GRID files there is abolutely no metadata to tell that this is a dual porosity run (I think ...) - instead the whole grid is repeated one more time with cells for the fractures - following after the matrix cells. - + following after the matrix cells. + Naively the GRID file of a dual porosity run will report that it contains 2*NZ layers. In the current implementation heuristics is used to detect the situation, and the grid will only be @@ -366,7 +365,7 @@ For cells with NNC's attached the information is kept in a nnc_info_type structure. For a particular cell the nnc_info structure keeps track of which other cells this particular cell - is connected to, on a per grid (i.e. LGR) basis. + is connected to, on a per grid (i.e. LGR) basis. In the nnc_info structure the different grids are identified through the lgr_nr. @@ -390,10 +389,10 @@ // Get all the nnc connections from @cell_index to other cells in the same grid { const int_vector_type * nnc_list = nnc_info_get_self_index_list( nnc_info ); - for (int j=0; j < int_vector_size( nnc_list ); j++) + for (int j=0; j < int_vector_size( nnc_list ); j++) printf("Cell[%d] -> %d in the same grid \n",cell_index , int_vector_iget(nnc_list , j)); } - + { for (int lgr_index=0; lgr_index < nnc_info_get_size( nnc_info ); lgr_index++) { @@ -401,11 +400,11 @@ int lgr_nr = nnc_vector_get_lgr_nr( nnc_vector ); if (lgr_nr != nnc_info_get_lgr_nr( nnc_info )) { const int_vector_type * nnc_list = nnc_vector_get_index_list( nnc_vector ); - for (int j=0; j < int_vector_size( nnc_list ); j++) - printf("Cell[%d] -> %d in lgr:%d/%s \n",cell_index , int_vector_iget(nnc_list , j) , lgr_nr , ecl_grid_get_lgr_name(ecl_grid , lgr_nr)); - } - } - } + for (int j=0; j < int_vector_size( nnc_list ); j++) + printf("Cell[%d] -> %d in lgr:%d/%s \n",cell_index , int_vector_iget(nnc_list , j) , lgr_nr , ecl_grid_get_lgr_name(ecl_grid , lgr_nr)); + } + } + } } @@ -413,7 +412,7 @@ properties and the fracture properties in a cell is implemented as a nnc where the fracture cell has global index in the range [nx*ny*nz, 2*nz*ny*nz). In ert we we have not implemented this double covering - in the case of dual porosity models, and therefor NNC involving + in the case of dual porosity models, and therefor NNC involving fracture cells are not considered. */ @@ -450,7 +449,7 @@ lower layer: upper layer (higher value of z - i.e. lower down in resrvoir). - + 2---3 6---7 | | | | 0---1 4---5 @@ -480,7 +479,7 @@ numbering does not follow a consistent rotation around the face: 6---7 /|\ | | | 4---5 | - | + | o----------> i 2---3 | | @@ -566,12 +565,13 @@ typedef struct ecl_cell_struct ecl_cell_type; #define GET_CELL_FLAG(cell,flag) (((cell->cell_flags & (flag)) == 0) ? false : true) #define SET_CELL_FLAG(cell,flag) ((cell->cell_flags |= (flag))) +#define METER_TO_FEET_SCALE_FACTOR 3.28084 struct ecl_cell_struct { point_type center; point_type corner_list[8]; - + int active; int active_index[2]; /* [0]: The active matrix index; [1]: the active fracture index */ const ecl_grid_type *lgr; /* if this cell is part of an lgr; this will point to a grid instance for that lgr; NULL if not part of lgr. */ @@ -579,7 +579,7 @@ struct ecl_cell_struct { int coarse_group; /* The index of the coarse group holding this cell -1 for non-coarsened cells. */ int cell_flags; nnc_info_type * nnc_info; /* Non-neighbour connection info*/ -}; +}; @@ -587,42 +587,42 @@ struct ecl_cell_struct { struct ecl_grid_struct { UTIL_TYPE_ID_DECLARATION; - int lgr_nr; /* EGRID files: corresponds to item 4 in gridhead - 0 for the main grid. - GRID files: 0 for the main grid, then 1 -> number of LGRs in order read from file*/ + int lgr_nr; /* EGRID files: corresponds to item 4 in gridhead - 0 for the main grid. + GRID files: 0 for the main grid, then 1 -> number of LGRs in order read from file*/ char * name; /* the name of the file for the main grid - name of the lgr for lgrs. */ int ny,nz,nx; int size; /* == nx*ny*nz */ - int total_active; + int total_active; int total_active_fracture; bool * visited; /* internal helper struct used when searching for index - can be NULL. */ int * index_map; /* this a list of nx*ny*nz elements, where value -1 means inactive cell .*/ int * inv_index_map; /* this is list of total_active elements - which point back to the index_map. */ int * fracture_index_map; /* For fractures: this a list of nx*ny*nz elements, where value -1 means inactive cell .*/ - int * inv_fracture_index_map; /* For fractures: this is list of total_active elements - which point back to the index_map. */ + int * inv_fracture_index_map; /* For fractures: this is list of total_active elements - which point back to the index_map. */ ecl_cell_type * cells; char * parent_name; /* the name of the parent for a nested lgr - for the main grid, and also a lgr descending directly from the main grid this will be NULL. */ hash_type * children; /* a table of lgr children for this grid. */ - const ecl_grid_type * parent_grid; /* the parent grid for this (lgr) - NULL for the main grid. */ + const ecl_grid_type * parent_grid; /* the parent grid for this (lgr) - NULL for the main grid. */ const ecl_grid_type * global_grid; /* the global grid - NULL for the main grid. */ - + bool coarsening_active; vector_type * coarse_cells; /* the two fields below are for *storing* lgr grid instances. observe that these fields will be NULL for lgr grids, i.e. grids with - lgr_nr > 0. + lgr_nr > 0. */ vector_type * LGR_list; /* a vector of ecl_grid instances for LGRs - the index corresponds to the order LGRs are read from file*/ int_vector_type * lgr_index_map; /* a vector that maps LGR-nr for EGRID files to index into the LGR_list.*/ hash_type * LGR_hash; /* a hash of pointers to ecl_grid instances - for name based lookup of lgr. */ int parent_box[6]; /* integers i1,i2, j1,j2, k1,k2 of the parent grid region containing this lgr. the indices are inclusive - zero offset */ - /* not used yet .. */ - - int dualp_flag; + /* not used yet .. */ + + int dualp_flag; bool use_mapaxes; double unit_x[2]; double unit_y[2]; @@ -634,10 +634,11 @@ struct ecl_grid_struct { int last_block_index; double_vector_type ** values; ecl_kw_type * coord_kw; /* Retained for writing the grid to file. - In principal it should be possible to + In principal it should be possible to recalculate this from the cell coordinates, but in cases with skewed cells this has proved numerically challenging. */ + bool is_metric; }; @@ -646,8 +647,8 @@ struct ecl_grid_struct { static void ecl_cell_compare(const ecl_cell_type * c1 , const ecl_cell_type * c2, bool include_nnc , bool * equal) { int i; - - if (c1->active != c2->active) + + if (c1->active != c2->active) *equal = false; @@ -659,14 +660,14 @@ static void ecl_cell_compare(const ecl_cell_type * c1 , const ecl_cell_type * c2 if (c1->coarse_group != c2->coarse_group) *equal = false; - - if (c1->host_cell != c2->host_cell) + + if (c1->host_cell != c2->host_cell) *equal = false; - + if (*equal) { - for (i=0; i < 8; i++) + for (i=0; i < 8; i++) point_compare( &c1->corner_list[i] , &c2->corner_list[i] , equal ); - + } if (include_nnc) { @@ -720,7 +721,7 @@ static void ecl_cell_fwrite_GRID( const ecl_grid_type * grid , const ecl_cell_ty if (cell->active & CELL_ACTIVE_MATRIX) ecl_kw_iset_int( coords_kw , 4 , 1); } - + if (coords_size == 7) { ecl_kw_iset_int( coords_kw , 5 , cell->host_cell + 1); ecl_kw_iset_int( coords_kw , 6 , cell->coarse_group + 1); @@ -731,12 +732,12 @@ static void ecl_cell_fwrite_GRID( const ecl_grid_type * grid , const ecl_cell_ty float * corners = ecl_kw_get_void_ptr( corners_kw ); point_type point; int c; - + for (c = 0; c < 8; c++) { point_copy_values( &point , &cell->corner_list[c] ); if (grid->use_mapaxes) point_mapaxes_invtransform( &point , grid->origo , grid->unit_x , grid->unit_y ); - + corners[3*c ] = point.x; corners[3*c + 1] = point.y; corners[3*c + 2] = point.z; @@ -777,8 +778,8 @@ static void ecl_cell_ri_export( const ecl_cell_type * cell , double * ri_points) ri_points[ ri_point * 3 ] = cell->corner_list[ecl_point].x; ri_points[ ri_point * 3 + 1 ] = cell->corner_list[ecl_point].y; ri_points[ ri_point * 3 + 2 ] = -cell->corner_list[ecl_point].z; - - + + // Points 6 & 7 ri_points[ ri_offset + ri_point * 3 ] = cell->corner_list[ecl_offset + ecl_point].x; ri_points[ ri_offset + ri_point * 3 + 1 ] = cell->corner_list[ecl_offset + ecl_point].y; @@ -791,12 +792,12 @@ static void ecl_cell_ri_export( const ecl_cell_type * cell , double * ri_points) static double max2( double x1 , double x2) { return (x1 > x2) ? x1 : x2; -} +} static double min2( double x1 , double x2) { return (x1 < x2) ? x1 : x2; -} +} static double min4(double x1 , double x2 , double x3 , double x4) { @@ -865,12 +866,12 @@ static double ecl_cell_max_y( const ecl_cell_type * cell ) { located among the rest of the grid become completely warped - with insane volumes, parts of the reservoir volume doubly covered, and so on. - + To keep these cells out of the real-world (i.e. involving utm coordinates) computations they are marked as 'tainted' in this function. The tainting procedure is completely heuristic, and probably wrong. - + -------------- There is second heuristic which marks cells as invalid. In some @@ -881,7 +882,7 @@ static double ecl_cell_max_y( const ecl_cell_type * cell ) { completely. We therefor try to invalidate such cells here. The algorithm used is the same as used for RMS; however RMS will mark the cells as inactive - whereas we mark already inactive cells as - invalid. + invalid. It is very important that this mechanism is NOT used to set cells to inactive; as that will break completely when it comes to @@ -911,7 +912,7 @@ static void ecl_cell_taint_cell( ecl_cell_type * cell ) { const point_type pi = cell->corner_list[cell_index]; if (pi.z != p0.z) // There is a difference - the cell is certainly valid. - break; + break; else { cell_index++; if (cell_index == 8) { @@ -935,11 +936,11 @@ static void ecl_cell_taint_cell( ecl_cell_type * cell ) { /** Observe that when allocating based on a grid file not all cells are necessarily accessed beyond this function. In general not all cells - will have a coords/corners section in the grid file. + will have a coords/corners section in the grid file. */ static void ecl_cell_init( ecl_cell_type * cell , bool init_valid) { - cell->active = CELL_NOT_ACTIVE; + cell->active = CELL_NOT_ACTIVE; cell->lgr = NULL; cell->host_cell = HOST_CELL_NONE; cell->coarse_group = COARSE_GROUP_NONE; @@ -948,7 +949,7 @@ static void ecl_cell_init( ecl_cell_type * cell , bool init_valid) { cell->active_index[FRACTURE_INDEX] = -1; if (init_valid) cell->cell_flags = CELL_FLAG_VALID; - + cell->nnc_info = NULL; } @@ -1008,11 +1009,11 @@ static double C(double *r,int f1,int f2,int f3){ if (f2 == 0) { if (f3 == 0) return r[0]; // 000 - else + else return r[4] - r[0]; // 001 } else { - if (f3 == 0) - return r[2] - r[0]; // 010 + if (f3 == 0) + return r[2] - r[0]; // 010 else return r[6] + r[0] - r[4] - r[2]; // 011 } @@ -1020,11 +1021,11 @@ static double C(double *r,int f1,int f2,int f3){ if (f2 == 0) { if (f3 == 0) return r[1] - r[0]; // 100 - else + else return r[5]+r[0]-r[4]-r[1]; // 101 } else { - if (f3 == 0) - return r[3]+r[0]-r[2]-r[1]; // 110 + if (f3 == 0) + return r[3]+r[0]-r[2]-r[1]; // 110 else return r[7]+r[4]+r[2]+r[1]-r[6]-r[5]-r[3]-r[0]; // 111 } @@ -1046,7 +1047,7 @@ static double ecl_cell_get_volume_tskille( ecl_cell_type * cell ) { Z[c] = cell->corner_list[c].z; } } - + for (pb=0;pb<=1;pb++) for (pg=0;pg<=1;pg++) for (qa=0;qa<=1;qa++) @@ -1054,16 +1055,16 @@ static double ecl_cell_get_volume_tskille( ecl_cell_type * cell ) { for (ra=0;ra<=1;ra++) for (rb=0;rb<=1;rb++) { int divisor = (qa+ra+1)*(pb+rb+1)*(pg+qg+1); - double dV = C(X,1,pb,pg) * C(Y,qa,1,qg) * C(Z,ra,rb,1) - - C(X,1,pb,pg) * C(Z,qa,1,qg) * C(Y,ra,rb,1) - - C(Y,1,pb,pg) * C(X,qa,1,qg) * C(Z,ra,rb,1) + - C(Y,1,pb,pg) * C(Z,qa,1,qg) * C(X,ra,rb,1) + - C(Z,1,pb,pg) * C(X,qa,1,qg) * C(Y,ra,rb,1) - + double dV = C(X,1,pb,pg) * C(Y,qa,1,qg) * C(Z,ra,rb,1) - + C(X,1,pb,pg) * C(Z,qa,1,qg) * C(Y,ra,rb,1) - + C(Y,1,pb,pg) * C(X,qa,1,qg) * C(Z,ra,rb,1) + + C(Y,1,pb,pg) * C(Z,qa,1,qg) * C(X,ra,rb,1) + + C(Z,1,pb,pg) * C(X,qa,1,qg) * C(Y,ra,rb,1) - C(Z,1,pb,pg) * C(Y,qa,1,qg) * C(X,ra,rb,1); - + volume += dV / divisor; } - + return fabs(volume); } @@ -1075,18 +1076,18 @@ static double ecl_cell_get_signed_volume( ecl_cell_type * cell) { int itet; double volume = 0; for (itet = 0; itet < 12; itet++) { - - /* + + /* using both tetrahedron decompositions - gives good agreement with porv from eclipse init files. */ ecl_cell_init_tetrahedron( cell , &tet , 0 , itet ); volume += tetrahedron_volume( &tet ); - + ecl_cell_init_tetrahedron( cell , &tet , 1 , itet ); volume += tetrahedron_volume( &tet ); } - + return volume * 0.5; } } @@ -1116,17 +1117,17 @@ static bool triangle_contains(const point_type *p0 , const point_type * p1 , con { double v1 = triangle_area(p0->x , p0->y, p1->x , p1->y, - x , y); - + x , y); + double v2 = triangle_area(p0->x , p0->y, x , y, p2->x , p2->y); - + double v3 = triangle_area(x , y, p1->x , p1->y, p2->x , p2->y); - - + + if (fabs( vt - (v1 + v2 + v3 )) < epsilon) return true; else @@ -1137,11 +1138,11 @@ static bool triangle_contains(const point_type *p0 , const point_type * p1 , con -/* +/* if the layer defined by the cell corners 0-1-2-3 (lower == true) or 4-5-6-7 (lower == false) contain the point (x,y) the function will return true - otehrwise false. - + the function works by dividing the cell face into two triangles, which are checked one at a time with the function triangle_contains(). @@ -1155,17 +1156,17 @@ static bool ecl_cell_layer_contains_xy( const ecl_cell_type * cell , bool lower_ const point_type *p0,*p1,*p2,*p3; { int corner_offset; - if (lower_layer) + if (lower_layer) corner_offset = 0; else corner_offset = 4; - + p0 = &cell->corner_list[corner_offset + 0]; p1 = &cell->corner_list[corner_offset + 1]; p2 = &cell->corner_list[corner_offset + 2]; p3 = &cell->corner_list[corner_offset + 3]; } - + if (triangle_contains(p0,p1,p2,x,y)) return true; else @@ -1174,10 +1175,10 @@ static bool ecl_cell_layer_contains_xy( const ecl_cell_type * cell , bool lower_ } - + /** - lower layer: upper layer - + lower layer: upper layer + 2---3 6---7 | | | | 0---1 4---5 @@ -1190,7 +1191,7 @@ static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset cell->corner_list[2] = cell->corner_list[0]; // Point 2 point_shift(&cell->corner_list[2] , jvec[0] , jvec[1] , jvec[2]); - + cell->corner_list[3] = cell->corner_list[1]; // Point 3 point_shift(&cell->corner_list[3] , jvec[0] , jvec[1] , jvec[2]); @@ -1202,7 +1203,7 @@ static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset } } - if (actnum != NULL) + if (actnum != NULL) cell->active = actnum[global_index]; else cell->active = CELL_ACTIVE; @@ -1285,7 +1286,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du grid->ny = ny; grid->nz = nz; grid->size = nx*ny*nz; - grid->lgr_nr = lgr_nr; + grid->lgr_nr = lgr_nr; grid->global_grid = global_grid; grid->coarsening_active = false; @@ -1293,21 +1294,22 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du grid->coord_kw = NULL; grid->visited = NULL; grid->inv_index_map = NULL; - grid->index_map = NULL; + grid->index_map = NULL; grid->fracture_index_map = NULL; grid->inv_fracture_index_map = NULL; ecl_grid_alloc_cells( grid , init_valid ); - + grid->is_metric = true; + if (global_grid != NULL) { /* this is an lgr instance, and we inherit the global grid transformations from the main grid. */ - grid->unit_x[0] = global_grid->unit_x[0]; - grid->unit_x[1] = global_grid->unit_x[1]; - grid->unit_y[0] = global_grid->unit_y[0]; - grid->unit_y[1] = global_grid->unit_y[1]; - grid->origo[0] = global_grid->origo[0]; - grid->origo[1] = global_grid->origo[1]; + grid->unit_x[0] = global_grid->unit_x[0]; + grid->unit_x[1] = global_grid->unit_x[1]; + grid->unit_y[0] = global_grid->unit_y[0]; + grid->unit_y[1] = global_grid->unit_y[1]; + grid->origo[0] = global_grid->origo[0]; + grid->origo[1] = global_grid->origo[1]; grid->use_mapaxes = global_grid->use_mapaxes; } else { grid->unit_x[0] = 1; @@ -1323,12 +1325,12 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du grid->block_dim = 0; grid->values = NULL; if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) { /* this is the main grid */ - grid->LGR_list = vector_alloc_new(); + grid->LGR_list = vector_alloc_new(); grid->lgr_index_map = int_vector_alloc(0,0); grid->LGR_hash = hash_alloc(); } else { grid->LGR_list = NULL; - grid->lgr_index_map = NULL; + grid->lgr_index_map = NULL; grid->LGR_hash = NULL; } grid->name = NULL; @@ -1347,10 +1349,10 @@ static int ecl_grid_get_global_index__(const ecl_grid_type * ecl_grid , int i , } -static void ecl_grid_set_cell_EGRID(ecl_grid_type * ecl_grid , int i, int j , int k , - double x[4][2] , double y[4][2] , double z[4][2] , +static void ecl_grid_set_cell_EGRID(ecl_grid_type * ecl_grid , int i, int j , int k , + double x[4][2] , double y[4][2] , double z[4][2] , const int * actnum, const int * corsnum) { - + const int global_index = ecl_grid_get_global_index__(ecl_grid , i , j , k ); ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index ); int ip , iz; @@ -1365,7 +1367,7 @@ static void ecl_grid_set_cell_EGRID(ecl_grid_type * ecl_grid , int i, int j , in } } - + /* @@ -1376,16 +1378,16 @@ static void ecl_grid_set_cell_EGRID(ecl_grid_type * ecl_grid , int i, int j , in */ if (actnum == NULL) cell->active = CELL_ACTIVE; - else + else cell->active = actnum[global_index]; - + if (corsnum != NULL) cell->coarse_group = corsnum[ global_index ] - 1; } static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size , const int * coords , const float * corners) { - + const int i = coords[0] - 1; /* eclipse 1 offset */ const int j = coords[1] - 1; int k = coords[2] - 1; @@ -1411,7 +1413,7 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size , global_index = ecl_grid_get_global_index__(ecl_grid , i, j , k); cell = ecl_grid_get_cell( ecl_grid , global_index); - + /* the coords keyword can optionally contain 4,5 or 7 elements: coords[0..2] = i,j,k @@ -1436,15 +1438,15 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size , int c; - /* - The ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr test checks if - this is a LGR; if this test applies we either have bug - or a + /* + The ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr test checks if + this is a LGR; if this test applies we either have bug - or a GRID file with LGRs and only 4/5 elements in the coords keywords. In the latter case we must start using the LGRILG keyword. */ - if ((ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr) && (coords_size != 7)) + if ((ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr) && (coords_size != 7)) util_abort("%s: Need 7 element coords keywords for LGR - or reimplement to use LGRILG keyword.\n",__func__); - + switch(coords_size) { case 4: /* all cells active */ cell->active += active_value; @@ -1462,14 +1464,14 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size , default: util_abort("%s: coord size:%d unrecognized - should 4,5 or 7.\n",__func__ , coords_size); } - + if (matrix_cell) { for (c = 0; c < 8; c++) { point_set(&cell->corner_list[c] , corners[3*c] , corners[3*c + 1] , corners[3*c + 2]); - + if (ecl_grid->use_mapaxes) point_mapaxes_transform( &cell->corner_list[c] , ecl_grid->origo , ecl_grid->unit_x , ecl_grid->unit_y ); - + } } } @@ -1486,11 +1488,11 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size , static void ecl_grid_init_index_map__( ecl_grid_type * ecl_grid , int * index_map , int * inv_index_map , int active_mask, int type_index) { int global_index; - for (global_index = 0; global_index < ecl_grid->size; global_index++) { + for (global_index = 0; global_index < ecl_grid->size; global_index++) { const ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index); if (cell->active & active_mask) { index_map[global_index] = cell->active_index[type_index]; - + if (cell->coarse_group == COARSE_GROUP_NONE) inv_index_map[cell->active_index[type_index]] = global_index; //else: In the case of coarse groups the inv_index_map is set below. @@ -1516,7 +1518,7 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) { ecl_grid_init_index_map__( ecl_grid , ecl_grid->fracture_index_map , ecl_grid->inv_fracture_index_map , CELL_ACTIVE_FRACTURE , FRACTURE_INDEX); } - + /* Update the inverse map in the case of coarse cells. Observe that in the case of coarse cells with more than one active cell in the main grid, the inverse active -> global mapping will map to the @@ -1530,11 +1532,11 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) { int active_value = ecl_coarse_cell_iget_active_value( coarse_cell , 0 ); int active_index = ecl_coarse_cell_get_active_index( coarse_cell ); int active_fracture_index = ecl_coarse_cell_get_active_fracture_index( coarse_cell ); - - if (active_value & CELL_ACTIVE_MATRIX) + + if (active_value & CELL_ACTIVE_MATRIX) ecl_grid->inv_index_map[ active_index ] = global_index; // The active -> global mapping point to one "random" cell in the coarse group - - if (active_value & CELL_ACTIVE_FRACTURE) + + if (active_value & CELL_ACTIVE_FRACTURE) ecl_grid->inv_fracture_index_map[ active_fracture_index ] = global_index; { @@ -1543,19 +1545,19 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) { int ic; for (ic =0; ic < coarse_size; ic++) { int gi = int_vector_iget( global_index_list , ic ); - - if (active_value & CELL_ACTIVE_MATRIX) + + if (active_value & CELL_ACTIVE_MATRIX) ecl_grid->index_map[ gi ] = active_index; // All the cells in the coarse group point to the same active index. - - if (active_value & CELL_ACTIVE_FRACTURE) + + if (active_value & CELL_ACTIVE_FRACTURE) ecl_grid->fracture_index_map[ gi ] = active_fracture_index; } - } + } } // else the coarse cell does not have any active cells. } } } - + /* @@ -1568,33 +1570,33 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) { int global_index; int active_index = 0; int active_fracture_index = 0; - + if (!ecl_grid_have_coarse_cells( ecl_grid )) { /* Keeping a fast path for the 99% most common case of no coarse groups and single porosity. */ { for (global_index = 0; global_index < ecl_grid->size; global_index++) { ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index); - + if (cell->active & CELL_ACTIVE_MATRIX) { cell->active_index[MATRIX_INDEX] = active_index; active_index++; - } + } } } - + if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) { for (global_index = 0; global_index < ecl_grid->size; global_index++) { ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index); if (cell->active & CELL_ACTIVE_FRACTURE) { cell->active_index[FRACTURE_INDEX] = active_fracture_index; active_fracture_index++; - } + } } } } else { /* --- More involved path in the case of coarsening groups. --- */ - + /* 1: Go through all the cells and set the active index. In the case of coarse cells we only set the common active index of the entire coarse cell. @@ -1603,7 +1605,7 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) { ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index); if (cell->active != CELL_NOT_ACTIVE) { if (cell->coarse_group == COARSE_GROUP_NONE) { - + if (cell->active & CELL_ACTIVE_MATRIX) { cell->active_index[MATRIX_INDEX] = active_index; active_index++; @@ -1618,10 +1620,10 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) { ecl_coarse_cell_type * coarse_cell = ecl_grid_iget_coarse_group( ecl_grid , cell->coarse_group ); ecl_coarse_cell_update_index( coarse_cell , global_index , &active_index , &active_fracture_index , cell->active); } - } + } } - + /* 2: Go through all the coarse cells and set the active index and active value of all the cells in the coarse cell to the @@ -1642,10 +1644,10 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) { global_index = coarse_cell_list[i]; { ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index ); - + if (cell_active_value & CELL_ACTIVE_MATRIX) cell->active_index[MATRIX_INDEX] = cell_active_index; - + /* Coarse cell and dual porosity - that is probably close to zero measure. */ if (cell_active_value & CELL_ACTIVE_FRACTURE) { int cell_active_fracture_index = ecl_coarse_cell_get_active_fracture_index( coarse_cell ); @@ -1673,7 +1675,7 @@ static void ecl_grid_update_index( ecl_grid_type * ecl_grid) { /* Coarse cells */ static ecl_coarse_cell_type * ecl_grid_get_or_create_coarse_cell( ecl_grid_type * ecl_grid , int coarse_nr) { - if (vector_safe_iget( ecl_grid->coarse_cells , coarse_nr ) == NULL) + if (vector_safe_iget( ecl_grid->coarse_cells , coarse_nr ) == NULL) vector_iset_owned_ref( ecl_grid->coarse_cells , coarse_nr , ecl_coarse_cell_alloc() , ecl_coarse_cell_free__); return vector_iget( ecl_grid->coarse_cells , coarse_nr ); @@ -1732,8 +1734,8 @@ bool ecl_grid_cell_in_coarse_group3( const ecl_grid_type * main_grid , int i , i /*****************************************************************/ -static void ecl_grid_pillar_cross_planes(const point_type * p0, - double e_x , double e_y , double e_z , +static void ecl_grid_pillar_cross_planes(const point_type * p0, + double e_x , double e_y , double e_z , const double *z , double *x , double *y) { int k; if (e_z != 0) { @@ -1765,11 +1767,11 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , const float * mapa { const double unit_y[2] = {mapaxes[0] - mapaxes[2] , mapaxes[1] - mapaxes[3]}; const double unit_x[2] = {mapaxes[4] - mapaxes[2] , mapaxes[5] - mapaxes[3]}; - + { double norm_x = 1.0/sqrt( unit_x[0]*unit_x[0] + unit_x[1]*unit_x[1] ); double norm_y = 1.0/sqrt( unit_y[0]*unit_y[0] + unit_y[1]*unit_y[1] ); - + ecl_grid->unit_x[0] = unit_x[0] * norm_x; ecl_grid->unit_x[1] = unit_x[1] * norm_x; ecl_grid->unit_y[0] = unit_y[0] * norm_y; @@ -1798,14 +1800,14 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , const float * mapa This 'mostly' agrees with the GRIDHEAD(4) item, but unfortunately not always. Cases have popped up where the series of GRIDHEAD(4) values from lgr to lgr have holes :-( - + when installed in the lgr_list vector the lgr grid is installed with a destructor, i.e. the grid is destroyed when the vector is destroyed. 2. in the main->lgr_hash the lgr instance is installed with the lgrname as key. only a reference is installed in the hash - table. + table. observe that this is in principle somewhat different from the install functions below; here the lgr is added to the top level @@ -1817,7 +1819,7 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , const float * mapa static void ecl_grid_add_lgr( ecl_grid_type * main_grid , ecl_grid_type * lgr_grid) { vector_append_owned_ref( main_grid->LGR_list , lgr_grid , ecl_grid_free__); - int_vector_iset(main_grid->lgr_index_map, lgr_grid->lgr_nr, vector_get_size(main_grid->LGR_list)-1); + int_vector_iset(main_grid->lgr_index_map, lgr_grid->lgr_nr, vector_get_size(main_grid->LGR_list)-1); hash_insert_ref( main_grid->LGR_hash , lgr_grid->name , lgr_grid); } @@ -1844,7 +1846,7 @@ static void ecl_grid_install_lgr_EGRID(ecl_grid_type * host_grid , ecl_grid_type int host_index = hostnum[ global_lgr_index ] - 1; ecl_cell_type * lgr_cell = ecl_grid_get_cell( lgr_grid , global_lgr_index); ecl_cell_type * host_cell = ecl_grid_get_cell( host_grid , host_index ); - + ecl_cell_install_lgr( host_cell , lgr_grid ); lgr_cell->host_cell = host_index; } @@ -1857,7 +1859,7 @@ static void ecl_grid_install_lgr_EGRID(ecl_grid_type * host_grid , ecl_grid_type */ static void ecl_grid_install_lgr_GRID(ecl_grid_type * host_grid , ecl_grid_type * lgr_grid) { int global_lgr_index; - + for (global_lgr_index = 0; global_lgr_index < lgr_grid->size; global_lgr_index++) { ecl_cell_type * lgr_cell = ecl_grid_get_cell( lgr_grid , global_lgr_index); ecl_cell_type * host_cell = ecl_grid_get_cell( host_grid , lgr_cell->host_cell ); @@ -1873,7 +1875,7 @@ static void ecl_grid_install_lgr_GRID(ecl_grid_type * host_grid , ecl_grid_type nested lgr. for normal lgr descending directly from the coarse grid the parent_name is set to NULL. */ - + static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_file_type * ecl_file , int grid_nr) { ecl_kw_type * lgrname_kw = ecl_file_iget_named_kw( ecl_file , LGR_KW , grid_nr - 1); @@ -1882,7 +1884,7 @@ static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_fil ecl_kw_type * parent_kw = ecl_file_iget_named_kw( ecl_file , LGR_PARENT_KW , grid_nr -1); char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( parent_kw , 0)); - if (strlen( parent ) > 0) + if (strlen( parent ) > 0) lgr_grid->parent_name = parent; else /* lgr_grid->parent has been initialized to NULL */ free( parent ); @@ -1907,10 +1909,10 @@ static void ecl_grid_set_lgr_name_GRID(ecl_grid_type * lgr_grid , const ecl_file */ if (ecl_kw_get_size( lgr_kw ) == 2) { char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( lgr_kw , 1)); - + if ((strlen(parent) == 0) || (strcmp(parent , GLOBAL_STRING ) == 0)) free( parent ); - else + else lgr_grid->parent_name = parent; } } @@ -1925,7 +1927,7 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid , const f const int nz = ecl_grid->nz; int i; - + for (i=0; i < nx; i++) { point_type pillars[4][2]; int pillar_index[4]; @@ -1934,12 +1936,12 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid , const f pillar_index[2] = 6 * ((j + 1) * (nx + 1) + i ); pillar_index[3] = 6 * ((j + 1) * (nx + 1) + i + 1); - { + { int ip; for (ip = 0; ip < 4; ip++) { int index = pillar_index[ip]; point_set(&pillars[ip][0] , coord[index] , coord[index + 1] , coord[index + 2]); - + index += 3; point_set(&pillars[ip][1] , coord[index] , coord[index + 1] , coord[index + 2]); } @@ -1950,7 +1952,7 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid , const f double ey[4]; double ez[4]; int k; - + { int ip; for (ip = 0; ip < 4; ip++) { @@ -1959,8 +1961,8 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid , const f ez[ip] = pillars[ip][1].z - pillars[ip][0].z; } } - - + + for (k=0; k < nz; k++) { double x[4][2]; double y[4][2]; @@ -1975,13 +1977,13 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid , const f z[3][c] = zcorn[k*8*nx*ny + j*4*nx + 2*nx + 2*i + 1 + c*4*nx*ny]; } } - + { int ip; - for (ip = 0; ip < 4; ip++) + for (ip = 0; ip < 4; ip++) ecl_grid_pillar_cross_planes(&pillars[ip][0] , ex[ip], ey[ip] , ez[ip] , z[ip] , x[ip] , y[ip]); } - + ecl_grid_set_cell_EGRID(ecl_grid , i , j , k , x , y , z , actnum , corsnum); } } @@ -1993,7 +1995,7 @@ void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid , const float * zcorn , const int ny = ecl_grid->ny; int j; #pragma omp parallel for - for ( j=0; j < ny; j++) + for ( j=0; j < ny; j++) ecl_grid_init_GRDECL_data_jslice( ecl_grid , zcorn, coord , actnum , corsnum , j ); } @@ -2005,19 +2007,19 @@ void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid , const float * zcorn , 0---1 */ -static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid , - int dualp_flag , int nx , int ny , int nz , - const float * zcorn , const float * coord , const int * actnum, const float * mapaxes, const int * corsnum, +static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid , + int dualp_flag , int nx , int ny , int nz , + const float * zcorn , const float * coord , const int * actnum, const float * mapaxes, const int * corsnum, int lgr_nr) { ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , dualp_flag , nx,ny,nz,lgr_nr,true); - + if (mapaxes != NULL) ecl_grid_init_mapaxes( ecl_grid , mapaxes ); if (corsnum != NULL) ecl_grid->coarsening_active = true; - + ecl_grid->coord_kw = ecl_kw_alloc_new("COORD" , 6*(nx + 1) * (ny + 1) , ECL_FLOAT_TYPE , coord ); ecl_grid_init_GRDECL_data( ecl_grid , zcorn , coord , actnum , corsnum); @@ -2043,21 +2045,21 @@ static void ecl_grid_copy_content( ecl_grid_type * target_grid , const ecl_grid_ const ecl_cell_type * src_cell = ecl_grid_get_cell( src_grid , global_index ); ecl_cell_memcpy( target_cell , src_cell ); - if (src_cell->nnc_info) + if (src_cell->nnc_info) target_cell->nnc_info = nnc_info_alloc_copy( src_cell->nnc_info ); } ecl_grid_copy_mapaxes( target_grid , src_grid ); target_grid->parent_name = util_alloc_string_copy( src_grid->parent_name ); - target_grid->name = util_alloc_string_copy( src_grid->name ); - + target_grid->name = util_alloc_string_copy( src_grid->name ); + target_grid->coarsening_active = src_grid->coarsening_active; ecl_grid_init_coarse_cells( target_grid ); } static ecl_grid_type * ecl_grid_alloc_copy__( const ecl_grid_type * src_grid, ecl_grid_type * main_grid ) { ecl_grid_type * copy_grid = ecl_grid_alloc_empty( main_grid , src_grid->dualp_flag , ecl_grid_get_nx( src_grid ) , ecl_grid_get_ny( src_grid ) , ecl_grid_get_nz( src_grid ) , 0 , false ); - + ecl_grid_copy_content( copy_grid , src_grid ); // This will handle everything except LGR relationships which is established in the calling routine ecl_grid_update_index( copy_grid ); @@ -2069,31 +2071,31 @@ static ecl_grid_type * ecl_grid_alloc_copy__( const ecl_grid_type * src_grid, e ecl_grid_type * ecl_grid_alloc_copy( const ecl_grid_type * src_grid ) { ecl_grid_type * copy_grid = ecl_grid_alloc_copy__( src_grid , NULL ); - + { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( src_grid->LGR_list ); grid_nr++) { const ecl_grid_type * src_lgr = vector_iget_const( src_grid->LGR_list , grid_nr); ecl_grid_type * copy_lgr = ecl_grid_alloc_copy__( src_lgr , copy_grid ); ecl_grid_type * host_grid; - + ecl_grid_add_lgr( copy_grid , copy_lgr ); // This handles the storage ownership of the LGR. if (copy_lgr->parent_name == NULL) host_grid = copy_grid; - else + else host_grid = ecl_grid_get_lgr( copy_grid , copy_lgr->parent_name ); - + { int global_lgr_index; - + for (global_lgr_index = 0; global_lgr_index < copy_lgr->size; global_lgr_index++) { ecl_cell_type * lgr_cell = ecl_grid_get_cell( copy_lgr , global_lgr_index); ecl_cell_type * host_cell = ecl_grid_get_cell( host_grid , lgr_cell->host_cell ); - + ecl_cell_install_lgr( host_cell , copy_lgr ); } ecl_grid_install_lgr_common( host_grid , copy_lgr ); - + } } @@ -2132,16 +2134,16 @@ const float * ecl_grid_get_mapaxes_from_kw__(const ecl_kw_type * mapaxes_kw) { return mapaxes_data; } -static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid , - int dualp_flag, - const ecl_kw_type * gridhead_kw , - const ecl_kw_type * zcorn_kw , - const ecl_kw_type * coord_kw , - const ecl_kw_type * actnum_kw , /* Can be NULL */ +static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid , + int dualp_flag, + const ecl_kw_type * gridhead_kw , + const ecl_kw_type * zcorn_kw , + const ecl_kw_type * coord_kw , + const ecl_kw_type * actnum_kw , /* Can be NULL */ const ecl_kw_type * mapaxes_kw , /* Can be NULL */ - const ecl_kw_type * corsnum_kw) { /* Can be NULL */ + const ecl_kw_type * corsnum_kw) { /* Can be NULL */ int gtype, nx,ny,nz, lgr_nr; - + gtype = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_TYPE_INDEX); nx = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NX_INDEX); ny = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NY_INDEX); @@ -2153,18 +2155,18 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid , if (grid_nr != ecl_kw_iget_int( gridhead_kw , GRIDHEAD_LGR_INDEX)) util_abort("%s: internal error in grid loader - lgr index mismatch\n",__func__); - + But then suddenly a EGRID file where this did not apply appeared :-( */ if (gtype != GRIDHEAD_GRIDTYPE_CORNERPOINT) util_abort("%s: gtype:%d fatal error when loading grid - must have corner point grid - aborting\n",__func__ , gtype ); - + { const float * mapaxes_data = NULL; const int * actnum_data = NULL; const int * corsnum_data = NULL; - + if (mapaxes_kw != NULL) mapaxes_data = ecl_grid_get_mapaxes_from_kw__(mapaxes_kw); @@ -2173,14 +2175,14 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid , if (corsnum_kw != NULL) corsnum_data = ecl_kw_get_int_ptr( corsnum_kw ); - - return ecl_grid_alloc_GRDECL_data__(global_grid , - dualp_flag , - nx , ny , nz , - ecl_kw_get_float_ptr(zcorn_kw) , - ecl_kw_get_float_ptr(coord_kw) , + + return ecl_grid_alloc_GRDECL_data__(global_grid , + dualp_flag , + nx , ny , nz , + ecl_kw_get_float_ptr(zcorn_kw) , + ecl_kw_get_float_ptr(coord_kw) , actnum_data, - mapaxes_data, + mapaxes_data, corsnum_data, lgr_nr); } @@ -2191,12 +2193,12 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid , If you create/load ecl_kw instances for the various fields, this function can be used to create a GRID instance, without going through a GRID/EGRID file. Does not support LGR or coarsening - hierarchies. + hierarchies. */ -ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , - const ecl_kw_type * zcorn_kw , - const ecl_kw_type * coord_kw , +ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , + const ecl_kw_type * zcorn_kw , + const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , /* Can be NULL */ const ecl_kw_type * mapaxes_kw ) { /* Can be NULL */ @@ -2215,15 +2217,15 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , static void ecl_grid_init_cell_nnc_info(ecl_grid_type * ecl_grid, int global_index) { ecl_cell_type * grid_cell = ecl_grid_get_cell(ecl_grid, global_index); - - if (!grid_cell->nnc_info) - grid_cell->nnc_info = nnc_info_alloc(ecl_grid->lgr_nr); + + if (!grid_cell->nnc_info) + grid_cell->nnc_info = nnc_info_alloc(ecl_grid->lgr_nr); } /* This function populates nnc_info for cells with non neighbour - connections. For cells C1 and C2 the function will only add the directed link: + connections. For cells C1 and C2 the function will only add the directed link: C1 -> C2 @@ -2232,26 +2234,26 @@ static void ecl_grid_init_cell_nnc_info(ecl_grid_type * ecl_grid, int global_ind NNC1 -> NNC2 For nnc between cells in the same grid. NNCG -> NNCL For global -> lgr connection - NNA1 -> NNA2 For links between different LGRs + NNA1 -> NNA2 For links between different LGRs */ static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid2, const ecl_kw_type * keyword1, const ecl_kw_type * keyword2) { - + int * grid1_nnc_cells = ecl_kw_get_int_ptr(keyword1); int * grid2_nnc_cells = ecl_kw_get_int_ptr(keyword2); - int nnc_count = ecl_kw_get_size(keyword2); + int nnc_count = ecl_kw_get_size(keyword2); int nnc_index; for (nnc_index = 0; nnc_index < nnc_count; nnc_index++) { int grid1_cell_index = grid1_nnc_cells[nnc_index] -1; int grid2_cell_index = grid2_nnc_cells[nnc_index] -1; - - + + /* In the ECLIPSE output format grids with dual porosity are (to some extent ...) modeled as two independent grids stacked on top of eachother, where the fracture cells have global index in the range - [nx*ny*nz, 2*nx*ny*nz). + [nx*ny*nz, 2*nx*ny*nz). The physical connection between the matrix and the fractures in cell nr c is modelled as an nnc: cell[c] -> cell[c + nx*ny*nz]. In @@ -2260,13 +2262,13 @@ static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid nnc connections involving fracture cells (i.e. cell_index >= nx*ny*nz). */ - if ((FILEHEAD_SINGLE_POROSITY != grid1->dualp_flag) && - ((grid1_cell_index >= grid1->size) || + if ((FILEHEAD_SINGLE_POROSITY != grid1->dualp_flag) && + ((grid1_cell_index >= grid1->size) || (grid2_cell_index >= grid2->size))) - break; - + break; + + - { ecl_cell_type * grid1_cell = ecl_grid_get_cell(grid1, grid1_cell_index); ecl_grid_init_cell_nnc_info(grid1, grid1_cell_index); @@ -2280,10 +2282,10 @@ static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid This function reads the non-neighbour connection data from file and initializes the grid structure with the the nnc data */ static void ecl_grid_init_nnc(ecl_grid_type * main_grid, ecl_file_type * ecl_file) { - int num_nnchead_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEAD_KW ); - - int i; - for (i = 0; i < num_nnchead_kw; i++) { + int num_nnchead_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEAD_KW ); + + int i; + for (i = 0; i < num_nnchead_kw; i++) { ecl_file_push_block(ecl_file); /* <---------------------------------------------------------------- */ ecl_file_select_block(ecl_file , NNCHEAD_KW , i); { @@ -2319,22 +2321,22 @@ static void ecl_grid_init_nnc(ecl_grid_type * main_grid, ecl_file_type * ecl_fil LGRs) and initializes the grid structure with the nnc data. */ static void ecl_grid_init_nnc_amalgamated(ecl_grid_type * main_grid, ecl_file_type * ecl_file) { - int num_nncheada_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEADA_KW ); - - int i; - for (i = 0; i < num_nncheada_kw; i++) { + int num_nncheada_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEADA_KW ); + + int i; + for (i = 0; i < num_nncheada_kw; i++) { ecl_kw_type * nncheada_kw = ecl_file_iget_named_kw( ecl_file , NNCHEADA_KW , i); - int lgr_nr1 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX); - int lgr_nr2 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX); - - ecl_grid_type * lgr_grid1 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr1); - ecl_grid_type * lgr_grid2 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr2); - + int lgr_nr1 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX); + int lgr_nr2 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX); + + ecl_grid_type * lgr_grid1 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr1); + ecl_grid_type * lgr_grid2 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr2); + ecl_kw_type * nna1_kw = ecl_file_iget_named_kw( ecl_file , NNA1_KW , i); ecl_kw_type * nna2_kw = ecl_file_iget_named_kw( ecl_file , NNA2_KW , i); - + ecl_grid_init_nnc_cells( lgr_grid1 ,lgr_grid2, nna1_kw, nna2_kw); - + } } @@ -2347,7 +2349,7 @@ static void ecl_grid_init_nnc_amalgamated(ecl_grid_type * main_grid, ecl_file_ty 1. Load the file and extracte the keywords. 2. Call xx_alloc_GRDECL_kw__() to build grid based on keywords. 3. Call xx_alloc_GRDECL_data__() to build the grid based on keyword data. - + The point is that external scope can create grid based on both a list of keywords, and actual data - in addition to the normal loading of a full file. Currently the 'shortcuts' @@ -2362,40 +2364,40 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const ecl_kw_type * coord_kw = ecl_file_iget_named_kw( ecl_file , COORD_KW , grid_nr); ecl_kw_type * corsnum_kw = NULL; ecl_kw_type * actnum_kw = NULL; - ecl_kw_type * mapaxes_kw = NULL; + ecl_kw_type * mapaxes_kw = NULL; int dualp_flag; if (grid_nr == 0) { ecl_kw_type * filehead_kw = ecl_file_iget_named_kw( ecl_file , FILEHEAD_KW , grid_nr); dualp_flag = ecl_kw_iget_int( filehead_kw , FILEHEAD_DUALP_INDEX ); } else dualp_flag = main_grid->dualp_flag; - + /** If ACTNUM is not present - that is is interpreted as - all active. */ if (ecl_file_get_num_named_kw(ecl_file , ACTNUM_KW) > grid_nr) actnum_kw = ecl_file_iget_named_kw( ecl_file , ACTNUM_KW , grid_nr); - + if (grid_nr == 0) { /* MAPAXES and COARSENING only apply to the global grid. */ - if (ecl_file_has_kw( ecl_file , MAPAXES_KW)) + if (ecl_file_has_kw( ecl_file , MAPAXES_KW)) mapaxes_kw = ecl_file_iget_named_kw( ecl_file , MAPAXES_KW , 0); - - if (ecl_file_has_kw( ecl_file , CORSNUM_KW)) + + if (ecl_file_has_kw( ecl_file , CORSNUM_KW)) corsnum_kw = ecl_file_iget_named_kw( ecl_file , CORSNUM_KW , 0); } - + { - ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__( main_grid , - dualp_flag , - gridhead_kw , - zcorn_kw , - coord_kw , - actnum_kw , - mapaxes_kw , + ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__( main_grid , + dualp_flag , + gridhead_kw , + zcorn_kw , + coord_kw , + actnum_kw , + mapaxes_kw , corsnum_kw ); - + if (ECL_GRID_MAINGRID_LGR_NR != grid_nr) ecl_grid_set_lgr_name_EGRID(ecl_grid , ecl_file , grid_nr); return ecl_grid; } @@ -2410,30 +2412,33 @@ static ecl_grid_type * ecl_grid_alloc_EGRID(const char * grid_file) { util_abort("%s: %s wrong file type - expected .EGRID file - aborting \n",__func__ , grid_file); { ecl_file_type * ecl_file = ecl_file_open( grid_file , 0); - int num_grid = ecl_file_get_num_named_kw( ecl_file , GRIDHEAD_KW ); - ecl_grid_type * main_grid = ecl_grid_alloc_EGRID__( NULL , ecl_file , 0 ); - int grid_nr; - - for ( grid_nr = 1; grid_nr < num_grid; grid_nr++) { - ecl_grid_type * lgr_grid = ecl_grid_alloc_EGRID__( main_grid , ecl_file , grid_nr ); - ecl_grid_add_lgr( main_grid , lgr_grid ); - { - ecl_grid_type * host_grid; - ecl_kw_type * hostnum_kw = ecl_file_iget_named_kw( ecl_file , HOSTNUM_KW , grid_nr - 1); - if (lgr_grid->parent_name == NULL) - host_grid = main_grid; - else - host_grid = ecl_grid_get_lgr( main_grid , lgr_grid->parent_name ); - - ecl_grid_install_lgr_EGRID( host_grid , lgr_grid , ecl_kw_get_int_ptr( hostnum_kw) ); + if (ecl_file) { + int num_grid = ecl_file_get_num_named_kw( ecl_file , GRIDHEAD_KW ); + ecl_grid_type * main_grid = ecl_grid_alloc_EGRID__( NULL , ecl_file , 0 ); + int grid_nr; + + for ( grid_nr = 1; grid_nr < num_grid; grid_nr++) { + ecl_grid_type * lgr_grid = ecl_grid_alloc_EGRID__( main_grid , ecl_file , grid_nr ); + ecl_grid_add_lgr( main_grid , lgr_grid ); + { + ecl_grid_type * host_grid; + ecl_kw_type * hostnum_kw = ecl_file_iget_named_kw( ecl_file , HOSTNUM_KW , grid_nr - 1); + if (lgr_grid->parent_name == NULL) + host_grid = main_grid; + else + host_grid = ecl_grid_get_lgr( main_grid , lgr_grid->parent_name ); + + ecl_grid_install_lgr_EGRID( host_grid , lgr_grid , ecl_kw_get_int_ptr( hostnum_kw) ); + } } - } - main_grid->name = util_alloc_string_copy( grid_file ); - ecl_grid_init_nnc(main_grid, ecl_file); - ecl_grid_init_nnc_amalgamated(main_grid, ecl_file); - - ecl_file_close( ecl_file ); - return main_grid; + main_grid->name = util_alloc_string_copy( grid_file ); + ecl_grid_init_nnc(main_grid, ecl_file); + ecl_grid_init_nnc_amalgamated(main_grid, ecl_file); + + ecl_file_close( ecl_file ); + return main_grid; + } else + return NULL; } } @@ -2448,16 +2453,16 @@ static ecl_grid_type * ecl_grid_alloc_GRID_data__(ecl_grid_type * global_grid , nz = nz / 2; { ecl_grid_type * grid = ecl_grid_alloc_empty( global_grid , dualp_flag , nx , ny , nz , grid_nr, false); - + if (mapaxes != NULL) ecl_grid_init_mapaxes( grid , mapaxes ); - + { int index; - for ( index=0; index < num_coords; index++) + for ( index=0; index < num_coords; index++) ecl_grid_set_cell_GRID(grid , coords_size , coords[index] , corners[index]); } - + ecl_grid_init_coarse_cells( grid ); ecl_grid_update_index( grid ); ecl_grid_taint_cells( grid ); @@ -2471,8 +2476,8 @@ static ecl_grid_type * ecl_grid_alloc_GRID_data__(ecl_grid_type * global_grid , */ ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx , int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes) { - return ecl_grid_alloc_GRID_data__( NULL , - num_coords , + return ecl_grid_alloc_GRID_data__( NULL , + num_coords , FILEHEAD_SINGLE_POROSITY , /* Does currently not support to determine dualp_flag from inspection. */ nx , ny , nz , 0 , coords_size , coords , corners , mapaxes); } @@ -2495,12 +2500,12 @@ static int ecl_grid_dual_porosity_GRID_check( ecl_file_type * ecl_file ) { ecl_kw_type * matrix_kw; ecl_kw_type * fracture_kw; - + if (num_corners > nx*ny*nz) fracture_index = nx*ny*nz/2; else fracture_index = num_corners / 2; - + while (true) { matrix_kw = ecl_file_iget_named_kw( ecl_file, CORNERS_KW , matrix_index ); fracture_kw = ecl_file_iget_named_kw( ecl_file, CORNERS_KW , fracture_index ); @@ -2509,7 +2514,7 @@ static int ecl_grid_dual_porosity_GRID_check( ecl_file_type * ecl_file ) { dualp_flag = FILEHEAD_SINGLE_POROSITY; break; } - + matrix_index++; fracture_index++; if (fracture_index == nx*ny*nz) @@ -2533,7 +2538,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const ny = ecl_kw_iget_int(dimens_kw , DIMENS_NY_INDEX); nz = ecl_kw_iget_int(dimens_kw , DIMENS_NZ_INDEX); } - + // 2: Fetching the mapaxes data from the MAPAXES keyword; the // keyword is optional, and is only applicable to the global grid. @@ -2543,7 +2548,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const mapaxes_data = ecl_grid_get_mapaxes_from_kw__(mapaxes_kw); } } - + /* The number of COORDS/CORNERS blocks depends on the GRIDFILE option @@ -2556,7 +2561,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const 2. The GRID file only contains the global information, and can not contain LGR information. - + If the GRIDFILE option is set to 2 ECLIPSE will save coordinate information for all the cells in the grid, and also lgrs. To determine how many coords keywords we should read we use the @@ -2564,10 +2569,10 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const 1. If global_grid != NULL : this is an lgr, and num_coords = nx*ny*nz; - + 2. If global_grid == NULL : this is the global grid. We check how many COORDS keywords there are in the file: - + a) If there are >= nx*ny*nz keywords we set num_coords == nx*ny*nz. @@ -2585,7 +2590,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const { int num_coords; - + if (global_grid == NULL) { /* This is the main grid - can be both nactive or nx*ny*nz coord elements. */ int num_coords_kw = ecl_file_get_num_named_kw( ecl_file , COORDS_KW); @@ -2597,20 +2602,20 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const /* This is an lgr - always nx*ny*nz elements. */ num_coords = nx*ny*nz; - + // 3: Fetching the main chunk of cell data from the COORDS and // CORNERS keywords. { int coords_size = -1; int index; - + int ** coords = util_calloc( num_coords , sizeof * coords ); float ** corners = util_calloc( num_coords , sizeof * corners ); - + for (index = 0; index < num_coords; index++) { const ecl_kw_type * coords_kw = ecl_file_iget_named_kw(ecl_file , COORDS_KW , index + cell_offset); const ecl_kw_type * corners_kw = ecl_file_iget_named_kw(ecl_file , CORNERS_KW , index + cell_offset); - + coords[index] = ecl_kw_get_int_ptr(coords_kw); corners[index] = ecl_kw_get_float_ptr(corners_kw); coords_size = ecl_kw_get_size( coords_kw ); @@ -2637,7 +2642,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID(const char * grid_file) { file_type = ecl_util_get_file_type(grid_file , NULL , NULL); if (file_type != ECL_GRID_FILE) util_abort("%s: %s wrong file type - expected .GRID file - aborting \n",__func__ , grid_file); - + { int cell_offset = 0; ecl_file_type * ecl_file = ecl_file_open( grid_file , 0); @@ -2656,12 +2661,12 @@ static ecl_grid_type * ecl_grid_alloc_GRID(const char * grid_file) { ecl_grid_add_lgr( main_grid , lgr_grid ); { ecl_grid_type * host_grid; - + if (lgr_grid->parent_name == NULL) host_grid = main_grid; - else + else host_grid = ecl_grid_get_lgr( main_grid , lgr_grid->parent_name ); - + ecl_grid_install_lgr_GRID( host_grid , lgr_grid ); } } @@ -2670,7 +2675,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID(const char * grid_file) { return main_grid; } } - + /** @@ -2786,7 +2791,7 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , con nx, ny, nz, /*lgr_nr=*/0, /*init_valid=*/true); - + /* First layer - where the DEPTHZ keyword applies. */ { int i,j; @@ -2801,7 +2806,7 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , con double z1 = depthz[ i + 1 + j*(nx + 1)]; double z2 = depthz[ i + (j + 1)*(nx + 1)]; double z3 = depthz[ i + 1 + (j + 1)*(nx + 1)]; - + point_set(&cell->corner_list[0] , x0 , y0 , z0); point_set(&cell->corner_list[1] , x0 + dxv[i] , y0 , z1); @@ -2850,7 +2855,7 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , con int global_index = i + j*nx + k*nx*ny; ecl_cell_type* cell = ecl_grid_get_cell(grid, global_index); - if (actnum) + if (actnum) cell->active = actnum[global_index]; else cell->active = CELL_ACTIVE; @@ -2870,7 +2875,7 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , con are all of length nx*ny*nz. In principle all values of these four arrays are independent - but taking that all out will create some really weird looking grids. For physical correctness there should - be many constraints among the different values. + be many constraints among the different values. The x and y position of a cell is found by adding the increments from dx and dy, whereas the vertical position is read dircetly out @@ -2882,7 +2887,7 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , con */ ecl_grid_type * ecl_grid_alloc_dx_dy_dz_tops( int nx, int ny , int nz , const double * dx , const double * dy , const double * dz , const double * tops , const int * actnum) { - + ecl_grid_type* grid = ecl_grid_alloc_empty(NULL, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, @@ -2902,19 +2907,19 @@ ecl_grid_type * ecl_grid_alloc_dx_dy_dz_tops( int nx, int ny , int nz , const do double z0 = tops[ g ]; point_set(&cell->corner_list[0] , x0 , y0[i] , z0); - point_set(&cell->corner_list[1] , x0 + dx[g] , y0[i] , z0); + point_set(&cell->corner_list[1] , x0 + dx[g] , y0[i] , z0); point_set(&cell->corner_list[2] , x0 , y0[i] + dy[g] , z0); point_set(&cell->corner_list[3] , x0 + dx[g] , y0[i] + dy[g] , z0); point_set(&cell->corner_list[4] , x0 , y0[i] , z0 + dz[g]); - point_set(&cell->corner_list[5] , x0 + dx[g] , y0[i] , z0 + dz[g]); + point_set(&cell->corner_list[5] , x0 + dx[g] , y0[i] , z0 + dz[g]); point_set(&cell->corner_list[6] , x0 , y0[i] + dy[g] , z0 + dz[g]); point_set(&cell->corner_list[7] , x0 + dx[g] , y0[i] + dy[g] , z0 + dz[g]); - + x0 += dx[g]; y0[i] += dy[g]; - - if (actnum != NULL) + + if (actnum != NULL) cell->active = actnum[g]; else cell->active = CELL_ACTIVE; @@ -2950,7 +2955,7 @@ ecl_grid_type * ecl_grid_alloc(const char * grid_file ) { ecl_grid = ecl_grid_alloc_EGRID(grid_file); else util_abort("%s must have .GRID or .EGRID file - %s not recognized \n", __func__ , grid_file); - + return ecl_grid; } @@ -2967,32 +2972,32 @@ static void ecl_grid_file_nactive_dims( fortio_type * data_fortio , int * dims) static bool ecl_grid_file_EGRID_dims( fortio_type * grid_fortio , fortio_type * data_fortio , int * dims ) { - + if (ecl_kw_fseek_kw( GRIDHEAD_KW , false , false , grid_fortio)) { { ecl_kw_type * gridhead_kw = ecl_kw_fread_alloc( grid_fortio ); dims[0] = ecl_kw_iget_int( gridhead_kw , GRIDHEAD_NX_INDEX ); dims[1] = ecl_kw_iget_int( gridhead_kw , GRIDHEAD_NY_INDEX ); dims[2] = ecl_kw_iget_int( gridhead_kw , GRIDHEAD_NZ_INDEX ); - + ecl_kw_free( gridhead_kw ); } ecl_grid_file_nactive_dims( data_fortio , dims ); return true; } else return false; - + } static bool ecl_grid_file_GRID_dims( fortio_type * grid_fortio , fortio_type * data_fortio , int * dims ) { - + if (ecl_kw_fseek_kw( DIMENS_KW , false , false , grid_fortio)) { { ecl_kw_type * dimens_kw = ecl_kw_fread_alloc( grid_fortio ); dims[0] = ecl_kw_iget_int( dimens_kw , DIMENS_NX_INDEX ); dims[1] = ecl_kw_iget_int( dimens_kw , DIMENS_NY_INDEX ); dims[2] = ecl_kw_iget_int( dimens_kw , DIMENS_NZ_INDEX ); - + ecl_kw_free( dimens_kw ); } @@ -3000,7 +3005,7 @@ static bool ecl_grid_file_GRID_dims( fortio_type * grid_fortio , fortio_type * d return true; } else return false; - + } /** @@ -3008,8 +3013,8 @@ static bool ecl_grid_file_GRID_dims( fortio_type * grid_fortio , fortio_type * d @grid_filename; the input file must be a GRID/EGRID file. On exit the dims array will be filled as: - dims[0] = nx; - dims[1] = ny; + dims[0] = nx; + dims[1] = ny; dims[2] = nz; Optionally you can in addition supply the name of a restart or INIT @@ -3018,7 +3023,7 @@ static bool ecl_grid_file_GRID_dims( fortio_type * grid_fortio , fortio_type * d will be set as: dims[3] = nactive; - + The function as a whole will return true if the grid dimensions (nx,ny,nz) are sucessfully set. If the dimensions are not set the dims vector is not touched. @@ -3036,25 +3041,25 @@ bool ecl_grid_file_dims( const char * grid_filename , const char * init_restart_ if (grid_fortio) { fortio_type * data_fortio = NULL; bool data_fmt_file; - + if (init_restart_filename) { ecl_util_get_file_type( init_restart_filename , &data_fmt_file , NULL ); data_fortio = fortio_open_reader( init_restart_filename , data_fmt_file , ECL_ENDIAN_FLIP ); } - - + + if (grid_file_type == ECL_GRID_FILE) input_file_OK = ecl_grid_file_GRID_dims( grid_fortio , data_fortio , dims ); else input_file_OK = ecl_grid_file_EGRID_dims( grid_fortio , data_fortio , dims ); - + if (data_fortio) fortio_fclose( data_fortio ); - + fortio_fclose( grid_fortio ); } - } - + } + return input_file_OK; } @@ -3071,7 +3076,7 @@ bool ecl_grid_file_dims( const char * grid_filename , const char * init_restart_ 2 case_input - an existing ECLIPSE file which is not a grid file; if it has definite formatted/unformatted status look only for those GRID/EGRID with the same formatted/unformatted status. - + 3 case_input is only an ECLIPSE base, look for formatted/unformatted files with the correct basename. @@ -3091,7 +3096,7 @@ char * ecl_grid_alloc_case_filename( const char * case_input ) { ecl_file_enum file_type; bool fmt_file; file_type = ecl_util_get_file_type( case_input , &fmt_file , NULL); - + if (file_type == ECL_GRID_FILE) return util_alloc_string_copy( case_input ); /* Case 1 */ else if (file_type == ECL_EGRID_FILE) @@ -3116,7 +3121,7 @@ char * ecl_grid_alloc_case_filename( const char * case_input ) { else if (util_file_exists( FGRID )) grid_file = util_alloc_string_copy( FGRID ); /* - else: could not find a GRID/EGRID. + else: could not find a GRID/EGRID. */ free( EGRID ); @@ -3126,12 +3131,12 @@ char * ecl_grid_alloc_case_filename( const char * case_input ) { } else { /* Case 2 - we know the formatted / unformatted status. */ char * EGRID = ecl_util_alloc_filename( path , basename , ECL_EGRID_FILE , fmt_file , -1); char * GRID = ecl_util_alloc_filename( path , basename , ECL_GRID_FILE , fmt_file , -1); - + if (util_file_exists( EGRID )) grid_file = util_alloc_string_copy( EGRID ); else if (util_file_exists( GRID )) grid_file = util_alloc_string_copy( GRID ); - + free( EGRID ); free( GRID ); } @@ -3146,9 +3151,9 @@ ecl_grid_type * ecl_grid_load_case( const char * case_input ) { char * grid_file = ecl_grid_alloc_case_filename( case_input ); if (grid_file != NULL) { - if (util_file_exists( grid_file )) + if (util_file_exists( grid_file )) ecl_grid = ecl_grid_alloc( grid_file ); - + free( grid_file ); } return ecl_grid; @@ -3171,15 +3176,15 @@ static bool ecl_grid_compare_coarse_cells(const ecl_grid_type * g1 , const ecl_g if (vector_get_size( g1->coarse_cells ) == vector_get_size( g2->coarse_cells )) { bool equal = true; int c; - + for (c = 0; c < vector_get_size( g1->coarse_cells ); c++) { const ecl_coarse_cell_type * coarse_cell1 = vector_iget_const( g1->coarse_cells , c); const ecl_coarse_cell_type * coarse_cell2 = vector_iget_const( g2->coarse_cells , c); - + equal = ecl_coarse_cell_equal( coarse_cell1 , coarse_cell2 ); - if (!equal) + if (!equal) if (verbose) fprintf(stderr,"Difference in coarse cell:%d \n",c ); - + } return equal; } else @@ -3195,7 +3200,7 @@ static bool ecl_grid_compare_cells(const ecl_grid_type * g1 , const ecl_grid_typ ecl_cell_type *c1 = ecl_grid_get_cell( g1 , g ); ecl_cell_type *c2 = ecl_grid_get_cell( g2 , g ); ecl_cell_compare(c1 , c2 , include_nnc , &this_equal); - + if (!this_equal) { if (verbose) { int i,j,k; @@ -3207,7 +3212,7 @@ static bool ecl_grid_compare_cells(const ecl_grid_type * g1 , const ecl_grid_typ printf("-----------------------------------------------------------------\n"); ecl_cell_dump_ascii( c2 , i , j , k , stdout , NULL ); printf("-----------------------------------------------------------------\n"); - + } equal = false; break; @@ -3218,21 +3223,21 @@ static bool ecl_grid_compare_cells(const ecl_grid_type * g1 , const ecl_grid_typ static bool ecl_grid_compare_index(const ecl_grid_type * g1 , const ecl_grid_type * g2, bool verbose) { bool equal = true; - + if (g1->total_active != g2->total_active) { - if (verbose) + if (verbose) fprintf(stderr,"Difference in total active:%d / %d\n",g1->total_active , g2->total_active); equal = false; } - + if (equal) { if (memcmp( g1->index_map , g2->index_map , g1->size * sizeof * g1->index_map ) != 0) { equal = false; - if (verbose) + if (verbose) fprintf(stderr,"Difference in index map \n"); } } - + if (equal) { if (memcmp( g1->inv_index_map , g2->inv_index_map , g1->total_active * sizeof * g1->inv_index_map ) != 0) { equal = false; @@ -3240,7 +3245,7 @@ static bool ecl_grid_compare_index(const ecl_grid_type * g1 , const ecl_grid_typ fprintf(stderr,"Difference in inverse index map \n"); } } - + if (equal && (g1->dualp_flag != FILEHEAD_SINGLE_POROSITY)) { if (g1->total_active_fracture != g2->total_active_fracture) { if (verbose) @@ -3255,7 +3260,7 @@ static bool ecl_grid_compare_index(const ecl_grid_type * g1 , const ecl_grid_typ fprintf(stderr,"Difference in fracture_index_map \n"); } } - + if (equal) { if (memcmp( g1->inv_fracture_index_map , g2->inv_fracture_index_map , g1->total_active_fracture * sizeof * g1->inv_fracture_index_map ) != 0) { equal = false; @@ -3263,7 +3268,7 @@ static bool ecl_grid_compare_index(const ecl_grid_type * g1 , const ecl_grid_typ fprintf(stderr,"Difference in inv_fracture_index_map \n"); } } - + } return equal; } @@ -3273,7 +3278,7 @@ static bool ecl_grid_compare_mapaxes(const ecl_grid_type * g1 , const ecl_grid_t bool equal = true; if (g1->use_mapaxes == g2->use_mapaxes) { if (g1->use_mapaxes) { - if (memcmp( g1->mapaxes , g2->mapaxes , sizeof * g1->mapaxes ) != 0) + if (memcmp( g1->mapaxes , g2->mapaxes , sizeof * g1->mapaxes ) != 0) equal = false; } } else @@ -3281,24 +3286,24 @@ static bool ecl_grid_compare_mapaxes(const ecl_grid_type * g1 , const ecl_grid_t if (!equal && verbose) fprintf(stderr,"Difference in mapaxes \n" ); - + return equal; } /** Return true if grids g1 and g2 are equal, and false otherwise. To - return true all cells must be identical. + return true all cells must be identical. */ static bool ecl_grid_compare__(const ecl_grid_type * g1 , const ecl_grid_type * g2, bool include_nnc , bool verbose) { - + bool equal = true; if (g1->size != g2->size) equal = false; // The name of the parent grid corresponds to a filename; they can be different. - if (equal && g1->parent_grid) { + if (equal && g1->parent_grid) { if (!util_string_equal( g1->name , g2->name )) { equal = false; if (verbose) @@ -3307,21 +3312,21 @@ static bool ecl_grid_compare__(const ecl_grid_type * g1 , const ecl_grid_type * } /* - When .GRID files are involved this is hardwired to FILEHEAD_SINGLE_POROSITY. + When .GRID files are involved this is hardwired to FILEHEAD_SINGLE_POROSITY. */ if (g1->dualp_flag != g2->dualp_flag) { equal = false; - if (verbose) + if (verbose) fprintf(stderr,"Dual porosity flags differ: %d / %d \n" , g1->dualp_flag , g2->dualp_flag); } - - if (equal) + + if (equal) equal = ecl_grid_compare_cells(g1 , g2 , include_nnc , verbose); if (equal) equal = ecl_grid_compare_index( g1 , g2 , true /*verbose*/); - if (equal) + if (equal) equal = ecl_grid_compare_coarse_cells( g1 , g2 , verbose ); if (equal) @@ -3340,9 +3345,9 @@ bool ecl_grid_compare(const ecl_grid_type * g1 , const ecl_grid_type * g2 , bool for (grid_nr = 0; grid_nr < vector_get_size( g1->LGR_list ); grid_nr++) { const ecl_grid_type * lgr1 = vector_iget_const( g1->LGR_list , grid_nr); const ecl_grid_type * lgr2 = vector_iget_const( g2->LGR_list , grid_nr); - + equal = ecl_grid_compare__(lgr1 , lgr2 , include_nnc , verbose); - if (!equal) + if (!equal) break; } } else @@ -3360,7 +3365,7 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in const double min_volume = 1e-9; point_type p; ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index ); - + point_set( &p , x , y , z); /* 1. first check if the point z value is below the deepest point of @@ -3370,12 +3375,12 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in 3. full geometric verification. */ - if (GET_CELL_FLAG(cell , CELL_FLAG_TAINTED)) + if (GET_CELL_FLAG(cell , CELL_FLAG_TAINTED)) return false; if (p.z < ecl_cell_min_z( cell )) return false; - + if (p.z > ecl_cell_max_z( cell )) return false; @@ -3387,7 +3392,7 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in if (p.y < ecl_cell_min_y( cell )) return false; - + if (p.y > ecl_cell_max_y( cell )) return false; @@ -3395,7 +3400,7 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in int i,j,k; ecl_grid_get_ijk1( ecl_grid , global_index , &i , &j , &k); ecl_cell_assert_center( cell ); - + /* Special case checks for the corner points. */ @@ -3408,7 +3413,7 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in else return false; } - + if (point_equal( &p , &cell->corner_list[2])) { if (j == (ecl_grid->ny - 1)) return true; @@ -3455,7 +3460,7 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in else return false; } - + { double sign = 1.0; int plane_nr = 0; @@ -3464,23 +3469,23 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in point_type * p0; point_type * p1; point_type * p2; - + if (signed_volume < 0) sign = -1; { - while (true) { + while (true) { p0 = &cell->corner_list[ bounding_planes[plane_nr][0] ]; p1 = &cell->corner_list[ bounding_planes[plane_nr][1] ]; p2 = &cell->corner_list[ bounding_planes[plane_nr][2] ]; - - if (point_equal(p0, p1) || point_equal(p0,p2) || point_equal(p1,p2)) + + if (point_equal(p0, p1) || point_equal(p0,p2) || point_equal(p1,p2)) return false; - if (sign * point3_plane_distance(p0 , p1 , p2 , &p ) < 0) + if (sign * point3_plane_distance(p0 , p1 , p2 , &p ) < 0) return false; - + plane_nr++; - if (plane_nr == 6) + if (plane_nr == 6) return true; } } @@ -3489,7 +3494,7 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in } } - + /* More 'correct' version based on tetrahedron decomposition; unfortunately getting this to be reliable proved to difficult. @@ -3499,20 +3504,20 @@ bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_in int tetrahedron_nr = 0; tetrahedron_type tet; if (ecl_cell_get_volume( cell ) > 0) { - // + // // General check if point is inside tetrahedrons. Does never // exit from this loop - only returns from the whole function. // - while (true) { + while (true) { ecl_cell_init_tetrahedron( cell , &tet , method , tetrahedron_nr ); - if (tetrahedron_contains( &tet , &p )) + if (tetrahedron_contains( &tet , &p )) return true; - + tetrahedron_nr++; if (tetrahedron_nr == 12) return false; - } + } } else return false; } @@ -3542,7 +3547,7 @@ int ecl_grid_get_global_index_from_xy( const ecl_grid_type * ecl_grid , int k , for (i=0; i < ecl_grid->nx; i++) { int global_index = ecl_grid_get_global_index3( ecl_grid , i , j , k ); if (ecl_cell_layer_contains_xy( ecl_grid_get_cell( ecl_grid , global_index ) , lower_layer , x , y)) - return global_index; + return global_index; } return -1; /* Did not find x,y */ } @@ -3561,8 +3566,8 @@ int ecl_grid_get_global_index_from_xy_bottom( const ecl_grid_type * ecl_grid , d static void ecl_grid_clear_visited( ecl_grid_type * grid ) { if (grid->visited == NULL) grid->visited = util_calloc( grid->size , sizeof * grid->visited ); - - { + + { int i; for (i=0; i < grid->size; i++) grid->visited[i] = false; @@ -3570,8 +3575,8 @@ static void ecl_grid_clear_visited( ecl_grid_type * grid ) { } -/* - Box coordinates are not inclusive, i.e. [i1,i2) +/* + Box coordinates are not inclusive, i.e. [i1,i2) */ static int ecl_grid_box_contains_xyz( const ecl_grid_type * grid , int i1, int i2 , int j1 , int j2 , int k1 , int k2 , const point_type * p) { @@ -3610,7 +3615,7 @@ static int ecl_grid_box_contains_xyz( const ecl_grid_type * grid , int i1, int i and scan through the grid linearly. - start_index != 0: + start_index != 0: 1. Check the cell 'start_index'. 2. Check the neighbours (i +/- 1, j +/- 1, k +/- 1 ). 3. Give up and do a linear search starting from start_index. @@ -3624,7 +3629,7 @@ int ecl_grid_get_global_index_from_xyz(ecl_grid_type * grid , double x , double point_type p; point_set( &p , x , y , z); ecl_grid_clear_visited( grid ); - + if (start_index >= 0) { /* Try start index */ if (ecl_grid_cell_contains_xyz1( grid , start_index , x,y,z)) @@ -3640,11 +3645,11 @@ int ecl_grid_get_global_index_from_xyz(ecl_grid_type * grid , double x , double i1 = util_int_max( 0 , i - 1 ); j1 = util_int_max( 0 , j - 1 ); k1 = util_int_max( 0 , k - 1 ); - + i2 = util_int_min( nx , i + 1 ); j2 = util_int_min( ny , j + 1 ); k2 = util_int_min( nz , k + 1 ); - + global_index = ecl_grid_box_contains_xyz( grid , i1 , i2 , j1 , j2 , k1 , k2 , &p); if (global_index >= 0) return global_index; @@ -3654,24 +3659,24 @@ int ecl_grid_get_global_index_from_xyz(ecl_grid_type * grid , double x , double i1 = util_int_max( 0 , i - 2 ); j1 = util_int_max( 0 , j - 2 ); k1 = util_int_max( 0 , k - 2 ); - + i2 = util_int_min( nx , i + 2 ); j2 = util_int_min( ny , j + 2 ); k2 = util_int_min( nz , k + 2 ); - + global_index = ecl_grid_box_contains_xyz( grid , i1 , i2 , j1 , j2 , k1 , k2 , &p); if (global_index >= 0) return global_index; } - } - - /* + } + + /* OK - the attempted shortcuts did not pay off. We start on the full linear search starting from start_index. */ - + { int index = 0; global_index = -1; @@ -3680,7 +3685,7 @@ int ecl_grid_get_global_index_from_xyz(ecl_grid_type * grid , double x , double int current_index = ((index + start_index) % grid->size); bool cell_contains; cell_contains = ecl_grid_cell_contains_xyz1( grid , current_index , x , y , z); - + if (cell_contains) { global_index = current_index; break; @@ -3688,16 +3693,97 @@ int ecl_grid_get_global_index_from_xyz(ecl_grid_type * grid , double x , double index++; if (index == grid->size) break; - } + } } return global_index; } +static bool ecl_grid_sublayer_contanins_xy__(const ecl_grid_type * grid , double x , double y , int k , int i1 , int i2 , int j1 , int j2, geo_polygon_type * polygon) { + int i,j; + geo_polygon_reset( polygon ); + + /* Bottom edge */ + for (i=i1; i < i2; i++) { + double corner_pos[3]; + ecl_grid_get_corner_xyz( grid , i , j1 , k , &corner_pos[0] , &corner_pos[1] , &corner_pos[2]); + geo_polygon_add_point( polygon , corner_pos[0] , corner_pos[1]); + } + + /* Right edge */ + for (j=j1; j < j2; j++) { + double corner_pos[3]; + ecl_grid_get_corner_xyz( grid , i2 , j , k , &corner_pos[0] , &corner_pos[1] , &corner_pos[2]); + geo_polygon_add_point( polygon , corner_pos[0] , corner_pos[1]); + } + + /* Top edge */ + for (i=i2; i > i1; i--) { + double corner_pos[3]; + ecl_grid_get_corner_xyz( grid , i , j2 , k , &corner_pos[0] , &corner_pos[1] , &corner_pos[2]); + geo_polygon_add_point( polygon , corner_pos[0] , corner_pos[1]); + } + + /* Left edge */ + for (j=j2; j > j1; j--) { + double corner_pos[3]; + ecl_grid_get_corner_xyz( grid , i1 , j , k , &corner_pos[0] , &corner_pos[1] , &corner_pos[2]); + geo_polygon_add_point( polygon , corner_pos[0] , corner_pos[1]); + } + geo_polygon_close( polygon ); + return geo_polygon_contains_point__( polygon , x , y , true ); +} +bool ecl_grid_get_ij_from_xy( const ecl_grid_type * grid , double x , double y , int k , int* i, int* j) { + geo_polygon_type * polygon = geo_polygon_alloc( NULL ); + int nx = ecl_grid_get_nx( grid ); + int ny = ecl_grid_get_ny( grid ); + bool inside = ecl_grid_sublayer_contanins_xy__(grid , x , y , k , 0 , nx , 0 , ny , polygon); + if (inside) { + int i1 = 0; + int i2 = nx; + int j1 = 0; + int j2 = ny; + + while (true) { + if ((i2 - i1) > 1) { + int ic = (i1 + i2) / 2; + if (ecl_grid_sublayer_contanins_xy__(grid , x , y , k , i1 , ic , j1 , j2 , polygon)) + i2 = ic; + else { + if (!ecl_grid_sublayer_contanins_xy__(grid , x , y , k , ic , i2 , j1 , j2 , polygon)) + util_abort("%s: point nowhere to be found ... \n",__func__); + i1 = ic; + } + } + + if ((j2 - j1) > 1) { + int jc = (j1 + j2) / 2; + if (ecl_grid_sublayer_contanins_xy__(grid , x , y , k , i1 , i2 , j1 , jc , polygon)) + j2 = jc; + else { + if (!ecl_grid_sublayer_contanins_xy__(grid , x , y , k , i1 , i2 , jc , j2 , polygon)) + util_abort("%s: point nowhere to be found ... \n",__func__); + j1 = jc; + } + } + + if ((i2 - i1) == 1 && (j2 - j1) == 1) { + *i = i1; + *j = j1; + break; + } + } + } + + geo_polygon_free( polygon ); + return inside; +} + + void ecl_grid_alloc_blocking_variables(ecl_grid_type * grid, int block_dim) { int index; @@ -3761,10 +3847,10 @@ void ecl_grid_free(ecl_grid_type * grid) { ecl_grid_free_cells( grid ); util_safe_free(grid->index_map); util_safe_free(grid->inv_index_map); - + util_safe_free(grid->fracture_index_map); util_safe_free(grid->inv_fracture_index_map); - + if (grid->values != NULL) { int i; for (i=0; i < grid->block_size; i++) @@ -3778,7 +3864,7 @@ void ecl_grid_free(ecl_grid_type * grid) { } if (grid->coord_kw != NULL) ecl_kw_free( grid->coord_kw ); - + vector_free( grid->coarse_cells ); hash_free( grid->children ); util_safe_free( grid->parent_name ); @@ -3819,13 +3905,13 @@ void ecl_grid_get_distance(const ecl_grid_type * grid , int global_index1, int g /** Only checks that i,j,k are in the required intervals: - + 0 <= i < nx 0 <= j < ny 0 <= k < nz */ - + bool ecl_grid_ijk_valid(const ecl_grid_type * grid , int i , int j , int k) { bool OK = false; @@ -3870,13 +3956,13 @@ grid_dims_type ecl_grid_iget_dims( const ecl_grid_type * grid , int grid_nr) { if (grid_nr == 0) lgr = grid; else - lgr = ecl_grid_iget_lgr(grid, grid_nr - 1); - + lgr = ecl_grid_iget_lgr(grid, grid_nr - 1); + dims.nx = lgr->nx; dims.ny = lgr->ny; dims.nz = lgr->nz; dims.nactive = lgr->total_active; - + return dims; } @@ -3935,7 +4021,7 @@ int ecl_grid_get_global_index1F(const ecl_grid_type * ecl_grid , int active_frac /** Converts: (i,j,k) -> active_index (i,j,k ) are zero offset. - + Will return -1 if the cell is not active. */ @@ -3947,7 +4033,7 @@ int ecl_grid_get_active_index3(const ecl_grid_type * ecl_grid , int i , int j , /** Converts: global_index -> active_index. - + Will return -1 if the cell is not active. */ @@ -3964,13 +4050,13 @@ int ecl_grid_get_active_fracture_index3(const ecl_grid_type * ecl_grid , int i , /** Converts: global_index -> active_index. - + Will return -1 if the cell is not active. */ int ecl_grid_get_active_fracture_index1(const ecl_grid_type * ecl_grid , int global_index) { if (ecl_grid->fracture_index_map == NULL) - return -1; + return -1; else return ecl_grid->fracture_index_map[global_index]; } @@ -3979,7 +4065,7 @@ int ecl_grid_get_active_fracture_index1(const ecl_grid_type * ecl_grid , int glo /* Converts global_index -> (i,j,k) - + This function returns C-based zero offset indices. cell_ */ @@ -4065,24 +4151,24 @@ void ecl_grid_get_corner_xyz(const ecl_grid_type * grid , int i , int j , int k, if (k < 0 || k > grid->nz) util_abort("%s: invalid k value:%d Valid range: [0,%d] \n",__func__ , k,grid->nz); - + { int corner_nr = 0; if (i == grid->nx) { i -= 1; corner_nr += 1; } - + if (j == grid->ny) { j -= 1; corner_nr += 2; } - + if (k == grid->nz) { k -= 1; corner_nr += 4; } - + ecl_grid_get_cell_corner_xyz3( grid , i , j , k , corner_nr , xpos , ypos , zpos); } } @@ -4122,9 +4208,9 @@ int ecl_grid_locate_depth( const ecl_grid_type * grid , double depth , int i , i double top = bottom; bottom = ecl_grid_get_bottom3( grid , i , j , k ); - if ((depth >= top) && (depth < bottom)) + if ((depth >= top) && (depth < bottom)) return k; - + k++; if (k == grid->nz) util_abort("%s: internal error when scanning for depth:%g \n",__func__ , depth); @@ -4135,7 +4221,7 @@ int ecl_grid_locate_depth( const ecl_grid_type * grid , double depth , int i , i /** - Returns the depth of the top surface of the cell. + Returns the depth of the top surface of the cell. */ double ecl_grid_get_top1(const ecl_grid_type * grid , int global_index) { @@ -4143,9 +4229,9 @@ double ecl_grid_get_top1(const ecl_grid_type * grid , int global_index) { double depth = 0; int ij; - for (ij = 0; ij < 4; ij++) + for (ij = 0; ij < 4; ij++) depth += cell->corner_list[ij].z; - + return depth * 0.25; } @@ -4177,7 +4263,7 @@ double ecl_grid_get_top1A(const ecl_grid_type * grid , int active_index) { /** - Returns the depth of the bottom surface of the cell. + Returns the depth of the bottom surface of the cell. */ double ecl_grid_get_bottom1(const ecl_grid_type * grid , int global_index) { @@ -4185,9 +4271,9 @@ double ecl_grid_get_bottom1(const ecl_grid_type * grid , int global_index) { double depth = 0; int ij; - for (ij = 0; ij < 4; ij++) + for (ij = 0; ij < 4; ij++) depth += cell->corner_list[ij + 4].z; - + return depth * 0.25; } @@ -4205,15 +4291,15 @@ double ecl_grid_get_bottom1A(const ecl_grid_type * grid , int active_index) { } - + double ecl_grid_get_cell_thickness1( const ecl_grid_type * grid , int global_index ) { const ecl_cell_type * cell = ecl_grid_get_cell( grid , global_index); double thickness = 0; int ij; - - for (ij = 0; ij < 4; ij++) + + for (ij = 0; ij < 4; ij++) thickness += (cell->corner_list[ij + 4].z - cell->corner_list[ij].z); - + return thickness * 0.25; } @@ -4229,13 +4315,13 @@ double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j const nnc_info_type * ecl_grid_get_cell_nnc_info1( const ecl_grid_type * grid , int global_index) { const ecl_cell_type * cell = ecl_grid_get_cell( grid , global_index); return cell->nnc_info; -} +} const nnc_info_type * ecl_grid_get_cell_nnc_info3( const ecl_grid_type * grid , int i , int j , int k) { const int global_index = ecl_grid_get_global_index3(grid , i,j,k); - return ecl_grid_get_cell_nnc_info1(grid, global_index); + return ecl_grid_get_cell_nnc_info1(grid, global_index); } @@ -4284,7 +4370,7 @@ double ecl_grid_cell_invalid1A(const ecl_grid_type * grid , int active_index) { /* Functions for LGR query/lookup/... */ static void __assert_main_grid(const ecl_grid_type * ecl_grid) { - if (ecl_grid->lgr_nr != ECL_GRID_MAINGRID_LGR_NR) + if (ecl_grid->lgr_nr != ECL_GRID_MAINGRID_LGR_NR) util_abort("%s: tried to get LGR grid from another LGR_grid - only main grid can be used as first input \n",__func__); } @@ -4294,7 +4380,7 @@ static void __assert_main_grid(const ecl_grid_type * ecl_grid) { lgr with name lgr_name. The function will fail HARD if no lgr with this name is installed under the present main grid; check first with ecl_grid_has_lgr() if you are whimp. - + Leading/trailing spaces on lgr_name are stripped prior to the hash lookup. */ @@ -4343,7 +4429,7 @@ bool ecl_grid_have_coarse_cells( const ecl_grid_type * main_grid ) { */ int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid ) { __assert_main_grid( main_grid ); - return vector_get_size( main_grid->LGR_list ); + return vector_get_size( main_grid->LGR_list ); } /** @@ -4358,11 +4444,11 @@ ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid, int lgr_index return vector_iget( main_grid->LGR_list , lgr_index); } -/* +/* This function returns the lgr with the given lgr_nr. The lgr_nr is the fourth element in the GRIDHEAD for EGRID files. The lgr nr is equal to the grid nr if the grid's are consecutive numbered and - read from file in increasing lgr nr order. + read from file in increasing lgr nr order. This method can only be used for EGRID files. For GRID files the lgr_nr is 0 for all grids. @@ -4384,11 +4470,11 @@ ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, in 1. The functions will happily return NULL if no LGR is associated with the cell indicated - in fact that is (currently) the only way to query whether a particular cell has a LGR. - + 2. If a certain cell is refined in several levels this function will return a pointer to the first level of refinement. The return value can can be used for repeated calls to descend - deeper into the refinement hierarchy. + deeper into the refinement hierarchy. */ @@ -4422,7 +4508,7 @@ const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ) { /*****************************************************************/ -/** +/** Allocates a stringlist instance with the lookup names of the lgr names in this grid. */ @@ -4438,7 +4524,7 @@ const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_in if (lgr_index < (vector_get_size( ecl_grid->LGR_list ))) { const ecl_grid_type * lgr = vector_iget( ecl_grid->LGR_list , lgr_index); return lgr->name; - } else + } else return NULL; } @@ -4468,16 +4554,16 @@ int ecl_grid_get_lgr_nr_from_name( const ecl_grid_type * grid , const char * nam /*****************************************************************/ /** - This function returns the lgr_nr field of the grid; for GRID files, this + This function returns the lgr_nr field of the grid; for GRID files, this is just the occurence number in the grid file. Starting with 0 at the main grid, and then increasing consecutively through the lgr sections. - For EGRID files, this is the LGR number (fourth element in the + For EGRID files, this is the LGR number (fourth element in the gridhead). */ -int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid ) { - return ecl_grid->lgr_nr; +int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid ) { + return ecl_grid->lgr_nr; } const char * ecl_grid_get_name( const ecl_grid_type * ecl_grid ) { @@ -4545,7 +4631,7 @@ void ecl_grid_summarize(const ecl_grid_type * ecl_grid) { printf(" Volume ................: %d \n",nx*ny*nz); printf(" Origo X................: %10.2f \n",ecl_grid->origo[0]); printf(" Origo Y................: %10.2f \n",ecl_grid->origo[1]); - + if (ECL_GRID_MAINGRID_LGR_NR == ecl_grid->lgr_nr) { int grid_nr; for (grid_nr=1; grid_nr < vector_get_size( ecl_grid->LGR_list ); grid_nr++) { @@ -4558,7 +4644,7 @@ void ecl_grid_summarize(const ecl_grid_type * ecl_grid) { /*****************************************************************/ /** - + This function is used to translate (with the help of the ecl_grid functionality) i,j,k to an index which can be used to look up an element in the ecl_kw instance. It is just a minor convenience @@ -4593,12 +4679,12 @@ static int ecl_grid_get_property_index__(const ecl_grid_type * ecl_grid , const int kw_size = ecl_kw_get_size( ecl_kw ); int lookup_index = -1; - if (kw_size == ecl_grid->nx * ecl_grid->ny * ecl_grid->nz) + if (kw_size == ecl_grid->nx * ecl_grid->ny * ecl_grid->nz) lookup_index = ecl_grid_get_global_index3(ecl_grid , i , j , k); - else if (kw_size == ecl_grid->total_active) - /* Will be set to -1 if the cell is not active. */ + else if (kw_size == ecl_grid->total_active) + /* Will be set to -1 if the cell is not active. */ lookup_index = ecl_grid_get_active_index3(ecl_grid , i , j , k); - else + else util_abort("%s: incommensurable size ... \n",__func__); return lookup_index; @@ -4614,9 +4700,9 @@ static bool ecl_grid_get_property__(const ecl_grid_type * ecl_grid , const ecl_k if (lookup_index >= 0) { ecl_kw_iget( ecl_kw , lookup_index , value ); return true; - } else + } else return false; - + } else { util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_util_get_type_name( ecl_type ) , __func__); return false; @@ -4660,12 +4746,12 @@ float ecl_grid_get_float_property(const ecl_grid_type * ecl_grid , const ecl_kw_ ecl_type_enum ecl_type = ecl_kw_get_type( ecl_kw ); if (ecl_type == ECL_FLOAT_TYPE) { float value; - + if (ecl_grid_get_property__( ecl_grid , ecl_kw , i , j , k , &value)) return value; else return -1; // (i,j,k) Points to an inactive cell. - + } else { util_abort("%s: Wrong type \n" , __func__); return -1; @@ -4676,7 +4762,7 @@ double ecl_grid_get_property(const ecl_grid_type * ecl_grid , const ecl_kw_type ecl_type_enum ecl_type = ecl_kw_get_type( ecl_kw ); if ((ecl_type == ECL_FLOAT_TYPE) || (ecl_type == ECL_INT_TYPE) || (ecl_type == ECL_DOUBLE_TYPE)) { int lookup_index = ecl_grid_get_property_index__( ecl_grid , ecl_kw , i , j , k ); - + if (lookup_index >= 0) return ecl_kw_iget_as_double( ecl_kw , lookup_index ); else @@ -4712,11 +4798,11 @@ void ecl_grid_get_column_property(const ecl_grid_type * ecl_grid , const ecl_kw_ int kw_size = ecl_kw_get_size( ecl_kw ); bool use_global_index = false; - if (kw_size == ecl_grid->nx * ecl_grid->ny * ecl_grid->nz) + if (kw_size == ecl_grid->nx * ecl_grid->ny * ecl_grid->nz) use_global_index = true; - else if (kw_size == ecl_grid->total_active) + else if (kw_size == ecl_grid->total_active) use_global_index = false; - else + else util_abort("%s: incommensurable sizes: nx*ny*nz = %d nactive=%d kw_size:%d \n",__func__ , ecl_grid->size , ecl_grid->total_active , ecl_kw_get_size( ecl_kw )); double_vector_reset( column ); @@ -4733,7 +4819,7 @@ void ecl_grid_get_column_property(const ecl_grid_type * ecl_grid , const ecl_kw_ } } } - } else + } else util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_util_get_type_name( ecl_type ) , __func__); } @@ -4774,7 +4860,7 @@ int ecl_grid_get_region_cells(const ecl_grid_type * ecl_grid , const ecl_kw_type if (ecl_kw_get_type( region_kw ) == ECL_INT_TYPE) { const int * region_ptr = ecl_kw_iget_ptr( region_kw , 0); int_vector_reset( index_list ); - + { int global_index; @@ -4815,7 +4901,7 @@ void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_t int int_default; int bool_default; ecl_type_enum ecl_type = ecl_kw_get_type( ecl_kw ); - + if (ecl_type == ECL_FLOAT_TYPE) { float_default = (float) double_default; default_ptr = &float_default; @@ -4834,16 +4920,16 @@ void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_t util_abort("%s: only 0 and 1 are allowed for bool interpolation\n",__func__); default_ptr = &bool_default; } - - if (default_ptr == NULL) + + if (default_ptr == NULL) util_abort("%s: invalid type \n",__func__); - + { ecl_kw_type * tmp_kw = ecl_kw_alloc_scatter_copy( ecl_kw , ecl_grid->size , ecl_grid->inv_index_map , default_ptr ); ecl_kw_fprintf_grdecl__( tmp_kw , special_header , stream ); ecl_kw_free( tmp_kw ); } - } else + } else util_abort("%s: size mismatch. ecl_kw must have either nx*ny*ny elements or nactive elements\n",__func__); } @@ -4881,7 +4967,7 @@ bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ) { consistent &= ecl_grid_test_lgr_consistency2( ecl_grid , lgr ); consistent &= ecl_grid_test_lgr_consistency( lgr ); } - hash_iter_free( lgr_iter ); + hash_iter_free( lgr_iter ); return consistent; } @@ -4896,7 +4982,7 @@ static void ecl_grid_dump__(const ecl_grid_type * grid , FILE * stream) { util_fwrite_int( grid->total_active , stream ); util_fwrite_int_vector( grid->index_map , grid->size , stream , __func__ ); util_fwrite_int_vector( grid->inv_index_map , grid->total_active , stream , __func__ ); - + { int i; for (i=0; i < grid->size; i++) { @@ -4915,7 +5001,7 @@ static void ecl_grid_dump_ascii__(ecl_grid_type * grid , bool active_only , FILE fprintf(stream , "nz : %6d\n",grid->nz); fprintf(stream , "nactive : %6d\n",grid->total_active); fprintf(stream , "nactive fracture : %6d\n",grid->total_active_fracture); - + { int l; for (l=0; l < grid->size; l++) { @@ -4935,25 +5021,25 @@ static void ecl_grid_dump_ascii__(ecl_grid_type * grid , bool active_only , FILE representation. The purpose of these dumps is to be able to test the internal representation of the grid. No metadata is dumped, and apart from byte-by-byte comparisons, the dump files are *not* meant - to be read. + to be read. */ void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream) { - ecl_grid_dump__(grid, stream ); + ecl_grid_dump__(grid, stream ); { int i; - for (i = 0; i < vector_get_size( grid->LGR_list ); i++) - ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream ); + for (i = 0; i < vector_get_size( grid->LGR_list ); i++) + ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream ); } } void ecl_grid_dump_ascii(ecl_grid_type * grid , bool active_only , FILE * stream) { - ecl_grid_dump_ascii__( grid , active_only , stream ); + ecl_grid_dump_ascii__( grid , active_only , stream ); { int i; - for (i = 0; i < vector_get_size( grid->LGR_list ); i++) - ecl_grid_dump_ascii__( vector_iget( grid->LGR_list , i) , active_only , stream ); + for (i = 0; i < vector_get_size( grid->LGR_list ); i++) + ecl_grid_dump_ascii__( vector_iget( grid->LGR_list , i) , active_only , stream ); } } @@ -5064,7 +5150,7 @@ static void ecl_grid_fwrite_gridunits( fortio_type * fortio) { static void ecl_grid_fwrite_main_GRID_headers( const ecl_grid_type * ecl_grid , fortio_type * fortio ) { ecl_grid_fwrite_mapunits( fortio ); - if (ecl_grid->use_mapaxes) + if (ecl_grid->use_mapaxes) ecl_grid_fwrite_mapaxes( ecl_grid->mapaxes , fortio ); ecl_grid_fwrite_gridunits( fortio ); } @@ -5091,9 +5177,9 @@ static void ecl_grid_fwrite_GRID__( const ecl_grid_type * grid , int coords_size ecl_kw_free( dimens_kw ); } - if (grid->parent_grid == NULL) + if (grid->parent_grid == NULL) ecl_grid_fwrite_main_GRID_headers( grid , fortio ); - + { ecl_kw_type * radial_kw = ecl_kw_alloc( RADIAL_KW , 1 , ECL_CHAR_TYPE); ecl_kw_iset_string8( radial_kw , 0 , "FALSE" ); @@ -5110,7 +5196,7 @@ static void ecl_grid_fwrite_GRID__( const ecl_grid_type * grid , int coords_size for (i=0; i < grid->nx; i++) { int global_index = ecl_grid_get_global_index__(grid , i , j , k ); const ecl_cell_type * cell = ecl_grid_get_cell( grid , global_index ); - + ecl_cell_fwrite_GRID( grid , cell , false , coords_size , i,j,k,global_index,coords_kw , corners_kw , fortio ); } } @@ -5122,7 +5208,7 @@ static void ecl_grid_fwrite_GRID__( const ecl_grid_type * grid , int coords_size for (i=0; i < grid->nx; i++) { int global_index = ecl_grid_get_global_index__(grid , i , j , k - grid->nz ); const ecl_cell_type * cell = ecl_grid_get_cell( grid , global_index ); - + ecl_cell_fwrite_GRID( grid , cell , true , coords_size , i,j,k,global_index , coords_kw , corners_kw , fortio ); } } @@ -5132,21 +5218,21 @@ static void ecl_grid_fwrite_GRID__( const ecl_grid_type * grid , int coords_size } -void ecl_grid_fwrite_GRID( const ecl_grid_type * grid , const char * filename) { +void ecl_grid_fwrite_GRID( const ecl_grid_type * grid , const char * filename) { int coords_size = 5; bool fmt_file = false; fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP ); if (hash_get_size( grid->children ) > 0) coords_size = 7; - + if (grid->coarsening_active) coords_size = 7; - + ecl_grid_fwrite_GRID__( grid , coords_size , fortio ); - + { - int grid_nr; + int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { const ecl_grid_type * igrid = vector_iget_const( grid->LGR_list , grid_nr ); ecl_grid_fwrite_GRID__( igrid , coords_size , fortio ); @@ -5173,14 +5259,14 @@ ENDGRID 0:INTE /** This function does by construction not take a grid instance as argument, so that it can be called from an external scope to create - a standard EGRID header without creating a grid instance first. + a standard EGRID header without creating a grid instance first. */ static void ecl_grid_fwrite_main_EGRID_header( const float * mapaxes, int dualp_flag , fortio_type * fortio ) { int EGRID_VERSION = 3; int RELEASE_YEAR = 2007; int COMPAT_VERSION = 0; - + { ecl_kw_type * filehead_kw = ecl_kw_alloc( FILEHEAD_KW , 100 , ECL_INT_TYPE ); ecl_kw_scalar_set_int( filehead_kw , 0 ); @@ -5197,7 +5283,7 @@ static void ecl_grid_fwrite_main_EGRID_header( const float * mapaxes, int dualp_ } ecl_grid_fwrite_mapunits( fortio ); - if (mapaxes != NULL) + if (mapaxes != NULL) ecl_grid_fwrite_mapaxes( mapaxes , fortio ); ecl_grid_fwrite_gridunits( fortio ); @@ -5228,7 +5314,7 @@ void ecl_grid_fwrite_EGRID_header( int dims[3] , const float mapaxes[6], fortio_ /* Will scan the halfopen k-interval [k1,k2) to find a cell which has - valid geometry. If no cell is found the function will return -1. + valid geometry. If no cell is found the function will return -1. */ static int ecl_grid_get_valid_index( const ecl_grid_type * grid , int i , int j , int k1 , int k2) { @@ -5239,7 +5325,7 @@ static int ecl_grid_get_valid_index( const ecl_grid_type * grid , int i , int j while (true) { ecl_cell_type * cell; global_index = ecl_grid_get_global_index3( grid , i , j , k ); - + cell = ecl_grid_get_cell( grid , global_index ); if (GET_CELL_FLAG(cell , CELL_FLAG_VALID)) return global_index; @@ -5249,7 +5335,7 @@ static int ecl_grid_get_valid_index( const ecl_grid_type * grid , int i , int j return -1; } } - + } @@ -5264,20 +5350,20 @@ static int ecl_grid_get_top_valid_index( const ecl_grid_type * grid , int i , in static bool ecl_grid_init_coord_section__( const ecl_grid_type * grid , int i, int j , int i_corner, int j_corner , bool force_set , float * coord_float , double * coord_double ) { - + const int top_index = ecl_grid_get_top_valid_index( grid , i , j ); const int bottom_index = ecl_grid_get_bottom_valid_index( grid , i , j ); - - if (top_index == -1) + + if (top_index == -1) util_exit("% : no cell with a valid geometry description found in (i,j) = %d,%d - then what? \n",__func__ , i,j); - + { point_type top_point; point_type bottom_point; - + const ecl_cell_type * bottom_cell = ecl_grid_get_cell( grid , bottom_index ); const ecl_cell_type * top_cell = ecl_grid_get_cell( grid , top_index); - + /* 2---3 | | @@ -5288,14 +5374,14 @@ static bool ecl_grid_init_coord_section__( const ecl_grid_type * grid , int i, i { point_copy_values( &top_point , &top_cell->corner_list[corner_index]); point_copy_values( &bottom_point , &bottom_cell->corner_list[ corner_index + 4]); - - + + if ((top_point.z == bottom_point.z) && (force_set == false)) { return false; } else { point_mapaxes_invtransform( &top_point , grid->origo , grid->unit_x , grid->unit_y ); point_mapaxes_invtransform( &bottom_point , grid->origo , grid->unit_x , grid->unit_y ); - + if (coord_float) { coord_float[coord_offset] = top_point.x; @@ -5311,13 +5397,13 @@ static bool ecl_grid_init_coord_section__( const ecl_grid_type * grid , int i, i coord_double[coord_offset] = top_point.x; coord_double[coord_offset + 1] = top_point.y; coord_double[coord_offset + 2] = top_point.z; - + coord_double[coord_offset + 3] = bottom_point.x; coord_double[coord_offset + 4] = bottom_point.y; coord_double[coord_offset + 5] = bottom_point.z; } - + return true; } } @@ -5354,9 +5440,9 @@ void ecl_grid_init_coord_data( const ecl_grid_type * grid , float * coord ) { */ int i,j; for (j=0; j <= grid->ny; j++) { - for (i=0; i <= grid->nx; i++) + for (i=0; i <= grid->nx; i++) ecl_grid_init_coord_section( grid , i , j , coord , NULL); - + } } @@ -5370,9 +5456,9 @@ void ecl_grid_init_coord_data_double( const ecl_grid_type * grid , double * coor */ int i,j; for (j=0; j <= grid->ny; j++) { - for (i=0; i <= grid->nx; i++) + for (i=0; i <= grid->nx; i++) ecl_grid_init_coord_section( grid , i , j , NULL , coord); - + } } @@ -5428,7 +5514,7 @@ static void ecl_grid_init_zcorn_data__( const ecl_grid_type * grid , float * zco zcorn_float[z3] = p2.z; zcorn_float[z4] = p3.z; } - + if (zcorn_double) { zcorn_double[z1] = p0.z; zcorn_double[z2] = p1.z; @@ -5481,19 +5567,19 @@ void ecl_grid_init_actnum_data( const ecl_grid_type * grid , int * actnum ) { /* In the case of coarse cells we must query the coarse cell for the original, uncoarsened distribution of actnum values. */ ecl_coarse_cell_type * coarse_cell = ecl_grid_iget_coarse_group( grid , cell->coarse_group ); - + /* 1: Set all the elements in the coarse group to inactive. */ { int group_size = ecl_coarse_cell_get_size( coarse_cell ); const int * index_ptr = ecl_coarse_cell_get_index_ptr( coarse_cell ); int j; - for (j=0; j < group_size; j++) - actnum[index_ptr[j]] = CELL_NOT_ACTIVE; + for (j=0; j < group_size; j++) + actnum[index_ptr[j]] = CELL_NOT_ACTIVE; } - + /* 2: Explicitly pick up the active cells from the coarse group and mark them correctly. */ - { + { int num_active = ecl_coarse_cell_get_num_active( coarse_cell ); int j; @@ -5523,6 +5609,37 @@ ecl_kw_type * ecl_grid_alloc_actnum_kw( const ecl_grid_type * grid ) { return actnum_kw; } + +void ecl_grid_compressed_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw) { + if ((ecl_kw_get_size( target_kw ) == ecl_grid_get_nactive(grid)) && (ecl_kw_get_size( src_kw ) == ecl_grid_get_global_size(grid))) { + int active_index = 0; + int global_index; + for (global_index = 0; global_index < ecl_grid_get_global_size( grid ); global_index++) { + if (ecl_grid_cell_active1(grid, global_index)) { + ecl_kw_iset( target_kw , active_index , ecl_kw_iget_ptr(src_kw , global_index)); + active_index++; + } + } + } else + util_abort("%s: size mismatch target:%d src:%d expected %d,%d \n",ecl_kw_get_size( target_kw ), ecl_kw_get_size( src_kw ) , ecl_grid_get_nactive(grid) , ecl_grid_get_global_size(grid)); +} + + +void ecl_grid_global_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw) { + if ((ecl_kw_get_size( src_kw ) == ecl_grid_get_nactive(grid)) && (ecl_kw_get_size( target_kw ) == ecl_grid_get_global_size(grid))) { + int active_index = 0; + int global_index; + for (global_index = 0; global_index < ecl_grid_get_global_size( grid ); global_index++) { + if (ecl_grid_cell_active1(grid, global_index)) { + ecl_kw_iset( target_kw , global_index , ecl_kw_iget_ptr(src_kw , active_index)); + active_index++; + } + } + } else + util_abort("%s: size mismatch target:%d src:%d expected %d,%d \n",ecl_kw_get_size( target_kw ), ecl_kw_get_size( src_kw ) , ecl_grid_get_global_size(grid), ecl_grid_get_nactive(grid)); +} + + /*****************************************************************/ static void ecl_grid_init_hostnum_data( const ecl_grid_type * grid , int * hostnum ) { @@ -5601,9 +5718,10 @@ void ecl_grid_reset_actnum( ecl_grid_type * grid , const int * actnum ) { } -static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio) { + +static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio, bool metric_output) { bool is_lgr = true; - if (grid->parent_grid == NULL) + if (grid->parent_grid == NULL) is_lgr = false; /* Writing header */ @@ -5623,22 +5741,47 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio ecl_kw_iset_string8( lgr_parent_kw , 0 , grid->parent_name ); else ecl_kw_iset_string8( lgr_parent_kw , 0 , ""); - + ecl_kw_fwrite( lgr_parent_kw , fortio ); ecl_kw_free( lgr_parent_kw ); } } - + ecl_grid_fwrite_gridhead_kw( grid->nx , grid->ny , grid->nz , grid->lgr_nr , fortio); /* Writing main grid data */ { { ecl_grid_assert_coord_kw( grid ); - ecl_kw_fwrite( grid->coord_kw , fortio ); + if(metric_output != grid->is_metric){ + ecl_kw_type * coord_kw = ecl_kw_alloc_copy(grid->coord_kw); + double scale_factor = 0.0; + if (grid->is_metric){ + scale_factor = METER_TO_FEET_SCALE_FACTOR; + } else{ + scale_factor = (1 / METER_TO_FEET_SCALE_FACTOR); + } + ecl_kw_scale_float(coord_kw, scale_factor); + ecl_kw_fwrite(coord_kw, fortio); + ecl_kw_free(coord_kw); + }else{ + ecl_kw_fwrite( grid->coord_kw , fortio ); + } } { ecl_kw_type * zcorn_kw = ecl_grid_alloc_zcorn_kw( grid ); + if(metric_output != grid->is_metric){ + double scale_factor = 0.0; + if (grid->is_metric){ + scale_factor = METER_TO_FEET_SCALE_FACTOR; + } else{ + scale_factor = (1 / METER_TO_FEET_SCALE_FACTOR); + } + ecl_kw_scale_float(zcorn_kw, scale_factor); + } ecl_kw_fwrite( zcorn_kw , fortio ); + + + ecl_kw_free( zcorn_kw ); } { @@ -5656,14 +5799,14 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio ecl_kw_fwrite( corsnum_kw , fortio ); ecl_kw_free( corsnum_kw ); } - + { ecl_kw_type * endgrid_kw = ecl_kw_alloc( ENDGRID_KW , 0 , ECL_INT_TYPE ); ecl_kw_fwrite( endgrid_kw , fortio ); ecl_kw_free( endgrid_kw ); } } - + if (is_lgr) { ecl_kw_type * endlgr_kw = ecl_kw_alloc( ENDLGR_KW , 0 , ECL_INT_TYPE ); ecl_kw_fwrite( endlgr_kw , fortio ); @@ -5672,16 +5815,16 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio } -void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename) { +void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename, bool output_metric) { bool fmt_file = false; fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP ); - - ecl_grid_fwrite_EGRID__( grid , fortio ); + + ecl_grid_fwrite_EGRID__( grid , fortio, output_metric ); { - int grid_nr; + int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { ecl_grid_type * igrid = vector_iget( grid->LGR_list , grid_nr ); - ecl_grid_fwrite_EGRID__( igrid , fortio ); + ecl_grid_fwrite_EGRID__( igrid , fortio, output_metric ); } } fortio_fclose( fortio ); @@ -5701,7 +5844,7 @@ void ecl_grid_fprintf_grdecl(ecl_grid_type * grid , FILE * stream ) { ecl_kw_free( mapunits_kw ); fprintf(stream , "\n"); } - + if (grid->use_mapaxes) { ecl_kw_type * mapaxes_kw = ecl_grid_alloc_mapaxes_kw( grid->mapaxes ); ecl_kw_fprintf_grdecl( mapaxes_kw , stream ); @@ -5714,8 +5857,8 @@ void ecl_grid_fprintf_grdecl(ecl_grid_type * grid , FILE * stream ) { ecl_kw_free( gridunits_kw ); fprintf(stream , "\n"); } - - /* + + /* The specgrid header is not properly internalized; the fourth and fifth elements are just set to hardcoded values. */ @@ -5725,7 +5868,7 @@ void ecl_grid_fprintf_grdecl(ecl_grid_type * grid , FILE * stream ) { fprintf(stream , "%s\n" , SPECGRID_KW); fprintf(stream , " %d %d %d %d %c / \n\n",grid->nx , grid->ny , grid->nz , numres , coord_type); } - + { ecl_grid_assert_coord_kw( grid ); ecl_kw_fprintf_grdecl( grid->coord_kw , stream ); @@ -5745,7 +5888,7 @@ void ecl_grid_fprintf_grdecl(ecl_grid_type * grid , FILE * stream ) { ecl_kw_free( actnum_kw ); fprintf(stream , "\n"); } -} +} /*****************************************************************/ @@ -5753,7 +5896,7 @@ void ecl_grid_fprintf_grdecl(ecl_grid_type * grid , FILE * stream ) { /** The ri_points pointer should point to the base address of the points data; this function will calculate the correct offset based on - global_index. + global_index. */ void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points) { @@ -5765,7 +5908,7 @@ void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index void ecl_grid_ri_export( const ecl_grid_type * ecl_grid , double * ri_points) { int global_index; - for (global_index = 0; global_index < ecl_grid->size; global_index++) + for (global_index = 0; global_index < ecl_grid->size; global_index++) ecl_grid_cell_ri_export( ecl_grid , global_index , ri_points ); } @@ -5784,7 +5927,7 @@ static int ecl_grid_get_num_nnc__( const ecl_grid_type * grid ) { int num_nnc = 0; for (g = 0; g < grid->size; g++) { const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( grid , g ); - if (nnc_info) + if (nnc_info) num_nnc += nnc_info_get_total_size( nnc_info ); } return num_nnc; @@ -5795,7 +5938,7 @@ static int ecl_grid_get_num_nnc__( const ecl_grid_type * grid ) { int ecl_grid_get_num_nnc( const ecl_grid_type * grid ) { int num_nnc = ecl_grid_get_num_nnc__( grid ); { - int grid_nr; + int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { ecl_grid_type * igrid = vector_iget( grid->LGR_list , grid_nr ); num_nnc += ecl_grid_get_num_nnc__( igrid ); diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_kw.c b/ThirdParty/Ert/devel/libecl/src/ecl_kw.c index 80073779d4..449868ba20 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_kw.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_kw.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_kw.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_kw.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -24,6 +24,7 @@ #include <ert/util/util.h> #include <ert/util/buffer.h> +#include <ert/util/int_vector.h> #include <ert/ecl/ecl_kw.h> #include <ert/ecl/ecl_util.h> @@ -33,13 +34,17 @@ #define ECL_KW_TYPE_ID 6111098 + + + + struct ecl_kw_struct { UTIL_TYPE_ID_DECLARATION; int size; int sizeof_ctype; ecl_type_enum ecl_type; - char * header8; /* Header which is right padded with ' ' to become exactly 8 characters long. Should only be used internally.*/ - char * header; /* Header which is trimmed to no-space. */ + char * header8; /* Header which is right padded with ' ' to become exactly 8 characters long. Should only be used internally.*/ + char * header; /* Header which is trimmed to no-space. */ char * data; /* The actual data vector. */ bool shared_data; /* Whether this keyword has shared data or not. */ }; @@ -66,9 +71,9 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID ) certain number of elements in each row, i.e. four columns for float data: - 0.000 0.000 0.000 0.000 - 0.000 0.000 0.000 0.000 - 0.000 0.000 0.000 0.000 + 0.000 0.000 0.000 0.000 + 0.000 0.000 0.000 0.000 + 0.000 0.000 0.000 0.000 .... These #define symbols define the number of columns for the @@ -84,7 +89,7 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID ) /*****************************************************************/ /* Format string used when writing a formatted header. */ -#define WRITE_HEADER_FMT " '%-8s' %11d '%-4s'\n" +#define WRITE_HEADER_FMT " '%-8s' %11d '%-4s'\n" @@ -112,7 +117,7 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID ) #define READ_FMT_INT "%d" #define READ_FMT_MESS "%8c" #define READ_FMT_BOOL " %c" -#define READ_FMT_DOUBLE "%lgD%d" +#define READ_FMT_DOUBLE "%lgD%d" #define WRITE_FMT_CHAR " '%-8s'" @@ -135,7 +140,7 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID ) o In the unformatted ECLIPSE files the boolean values are represented as integers with the values ECL_BOOL_TRUE_INT and ECL_BOOL_FALSE_INT respectively. - + Internally in an ecl_kw instance boolean values are represented as integers (NOT bool), with the representation given by ECL_BOOL_TRUE_INT and ECL_BOOL_FALSE_INT. This implies that read/write of unformatted @@ -147,7 +152,7 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID ) // For formatted files: -#define BOOL_TRUE_CHAR 'T' +#define BOOL_TRUE_CHAR 'T' #define BOOL_FALSE_CHAR 'F' @@ -205,7 +210,6 @@ const char * ecl_kw_get_write_fmt( ecl_type_enum ecl_type ) { } } - static int get_blocksize( ecl_type_enum ecl_type ) { if (ecl_type == ECL_CHAR_TYPE) return BLOCKSIZE_CHAR; @@ -247,24 +251,24 @@ static int get_columns( ecl_type_enum ecl_type ) { /******************************************************************/ static void ecl_kw_assert_index(const ecl_kw_type *ecl_kw , int index, const char *caller) { - if (index < 0 || index >= ecl_kw->size) + if (index < 0 || index >= ecl_kw->size) util_abort("%s: Invalid index lookup. kw:%s input_index:%d size:%d \n",caller , ecl_kw->header , index , ecl_kw->size); } static void ecl_kw_endian_convert_data(ecl_kw_type *ecl_kw) { - if (ecl_kw->ecl_type != ECL_CHAR_TYPE && ecl_kw->ecl_type != ECL_MESS_TYPE) + if (ecl_kw->ecl_type != ECL_CHAR_TYPE && ecl_kw->ecl_type != ECL_MESS_TYPE) util_endian_flip_vector(ecl_kw->data , ecl_kw->sizeof_ctype , ecl_kw->size); } -const char * ecl_kw_get_header8(const ecl_kw_type *ecl_kw) { - return ecl_kw->header8; +const char * ecl_kw_get_header8(const ecl_kw_type *ecl_kw) { + return ecl_kw->header8; } /* - Return the header without the trailing spaces + Return the header without the trailing spaces */ const char * ecl_kw_get_header(const ecl_kw_type * ecl_kw ) { return ecl_kw->header; @@ -311,9 +315,9 @@ static bool ecl_kw_string_eq(const char *s1 , const char *s2) { const int len2 = strlen(short_kw); int index; bool eq = true; - if (len1 > ECL_STRING_LENGTH) + if (len1 > ECL_STRING_LENGTH) util_abort("%s : eclipse keyword:%s is too long - aborting \n",__func__ , long_kw); - + for (index = 0; index < len2; index++) eq = eq & (long_kw[index] == short_kw[index]); @@ -336,12 +340,12 @@ bool ecl_kw_ichar_eq(const ecl_kw_type *ecl_kw , int i , const char *value) { static bool ecl_kw_size_and_type_equal( const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2 ) { bool equal = true; - - if (ecl_kw1->size != ecl_kw2->size) + + if (ecl_kw1->size != ecl_kw2->size) equal = false; - else if (ecl_kw1->ecl_type != ecl_kw2->ecl_type) + else if (ecl_kw1->ecl_type != ecl_kw2->ecl_type) equal = false; - + return equal; } @@ -349,7 +353,7 @@ static bool ecl_kw_size_and_type_equal( const ecl_kw_type *ecl_kw1 , const ecl_k bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2) { bool equal = true; - if (strcmp(ecl_kw1->header8 , ecl_kw2->header8) != 0) + if (strcmp(ecl_kw1->header8 , ecl_kw2->header8) != 0) equal = false; else equal = ecl_kw_size_and_type_equal( ecl_kw1 , ecl_kw2 ); @@ -368,7 +372,7 @@ static bool ecl_kw_data_equal__( const ecl_kw_type * ecl_kw , const void * data /** Observe that the comparison is done with memcmp() - - i.e. "reasonably good" numerical agreement is *not* enough. + i.e. "reasonably good" numerical agreement is *not* enough. */ bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data) { @@ -395,27 +399,28 @@ bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2) { bool equal = ecl_kw_header_eq( ecl_kw1 , ecl_kw2 ); if (equal) equal = ecl_kw_data_equal( ecl_kw1 , ecl_kw2->data ); - + return equal; } -#define CMP(ctype) \ +#define CMP(ctype,ABS) \ static bool CMP_ ## ctype( ctype v1, ctype v2 , ctype epsilon) { \ - if ((abs(v1) + abs(v2)) == 0) \ + if ((ABS(v1) + ABS(v2)) == 0) \ return true; \ else { \ - ctype d = fabs(v1 - v2) / (fabs(v1) + fabs(v2)); \ + ctype d = ABS(v1 - v2) / (ABS(v1) + ABS(v2)); \ if (d < epsilon) \ return true; \ else \ return false; \ } \ -} -CMP(float) -CMP(double) +} +CMP(float,fabsf) +CMP(double,fabs) #undef CMP + #define ECL_KW_NUMERIC_CMP(ctype) \ static bool ecl_kw_numeric_equal_ ## ctype( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , ctype rel_diff) { \ int index; \ @@ -440,17 +445,17 @@ ECL_KW_NUMERIC_CMP( double ) /** This function compares the data of two ecl_kw instances, and returns true if the relative numerical difference is less than - @rel_diff. Does not consider consider the kw header. + @rel_diff. Does not consider consider the kw header. */ bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , double rel_diff) { bool equal = true; if ( ecl_kw1->ecl_type != ecl_kw2->ecl_type) equal = false; - + if ( ecl_kw1->size != ecl_kw2->size) equal = false; - + if (equal) { if (ecl_kw1->ecl_type == ECL_FLOAT_TYPE) equal = ecl_kw_numeric_equal_float( ecl_kw1 , ecl_kw2 , rel_diff ); @@ -468,7 +473,7 @@ bool ecl_kw_block_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_k if (ecl_kw_header_eq( ecl_kw1 , ecl_kw2)) { if (cmp_elements == 0) cmp_elements = ecl_kw1->size; - + return ecl_kw_data_equal__( ecl_kw1 , ecl_kw2->data , cmp_elements ); } else return false; @@ -478,7 +483,7 @@ bool ecl_kw_block_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_k static void ecl_kw_set_shared_ref(ecl_kw_type * ecl_kw , void *data_ptr) { if (!ecl_kw->shared_data) { - if (ecl_kw->data != NULL) + if (ecl_kw->data != NULL) util_abort("%s: can not change to shared for keyword with allocated storage - aborting \n",__func__); } ecl_kw->shared_data = true; @@ -490,9 +495,9 @@ static void ecl_kw_set_shared_ref(ecl_kw_type * ecl_kw , void *data_ptr) { static void ecl_kw_initialize(ecl_kw_type * ecl_kw , const char *header , int size , ecl_type_enum ecl_type) { ecl_kw->ecl_type = ecl_type; ecl_kw->sizeof_ctype = ecl_util_get_sizeof_ctype(ecl_kw->ecl_type); - if (strlen(header) > ECL_STRING_LENGTH) + if (strlen(header) > ECL_STRING_LENGTH) util_abort("%s: Fatal error: ecl_header_name:%s is longer than eight characters - aborting \n",__func__,header); - + ecl_kw_set_header_name(ecl_kw , header); ecl_kw->size = size; } @@ -500,7 +505,7 @@ static void ecl_kw_initialize(ecl_kw_type * ecl_kw , const char *header , int s static size_t ecl_kw_fortio_data_size( const ecl_kw_type * ecl_kw) { const int blocksize = get_blocksize( ecl_kw->ecl_type ); const int num_blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); - + return num_blocks * (4 + 4) + // Fortran fluff for each block ecl_kw->size * ecl_util_get_sizeof_ctype_fortio( ecl_kw->ecl_type ); // Actual data } @@ -509,18 +514,19 @@ static size_t ecl_kw_fortio_data_size( const ecl_kw_type * ecl_kw) { /** Returns the number of bytes this ecl_kw instance would occupy in - BINARY file. + BINARY file; we add 2*4 to the header size to include the size of + the fortran header and trailer combo. */ size_t ecl_kw_fortio_size( const ecl_kw_type * ecl_kw ) { - size_t size = ECL_KW_FORTIO_HEADER_SIZE; + size_t size = ECL_KW_HEADER_FORTIO_SIZE; size += ecl_kw_fortio_data_size(ecl_kw ); return size; } /** - The data is copied from the input argument to the ecl_kw; data can be NULL. + The data is copied from the input argument to the ecl_kw; data can be NULL. */ ecl_kw_type * ecl_kw_alloc_new(const char * header , int size, ecl_type_enum ecl_type , const void * data) { ecl_kw_type *ecl_kw; @@ -557,7 +563,7 @@ ecl_kw_type * ecl_kw_alloc_new_shared(const char * header , int size, ecl_type_ ecl_kw_type * ecl_kw_alloc_empty() { ecl_kw_type *ecl_kw; - + ecl_kw = util_malloc(sizeof *ecl_kw ); ecl_kw->header = NULL; ecl_kw->header8 = NULL; @@ -567,7 +573,7 @@ ecl_kw_type * ecl_kw_alloc_empty() { ecl_kw->sizeof_ctype = 0; UTIL_TYPE_ID_INIT(ecl_kw , ECL_KW_TYPE_ID); - + return ecl_kw; } @@ -588,7 +594,7 @@ void ecl_kw_free__(void *void_ecl_kw) { void ecl_kw_memcpy_data( ecl_kw_type * target , const ecl_kw_type * src) { if (!ecl_kw_assert_binary( target , src )) util_abort("%s: type/size mismatch \n",__func__); - + memcpy(target->data , src->data , target->size * target->sizeof_ctype); } @@ -616,7 +622,7 @@ ecl_kw_type *ecl_kw_alloc_copy(const ecl_kw_type *src) { /** This function will allocate a new copy of @src, where only the elements corresponding to the slice [index1:index2) is included. - + The input parameters @index1 and @index2 can to some extent be out-of-range: @@ -624,10 +630,10 @@ ecl_kw_type *ecl_kw_alloc_copy(const ecl_kw_type *src) { index2 = min( index2 , size ); If index1 > index2 it will fail hard; the same applies if stride is - <= 0. + <= 0. */ - + ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int index2, int stride) { if (index1 < 0) index1 = 0; @@ -648,7 +654,7 @@ ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int new_kw = ecl_kw_alloc_empty(); ecl_kw_initialize(new_kw , src->header , new_size , src->ecl_type); ecl_kw_alloc_data(new_kw); - + /* 2: Copy over the elements. */ src_index = index1; { @@ -656,7 +662,7 @@ ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int const char * src_ptr = src->data; char * new_ptr = new_kw->data; int sizeof_ctype = new_kw->sizeof_ctype; - + while ( src_index < index2 ) { memcpy( &new_ptr[ target_index * sizeof_ctype ] , &src_ptr[ src_index * sizeof_ctype ] , sizeof_ctype ); src_index += stride; @@ -668,10 +674,10 @@ ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int return new_kw; } } - - + + /** Will allocate a copy of the src_kw. Will copy @count elements @@ -691,7 +697,7 @@ ecl_kw_type * ecl_kw_alloc_sub_copy( const ecl_kw_type * src, const char * new_k if ((offset < 0) || (offset >= src->size)) util_abort("%s: invalid offset - limits: [%d,%d) \n",__func__ , 0 , src->size); if ((count + offset) > src->size) util_abort("%s: invalid count value: %d \n",__func__ , count); - + { void * src_data = ecl_kw_iget_ptr( src , offset ); return ecl_kw_alloc_new( new_kw , count , src->ecl_type , src_data ); @@ -701,7 +707,7 @@ ecl_kw_type * ecl_kw_alloc_sub_copy( const ecl_kw_type * src, const char * new_k const void * ecl_kw_copyc__(const void * void_kw) { - return ecl_kw_alloc_copy((const ecl_kw_type *) void_kw); + return ecl_kw_alloc_copy((const ecl_kw_type *) void_kw); } static void * ecl_kw_iget_ptr_static(const ecl_kw_type *ecl_kw , int i) { @@ -711,7 +717,7 @@ static void * ecl_kw_iget_ptr_static(const ecl_kw_type *ecl_kw , int i) { static void ecl_kw_iget_static(const ecl_kw_type *ecl_kw , int i , void *iptr) { - memcpy(iptr , ecl_kw_iget_ptr_static(ecl_kw , i) , ecl_kw->sizeof_ctype); + memcpy(iptr , ecl_kw_iget_ptr_static(ecl_kw , i) , ecl_kw->sizeof_ctype); } @@ -721,17 +727,17 @@ static void ecl_kw_iset_static(ecl_kw_type *ecl_kw , int i , const void *iptr) { } -void ecl_kw_iget(const ecl_kw_type *ecl_kw , int i , void *iptr) { +void ecl_kw_iget(const ecl_kw_type *ecl_kw , int i , void *iptr) { ecl_kw_iget_static(ecl_kw , i , iptr); } /** - Will return a double value for underlying data types of double, + Will return a double value for underlying data types of double, float and int. */ double ecl_kw_iget_as_double(const ecl_kw_type * ecl_kw , int index) { - if (ecl_kw->ecl_type == ECL_FLOAT_TYPE) + if (ecl_kw->ecl_type == ECL_FLOAT_TYPE) return ecl_kw_iget_float( ecl_kw , index); /* Here the compiler will silently insert a float -> double conversion. */ else if (ecl_kw->ecl_type == ECL_DOUBLE_TYPE) return ecl_kw_iget_double( ecl_kw, index); @@ -748,7 +754,7 @@ double ecl_kw_iget_as_double(const ecl_kw_type * ecl_kw , int index) { */ float ecl_kw_iget_as_float(const ecl_kw_type * ecl_kw , int i) { - if (ecl_kw->ecl_type == ECL_FLOAT_TYPE) + if (ecl_kw->ecl_type == ECL_FLOAT_TYPE) return ecl_kw_iget_float( ecl_kw , i); else if (ecl_kw->ecl_type == ECL_DOUBLE_TYPE) return (float) ecl_kw_iget_double( ecl_kw, i); @@ -775,10 +781,10 @@ ECL_KW_IGET_TYPED(int , ECL_INT_TYPE); bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i) { - int int_value; - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - ecl_kw_iget_static(ecl_kw , i , &int_value); + int int_value; + if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) + util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); + ecl_kw_iget_static(ecl_kw , i , &int_value); if (int_value == ECL_BOOL_TRUE_INT) return true; else if (int_value == ECL_BOOL_FALSE_INT) @@ -790,8 +796,8 @@ bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i) { } const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i) { - if (ecl_kw_get_type(ecl_kw) != ECL_CHAR_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); + if (ecl_kw_get_type(ecl_kw) != ECL_CHAR_TYPE) + util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); return ecl_kw_iget_ptr( ecl_kw , i ); } @@ -800,7 +806,7 @@ const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i) { This will set the elemnts of the ecl_kw data storage in index to the value of s8; if s8 is shorter than 8 characters the result will be padded, if s8 is longer than 8 characters the characters from 9 - and out will be ignored. + and out will be ignored. */ void ecl_kw_iset_string8(ecl_kw_type * ecl_kw , int index , const char *s8) { char * ecl_string = (char *) ecl_kw_iget_ptr( ecl_kw , index ); @@ -813,15 +819,15 @@ void ecl_kw_iset_string8(ecl_kw_type * ecl_kw , int index , const char *s8) { /* The string is padded with trailing spaces. */ int string_length = strlen( s8 ); int i; - + for (i=0; i < string_length; i++) ecl_string[i] = s8[i]; - + for (i=string_length; i < ECL_STRING_LENGTH; i++) ecl_string[i] = ' '; - + } - + ecl_string[ ECL_STRING_LENGTH ] = '\0'; } @@ -834,7 +840,7 @@ void ecl_kw_iset_string8(ecl_kw_type * ecl_kw , int index , const char *s8) { You should know what you are doing when sending in a string of length greater than 8 - maybe the overwriting of consecutive - elements is not what you want? + elements is not what you want? */ void ecl_kw_iset_char_ptr( ecl_kw_type * ecl_kw , int index, const char * s) { int strings = strlen( s ) / ECL_STRING_LENGTH; @@ -842,7 +848,7 @@ void ecl_kw_iset_char_ptr( ecl_kw_type * ecl_kw , int index, const char * s) { strings++; { int sub_index; - for (sub_index = 0; sub_index < strings; sub_index++) + for (sub_index = 0; sub_index < strings; sub_index++) ecl_kw_iset_string8( ecl_kw , index + sub_index , &s[ sub_index * ECL_STRING_LENGTH ]); } } @@ -866,7 +872,7 @@ bool ecl_kw_icmp_string( const ecl_kw_type * ecl_kw , int index, const char * ot return false; } - + #define ECL_KW_ISET_TYPED(ctype , ECL_TYPE) \ void ecl_kw_iset_ ## ctype(ecl_kw_type * ecl_kw, int i, ctype value) { \ @@ -943,15 +949,15 @@ ECL_KW_SCALE_INDEXED( int , ECL_INT_TYPE); void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value) { - int int_value; - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); + int int_value; + if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) + util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); if (bool_value) int_value = ECL_BOOL_TRUE_INT; else int_value = ECL_BOOL_FALSE_INT; - + ecl_kw_iset_static(ecl_kw , i , &int_value); } @@ -965,7 +971,7 @@ ctype * ecl_kw_get_ ## ctype ## _ptr(const ecl_kw_type * ecl_kw) { if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); \ return (ctype *) ecl_kw->data; \ -} +} ECL_KW_GET_TYPED_PTR(double , ECL_DOUBLE_TYPE); ECL_KW_GET_TYPED_PTR(float , ECL_FLOAT_TYPE); @@ -979,14 +985,14 @@ void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw) { /*****************************************************************/ -void * ecl_kw_iget_ptr(const ecl_kw_type *ecl_kw , int i) { +void * ecl_kw_iget_ptr(const ecl_kw_type *ecl_kw , int i) { return ecl_kw_iget_ptr_static(ecl_kw , i); } -void ecl_kw_iset(ecl_kw_type *ecl_kw , int i , const void *iptr) { +void ecl_kw_iset(ecl_kw_type *ecl_kw , int i , const void *iptr) { ecl_kw_iset_static(ecl_kw , i , iptr); } @@ -1006,14 +1012,14 @@ static bool ecl_kw_qskip(FILE *stream) { cont = false; OK = false; } else { - if (c == space || c == newline || c == tab) + if (c == space || c == newline || c == tab) cont = true; else if (c == sep) cont = false; } } return OK; -} +} static bool ecl_kw_fscanf_qstring(char *s , const char *fmt , int len, FILE *stream) { @@ -1026,7 +1032,7 @@ static bool ecl_kw_fscanf_qstring(char *s , const char *fmt , int len, FILE *str read_count += fscanf(stream , fmt , s); s[len] = null_char; read_count += fscanf(stream , "%c" , &last_sep); - + if (read_count != 2) util_abort("%s: reading \'xxxxxxxx\' formatted string failed \n",__func__); } @@ -1040,12 +1046,12 @@ static bool ecl_kw_fscanf_qstring(char *s , const char *fmt , int len, FILE *str format : 0.ddddD+01 - difficult to parse the 'D'; */ /** Should be: NESTED */ - + static double __fscanf_ECL_double( FILE * stream , const char * fmt) { int read_count , power; double value , arg; read_count = fscanf( stream , fmt , &arg , &power); - if (read_count == 2) + if (read_count == 2) value = arg * pow(10 , power ); else { util_abort("%s: read failed \n",__func__); @@ -1054,107 +1060,118 @@ static double __fscanf_ECL_double( FILE * stream , const char * fmt) { return value; } -void ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { - { - const char null_char = '\0'; - bool fmt_file = fortio_fmt_file( fortio ); - if (ecl_kw->size > 0) { - const int blocksize = get_blocksize( ecl_kw->ecl_type ); - if (fmt_file) { - const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); - const char * read_fmt = get_read_fmt( ecl_kw->ecl_type ); - FILE * stream = fortio_get_FILE(fortio); - int offset = 0; - int index = 0; - int ib,ir; - for (ib = 0; ib < blocks; ib++) { - int read_elm = util_int_min((ib + 1) * blocksize , ecl_kw->size) - ib * blocksize; - for (ir = 0; ir < read_elm; ir++) { - switch(ecl_kw->ecl_type) { - case(ECL_CHAR_TYPE): - ecl_kw_fscanf_qstring(&ecl_kw->data[offset] , read_fmt , 8, stream); - break; - case(ECL_INT_TYPE): - { - int iread = fscanf(stream , read_fmt , (int *) &ecl_kw->data[offset]); - if (iread != 1) - util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , offset / ecl_kw->sizeof_ctype , ecl_kw->header8 , fortio_filename_ref(fortio)); - } - break; - case(ECL_FLOAT_TYPE): - { - int iread = fscanf(stream , read_fmt , (float *) &ecl_kw->data[offset]); - if (iread != 1) { - util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , - offset / ecl_kw->sizeof_ctype , - ecl_kw->header8 , - fortio_filename_ref(fortio)); - } - } - break; - case(ECL_DOUBLE_TYPE): - { - double value = __fscanf_ECL_double( stream , read_fmt ); - ecl_kw_iset(ecl_kw , index , &value); - } - break; - case(ECL_BOOL_TYPE): - { - char bool_char; - if (fscanf(stream , read_fmt , &bool_char) == 1) { - if (bool_char == BOOL_TRUE_CHAR) - ecl_kw_iset_bool(ecl_kw , index , true); - else if (bool_char == BOOL_FALSE_CHAR) - ecl_kw_iset_bool(ecl_kw , index , false); - else - util_abort("%s: Logical value: [%c] not recogniced - aborting \n", __func__ , bool_char); - } else - util_abort("%s: read failed - premature file end? \n",__func__ ); +bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { + const char null_char = '\0'; + bool fmt_file = fortio_fmt_file( fortio ); + if (ecl_kw->size > 0) { + const int blocksize = get_blocksize( ecl_kw->ecl_type ); + if (fmt_file) { + const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); + const char * read_fmt = get_read_fmt( ecl_kw->ecl_type ); + FILE * stream = fortio_get_FILE(fortio); + int offset = 0; + int index = 0; + int ib,ir; + for (ib = 0; ib < blocks; ib++) { + int read_elm = util_int_min((ib + 1) * blocksize , ecl_kw->size) - ib * blocksize; + for (ir = 0; ir < read_elm; ir++) { + switch(ecl_kw->ecl_type) { + case(ECL_CHAR_TYPE): + ecl_kw_fscanf_qstring(&ecl_kw->data[offset] , read_fmt , 8, stream); + break; + case(ECL_INT_TYPE): + { + int iread = fscanf(stream , read_fmt , (int *) &ecl_kw->data[offset]); + if (iread != 1) + util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , offset / ecl_kw->sizeof_ctype , ecl_kw->header8 , fortio_filename_ref(fortio)); + } + break; + case(ECL_FLOAT_TYPE): + { + int iread = fscanf(stream , read_fmt , (float *) &ecl_kw->data[offset]); + if (iread != 1) { + util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , + offset / ecl_kw->sizeof_ctype , + ecl_kw->header8 , + fortio_filename_ref(fortio)); } - break; - case(ECL_MESS_TYPE): - ecl_kw_fscanf_qstring(&ecl_kw->data[offset] , read_fmt , 8 , stream); - break; - default: - util_abort("%s: Internal error: internal eclipse_type: %d not recognized - aborting \n",__func__ , ecl_kw->ecl_type); } - offset += ecl_kw->sizeof_ctype; - index++; + break; + case(ECL_DOUBLE_TYPE): + { + double value = __fscanf_ECL_double( stream , read_fmt ); + ecl_kw_iset(ecl_kw , index , &value); + } + break; + case(ECL_BOOL_TYPE): + { + char bool_char; + if (fscanf(stream , read_fmt , &bool_char) == 1) { + if (bool_char == BOOL_TRUE_CHAR) + ecl_kw_iset_bool(ecl_kw , index , true); + else if (bool_char == BOOL_FALSE_CHAR) + ecl_kw_iset_bool(ecl_kw , index , false); + else + util_abort("%s: Logical value: [%c] not recogniced - aborting \n", __func__ , bool_char); + } else + util_abort("%s: read failed - premature file end? \n",__func__ ); + } + break; + case(ECL_MESS_TYPE): + ecl_kw_fscanf_qstring(&ecl_kw->data[offset] , read_fmt , 8 , stream); + break; + default: + util_abort("%s: Internal error: internal eclipse_type: %d not recognized - aborting \n",__func__ , ecl_kw->ecl_type); } + offset += ecl_kw->sizeof_ctype; + index++; } - } else { - if (ecl_kw->ecl_type == ECL_CHAR_TYPE || ecl_kw->ecl_type == ECL_MESS_TYPE) { - const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); - int ib; - for (ib = 0; ib < blocks; ib++) { - /* - Due to the necessary terminating \0 characters there is - not a continous file/memory mapping. - */ - int read_elm = util_int_min((ib + 1) * blocksize , ecl_kw->size) - ib * blocksize; - FILE * stream = fortio_get_FILE(fortio); + } + return true; + } else { + bool read_ok = true; + if (ecl_kw->ecl_type == ECL_CHAR_TYPE || ecl_kw->ecl_type == ECL_MESS_TYPE) { + const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); + int ib = 0; + while (true) { + /* + Due to the necessary terminating \0 characters there is + not a continous file/memory mapping. + */ + int read_elm = util_int_min((ib + 1) * blocksize , ecl_kw->size) - ib * blocksize; + FILE * stream = fortio_get_FILE(fortio); + int record_size = fortio_init_read(fortio); + if (record_size >= 0) { int ir; - fortio_init_read(fortio); - for (ir = 0; ir < read_elm; ir++) { util_fread( &ecl_kw->data[(ib * blocksize + ir) * ecl_kw->sizeof_ctype] , 1 , ECL_STRING_LENGTH , stream , __func__); ecl_kw->data[(ib * blocksize + ir) * ecl_kw->sizeof_ctype + ECL_STRING_LENGTH] = null_char; } + read_ok = fortio_complete_read(fortio , record_size); + } else + read_ok = false; - fortio_complete_read(fortio); - } - } else - /** - This function handles the fuc***g blocks transparently at a - low level. - */ - fortio_fread_buffer(fortio , ecl_kw->data , ecl_kw->size * ecl_kw->sizeof_ctype); - - if (ECL_ENDIAN_FLIP) + if (!read_ok) + break; + + ib++; + if (ib == blocks) + break; + } + } else { + /** + This function handles the fuc***g blocks transparently at a + low level. + */ + read_ok = fortio_fread_buffer(fortio , ecl_kw->data , ecl_kw->size * ecl_kw->sizeof_ctype); + if (read_ok && ECL_ENDIAN_FLIP) ecl_kw_endian_convert_data(ecl_kw); } + return read_ok; } - } + } else + /* The keyword has zero size - and reading data is trivially OK. */ + return true; } @@ -1163,12 +1180,12 @@ void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ec FILE *stream = fortio_get_FILE( fortio ); int index; int element_size = ecl_util_get_sizeof_ctype(ecl_type); - + if(ecl_type == ECL_CHAR_TYPE || ecl_type == ECL_MESS_TYPE) { element_size = ECL_STRING_LENGTH; } - - + + for(index = 0; index < int_vector_size(index_map); index++) { int element_index = int_vector_iget(index_map, index); @@ -1185,19 +1202,20 @@ void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ec } /** - Allocates storage and reads data. + Allocates storage and reads data. */ -void ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { +bool ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { ecl_kw_alloc_data(ecl_kw); - ecl_kw_fread_data(ecl_kw , fortio); + return ecl_kw_fread_data(ecl_kw , fortio); } /** Static method without a class instance. */ -void ecl_kw_fskip_data__( ecl_type_enum ecl_type , const int element_count , fortio_type * fortio) { +bool ecl_kw_fskip_data__( ecl_type_enum ecl_type , const int element_count , fortio_type * fortio) { bool fmt_file = fortio_fmt_file(fortio); + bool skip_ok = true; if (element_count > 0) { if (fmt_file) { /* Formatted skipping actually involves reading the data - nice ??? */ @@ -1215,15 +1233,16 @@ void ecl_kw_fskip_data__( ecl_type_enum ecl_type , const int element_count , for element_size = ECL_STRING_LENGTH; } - fortio_data_fskip(fortio, element_size, element_count, block_count); + skip_ok = fortio_data_fskip(fortio, element_size, element_count, block_count); } } + return skip_ok; } -void ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { - ecl_kw_fskip_data__( ecl_kw->ecl_type , ecl_kw->size , fortio ); -} +bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { + return ecl_kw_fskip_data__( ecl_kw->ecl_type , ecl_kw->size , fortio ); +} /** @@ -1231,7 +1250,7 @@ void ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { function will read the file content at the current position, it is therefor essential that the file pointer is positioned at the beginning of a keyword when this function is called; otherwise it - will be complete crash and burn. + will be complete crash and burn. */ @@ -1241,7 +1260,7 @@ void ecl_kw_fskip_header( fortio_type * fortio) { ecl_kw_type * ecl_kw = ecl_kw_alloc_empty( ); ecl_kw_fread_header( ecl_kw , fortio ); ecl_kw_free( ecl_kw ); - } else + } else fortio_fskip_record( fortio ); } @@ -1254,16 +1273,16 @@ bool ecl_kw_fread_header(ecl_kw_type *ecl_kw , fortio_type * fortio) { char ecl_type_str[ECL_TYPE_LENGTH + 1]; int record_size; int size; - bool OK; + bool OK = true; if (fmt_file) { - OK = ecl_kw_fscanf_qstring(header , "%8c" , 8 , stream); + OK = ecl_kw_fscanf_qstring(header , "%8c" , 8 , stream); if (OK) { int read_count = fscanf(stream , "%d" , &size); if (read_count == 1) { ecl_kw_fscanf_qstring(ecl_type_str , "%4c" , 4 , stream); fgetc(stream); /* Reading the trailing newline ... */ - } else + } else util_abort("%s: reading failed - at end of file?\n",__func__); } } else { @@ -1271,18 +1290,24 @@ bool ecl_kw_fread_header(ecl_kw_type *ecl_kw , fortio_type * fortio) { ecl_type_str[ECL_TYPE_LENGTH] = null_char; record_size = fortio_init_read(fortio); if (record_size > 0) { - util_fread(header , sizeof(char) , ECL_STRING_LENGTH , stream , __func__); - util_fread(&size , sizeof(size) , 1 , stream , __func__); - util_fread(ecl_type_str , sizeof(char) , ECL_TYPE_LENGTH , stream , __func__); - fortio_complete_read(fortio); - - OK = true; - if (ECL_ENDIAN_FLIP) + char buffer[ECL_KW_HEADER_DATA_SIZE]; + size_t read_bytes = fread(buffer , 1 , ECL_KW_HEADER_DATA_SIZE , stream); + + if (read_bytes == ECL_KW_HEADER_DATA_SIZE) { + memcpy( header , &buffer[0] , ECL_STRING_LENGTH); + size = *( (int *) &buffer[ECL_STRING_LENGTH] ); + memcpy( ecl_type_str , &buffer[ECL_STRING_LENGTH + sizeof(size)] , ECL_TYPE_LENGTH); + + OK = fortio_complete_read(fortio , record_size); + } else + OK = false; + + if (OK && ECL_ENDIAN_FLIP) util_endian_flip_vector(&size , sizeof size , 1); - } else + } else OK = false; } - if (OK) + if (OK) ecl_kw_set_header(ecl_kw , header , size , ecl_type_str); return OK; @@ -1300,9 +1325,9 @@ bool ecl_kw_fread_header(ecl_kw_type *ecl_kw , fortio_type * fortio) { 'kw' is NOT found the file will be repositioned to the initial position, and the function will return false; unless abort_on_error == true in which case the function will abort if the 'kw' is not - found. + found. */ - + bool ecl_kw_fseek_kw(const char * kw , bool rewind , bool abort_on_error , fortio_type *fortio) { ecl_kw_type *tmp_kw = ecl_kw_alloc_empty(); @@ -1325,17 +1350,17 @@ bool ecl_kw_fseek_kw(const char * kw , bool rewind , bool abort_on_error , forti if (rewind) { fortio_rewind(fortio); rewind = false; - } else + } else cont = false; } } if (!kw_found) { - if (abort_on_error) + if (abort_on_error) util_abort("%s: failed to locate keyword:%s in file:%s - aborting \n",__func__ , kw , fortio_filename_ref(fortio)); - + fortio_fseek(fortio , init_pos , SEEK_SET); } - + ecl_kw_free(tmp_kw); return kw_found; } @@ -1366,7 +1391,7 @@ bool ecl_kw_fseek_last_kw(const char * kw , bool abort_on_error , fortio_type *f if (!cont) fortio_fseek(fortio , current_pos , SEEK_SET); } while (cont); } else { - if (abort_on_error) + if (abort_on_error) util_abort("%s: could not locate keyword:%s - aborting \n",__func__ , kw); else fortio_fseek(fortio , init_pos , SEEK_SET); @@ -1389,7 +1414,7 @@ void ecl_kw_set_data_ptr(ecl_kw_type * ecl_kw , void * data) { This is where the storage buffer of the ecl_kw is allocated. */ void ecl_kw_alloc_data(ecl_kw_type *ecl_kw) { - if (ecl_kw->shared_data) + if (ecl_kw->shared_data) util_abort("%s: trying to allocate data for ecl_kw object which has been declared with shared storage - aborting \n",__func__); { @@ -1402,9 +1427,9 @@ void ecl_kw_alloc_data(ecl_kw_type *ecl_kw) { void ecl_kw_free_data(ecl_kw_type *ecl_kw) { - if (!ecl_kw->shared_data) + if (!ecl_kw->shared_data) util_safe_free(ecl_kw->data); - + ecl_kw->data = NULL; } @@ -1413,7 +1438,7 @@ void ecl_kw_free_data(ecl_kw_type *ecl_kw) { void ecl_kw_set_header_name(ecl_kw_type * ecl_kw , const char * header) { ecl_kw->header8 = realloc(ecl_kw->header8 , ECL_STRING_LENGTH + 1); sprintf(ecl_kw->header8 , "%-8s" , header); - + /* Internalizing a header without the trailing spaces as well. */ util_safe_free( ecl_kw->header ); ecl_kw->header = util_alloc_strip_copy( ecl_kw->header8 ); @@ -1434,23 +1459,22 @@ void ecl_kw_set_header_alloc(ecl_kw_type *ecl_kw , const char *header , int siz bool ecl_kw_fread_realloc(ecl_kw_type *ecl_kw , fortio_type *fortio) { - bool OK; - OK = ecl_kw_fread_header(ecl_kw , fortio); - if (OK) - ecl_kw_fread_realloc_data( ecl_kw , fortio ); - - return OK; + bool OK = ecl_kw_fread_header(ecl_kw , fortio); + if (OK) + return ecl_kw_fread_realloc_data( ecl_kw , fortio ); + else + return false; } void ecl_kw_fread(ecl_kw_type * ecl_kw , fortio_type * fortio) { int current_size = ecl_kw->size; - if (!ecl_kw_fread_header(ecl_kw , fortio)) + if (!ecl_kw_fread_header(ecl_kw , fortio)) util_abort("%s: failed to read header for ecl_kw - aborting \n",__func__); - if (ecl_kw->size == current_size) + if (ecl_kw->size == current_size) ecl_kw_fread_data(ecl_kw , fortio); - else + else util_abort("%s: size mismatch - aborting \n",__func__); } @@ -1459,12 +1483,11 @@ ecl_kw_type *ecl_kw_fread_alloc(fortio_type *fortio) { bool OK; ecl_kw_type *ecl_kw = ecl_kw_alloc_empty(); OK = ecl_kw_fread_realloc(ecl_kw , fortio); - if (!OK) { free(ecl_kw); ecl_kw = NULL; } - + return ecl_kw; } @@ -1480,7 +1503,7 @@ void ecl_kw_fskip(fortio_type *fortio) { static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * fortio ) { - if (ECL_ENDIAN_FLIP) + if (ECL_ENDIAN_FLIP) ecl_kw_endian_convert_data(ecl_kw); { @@ -1491,7 +1514,7 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * for (block_nr = 0; block_nr < num_blocks; block_nr++) { int this_blocksize = util_int_min((block_nr + 1)*blocksize , ecl_kw->size) - block_nr*blocksize; if (ecl_kw->ecl_type == ECL_CHAR_TYPE || ecl_kw->ecl_type == ECL_MESS_TYPE) { - /* + /* Due to the terminating \0 characters there is not a continous file/memory mapping - the \0 characters arel skipped. @@ -1500,9 +1523,9 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * int record_size = this_blocksize * ECL_STRING_LENGTH; /* The total size in bytes of the record written by the fortio layer. */ int i; fortio_init_write(fortio , record_size ); - for (i = 0; i < this_blocksize; i++) + for (i = 0; i < this_blocksize; i++) fwrite(&ecl_kw->data[(block_nr * blocksize + i) * ecl_kw->sizeof_ctype] , 1 , ECL_STRING_LENGTH , stream); - fortio_complete_write(fortio); + fortio_complete_write(fortio , record_size); } else { int record_size = this_blocksize * ecl_kw->sizeof_ctype; /* The total size in bytes of the record written by the fortio layer. */ fortio_fwrite_record(fortio , &ecl_kw->data[block_nr * blocksize * ecl_kw->sizeof_ctype] , record_size); @@ -1510,7 +1533,7 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * } } - if (ECL_ENDIAN_FLIP) + if (ECL_ENDIAN_FLIP) ecl_kw_endian_convert_data(ecl_kw); } @@ -1522,7 +1545,7 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * formatting. ECLIPSE expects the following formatting for float and double values: - 0.ddddddddE+03 (float) + 0.ddddddddE+03 (float) 0.ddddddddddddddD+03 (double) The problem with printf have been: @@ -1535,7 +1558,7 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * the WRITE_FMT_DOUBLE and WRITE_FMT_FLOAT format specifiers updated accordingly. */ - + static void __fprintf_scientific(FILE * stream, const char * fmt , double x) { double pow_x = ceil(log10(fabs(x))); double arg_x = x / pow(10.0 , pow_x); @@ -1555,14 +1578,14 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * static void ecl_kw_fwrite_data_formatted( ecl_kw_type * ecl_kw , fortio_type * fortio ) { { - + FILE * stream = fortio_get_FILE( fortio ); const int blocksize = get_blocksize( ecl_kw->ecl_type ); const int columns = get_columns( ecl_kw->ecl_type ); const char * write_fmt = ecl_kw_get_write_fmt( ecl_kw->ecl_type ); const int num_blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); int block_nr; - + for (block_nr = 0; block_nr < num_blocks; block_nr++) { int this_blocksize = util_int_min((block_nr + 1)*blocksize , ecl_kw->size) - block_nr*blocksize; int num_lines = this_blocksize / columns + ( this_blocksize % columns == 0 ? 0 : 1); @@ -1619,7 +1642,7 @@ static void ecl_kw_fwrite_data_formatted( ecl_kw_type * ecl_kw , fortio_type * f void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio) { ecl_kw_type *ecl_kw = (ecl_kw_type *) _ecl_kw; bool fmt_file = fortio_fmt_file( fortio ); - + if (fmt_file) ecl_kw_fwrite_data_formatted( ecl_kw , fortio ); else @@ -1631,20 +1654,21 @@ void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio) { void ecl_kw_fwrite_header(const ecl_kw_type *ecl_kw , fortio_type *fortio) { FILE *stream = fortio_get_FILE(fortio); bool fmt_file = fortio_fmt_file(fortio); - if (fmt_file) + if (fmt_file) fprintf(stream , WRITE_HEADER_FMT , ecl_kw->header8 , ecl_kw->size , ecl_util_get_type_name( ecl_kw->ecl_type )); else { int size = ecl_kw->size; if (ECL_ENDIAN_FLIP) util_endian_flip_vector(&size , sizeof size , 1); - fortio_init_write(fortio , ECL_STRING_LENGTH + sizeof(int) + ECL_TYPE_LENGTH); - + fortio_init_write(fortio , ECL_KW_HEADER_DATA_SIZE ); + fwrite(ecl_kw->header8 , sizeof(char) , ECL_STRING_LENGTH , stream); fwrite(&size , sizeof(int) , 1 , stream); fwrite(ecl_util_get_type_name( ecl_kw->ecl_type ) , sizeof(char) , ECL_TYPE_LENGTH , stream); - fortio_complete_write(fortio); + fortio_complete_write(fortio , ECL_KW_HEADER_DATA_SIZE); + } } @@ -1678,7 +1702,7 @@ ecl_type_enum ecl_kw_get_type(const ecl_kw_type * ecl_kw) { return ecl_kw->ecl_t ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer) { - const char * header = buffer_fread_string( buffer ); + const char * header = buffer_fread_string( buffer ); int size = buffer_fread_int( buffer ); ecl_type_enum ecl_type = buffer_fread_int( buffer ); { @@ -1706,7 +1730,7 @@ void ecl_kw_fwrite_param_fortio(fortio_type * fortio, const char * header , ecl ecl_kw_fwrite(ecl_kw , fortio); ecl_kw_free(ecl_kw); } - + void ecl_kw_fwrite_param(const char * filename , bool fmt_file , const char * header , ecl_type_enum ecl_type , int size, void * data) { @@ -1771,7 +1795,7 @@ void ecl_kw_get_data_as_float(const ecl_kw_type * ecl_kw , float * float_data) { elements, where each element is the new index, i.e. new_kw[ mapping[i] ] = src_kw[i] - + For all inactive elements in new kw are set as follows: 0 - For float / int / double @@ -1792,26 +1816,26 @@ ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target else { /** Initialize with defaults .*/ switch (src_kw->ecl_type) { - case(ECL_INT_TYPE): + case(ECL_INT_TYPE): ecl_kw_scalar_set__( new_kw , &default_int ); break; - case(ECL_FLOAT_TYPE): + case(ECL_FLOAT_TYPE): ecl_kw_scalar_set__( new_kw , &default_float ); break; - case(ECL_DOUBLE_TYPE): + case(ECL_DOUBLE_TYPE): ecl_kw_scalar_set__( new_kw , &default_double ); break; - case(ECL_BOOL_TYPE): + case(ECL_BOOL_TYPE): ecl_kw_scalar_set__( new_kw , &default_bool ); break; - case(ECL_CHAR_TYPE): + case(ECL_CHAR_TYPE): ecl_kw_scalar_set__( new_kw , default_char ); break; default: util_abort("%s: unsupported type:%d \n", __func__ , src_kw->ecl_type); } } - + { int sizeof_ctype = ecl_util_get_sizeof_ctype( src_kw->ecl_type ); int i; @@ -1830,14 +1854,14 @@ void ecl_kw_fread_double_param(const char * filename , bool fmt_file , double * fortio_type * fortio = fortio_open_reader(filename , fmt_file , ECL_ENDIAN_FLIP); ecl_kw_type * ecl_kw = ecl_kw_fread_alloc(fortio); fortio_fclose(fortio); - - if (ecl_kw == NULL) + + if (ecl_kw == NULL) util_abort("%s: fatal error: loading parameter from: %s failed - aborting \n",__func__ , filename); ecl_kw_get_data_as_double(ecl_kw , double_data); ecl_kw_free(ecl_kw); } - + void ecl_kw_summarize(const ecl_kw_type * ecl_kw) { printf("%8s %10d:%4s \n",ecl_kw_get_header8(ecl_kw), @@ -1867,8 +1891,8 @@ ECL_KW_SCALAR_SET_TYPED( double , ECL_DOUBLE_TYPE ) #undef ECL_KW_SCALAR_SET_TYPED void ecl_kw_scalar_set_bool( ecl_kw_type * ecl_kw , bool bool_value) { - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); + if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) + util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); { int * data = ecl_kw_get_data_ref(ecl_kw); int int_value; @@ -1968,7 +1992,7 @@ void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_value) { ECL_KW_SHIFT_TYPED( int , ECL_INT_TYPE) ECL_KW_SHIFT_TYPED( float , ECL_FLOAT_TYPE) ECL_KW_SHIFT_TYPED( double , ECL_DOUBLE_TYPE ) -#undef ECL_KW_SHIFT_TYPED +#undef ECL_KW_SHIFT_TYPED void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value ) { @@ -1992,11 +2016,11 @@ bool ecl_kw_assert_numeric( const ecl_kw_type * kw ) { bool ecl_kw_assert_binary( const ecl_kw_type * kw1, const ecl_kw_type * kw2) { - if (kw1->size != kw2->size) + if (kw1->size != kw2->size) return false; /* Size mismatch */ - if (kw1->ecl_type != kw2->ecl_type) + if (kw1->ecl_type != kw2->ecl_type) return false; /* Type mismatch */ - + return true; } @@ -2017,29 +2041,29 @@ bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type if (kw1->ecl_type != ECL_TYPE) \ return false; /* Type mismatch */ \ return true; \ -} +} ECL_KW_ASSERT_TYPED_BINARY_OP( int , ECL_INT_TYPE ) ECL_KW_ASSERT_TYPED_BINARY_OP( float , ECL_FLOAT_TYPE ) ECL_KW_ASSERT_TYPED_BINARY_OP( double , ECL_DOUBLE_TYPE ) #undef ECL_KW_ASSERT_TYPED_BINARY_OP - + void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_kw) { if (!ecl_kw_assert_binary( target_kw , src_kw )) - util_abort("%s: type/size mismatch\n",__func__); - { - char * target_data = ecl_kw_get_data_ref( target_kw ); - const char * src_data = ecl_kw_get_data_ref( src_kw ); - int sizeof_ctype = ecl_util_get_sizeof_ctype(target_kw->ecl_type); + util_abort("%s: type/size mismatch\n",__func__); + { + char * target_data = ecl_kw_get_data_ref( target_kw ); + const char * src_data = ecl_kw_get_data_ref( src_kw ); + int sizeof_ctype = ecl_util_get_sizeof_ctype(target_kw->ecl_type); int set_size = int_vector_size( index_set ); const int * index_data = int_vector_get_const_ptr( index_set ); int i; - for (i=0; i < set_size; i++) { - int index = index_data[i]; + for (i=0; i < set_size; i++) { + int index = index_data[i]; memcpy( &target_data[ index * sizeof_ctype ] , &src_data[ index * sizeof_ctype] , sizeof_ctype); - } - } + } + } } @@ -2398,7 +2422,7 @@ void ecl_kw_inplace_inv(ecl_kw_type * my_kw) { void ecl_kw_inplace_update_file(const ecl_kw_type * ecl_kw , const char * filename, int index) { if (util_file_exists(filename)) { bool fmt_file = util_fmt_bit8(filename); - + { fortio_type * fortio = fortio_open_readwrite(filename , fmt_file , ECL_ENDIAN_FLIP); ecl_kw_ifseek_kw(ecl_kw_get_header8(ecl_kw) , fortio , index); @@ -2407,13 +2431,13 @@ void ecl_kw_inplace_update_file(const ecl_kw_type * ecl_kw , const char * filena long int current_pos = fortio_ftell( fortio ); ecl_kw_fread_header(file_kw , fortio); fortio_fseek( fortio , current_pos , SEEK_SET ); - + if (!((file_kw->size == ecl_kw->size) && (file_kw->ecl_type == ecl_kw->ecl_type))) util_abort("%s: header mismatch when trying to update:%s in %s \n",__func__ , ecl_kw_get_header8(ecl_kw) , filename); ecl_kw_free(file_kw); } - + fortio_fflush(fortio); ecl_kw_fwrite(ecl_kw , fortio); fortio_fclose(fortio); @@ -2424,28 +2448,26 @@ void ecl_kw_inplace_update_file(const ecl_kw_type * ecl_kw , const char * filena /******************************************************************/ -bool ecl_kw_is_kw_file(FILE * stream , bool fmt_file ) { - const long int init_pos = util_ftell(stream); +bool ecl_kw_is_kw_file(fortio_type * fortio) { + const long int init_pos = fortio_ftell( fortio ); bool kw_file; - + { ecl_kw_type * ecl_kw = ecl_kw_alloc_empty(); - fortio_type * fortio = fortio_alloc_FILE_wrapper(NULL , ECL_ENDIAN_FLIP , fmt_file , stream); - - if (fmt_file) + + if (fortio_fmt_file( fortio )) kw_file = ecl_kw_fread_header(ecl_kw , fortio); else { - if (fortio_is_fortio_file(fortio)) + if (fortio_is_fortio_file(fortio)) kw_file = ecl_kw_fread_header(ecl_kw , fortio); else kw_file = false; - } + } - fortio_free_FILE_wrapper(fortio); ecl_kw_free(ecl_kw); } - - util_fseek(stream , init_pos , SEEK_SET); + + fortio_fseek(fortio , init_pos , SEEK_SET); return kw_file; } @@ -2459,7 +2481,7 @@ bool ecl_kw_is_grdecl_file(FILE * stream) { bool at_eof = false; util_fskip_chars(stream , " \r\n\t" , &at_eof); /* Skipping intial space */ util_fskip_cchars(stream , " \r\n\t" , &at_eof); /* Skipping PORO/PERMX/... */ - if (at_eof) + if (at_eof) grdecl_file = false; else { grdecl_file = true; @@ -2467,7 +2489,7 @@ bool ecl_kw_is_grdecl_file(FILE * stream) { int c; do { c = fgetc(stream); - if (c == '\r' || c == '\n') + if (c == '\r' || c == '\n') break; else { if (c != ' ') { @@ -2482,7 +2504,7 @@ bool ecl_kw_is_grdecl_file(FILE * stream) { return grdecl_file; } - + #define KW_MAX_MIN(type) \ @@ -2518,7 +2540,7 @@ void ecl_kw_max_min(const ecl_kw_type * ecl_kw , void * _max , void *_min) { #define ECL_KW_MAX_MIN( ctype ) \ void ecl_kw_max_min_ ## ctype ( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min) { \ KW_MAX_MIN( ctype ); \ -} +} #define ECL_KW_MAX( ctype ) \ @@ -2599,9 +2621,9 @@ double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw ) { sum_ptr = &float_sum; else util_abort("%s: invalid type: \n",__func__); - + ecl_kw_element_sum( ecl_kw , sum_ptr ); - + if (ecl_kw->ecl_type == ECL_DOUBLE_TYPE) return double_sum; else if (ecl_kw->ecl_type == ECL_FLOAT_TYPE) @@ -2648,7 +2670,7 @@ static void ecl_kw_fprintf_data_bool( const ecl_kw_type * ecl_kw , const char * static void ecl_kw_fprintf_data_char( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream) { int i; - for (i=0; i < ecl_kw->size; i++) + for (i=0; i < ecl_kw->size; i++) fprintf(stream , fmt , &ecl_kw->data[ i * ecl_kw->sizeof_ctype]); } @@ -2666,3 +2688,5 @@ void ecl_kw_fprintf_data( const ecl_kw_type * ecl_kw , const char * fmt , FILE * ecl_kw_fprintf_data_char( ecl_kw , fmt , stream ); } + +#include "ecl_kw_functions.c" diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_kw_functions.c b/ThirdParty/Ert/devel/libecl/src/ecl_kw_functions.c new file mode 100644 index 0000000000..1737b808ff --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/src/ecl_kw_functions.c @@ -0,0 +1,130 @@ +/* + This file is included from the ecl_kw.c file during compilation. It + contains functions which are not really related to the ecl_kw as a + datastructure, but rather use an ecl_kw instance in a function. +*/ + + +/* + This is an extremely special-case function written for the region + creation code. Given a completed ecl_kw regions keyword, the purpose + of this function is to "detect and correct" uninitialized cells with + value 0. This function is purely heuristic: + + 1. It only considers cells which are active in the grid, i.e. where + actnum[] != 0. + + 2. It will scan the four neighbours in the xy plane, if all + neighbours agree on region value this value will be applied; + otherwise the value will not be changed. Neighbouring cells with + value zero are not considered when comparing. +*/ + + +void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, const int * actnum) { + int i,j,k; + int * data = ecl_kw_get_ptr( ecl_kw ); + + int_vector_type * undetermined1 = int_vector_alloc(0,0); + int_vector_type * undetermined2 = int_vector_alloc(0,0); + + for (k=0; k < nz; k++) { + int_vector_reset( undetermined1 ); + for (j=0; j < ny; j++) { + for (i=0; i < nx; i++) { + int g0 = i + j * nx + k* nx*ny; + + if (data[g0] == 0 && actnum[g0]) + int_vector_append( undetermined1 , g0 ); + } + } + + + while (true) { + int index; + bool finished = true; + + int_vector_reset( undetermined2 ); + for (index = 0; index < int_vector_size( undetermined1 ); index++) { + int g0 = int_vector_iget( undetermined1 , index ); + int j = (g0 - k * nx*ny) / nx; + int i = g0 - k * nx*ny - j * nx; + + if (data[g0] == 0 && actnum[g0]) { + int n1 = 0; + int n2 = 0; + int n3 = 0; + int n4 = 0; + + if (i > 0) { + int g1 = g0 - 1; + if (actnum[g1]) + n1 = data[g1]; + } + + if (i < (nx - 1)) { + int g2 = g0 + 1; + if (actnum[g2]) + n2 = data[g2]; + } + + if (j > 0) { + int g3 = g0 - nx; + if (actnum[g3]) + n3 = data[g3]; + } + + if (j < (ny - 1)) { + int g4 = g0 + nx; + if (actnum[g4]) + n4 = data[g4]; + } + + { + int new_value = 0; + + if (n1) + new_value = n1; + + if (n2) { + if (new_value == 0) + new_value = n2; + else if (new_value != n2) + new_value = -1; + } + + if (n3) { + if (new_value == 0) + new_value = n3; + else if (new_value != n3) + new_value = -1; + } + + if (n4) { + if (new_value == 0) + new_value = n4; + else if (new_value != n4) + new_value = -1; + } + + if (new_value > 0) { + data[g0] = new_value; + finished = false; + } + } + if ((n1 + n2 + n3 + n4) == 0) + int_vector_append( undetermined2 , g0 ); + } + } + { + int_vector_type * tmp = undetermined2; + undetermined2 = undetermined1; + undetermined1 = tmp; + } + if (finished || (int_vector_size( undetermined1) == 0)) + break; + } + } + int_vector_free( undetermined1 ); + int_vector_free( undetermined2 ); +} diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c b/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c index 07ef19cd09..03add70496 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <string.h> @@ -47,7 +47,7 @@ 3. The * notation can be used to print repeated values in a compact form, i.e. 1000*0.25 to get 1000 conecutive 0.25 values. - + The typical ECLIPSE keywords found in the datafile contain a mixture of numeric and character data; the current code assumes that all the data of a keyword is of the same underlying type, and do NOT support @@ -74,7 +74,7 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) { long start_pos = util_ftell( stream ); long current_pos; char next_kw[256]; - + /* Determine if the current position of the file pointer is at the beginning of the line; if not skip the rest of the line; this is @@ -83,17 +83,17 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) { { while (true) { char c; - if (util_ftell(stream) == 0) + if (util_ftell(stream) == 0) /* We are at the very beginning of the file. Can just jump out of the loop. */ break; - + util_fseek( stream , -1 , SEEK_CUR ); c = fgetc( stream ); if (c == '\n') { - /* + /* We have walked backwards reaching the start of the line. We have not reached any !isspace() characters on the way and can go back to start_pos and read from there. @@ -101,9 +101,9 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) { util_fseek( stream , start_pos , SEEK_SET ); break; } - + if (!isspace( c )) { - /* + /* We hit a non-whitespace character; this means that start_pos was not at the start of the line. We skip the rest of this line, and then start reading on the next line. @@ -114,12 +114,12 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) { util_fseek( stream , -2 , SEEK_CUR ); } } - - + + while (true) { current_pos = util_ftell( stream ); if (fscanf(stream , "%s" , next_kw) == 1) { - if ((next_kw[0] == next_kw[1]) && (next_kw[0] == ECL_COMMENT_CHAR)) + if ((next_kw[0] == next_kw[1]) && (next_kw[0] == ECL_COMMENT_CHAR)) // This is a comment line - skip it. util_fskip_lines( stream , 1 ); else { @@ -140,7 +140,7 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) { Will use the ecl_kw_grdecl_fseek_next_header() to seek out the next header string, and read and return that string. If no more headers are found the function will return NULL. The storage allocated by - this function must be free'd by the calling scope. + this function must be free'd by the calling scope. */ char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) { @@ -153,7 +153,7 @@ char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) { } -/** +/** This function will search through a GRDECL file to look for the 'kw'; input variables and return vales are similar to ecl_kw_fseek_kw(). Observe that the GRDECL files are extremely @@ -161,7 +161,7 @@ char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) { with a malformed GRDECL file. In particular the comparison is case sensitive; that is probably not - the case with ECLIPSE proper? + the case with ECLIPSE proper? If the kw is not found the file pointer is repositioned. */ @@ -189,27 +189,27 @@ static bool ecl_kw_grdecl_fseek_kw__(const char * kw , FILE * stream) { // static bool ecl_kw_grdecl_fseek_kw__OLD(const char * kw , FILE * stream) { // const int newline_char = '\n'; // long int init_pos = ftell(stream); -// +// // if (util_fseek_string(stream , kw , false , true)) { // /* // OK the keyword is found in the file; now we must verify that: -// +// // 1. It is terminated with a blank, i.e. when searching for // 'COORD' we do not want a positive on 'COORDSYS'. -// +// // 2. That the keyword indeed starts with a isspace() character; we -// are not interested in the 'SYS' in 'COORDSYS'. -// +// are not interested in the 'SYS' in 'COORDSYS'. +// // 3. That the current location is not a comment section. // */ // long int kw_pos = ftell( stream ); // bool valid_kw = false; // int c; -// +// // fseek( stream , strlen(kw) , SEEK_CUR); // Seek to end of kw -// c = fgetc( stream ); // Read one character +// c = fgetc( stream ); // Read one character // fseek( stream , kw_pos , SEEK_SET ); // Seek back to beginning of kw -// +// // if (isspace(c)) { // if (kw_pos > 0) { // fseek( stream , kw_pos - 1 , SEEK_SET); @@ -220,9 +220,9 @@ static bool ecl_kw_grdecl_fseek_kw__(const char * kw , FILE * stream) { // valid_kw = true; // } else // valid_kw = true; // kw is at the very beginning of the file. -// } -// -// +// } +// +// // if (valid_kw) { // // OK - the kw is validly terminated with a space/tab/newline; now // // we must verify that it is not in a comment section. @@ -232,30 +232,30 @@ static bool ecl_kw_grdecl_fseek_kw__(const char * kw , FILE * stream) { // while (true) { // fseek( stream , -2 , SEEK_CUR ); // c = fgetc( stream ); -// if ((c == newline_char) || (ftell(stream) == 0)) +// if ((c == newline_char) || (ftell(stream) == 0)) // break; // } // { // // We have gone as far back as necessary. // int line_length = kw_pos - ftell( stream ); // char * line = util_malloc(line_length + 1 , __func__); -// +// // fread( stream , sizeof * line , line_length , stream); // line[line_length] = '\0'; -// -// if (strstr( line , ECL_COMMENT_STRING) == NULL) -// // We are not in a commen section. +// +// if (strstr( line , ECL_COMMENT_STRING) == NULL) +// // We are not in a commen section. // valid_kw = true; // else // valid_kw = false; -// +// // free( line ); // } // } // } else // valid_kw = false; -// -// if (valid_kw) +// +// if (valid_kw) // return true; // else { // fseek( stream , strlen(kw) , SEEK_CUR ); // Skip over the kw so we don't find it again. @@ -265,8 +265,8 @@ static bool ecl_kw_grdecl_fseek_kw__(const char * kw , FILE * stream) { // fseek( stream , init_pos , SEEK_SET ); // return false; // } -// } -// } else +// } +// } else // return false; // } @@ -276,10 +276,10 @@ bool ecl_kw_grdecl_fseek_kw(const char * kw , bool rewind , FILE * stream) { return true; /* OK - we found the kw between current file pos and EOF. */ else if (rewind) { long int init_pos = util_ftell(stream); - + util_fseek(stream , 0L , SEEK_SET); if (ecl_kw_grdecl_fseek_kw__( kw , stream )) /* Try again from the beginning of the file. */ - return true; + return true; else util_fseek(stream , init_pos , SEEK_SET); /* Could not find it - reposition to initial position. */ } @@ -293,13 +293,13 @@ bool ecl_kw_grdecl_fseek_kw(const char * kw , bool rewind , FILE * stream) { /** Observe that this function does not preserve the '*' structure - which (might) have been used in the input. + which (might) have been used in the input. */ static void iset_range( char * data , int data_offset , int sizeof_ctype , void * value_ptr , int multiplier) { int index; - for ( index =0; index < multiplier; index++) + for ( index =0; index < multiplier; index++) memcpy( &data[ (index + data_offset) * sizeof_ctype ] , value_ptr , sizeof_ctype); } @@ -317,11 +317,11 @@ static void iset_range( char * data , int data_offset , int sizeof_ctype , void Whatever that 'F' is - it is discarded when the SPECGRID header is written to a GRID/EGRID file. For this reason we have the possibility of setting @strict to false; in which case the 'F' or - other characters in the numerical input will be ignored. + other characters in the numerical input will be ignored. If @strict is set to true the function will bomb when meeting a - non-numeric character like the 'F' above. - + non-numeric character like the 'F' above. + ---------------------------------------------------------------- The function supports multiplier keywords like: @@ -329,7 +329,7 @@ static void iset_range( char * data , int data_offset , int sizeof_ctype , void PERMX 10000*0.15 0.16 0.17 0.18 0.19 10000*0.20 / - + Observe that no-spaces-are-allowed-around-the-* */ @@ -358,7 +358,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ break; } } - } else if (strcmp(buffer , ECL_DATA_TERMINATION) == 0) + } else if (strcmp(buffer , ECL_DATA_TERMINATION) == 0) break; else { // We have read a valid input string; scan numerical input values from it. @@ -368,27 +368,27 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ int multiplier; void * value_ptr = NULL; bool char_input = false; - + if (ecl_type == ECL_INT_TYPE) { int value; - if (sscanf(buffer , "%d*%d" , &multiplier , &value) == 2) + if (sscanf(buffer , "%d*%d" , &multiplier , &value) == 2) {} - else if (sscanf( buffer , "%d" , &value) == 1) + else if (sscanf( buffer , "%d" , &value) == 1) multiplier = 1; else { char_input = true; if (strict) util_abort("%s: Malformed content:\"%s\" when reading keyword:%s \n",__func__ , buffer , header); } - + value_ptr = &value; } else if (ecl_type == ECL_FLOAT_TYPE) { float value; - if (sscanf(buffer , "%d*%g" , &multiplier , &value) == 2) + if (sscanf(buffer , "%d*%g" , &multiplier , &value) == 2) {} - else if (sscanf( buffer , "%g" , &value) == 1) + else if (sscanf( buffer , "%g" , &value) == 1) multiplier = 1; else { char_input = true; @@ -400,29 +400,31 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ } else if (ecl_type == ECL_DOUBLE_TYPE) { double value; - if (sscanf(buffer , "%d*%lg" , &multiplier , &value) == 2) + if (sscanf(buffer , "%d*%lg" , &multiplier , &value) == 2) {} - else if (sscanf( buffer , "%lg" , &value) == 1) + else if (sscanf( buffer , "%lg" , &value) == 1) multiplier = 1; else { char_input = true; if (strict) util_abort("%s: Malformed content:\"%s\" when reading keyword:%s \n",__func__ , buffer , header); } - + value_ptr = &value; - } else + } else util_abort("%s: sorry type:%s not supported \n",__func__ , ecl_util_get_type_name(ecl_type)); - - - if (char_input) + + /* + Removing this warning on user request: + if (char_input) fprintf(stderr,"Warning: character string: \'%s\' ignored when reading keyword:%s \n",buffer , header); - else { + */ + if (!char_input) { if (data_index + multiplier >= data_size) { data_size = 2*(data_index + multiplier); data = util_realloc( data , sizeof_ctype * data_size * sizeof * data); } - + iset_range( data , data_index , sizeof_ctype , value_ptr , multiplier ); data_index += multiplier; } @@ -430,7 +432,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ } if (atEOF) break; - } else + } else break; } free( buffer ); @@ -512,7 +514,7 @@ static ecl_kw_type * __ecl_kw_fscanf_alloc_grdecl__(FILE * stream , const char * if (fscanf(stream , "%s" , file_header) == 1) { int kw_size; char * data = fscanf_alloc_grdecl_data( file_header , strict , ecl_type , &kw_size , stream ); - + // Verify size if (size > 0) if (size != kw_size) { @@ -520,20 +522,20 @@ static ecl_kw_type * __ecl_kw_fscanf_alloc_grdecl__(FILE * stream , const char * util_abort("%s: size mismatch when loading:%s. File:%d elements. Requested:%d elements \n", __func__ , file_header , kw_size , size); } - + { ecl_kw_type * ecl_kw = ecl_kw_alloc_new( file_header , kw_size , ecl_type , NULL ); ecl_kw_set_data_ptr( ecl_kw , data ); return ecl_kw; } - } else + } else /** No header read - probably at EOF */ return NULL; } } /*****************************************************************/ -/* +/* Here comes the exported functions for loading a grdecl formatted keyword. All of these function invoke the fundamental ecl_kw_fscanf_alloc_grdecl__() function, but the set of input @@ -541,7 +543,7 @@ static ecl_kw_type * __ecl_kw_fscanf_alloc_grdecl__(FILE * stream , const char * accepts a @strict flag from calling scope; in general you should use strict == true. */ - + /** This function assumes that the file pointer has already been @@ -564,12 +566,12 @@ ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_data(FILE * stream , int size , ecl_typ /*****************************************************************/ -/* +/* This function will seek through the file and position the file pointer at the beginning of @kw before starting to load (this includes rewinding the file pointer). If @kw can not be found the - function will return NULL. - + function will return NULL. + As size is not supplied the function will keep loading data until the whole keyword is loaded, and then return. */ @@ -585,12 +587,12 @@ ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_dynamic( FILE * stream , const char * k /*****************************************************************/ -/* +/* This function will seek through the file and position the file pointer at the beginning of @kw before starting to load (this includes rewinding the file pointer). If @kw can not be found the - function will return NULL. - + function will return NULL. + When the data has been loaded the function will compare actual size with the supplied size argument and verify equality; if they differ it will crash hard. If you are uncertain of the size use the @@ -610,7 +612,7 @@ ecl_kw_type * ecl_kw_fscanf_alloc_grdecl( FILE * stream , const char * kw , int /*****************************************************************/ -/* +/* This function will read and allocate the next keyword in the file. This function does not take either kw or the size of the kw as input, and has virtually zero possibilities to check what it is @@ -638,21 +640,21 @@ ecl_kw_type * ecl_kw_fscanf_alloc_current_grdecl( FILE * stream , ecl_type_enum /* This method allows to write with a different header, i.e. PORO_XXXX. This header is even allowed to break the 8 character - length limit; i.e. loading it back naively will fail. + length limit; i.e. loading it back naively will fail. */ -void ecl_kw_fprintf_grdecl__(const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream) { +void ecl_kw_fprintf_grdecl__(const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream) { if (special_header) - fprintf(stream,"%s\n" , special_header); - else + fprintf(stream,"%s\n" , special_header); + else fprintf(stream,"%s\n" , ecl_kw_get_header(ecl_kw)); { - fortio_type * fortio = fortio_alloc_FILE_wrapper(NULL , false , true , stream); /* Endian flip should *NOT* be used */ + fortio_type * fortio = fortio_alloc_FILE_wrapper(NULL , false , true , true , stream); /* Endian flip should *NOT* be used */ ecl_kw_fwrite_data(ecl_kw , fortio); fortio_free_FILE_wrapper( fortio ); } - fprintf(stream,"/\n"); + fprintf(stream,"/\n"); } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_nnc_export.c b/ThirdParty/Ert/devel/libecl/src/ecl_nnc_export.c index 330cb36354..3fbae6a40a 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_nnc_export.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_nnc_export.c @@ -1,20 +1,20 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more detals. -*/ + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more detals. +*/ #include <stdlib.h> #include <ert/util/int_vector.h> @@ -33,16 +33,17 @@ int ecl_nnc_export_get_size( const ecl_grid_type * grid ) { -static void ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , const ecl_file_type * init_file , ecl_nnc_type * nnc_data, int * nnc_offset) { +static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , const ecl_file_type * init_file , ecl_nnc_type * nnc_data, int * nnc_offset) { int nnc_index = *nnc_offset; int lgr_nr1 = ecl_grid_get_lgr_nr( grid ); int global_index1; + int valid_trans = 0 ; const ecl_grid_type * global_grid = ecl_grid_get_global_grid( grid ); if (!global_grid) global_grid = grid; - + for (global_index1 = 0; global_index1 < ecl_grid_get_global_size( grid ); global_index1++) { const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( grid , global_index1 ); if (nnc_info) { @@ -53,6 +54,7 @@ static void ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , con const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector ); int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector ); const ecl_kw_type * tran_kw = ecl_nnc_export_get_tranx_kw(global_grid , init_file , lgr_nr1 , lgr_nr2 ); + int index2; ecl_nnc_type nnc; @@ -62,7 +64,12 @@ static void ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , con for (index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) { nnc.global_index2 = int_vector_iget( grid2_index_list , index2 ); - nnc.trans = ecl_kw_iget_as_double( tran_kw , int_vector_iget( nnc_index_list , index2)); + if(tran_kw) { + nnc.trans = ecl_kw_iget_as_double(tran_kw, int_vector_iget(nnc_index_list, index2)); + valid_trans++; + }else{ + nnc.trans = ERT_ECL_DEFAULT_NNC_TRANS; + } nnc_data[nnc_index] = nnc; nnc_index++; @@ -71,21 +78,24 @@ static void ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , con } } *nnc_offset = nnc_index; + return valid_trans; } -void ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data) { +int ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data) { int nnc_index = 0; - ecl_nnc_export__( grid , 0 , init_file , nnc_data , &nnc_index ); + int total_valid_trans = 0; + total_valid_trans = ecl_nnc_export__( grid , 0 , init_file , nnc_data , &nnc_index ); { - int lgr_index; + int lgr_index; for (lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) { ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index ); - ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index ); + total_valid_trans += ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index ); } } nnc_index = ecl_nnc_export_get_size( grid ); ecl_nnc_sort( nnc_data , nnc_index ); + return total_valid_trans; } @@ -93,21 +103,21 @@ void ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_fi int ecl_nnc_cmp( const ecl_nnc_type * nnc1 , const ecl_nnc_type * nnc2) { if (nnc1->grid_nr1 != nnc2->grid_nr1) { - if (nnc1->grid_nr1 < nnc2->grid_nr1) + if (nnc1->grid_nr1 < nnc2->grid_nr1) return -1; else return 1; } if (nnc1->grid_nr2 != nnc2->grid_nr2) { - if (nnc1->grid_nr2 < nnc2->grid_nr2) + if (nnc1->grid_nr2 < nnc2->grid_nr2) return -1; else return 1; } if (nnc1->global_index1 != nnc2->global_index1) { - if (nnc1->global_index1 < nnc2->global_index1) + if (nnc1->global_index1 < nnc2->global_index1) return -1; else return 1; @@ -115,12 +125,12 @@ int ecl_nnc_cmp( const ecl_nnc_type * nnc1 , const ecl_nnc_type * nnc2) { if (nnc1->global_index2 != nnc2->global_index2) { - if (nnc1->global_index2 < nnc2->global_index2) + if (nnc1->global_index2 < nnc2->global_index2) return -1; else return 1; } - + return 0; } @@ -142,19 +152,19 @@ ecl_kw_type * ecl_nnc_export_get_tranll_kw( const ecl_grid_type * grid , const e ecl_kw_type * tran_kw = NULL; const int file_num_kw = ecl_file_get_size( init_file ); int global_kw_index = 0; - + while (true) { - if (global_kw_index >= file_num_kw) + if (global_kw_index >= file_num_kw) break; { ecl_kw_type * ecl_kw = ecl_file_iget_kw( init_file , global_kw_index ); if (strcmp( LGRJOIN_KW , ecl_kw_get_header( ecl_kw)) == 0) { - + if (ecl_kw_icmp_string( ecl_kw , 0 , lgr_name1) && ecl_kw_icmp_string( ecl_kw , 1 , lgr_name2)) { tran_kw = ecl_file_iget_kw( init_file , global_kw_index + 1); break; } - } + } global_kw_index++; } } @@ -166,47 +176,47 @@ ecl_kw_type * ecl_nnc_export_get_tranll_kw( const ecl_grid_type * grid , const e ecl_kw_type * ecl_nnc_export_get_tran_kw( const ecl_file_type * init_file , const char * kw , int lgr_nr ) { ecl_kw_type * tran_kw = NULL; - if (lgr_nr == 0) { if (strcmp(kw , TRANNNC_KW) == 0) - tran_kw = ecl_file_iget_named_kw( init_file , TRANNNC_KW , 0 ); + if(ecl_file_has_kw(init_file, kw)) { + tran_kw = ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0); + } } else { if ((strcmp(kw , TRANNNC_KW) == 0) || (strcmp(kw , TRANGL_KW) == 0)) { - int tran_kw_forward_skip; const int file_num_kw = ecl_file_get_size( init_file ); int global_kw_index = 0; bool finished = false; - - if (strcmp(kw , TRANNNC_KW) == 0) - tran_kw_forward_skip = 3; - else - tran_kw_forward_skip = 4; - - while (!finished) { + bool correct_lgrheadi = false; + int head_index = 0; + int steps = 0; + + + while(!finished){ ecl_kw_type * ecl_kw = ecl_file_iget_kw( init_file , global_kw_index ); - - if (strcmp( LGRHEADI_KW , ecl_kw_get_header( ecl_kw )) == 0) { + const char *current_kw = ecl_kw_get_header(ecl_kw); + if (strcmp( LGRHEADI_KW , current_kw) == 0) { if (ecl_kw_iget_int( ecl_kw , LGRHEADI_LGR_NR_INDEX) == lgr_nr) { - - if ((global_kw_index + tran_kw_forward_skip) < file_num_kw) { - ecl_kw_type * ecl_kw = ecl_file_iget_kw( init_file , global_kw_index + tran_kw_forward_skip); - - /* We found the TRANGL / TRANNC keyword we are after. */ - if (strcmp( kw , ecl_kw_get_header( ecl_kw )) == 0) { - tran_kw = ecl_kw; - finished = true; - break; - } + correct_lgrheadi = true; + head_index = global_kw_index; + }else{ + correct_lgrheadi = false; + } + } + if(correct_lgrheadi) { + if (strcmp(kw, current_kw) == 0) { + steps = global_kw_index - head_index; /* This is to calculate who fare from lgrheadi we found the TRANGL/TRANNNC key word */ + if(steps == 3 || steps == 4 || steps == 6) { /* We only support a file format where TRANNNC is 3 steps and TRANGL is 4 or 6 steps from LGRHEADI */ + tran_kw = ecl_kw; + finished = true; + break; } - - } - } - + } + } global_kw_index++; if (global_kw_index == file_num_kw) finished = true; - } + } } } return tran_kw; diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_region.c b/ThirdParty/Ert/devel/libecl/src/ecl_region.c index 26a205a4f7..88e2b8372e 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_region.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_region.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_region.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_region.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -55,7 +55,7 @@ the indices. You can also get the results in term of global indices. (Refer to ecl_grid for the difference between active and global indices). - + For the functions which take ecl_kw input, the ecl_kw instance must have either nx*ny*nz elements, or nactive(from the grid) elements. This is checked, and the program will fail hard if it is @@ -63,7 +63,7 @@ Example: -------- - + ecl_grid_type * ecl_grid; ecl_kw_type * soil; ecl_kw_type * regions; @@ -71,18 +71,18 @@ // Load grid, soil and regions somehow. - ecl_region = ecl_region_alloc( ecl_grid , false ); // Start with nothing selected + ecl_region = ecl_region_alloc( ecl_grid , false ); // Start with nothing selected ecl_region_select_in_interval( ecl_region , soil , 0.50, 1.00); // Select all cells with soil > 0.50 ecl_region_select_equal( ecl_region , regions , 3 ); // Only consider ECLIPSE region 3. ecl_region_select_k1k2( ecl_region , 5 , 8); // Select layers 5,6,7,8 { - int num_cells = ecl_region_get_global_size( ecl_region ); // How many cells are active + int num_cells = ecl_region_get_global_size( ecl_region ); // How many cells are active const int * cell_list = ecl_region_get_global_list( ecl_region ); // Get a list of indices int i; printf("%d cells satisfy your selection. The cells are: \n"); - for (i=0; i < num_cells; i++) - printf("Cell: %d \n",cell_list[i]); + for (i=0; i < num_cells; i++) + printf("Cell: %d \n",cell_list[i]); } ecl_region_free( ecl_region ); @@ -117,8 +117,8 @@ UTIL_SAFE_CAST_FUNCTION( ecl_region , ECL_REGION_TYPE_ID) static void ecl_region_invalidate_index_list( ecl_region_type * region ) { - region->global_index_list_valid = false; - region->active_index_list_valid = false; + region->global_index_list_valid = false; + region->active_index_list_valid = false; } @@ -151,7 +151,7 @@ ecl_region_type * ecl_region_alloc( const ecl_grid_type * ecl_grid , bool presel ecl_region_reset( region ); /* This MUST be called to ensure that xxx_valid is correctly initialized. */ return region; } - + @@ -183,17 +183,17 @@ void ecl_region_free__( void * __region ) { /*****************************************************************/ - + static void ecl_region_assert_global_index_list( ecl_region_type * region ) { if (!region->global_index_list_valid) { int global_index; int_vector_reset( region->global_index_list ); - for (global_index = 0; global_index < region->grid_vol; global_index++) - if (region->active_mask[ global_index ]) + for (global_index = 0; global_index < region->grid_vol; global_index++) + if (region->active_mask[ global_index ]) int_vector_append( region->global_index_list , global_index ); - + region->global_index_list_valid = true; } } @@ -269,15 +269,15 @@ static void ecl_region_assert_kw( const ecl_region_type * region , const ecl_kw_ *global_kw = true; else *global_kw = false; - + } -/*****************************************************************/ +/*****************************************************************/ void ecl_region_reset( ecl_region_type * ecl_region ) { int i; - for (i=0; i < ecl_region->grid_vol; i++) + for (i=0; i < ecl_region->grid_vol; i++) ecl_region->active_mask[i] = ecl_region->preselect; ecl_region_invalidate_index_list( ecl_region ); } @@ -306,7 +306,7 @@ void ecl_region_deselect_cell( ecl_region_type * region , int i , int j , int k) static void ecl_region_select_equal__( ecl_region_type * region , const ecl_kw_type * ecl_kw, int value , bool select) { bool global_kw; ecl_region_assert_kw( region , ecl_kw , &global_kw); - if (ecl_kw_get_type( ecl_kw ) != ECL_INT_TYPE) + if (ecl_kw_get_type( ecl_kw ) != ECL_INT_TYPE) util_abort("%s: sorry - select by equality is only supported for integer keywords \n",__func__); { const int * kw_data = ecl_kw_get_int_ptr( ecl_kw ); @@ -339,13 +339,60 @@ void ecl_region_deselect_equal( ecl_region_type * region , const ecl_kw_type * e ecl_region_select_equal__( region , ecl_kw , value , false ); } +/*****************************************************************/ + +static void ecl_region_select_bool_equal__( ecl_region_type * region , const ecl_kw_type * ecl_kw, bool value , bool select) { + bool global_kw; + ecl_region_assert_kw( region , ecl_kw , &global_kw); + if (ecl_kw_get_type( ecl_kw ) != ECL_BOOL_TYPE) + util_abort("%s: sorry - select by equality is only supported for boolean keywords \n",__func__); + { + if (global_kw) { + int global_index; + for (global_index = 0; global_index < region->grid_vol; global_index++) { + if (ecl_kw_iget_bool(ecl_kw , global_index) == value) + region->active_mask[ global_index ] = select; + } + } else { + int active_index; + for (active_index = 0; active_index < region->grid_active; active_index++) { + if (ecl_kw_iget_bool(ecl_kw , active_index) == value) { + int global_index = ecl_grid_get_global_index1A( region->parent_grid , active_index ); + region->active_mask[ global_index ] = select; + } + } + } + } + ecl_region_invalidate_index_list( region ); +} + + +void ecl_region_select_true( ecl_region_type * region , const ecl_kw_type * ecl_kw) { + ecl_region_select_bool_equal__( region , ecl_kw , true , true ); +} + + +void ecl_region_deselect_true( ecl_region_type * region , const ecl_kw_type * ecl_kw) { + ecl_region_select_bool_equal__( region , ecl_kw , true , false ); +} + + +void ecl_region_select_false( ecl_region_type * region , const ecl_kw_type * ecl_kw) { + ecl_region_select_bool_equal__( region , ecl_kw , false , true ); +} + + +void ecl_region_deselect_false( ecl_region_type * region , const ecl_kw_type * ecl_kw) { + ecl_region_select_bool_equal__( region , ecl_kw , false , false ); +} + /*****************************************************************/ static void ecl_region_select_in_interval__( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value , bool select) { bool global_kw; ecl_region_assert_kw( region , ecl_kw , &global_kw); - if (ecl_kw_get_type( ecl_kw ) != ECL_FLOAT_TYPE) + if (ecl_kw_get_type( ecl_kw ) != ECL_FLOAT_TYPE) util_abort("%s: sorry - select by in_interval is only supported for float keywords \n",__func__); { const float * kw_data = ecl_kw_get_float_ptr( ecl_kw ); @@ -368,7 +415,7 @@ static void ecl_region_select_in_interval__( ecl_region_type * region , const ec ecl_region_invalidate_index_list( region ); } - + void ecl_region_select_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value) { ecl_region_select_in_interval__( region , ecl_kw , min_value , max_value , true ); } @@ -396,7 +443,7 @@ static void ecl_region_select_with_limit__( ecl_region_type * region , const ecl ecl_region_assert_kw( region , ecl_kw , &global_kw); if (!((ecl_type == ECL_FLOAT_TYPE) || (ecl_type == ECL_INT_TYPE) || (ecl_type == ECL_DOUBLE_TYPE))) util_abort("%s: sorry - select by in_interval is only supported for float and integer keywords \n",__func__); - + { if (ecl_type == ECL_FLOAT_TYPE) { const float * kw_data = ecl_kw_get_float_ptr( ecl_kw ); @@ -512,22 +559,22 @@ void ecl_region_deselect_larger( ecl_region_type * ecl_region , const ecl_kw_typ /*****************************************************************/ -/** - Selection based on comparing two keywords. +/** + Selection based on comparing two keywords. */ static void ecl_region_cmp_select__( ecl_region_type * region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2 , bool select_less , bool select) { bool global_kw; ecl_region_assert_kw( region , kw1 , &global_kw); - if (ecl_kw_get_type( kw1 ) != ECL_FLOAT_TYPE) + if (ecl_kw_get_type( kw1 ) != ECL_FLOAT_TYPE) util_abort("%s: sorry - select by cmp() is only supported for float keywords \n",__func__); { - if ((ecl_kw_get_size( kw1 ) == ecl_kw_get_size( kw2 )) && + if ((ecl_kw_get_size( kw1 ) == ecl_kw_get_size( kw2 )) && (ecl_kw_get_type( kw1 ) == ecl_kw_get_type( kw2 ))) { - + const float * kw1_data = ecl_kw_get_float_ptr( kw1 ); const float * kw2_data = ecl_kw_get_float_ptr( kw2 ); - + if (global_kw) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) { @@ -555,7 +602,7 @@ static void ecl_region_cmp_select__( ecl_region_type * region , const ecl_kw_typ } } } - } else + } else util_abort("%s: type/size mismatch between keywords. \n",__func__); } ecl_region_invalidate_index_list( region ); @@ -592,9 +639,9 @@ static void ecl_region_select_from_box__( ecl_region_type * region , const ecl_b const int * active_list = ecl_box_get_global_list( ecl_box ); int box_index; - for (box_index = 0; box_index < box_size; box_index++) + for (box_index = 0; box_index < box_size; box_index++) region->active_mask[ active_list[box_index] ] = select; - + ecl_region_invalidate_index_list( region ); } @@ -611,11 +658,11 @@ void ecl_region_deselect_from_box( ecl_region_type * region , const ecl_box_type /** Observe that: - + 1. All the indices are inclusive. 2. All the indices have zero offset. - Only a thin wrapper around the ecl_region_select_from_box() function. + Only a thin wrapper around the ecl_region_select_from_box() function. */ static void ecl_region_select_from_ijkbox__( ecl_region_type * region , int i1 , int i2 , int j1 , int j2 , int k1 , int k2 , bool select) { @@ -640,15 +687,15 @@ void ecl_region_deselect_from_ijkbox( ecl_region_type * region , int i1 , int i2 /** Observe that i1 and i2 are: - + * ZERO offset. * An inclusive interval : [i1,i2] - - Input values below zero or above the upper limit are truncated. + + Input values below zero or above the upper limit are truncated. */ static void ecl_region_select_i1i2__( ecl_region_type * region , int i1 , int i2 , bool select) { - if (i1 > i2) + if (i1 > i2) util_abort("%s: i1 > i2 - this is illogical ... \n",__func__); i1 = util_int_max(0 , i1); i2 = util_int_min(region->grid_nx - 1 , i2); @@ -679,15 +726,15 @@ void ecl_region_deselect_i1i2( ecl_region_type * region , int i1 , int i2) { /** Observe that j1 and j2 are: - + * ZERO offset. * An inclusive interval : [i1,i2] - - Input values below zero or above the upper limit are truncated. + + Input values below zero or above the upper limit are truncated. */ static void ecl_region_select_j1j2__( ecl_region_type * region , int j1 , int j2 , bool select) { - if (j1 > j2) + if (j1 > j2) util_abort("%s: i1 > i2 - this is illogical ... \n",__func__); j1 = util_int_max(0 , j1); @@ -719,15 +766,15 @@ void ecl_region_deselect_j1j2( ecl_region_type * region , int j1 , int j2) { /** Observe that k1 and k2 are: - + * ZERO offset. * An inclusive interval : [i1,i2] - - Input values below zero or above the upper limit are truncated. + + Input values below zero or above the upper limit are truncated. */ static void ecl_region_select_k1k2__( ecl_region_type * region , int k1 , int k2 , bool select) { - if (k1 > k2) + if (k1 > k2) util_abort("%s: i1 > i2 - this is illogical ... \n",__func__); k1 = util_int_max(0 , k1); k2 = util_int_min(region->grid_nz - 1 , k2); @@ -933,7 +980,7 @@ void ecl_region_deselect_global_index( ecl_region_type * region , int global_ind cylinder piercing the complete reservoir. Currently all user-exported functions call the - ecl_region_clyinder_select__() with select_inside == true. + ecl_region_clyinder_select__() with select_inside == true. */ static void ecl_region_cylinder_select__( ecl_region_type * region , double x0 , double y0, double R , double z1 , double z2 , bool select_inside , bool select) { @@ -946,7 +993,7 @@ static void ecl_region_cylinder_select__( ecl_region_type * region , double x0 , ecl_grid_get_xyz1( region->parent_grid , global_index , &x , &y , &z); if ((z >= z1) && (z <= z2)) { double pointR2 = (x - x0) * (x - x0) + (y - y0) * (y - y0); - if ((pointR2 < R2) && (select_inside)) + if ((pointR2 < R2) && (select_inside)) region->active_mask[ global_index ] = select; else if ((pointR2 > R2) && (!select_inside)) region->active_mask[ global_index ] = select; @@ -962,22 +1009,22 @@ static void ecl_region_cylinder_select__( ecl_region_type * region , double x0 , double x,y,z; ecl_grid_get_xyz3( region->parent_grid , i,j,0 , &x , &y , &z); { - double pointR2 = (x - x0) * (x - x0) + (y - y0) * (y - y0); - bool select_column = false; - - if ((pointR2 < R2) && (select_inside)) - select_column = true; - else if ((pointR2 > R2) && (!select_inside)) - select_column = true; - - if (select_column) { - int k; - for (k=0; k < nz; k++) { - int global_index = ecl_grid_get_global_index3( region->parent_grid , i,j,k); - region->active_mask[ global_index ] = select; + double pointR2 = (x - x0) * (x - x0) + (y - y0) * (y - y0); + bool select_column = false; + + if ((pointR2 < R2) && (select_inside)) + select_column = true; + else if ((pointR2 > R2) && (!select_inside)) + select_column = true; + + if (select_column) { + int k; + for (k=0; k < nz; k++) { + int global_index = ecl_grid_get_global_index3( region->parent_grid , i,j,k); + region->active_mask[ global_index ] = select; + } } } - } } } } @@ -1009,10 +1056,10 @@ void ecl_region_deselect_in_zcylinder( ecl_region_type * region , double x0 , do /** Select or deselect points based on their distance to the plane - specified by normal vector @n and point @p. + specified by normal vector @n and point @p. */ -static void ecl_region_plane_select__( ecl_region_type * region, const double n[3] , const double p[3], bool select_above , bool select){ +static void ecl_region_plane_select__( ecl_region_type * region, const double n[3] , const double p[3], bool select_above , bool select){ const double a = n[0]; const double b = n[1]; const double c = -n[2]; @@ -1062,7 +1109,7 @@ void ecl_region_deselect_below_plane( ecl_region_type * region, const double n[3 follows: 1. The defining polygon is layed out at the top of the reservoir. - + 2. The set {(i,j,0)} of cells in the top layer inside the polygon is selected by checking the polygon perimeter. @@ -1077,13 +1124,13 @@ void ecl_region_deselect_below_plane( ecl_region_type * region, const double n[3 */ -static void ecl_region_polygon_select__( ecl_region_type * region , - const geo_polygon_type * polygon , +static void ecl_region_polygon_select__( ecl_region_type * region , + const geo_polygon_type * polygon , bool select_inside , bool select) { const int define_k = 0; // The k-level where the polygon is checked. const int k1 = 0; // Selection range in k - const int k2 = region->grid_nz; + const int k2 = region->grid_nz; { int i,j; @@ -1092,10 +1139,10 @@ static void ecl_region_polygon_select__( ecl_region_type * region , double x,y,z; bool inside; int global_index = ecl_grid_get_global_index3( region->parent_grid , i , j , define_k); - + ecl_grid_get_xyz1( region->parent_grid , global_index , &x , &y , &z); inside = geo_polygon_contains_point( polygon , x , y ); - + if (select_inside == inside) { int k; for (k=k1; k < k2; k++) { @@ -1146,13 +1193,45 @@ void ecl_region_select_active_index( ecl_region_type * region , int active_index void ecl_region_deselect_active_index( ecl_region_type * region , int active_index) { ecl_region_select_active_index__( region , active_index , false ); } +/*****************************************************************/ +static void ecl_region_select_from_layer__( ecl_region_type * region , const layer_type * layer , int k , int layer_value, bool select) { + int_vector_type * i_list = int_vector_alloc(0,0); + int_vector_type * j_list = int_vector_alloc(0,0); + + layer_cells_equal(layer, layer_value, i_list , j_list); + { + const int * i = int_vector_get_ptr( i_list ); + const int * j = int_vector_get_ptr( j_list ); + + int index; + for (index = 0; index < int_vector_size( i_list ); index++) { + int global_index = ecl_grid_get_global_index3( region->parent_grid , i[index] , j[index] , k); + region->active_mask[ global_index ] = select; + } + + } + if (int_vector_size( i_list ) > 0) + ecl_region_invalidate_index_list( region ); + + int_vector_free( i_list ); + int_vector_free( j_list ); +} + + +void ecl_region_select_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value) { + ecl_region_select_from_layer__( region , layer , k , layer_value , true ); +} + +void ecl_region_deselect_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value) { + ecl_region_select_from_layer__( region , layer , k , layer_value , false ); +} /*****************************************************************/ static void ecl_region_select_all__( ecl_region_type * region , bool select) { int global_index; - for (global_index = 0; global_index < region->grid_vol; global_index++) + for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[ global_index ] = select; ecl_region_invalidate_index_list( region ); } @@ -1171,7 +1250,7 @@ void ecl_region_deselect_all( ecl_region_type * region ) { void ecl_region_invert_selection( ecl_region_type * region ) { int global_index; - for (global_index = 0; global_index < region->grid_vol; global_index++) + for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[ global_index ] = !region->active_mask[ global_index ]; ecl_region_invalidate_index_list( region ); } @@ -1209,7 +1288,7 @@ bool ecl_region_contains_active( const ecl_region_type * ecl_region , int active Will update the selection in @region to ONLY contain the elements which are also present in @new_region. Will FAIL hard if the two regions do not share the same grid instance (checked by pointer - equality). + equality). A &= B */ @@ -1217,9 +1296,9 @@ bool ecl_region_contains_active( const ecl_region_type * ecl_region , int active void ecl_region_intersection( ecl_region_type * region , const ecl_region_type * new_region ) { if (region->parent_grid == new_region->parent_grid) { int global_index; - for (global_index = 0; global_index < region->grid_vol; global_index++) + for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] = (region->active_mask[global_index] && new_region->active_mask[global_index]); - + ecl_region_invalidate_index_list( region ); } else util_abort("%s: The two regions do not share grid - aborting \n",__func__); @@ -1237,9 +1316,9 @@ void ecl_region_union( ecl_region_type * region , const ecl_region_type * new_re int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] = (region->active_mask[global_index] || new_region->active_mask[global_index]); - + ecl_region_invalidate_index_list( region ); - } else + } else util_abort("%s: The two regions do not share grid - aborting \n",__func__); } @@ -1255,9 +1334,9 @@ void ecl_region_subtract( ecl_region_type * region , const ecl_region_type * new int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] &= !new_region->active_mask[global_index]; - + ecl_region_invalidate_index_list( region ); - } else + } else util_abort("%s: The two regions do not share grid - aborting \n",__func__); } @@ -1266,16 +1345,16 @@ void ecl_region_subtract( ecl_region_type * region , const ecl_region_type * new Will update the selection in @region to seselect the elements which are either in region or new_region: - A ^= B + A ^= B */ void ecl_region_xor( ecl_region_type * region , const ecl_region_type * new_region) { if (region->parent_grid == new_region->parent_grid) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] ^= !new_region->active_mask[global_index]; - + ecl_region_invalidate_index_list( region ); - } else + } else util_abort("%s: The two regions do not share grid - aborting \n",__func__); } @@ -1289,16 +1368,16 @@ const int_vector_type * ecl_region_get_kw_index_list( ecl_region_type * ecl_regi int grid_active = ecl_grid_get_active_size( ecl_region->parent_grid ); int grid_global = ecl_grid_get_global_size( ecl_region->parent_grid ); - if (kw_size == grid_active) + if (kw_size == grid_active) index_set = ecl_region_get_active_list( ecl_region ); else if (kw_size == grid_global) { if (force_active) index_set = ecl_region_get_global_active_list( ecl_region ); else index_set = ecl_region_get_global_list( ecl_region ); - } else - util_abort("%s: size mismatch: grid_active:%d grid_global:%d kw_size:%d \n",__func__ , grid_active , grid_global , kw_size); - + } else + util_abort("%s: size mismatch: grid_active:%d grid_global:%d kw_size:%d \n",__func__ , grid_active , grid_global , kw_size); + return index_set; } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rft_file.c b/ThirdParty/Ert/devel/libecl/src/ecl_rft_file.c index f06f9d00c2..c079c2e08b 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_rft_file.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rft_file.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_rft_file.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rft_file.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <string.h> @@ -46,9 +46,9 @@ All of this is just lumped together in one long vector, both in the file, and in this implementation. The data for one specific RFT - (one well, one time) is internalized in the ecl_rft_node type. + (one well, one time) is internalized in the ecl_rft_node type. */ - + #define ECL_RFT_FILE_ID 6610632 @@ -73,7 +73,7 @@ static ecl_rft_file_type * ecl_rft_file_alloc_empty(const char * filename) { /** Generating the two functions: - + bool ecl_rft_file_is_instance( void * ); ecl_rft_file_type * ecl_rft_file_safe_cast( void * ); */ @@ -94,25 +94,25 @@ ecl_rft_file_type * ecl_rft_file_alloc(const char * filename) { ecl_file_type * ecl_file = ecl_file_open( filename , 0); int global_index = 0; int block_nr = 0; - + while (true) { if (ecl_file_select_block( ecl_file , TIME_KW , block_nr)) { ecl_rft_node_type * rft_node = ecl_rft_node_alloc( ecl_file ); - if (rft_node != NULL) { + if (rft_node != NULL) { const char * well_name = ecl_rft_node_get_well_name( rft_node ); ecl_rft_file_add_node(rft_vector , rft_node); - if (!hash_has_key( rft_vector->well_index , well_name)) + if (!hash_has_key( rft_vector->well_index , well_name)) hash_insert_hash_owned_ref( rft_vector->well_index , well_name , int_vector_alloc( 0 , 0 ) , int_vector_free__); { int_vector_type * index_list = hash_get( rft_vector->well_index , well_name ); int_vector_append(index_list , global_index); - } + } global_index++; - } + } } else break; block_nr++; - } + } ecl_file_close( ecl_file ); return rft_vector; } @@ -123,7 +123,7 @@ ecl_rft_file_type * ecl_rft_file_alloc(const char * filename) { ecl_grid_load_case(). Will return NULL if no RFT file can be found, and the name of RFT file if it is found. New storage is allocated for the new name. - + */ char * ecl_rft_file_alloc_case_filename(const char * case_input ) { @@ -140,20 +140,20 @@ char * ecl_rft_file_alloc_case_filename(const char * case_input ) { if ((file_type == ECL_OTHER_FILE) || (file_type == ECL_DATA_FILE)) { /* Impossible to infer formatted/unformatted from the case_input */ char * RFT_file = ecl_util_alloc_filename( path , basename , ECL_RFT_FILE , false , -1 ); char * FRFT_file = ecl_util_alloc_filename( path , basename , ECL_RFT_FILE , true , -1 ); - + if (util_file_exists( RFT_file )) return_file = util_alloc_string_copy( RFT_file ); else if (util_file_exists( FRFT_file )) return_file = util_alloc_string_copy( FRFT_file ); - + free( RFT_file ); free( FRFT_file ); } else { char * RFT_file = ecl_util_alloc_filename( path , basename , ECL_RFT_FILE , fmt_file , -1 ); - + if (util_file_exists( RFT_file )) return_file = util_alloc_string_copy( RFT_file ); - + free( RFT_file ); } return return_file; @@ -183,7 +183,7 @@ bool ecl_rft_file_case_has_rft( const char * case_input ) { has_rft = true; free( file_name ); } - + return has_rft; } @@ -202,7 +202,7 @@ void ecl_rft_file_free__(void * arg) { } -/** +/** Will return the number of RFT nodes in the file. If @well != NULL only wells matching @well be included. The @well variable can contain '*', so the function call @@ -210,7 +210,7 @@ void ecl_rft_file_free__(void * arg) { ecl_rft_file_get_size__( rft_file , "OP*" , -1) will count the number of rft instances with a well name matching - well "OP*". + well "OP*". If recording_time >= only rft_nodes with recording time == @recording_time are included. @@ -262,7 +262,7 @@ const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) { /** Return rft_node number 'i' in the rft_file - not caring when this - particular RFT is from, or which well it is. + particular RFT is from, or which well it is. If you ask for an index which is beyond the size of the vector it will go up in flames - use ecl_file_get_size() first if you can not @@ -286,9 +286,9 @@ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , RFT - Well P1: 01/01/2002 RFT - Well P2: 01/01/2002 - The function call: + The function call: - ecl_rft_iget_well_rft(rft_file , "P2" , 1) + ecl_rft_iget_well_rft(rft_file , "P2" , 1) will return the rft node indicated by the arrow (i.e. the second occurence of well "P2" in the file.) @@ -307,6 +307,29 @@ ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_fi } +static int ecl_rft_file_get_node_index_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) { + int global_index = -1; + if (hash_has_key( rft_file->well_index , well)) { + const int_vector_type * index_vector = hash_get(rft_file->well_index , well); + int well_index = 0; + while (true) { + if (well_index == int_vector_size( index_vector )) + break; + + { + const ecl_rft_node_type * node = ecl_rft_file_iget_node( rft_file , int_vector_iget( index_vector , well_index )); + if (ecl_rft_node_get_date( node ) == recording_time) { + global_index = int_vector_iget( index_vector , well_index ); + break; + } + } + + well_index++; + } + } + return global_index; +} + /** Returns an rft_node for well 'well' and time 'recording_time'. If @@ -316,28 +339,17 @@ ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_fi ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) { - ecl_rft_node_type * node = NULL; - if (hash_has_key( rft_file->well_index , well)) { - const int_vector_type * index_vector = hash_get(rft_file->well_index , well); - int index = 0; - while (true) { - if (index == int_vector_size( index_vector )) - break; - - node = ecl_rft_file_iget_node( rft_file , int_vector_iget( index_vector , index )); - if (ecl_rft_node_get_date( node ) == recording_time) - break; - else { - node = NULL; - index++; - } - - } + int index = ecl_rft_file_get_node_index_time_rft(rft_file, well, recording_time); + if (index !=-1) { + return ecl_rft_file_iget_node(rft_file, index); + } else{ + return NULL; } - return node; } + + bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * well) { return hash_has_key(rft_file->well_index , well); } @@ -353,7 +365,7 @@ int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const } -/** +/** Returns the number of distinct wells in RFT file. */ int ecl_rft_file_get_num_wells( const ecl_rft_file_type * rft_file ) { @@ -368,5 +380,55 @@ stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_fil +void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes,int num_nodes, ert_ecl_unit_enum unit_set){ + ecl_rft_file_type * rft_file; + + if(util_file_exists(rft_file_name)){ + int node_index; + rft_file = ecl_rft_file_alloc( rft_file_name ); + for(node_index = 0; node_index < num_nodes; node_index++) { + ecl_rft_node_type * new_node = nodes[node_index]; + int storage_index = ecl_rft_file_get_node_index_time_rft(rft_file, ecl_rft_node_get_well_name(new_node), ecl_rft_node_get_date(new_node)); + if (storage_index == -1) { + ecl_rft_file_add_node(rft_file, new_node); + } else { + vector_iset_owned_ref(rft_file->data, storage_index, new_node,ecl_rft_node_free__); + } + } + }else{ + int node_index; + rft_file = ecl_rft_file_alloc_empty( rft_file_name ); + for(node_index = 0; node_index < num_nodes; node_index++) { + ecl_rft_file_add_node(rft_file, nodes[node_index]); + } + } + + { + bool fmt_file = false; + fortio_type * fortio = fortio_open_writer( rft_file_name , fmt_file , ECL_ENDIAN_FLIP ); + int node_index; + + /** + The sorting here works directly on the internal node storage + rft_file->data; that might in principle ruin the indexing of + the ecl_file object - it is therefor absolutely essential + that this ecl_rft_file object does not live beyond this + function, and also that the ecl_rft_file api functions are + avoided for the rest of this function. + */ + + vector_sort(rft_file->data,(vector_cmp_ftype *) ecl_rft_node_cmp); + for(node_index=0; node_index < vector_get_size( rft_file->data ); node_index++) { + const ecl_rft_node_type *new_node = vector_iget_const(rft_file->data, node_index); + ecl_rft_node_fwrite(new_node, fortio, unit_set); + } + + fortio_fclose( fortio ); + } + ecl_rft_file_free(rft_file); +} + + + diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rft_node.c b/ThirdParty/Ert/devel/libecl/src/ecl_rft_node.c index c04d4f2e7b..8f81f28dad 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_rft_node.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rft_node.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_rft_node.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rft_node.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <math.h> @@ -34,13 +34,14 @@ #include <ert/ecl/ecl_rft_node.h> #include <ert/ecl/ecl_rft_cell.h> -/** + +/** The RFT's from several wells, and possibly also several timesteps are lumped togeheter in one .RFT file. The ecl_rft_node implemented in this file contains the information for one - well/report step. + well/report step. */ - + /* @@ -57,13 +58,13 @@ struct ecl_rft_node_struct { char * well_name; /* Name of the well. */ ecl_rft_enum data_type; /* What type of data: RFT|PLT|SEGMENT */ - time_t recording_date; /* When was the RFT recorded - date.*/ + time_t recording_date; /* When was the RFT recorded - date.*/ double days; /* When was the RFT recorded - days after simulaton start. */ bool MSW; - - bool sort_perm_in_sync ; + + bool sort_perm_in_sync ; int_vector_type * sort_perm; - vector_type *cells; + vector_type *cells; }; @@ -72,20 +73,39 @@ struct ecl_rft_node_struct { Will return NULL if the data_type_string is equal to "SEGMENT" - that is not (yet) supported. */ +static ecl_rft_enum translate_from_sting_to_ecl_rft_enum(const char * data_type_string){ + ecl_rft_enum data_type = SEGMENT; + /* According to the ECLIPSE documentaton. */ + if (strchr(data_type_string , 'P') != NULL) + data_type = PLT; + else if (strchr(data_type_string, 'R') != NULL) + data_type = RFT; + else if (strchr(data_type_string , 'S') != NULL) + data_type = SEGMENT; + else + util_abort("%s: Could not determine type of RFT/PLT/SEGMENT data - aborting\n",__func__); + + return data_type; +} + +ecl_rft_node_type * ecl_rft_node_alloc_new(const char * well_name, const char * data_type_string, const time_t recording_date, const double days){ + ecl_rft_enum data_type = translate_from_sting_to_ecl_rft_enum(data_type_string); + ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node ); + UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); + rft_node->well_name = util_alloc_string_copy(well_name); + rft_node->cells = vector_alloc_new(); + rft_node->recording_date = recording_date; + rft_node->days = days; + rft_node->data_type = data_type; + rft_node->sort_perm = NULL; + rft_node->sort_perm_in_sync = false; + + return rft_node; +} + static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_string) { - ecl_rft_enum data_type = SEGMENT; - - /* According to the ECLIPSE documentaton. */ - if (strchr(data_type_string , 'P') != NULL) - data_type = PLT; - else if (strchr(data_type_string, 'R') != NULL) - data_type = RFT; - else if (strchr(data_type_string , 'S') != NULL) - data_type = SEGMENT; - else - util_abort("%s: Could not determine type of RFT/PLT/SEGMENT data - aborting\n",__func__); - + ecl_rft_enum data_type = translate_from_sting_to_ecl_rft_enum(data_type_string); /* Can return NULL */ if (data_type == SEGMENT) { @@ -96,12 +116,12 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_strin { ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node ); UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); - + rft_node->cells = vector_alloc_new(); rft_node->data_type = data_type; rft_node->sort_perm = NULL; rft_node->sort_perm_in_sync = false; - + return rft_node; } } @@ -111,7 +131,7 @@ UTIL_SAFE_CAST_FUNCTION( ecl_rft_node , ECL_RFT_NODE_ID ); UTIL_IS_INSTANCE_FUNCTION( ecl_rft_node , ECL_RFT_NODE_ID ); -static void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell) { +void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell) { vector_append_owned_ref( rft_node->cells , cell , ecl_rft_cell_free__ ); rft_node->sort_perm_in_sync = false; } @@ -134,35 +154,35 @@ static void ecl_rft_node_init_RFT_cells( ecl_rft_node_type * rft_node , const ec const int * i = ecl_kw_get_int_ptr( conipos ); const int * j = ecl_kw_get_int_ptr( conjpos ); const int * k = ecl_kw_get_int_ptr( conkpos ); - + { int c; for (c = 0; c < ecl_kw_get_size( conipos ); c++) { /* The connection coordinates are shifted -= 1; i.e. all internal usage is offset 0. */ - ecl_rft_cell_type * cell = ecl_rft_cell_alloc_RFT( i[c] - 1 , j[c] - 1 , k[c] - 1 , + ecl_rft_cell_type * cell = ecl_rft_cell_alloc_RFT( i[c] - 1 , j[c] - 1 , k[c] - 1 , depth[c] , P[c] , SW[c] , SG[c]); ecl_rft_node_append_cell( rft_node , cell ); } } } - - + + static void ecl_rft_node_init_PLT_cells( ecl_rft_node_type * rft_node , const ecl_file_type * rft) { /* For PLT there is quite a lot of extra information which is not yet internalized. */ const ecl_kw_type * conipos = ecl_file_iget_named_kw( rft , CONIPOS_KW , 0); const ecl_kw_type * conjpos = ecl_file_iget_named_kw( rft , CONJPOS_KW , 0); - const ecl_kw_type * conkpos = ecl_file_iget_named_kw( rft , CONKPOS_KW , 0); + const ecl_kw_type * conkpos = ecl_file_iget_named_kw( rft , CONKPOS_KW , 0); const int * i = ecl_kw_get_int_ptr( conipos ); const int * j = ecl_kw_get_int_ptr( conjpos ); const int * k = ecl_kw_get_int_ptr( conkpos ); - + const float * WR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONWRAT_KW , 0)); - const float * GR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGRAT_KW , 0)); - const float * OR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONORAT_KW , 0)); + const float * GR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGRAT_KW , 0)); + const float * OR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONORAT_KW , 0)); const float * P = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONPRES_KW , 0)); const float * depth = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONDEPTH_KW , 0)); const float * flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONVTUB_KW , 0)); @@ -170,12 +190,12 @@ static void ecl_rft_node_init_PLT_cells( ecl_rft_node_type * rft_node , const ec const float * gas_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGTUB_KW , 0)); const float * water_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONWTUB_KW , 0)); const float * connection_start = NULL; - const float * connection_end = NULL; + const float * connection_end = NULL; /* The keywords CONLENST_KW and CONLENEN_KW are ONLY present if we are dealing with a MSW well. */ if (ecl_file_has_kw( rft , CONLENST_KW)) connection_start = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONLENST_KW , 0)); - + if (ecl_file_has_kw( rft , CONLENEN_KW)) connection_end = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONLENEN_KW , 0)); @@ -185,15 +205,15 @@ static void ecl_rft_node_init_PLT_cells( ecl_rft_node_type * rft_node , const ec ecl_rft_cell_type * cell; double cs = 0; double ce = 0; - + if (connection_start) cs = connection_start[c]; - + if (connection_end) ce = connection_end[c]; /* The connection coordinates are shifted -= 1; i.e. all internal usage is offset 0. */ - cell = ecl_rft_cell_alloc_PLT( i[c] -1 , j[c] -1 , k[c] -1 , + cell = ecl_rft_cell_alloc_PLT( i[c] -1 , j[c] -1 , k[c] -1 , depth[c] , P[c] , OR[c] , GR[c] , WR[c] , cs , ce, flowrate[c] , oil_flowrate[c] , gas_flowrate[c] , water_flowrate[c]); ecl_rft_node_append_cell( rft_node , cell ); } @@ -210,18 +230,18 @@ static void ecl_rft_node_init_cells( ecl_rft_node_type * rft_node , const ecl_fi ecl_rft_node_init_RFT_cells( rft_node , rft ); else if (rft_node->data_type == PLT) ecl_rft_node_init_PLT_cells( rft_node , rft ); - + } ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * rft) { ecl_kw_type * welletc = ecl_file_iget_named_kw(rft , WELLETC_KW , 0); ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty(ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX)); - + if (rft_node != NULL) { ecl_kw_type * date_kw = ecl_file_iget_named_kw( rft , DATE_KW , 0); rft_node->well_name = util_alloc_strip_copy( ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX)); - + /* Time information. */ { int * time = ecl_kw_get_int_ptr( date_kw ); @@ -238,9 +258,9 @@ ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * rft) { return rft_node; } - -const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * rft_node) { - return rft_node->well_name; + +const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * rft_node) { + return rft_node->well_name; } @@ -279,7 +299,7 @@ const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_ static void ecl_rft_node_create_sort_perm( ecl_rft_node_type * rft_node ) { if (rft_node->sort_perm) int_vector_free( rft_node->sort_perm ); - + rft_node->sort_perm = vector_alloc_sort_perm( rft_node->cells , ecl_rft_cell_cmp__ ); rft_node->sort_perm_in_sync = true; } @@ -295,7 +315,7 @@ const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft else { if (!rft_node->sort_perm_in_sync) ecl_rft_node_create_sort_perm( rft_node ); - + return vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index )); } } @@ -317,20 +337,20 @@ double ecl_rft_node_iget_pressure( const ecl_rft_node_type * rft_node , int inde void ecl_rft_node_iget_ijk( const ecl_rft_node_type * rft_node , int index , int *i , int *j , int *k) { const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index ); - + ecl_rft_cell_get_ijk( cell , i,j,k); } -const ecl_rft_cell_type * ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k) { - int index = 0; +const ecl_rft_cell_type * ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k) { + int index = 0; int size = ecl_rft_node_get_size( rft_node ); while (true) { const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index ); - + if (ecl_rft_cell_ijk_equal( cell , i , j , k )) return cell; - + index++; if (index == size) /* Could not find it. */ return NULL; @@ -364,6 +384,9 @@ double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index) { } } +double ecl_rft_node_get_days(const ecl_rft_node_type * rft_node ){ + return rft_node->days; +} double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); @@ -429,4 +452,155 @@ bool ecl_rft_node_is_RFT( const ecl_rft_node_type * rft_node ) { return false; } +static void ecl_rft_node_fill_welletc(ecl_kw_type * welletc, ert_ecl_unit_enum unit_set){ + if(unit_set==ERT_ECL_METRIC_UNITS) { + ecl_kw_iset_string8(welletc, 0, " DAYS"); + ecl_kw_iset_string8(welletc, 2, ""); + ecl_kw_iset_string8(welletc, 3, " METRES"); + ecl_kw_iset_string8(welletc, 4, " BARSA"); + ecl_kw_iset_string8(welletc, 6, "STANDARD"); + ecl_kw_iset_string8(welletc, 7, " SM3/DAY"); + ecl_kw_iset_string8(welletc, 8, " SM3/DAY"); + ecl_kw_iset_string8(welletc, 9, " RM3/DAY"); + ecl_kw_iset_string8(welletc, 10, " M/SEC"); + ecl_kw_iset_string8(welletc, 11, ""); + ecl_kw_iset_string8(welletc, 12, " CP"); + ecl_kw_iset_string8(welletc, 13, " KG/SM3"); + ecl_kw_iset_string8(welletc, 14, " KG/DAY"); + ecl_kw_iset_string8(welletc, 15, " KG/KG"); + }else if(unit_set==ERT_ECL_FIELD_UNITS){ + ecl_kw_iset_string8(welletc, 0, " DAYS"); + ecl_kw_iset_string8(welletc, 2, ""); + ecl_kw_iset_string8(welletc, 3, " FEET"); + ecl_kw_iset_string8(welletc, 4, " PISA"); + ecl_kw_iset_string8(welletc, 6, "STANDARD"); + ecl_kw_iset_string8(welletc, 7, " STB/DAY"); + ecl_kw_iset_string8(welletc, 8, " MSCF/DAY"); + ecl_kw_iset_string8(welletc, 9, " RB/DAY"); + ecl_kw_iset_string8(welletc, 10, " FT/SEC"); + ecl_kw_iset_string8(welletc, 11, ""); + ecl_kw_iset_string8(welletc, 12, " CP"); + ecl_kw_iset_string8(welletc, 13, " LB/STB"); + ecl_kw_iset_string8(welletc, 14, " LB/DAY"); + ecl_kw_iset_string8(welletc, 15, " LB/LB"); + + }else if(unit_set==ERT_ECL_LAB_UNITS){ + ecl_kw_iset_string8(welletc, 0, " HR"); + ecl_kw_iset_string8(welletc, 2, ""); + ecl_kw_iset_string8(welletc, 3, " CM"); + ecl_kw_iset_string8(welletc, 4, " ATMA"); + ecl_kw_iset_string8(welletc, 6, "STANDARD"); + ecl_kw_iset_string8(welletc, 7, " SCC/HR"); + ecl_kw_iset_string8(welletc, 8, " SCC/HR"); + ecl_kw_iset_string8(welletc, 9, " RCC/SCC"); + ecl_kw_iset_string8(welletc, 10, " CM/SEC"); + ecl_kw_iset_string8(welletc, 11, ""); + ecl_kw_iset_string8(welletc, 12, " CP"); + ecl_kw_iset_string8(welletc, 13, " GM/SCC"); + ecl_kw_iset_string8(welletc, 14, " GH/HR"); + ecl_kw_iset_string8(welletc, 15, " GM/GM"); + } + + +} + +void ecl_rft_node_fwrite(const ecl_rft_node_type * rft_node, fortio_type * fortio, ert_ecl_unit_enum unit_set){ + ecl_rft_enum type = ecl_rft_node_get_type(rft_node); + if (type != RFT) + util_abort("%s: sorry - only writing of simple RFT is currently implemented",__func__); + + { + ecl_kw_type * time = ecl_kw_alloc(TIME_KW, 1, ECL_FLOAT_TYPE); + ecl_kw_iset_float(time, 0, ecl_rft_node_get_days(rft_node)); + ecl_kw_fwrite(time, fortio); + ecl_kw_free(time); + } + + { + ecl_kw_type * datevalue = ecl_kw_alloc(DATE_KW, 3, ECL_INT_TYPE); + time_t date = ecl_rft_node_get_date(rft_node); + int day; + int month; + int year; + ecl_util_set_date_values(date , &day , &month , &year); + ecl_kw_iset_int(datevalue, 0, day); + ecl_kw_iset_int(datevalue, 1, month); + ecl_kw_iset_int(datevalue, 2, year); + ecl_kw_fwrite(datevalue, fortio); + ecl_kw_free(datevalue); + } + + { + ecl_kw_type * welletc = ecl_kw_alloc(WELLETC_KW, 16, ECL_CHAR_TYPE); + ecl_rft_enum type = ecl_rft_node_get_type(rft_node); + + ecl_kw_iset_string8(welletc, 1, ecl_rft_node_get_well_name(rft_node)); + + if(type == PLT) { + ecl_kw_iset_string8(welletc, 5, "P"); + }else if(type == RFT){ + ecl_kw_iset_string8(welletc, 5, "R"); + }else if(type == SEGMENT){ + ecl_kw_iset_string8(welletc, 5, "S"); + } + ecl_rft_node_fill_welletc(welletc, unit_set); + ecl_kw_fwrite(welletc, fortio); + ecl_kw_free(welletc); + } + + { + int size_cells = ecl_rft_node_get_size(rft_node); + ecl_kw_type * conipos = ecl_kw_alloc(CONIPOS_KW, size_cells, ECL_INT_TYPE); + ecl_kw_type * conjpos = ecl_kw_alloc(CONJPOS_KW, size_cells, ECL_INT_TYPE); + ecl_kw_type * conkpos = ecl_kw_alloc(CONKPOS_KW, size_cells, ECL_INT_TYPE); + ecl_kw_type * hostgrid = ecl_kw_alloc(HOSTGRID_KW, size_cells, ECL_CHAR_TYPE); + ecl_kw_type * depth = ecl_kw_alloc(DEPTH_KW, size_cells, ECL_FLOAT_TYPE); + ecl_kw_type * pressure = ecl_kw_alloc(PRESSURE_KW, size_cells, ECL_FLOAT_TYPE); + ecl_kw_type * swat = ecl_kw_alloc(SWAT_KW, size_cells, ECL_FLOAT_TYPE); + ecl_kw_type * sgas = ecl_kw_alloc(SGAS_KW, size_cells, ECL_FLOAT_TYPE); + int i; + + for(i =0;i<size_cells;i++){ + const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , i); + ecl_kw_iset_int(conipos, i, ecl_rft_cell_get_i(cell)+1); + ecl_kw_iset_int(conjpos, i, ecl_rft_cell_get_j(cell)+1); + ecl_kw_iset_int(conkpos, i, ecl_rft_cell_get_k(cell)+1); + ecl_kw_iset_float(depth, i, ecl_rft_cell_get_depth(cell)); + ecl_kw_iset_float(pressure, i, ecl_rft_cell_get_pressure(cell)); + ecl_kw_iset_float(swat, i, ecl_rft_cell_get_swat(cell)); + ecl_kw_iset_float(sgas, i, ecl_rft_cell_get_sgas(cell)); + } + ecl_kw_fwrite(conipos, fortio); + ecl_kw_fwrite(conjpos, fortio); + ecl_kw_fwrite(conkpos, fortio); + ecl_kw_fwrite(hostgrid, fortio); + ecl_kw_fwrite(depth, fortio); + ecl_kw_fwrite(pressure, fortio); + ecl_kw_fwrite(swat, fortio); + ecl_kw_fwrite(sgas, fortio); + + ecl_kw_free(conipos); + ecl_kw_free(conjpos); + ecl_kw_free(conkpos); + ecl_kw_free(hostgrid); + ecl_kw_free(depth); + ecl_kw_free(pressure); + ecl_kw_free(swat); + ecl_kw_free(sgas); + } +} + +int ecl_rft_node_cmp( const ecl_rft_node_type * n1 , const ecl_rft_node_type * n2) { + time_t val1 = ecl_rft_node_get_date(n1); + time_t val2 = ecl_rft_node_get_date(n2); + + if (val1 < val2) + return -1; + else if (val1 == val2) + return 0; + else + return 1; + +} + diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c b/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c index 98e6e4506f..2abeac7af1 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c @@ -35,13 +35,15 @@ #include <ert/ecl/ecl_kw_magic.h> #include <ert/ecl/ecl_file_kw.h> #include <ert/ecl/ecl_rst_file.h> +#include <ert/ecl/ecl_rsthead.h> struct ecl_rst_file_struct { fortio_type * fortio; bool unified; bool fmt_file; }; - + + static ecl_rst_file_type * ecl_rst_file_alloc( const char * filename ) { bool unified = ecl_util_unified_file( filename ); @@ -112,46 +114,42 @@ void ecl_rst_file_end_solution( ecl_rst_file_type * rst_file ) { -static ecl_kw_type * ecl_rst_file_alloc_INTEHEAD( ecl_rst_file_type * rst_file , time_t date , int nx , int ny , int nz , int nactive , int phases, int simulator ) { +static ecl_kw_type * ecl_rst_file_alloc_INTEHEAD( ecl_rst_file_type * rst_file, + ecl_rsthead_type * rsthead, + int simulator ) { ecl_kw_type * intehead_kw = ecl_kw_alloc( INTEHEAD_KW , INTEHEAD_RESTART_SIZE , ECL_INT_TYPE ); ecl_kw_scalar_set_int( intehead_kw , 0 ); ecl_kw_iset_int( intehead_kw , INTEHEAD_UNIT_INDEX , INTEHEAD_METRIC_VALUE ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NX_INDEX , nx); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NY_INDEX , ny); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NZ_INDEX , nz); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NACTIVE_INDEX , nactive); - ecl_kw_iset_int( intehead_kw , INTEHEAD_PHASE_INDEX , phases ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NX_INDEX , rsthead->nx); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NY_INDEX , rsthead->ny); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NZ_INDEX , rsthead->nz); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NACTIVE_INDEX , rsthead->nactive); + ecl_kw_iset_int( intehead_kw , INTEHEAD_PHASE_INDEX , rsthead->phase_sum ); /* All well properties are hardcoded to zero. */ { - int NIWELZ = 0; int NGMAXZ = 0; int NWGMAX = 0; - int NWELLS = 0; - int NCWMAX = 0; - int NZWELZ = 0; - int NICONZ = 0; int NIGRPZ = 0; int NSWLMX = 0; int NSEGMX = 0; int NISEGZ = 0; - ecl_kw_iset_int( intehead_kw , INTEHEAD_NWELLS_INDEX , NWELLS ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NCWMAX_INDEX , NCWMAX ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NWELLS_INDEX , rsthead->nwells ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NCWMAX_INDEX , rsthead->ncwmax ); ecl_kw_iset_int( intehead_kw , INTEHEAD_NWGMAX_INDEX , NWGMAX ); ecl_kw_iset_int( intehead_kw , INTEHEAD_NGMAXZ_INDEX , NGMAXZ ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NIWELZ_INDEX , NIWELZ ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NZWELZ_INDEX , NZWELZ ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_NICONZ_INDEX , NICONZ ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NIWELZ_INDEX , rsthead->niwelz ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NZWELZ_INDEX , rsthead->nzwelz ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_NICONZ_INDEX , rsthead->niconz ); ecl_kw_iset_int( intehead_kw , INTEHEAD_NIGRPZ_INDEX , NIGRPZ ); { - int mday,month,year; - util_set_date_values( date , &mday , &month , &year ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_DAY_INDEX , mday ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_MONTH_INDEX , month ); - ecl_kw_iset_int( intehead_kw , INTEHEAD_YEAR_INDEX , year ); + util_set_date_values( rsthead->sim_time , &rsthead->day , &rsthead->month , &rsthead->year ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_DAY_INDEX , rsthead->day ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_MONTH_INDEX , rsthead->month ); + ecl_kw_iset_int( intehead_kw , INTEHEAD_YEAR_INDEX , rsthead->year ); } ecl_kw_iset_int( intehead_kw , INTEHEAD_IPROG_INDEX , simulator); @@ -195,12 +193,15 @@ static ecl_kw_type * ecl_rst_file_alloc_DOUBHEAD( ecl_rst_file_type * rst_file , -void ecl_rst_file_fwrite_header( ecl_rst_file_type * rst_file , int seqnum , time_t date , double days , int nx , int ny ,int nz , int nactive , int phases) { +void ecl_rst_file_fwrite_header( ecl_rst_file_type * rst_file , + int seqnum , + ecl_rsthead_type * rsthead_data ) { + if (rst_file->unified) ecl_rst_file_fwrite_SEQNUM( rst_file , seqnum ); { - ecl_kw_type * intehead_kw = ecl_rst_file_alloc_INTEHEAD( rst_file , date , nx , ny , nz , nactive , phases , INTEHEAD_ECLIPSE100_VALUE); + ecl_kw_type * intehead_kw = ecl_rst_file_alloc_INTEHEAD( rst_file , rsthead_data , INTEHEAD_ECLIPSE100_VALUE); ecl_kw_fwrite( intehead_kw , rst_file->fortio ); ecl_kw_free( intehead_kw ); } @@ -213,14 +214,14 @@ void ecl_rst_file_fwrite_header( ecl_rst_file_type * rst_file , int seqnum , tim { - ecl_kw_type * doubhead_kw = ecl_rst_file_alloc_DOUBHEAD( rst_file , days ); + ecl_kw_type * doubhead_kw = ecl_rst_file_alloc_DOUBHEAD( rst_file , rsthead_data->sim_days ); ecl_kw_fwrite( doubhead_kw , rst_file->fortio ); ecl_kw_free( doubhead_kw ); } } - void ecl_rst_file_add_kw(ecl_rst_file_type * rst_file , const ecl_kw_type * ecl_kw ) { ecl_kw_fwrite( ecl_kw , rst_file->fortio ); } + diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c b/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c index 3f5d3596e5..c2500fc25e 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_rstfile.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rstfile.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /*****************************************************************/ @@ -24,10 +24,10 @@ /* This file is included from the ecl_file.c file with a #include statement, i.e. it is the same compilation unit as ecl_file. The - separation is only to increase readability. + separation is only to increase readability. */ -/* +/* There is no special datastructure for working with restart files, they are 100% stock ecl_file instances with the following limited structure: @@ -61,12 +61,12 @@ keyword, the value in [] corresponds to the relevant part of the content of the keyword on the line, the labels A,B,C,D,E are used for references in the text below. - 0 | SEQNUM [0] \ A + 0 | SEQNUM [0] \ A 1 | INTEHEAD [01.01.2005] | - 2 | PRESSURE [... ] | - 3 | SWAT [...] | + 2 | PRESSURE [... ] | + 3 | SWAT [...] | | -----------------------+ - 4 | SEQNUM [5] | B + 4 | SEQNUM [5] | B 5 | INTEHEAD [01.06.2005] | 6 | PRESSURE [... ] | 7 | SWAT [...] | @@ -86,7 +86,7 @@ references in the text below. 13 | INTEHEAD [01.12.2009] | 14 | PRESSURE [...] | 15 | SWAT [...] / - + This restart file has the following features: @@ -98,7 +98,7 @@ This restart file has the following features: datafile. Observe that the file does not have the block structure visualized on this figure, the only thing separating the blocks in the file is the occurence of a SEQNUM keyword. - + o Only a few of the report steps are present, namely 0, 5, 10, 20 and 40. @@ -124,7 +124,7 @@ we have introduced the following concepts: the DAY, MONTH and YEAR values from an INTEHEAD keyword instance and convert to a time_t instance. The functions: - ecl_file_get_unrstmap_sim_time() and ecl_file_has_has_sim_time() + ecl_file_get_unrstmap_sim_time() and ecl_file_has_has_sim_time() can be used to query for simulation times and get the corresponding block maps. @@ -160,8 +160,8 @@ static time_t file_map_iget_restart_sim_date(const file_map_type * file_map , in ecl_kw_type * intehead_kw = file_map_iget_named_kw( seqnum_map , INTEHEAD_KW , 0); sim_time = ecl_rsthead_date( intehead_kw ); file_map_free( seqnum_map ); - } - + } + return sim_time; } @@ -174,8 +174,8 @@ static double file_map_iget_restart_sim_days(const file_map_type * file_map , in ecl_kw_type * doubhead_kw = file_map_iget_named_kw( seqnum_map , DOUBHEAD_KW , 0); sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX); file_map_free( seqnum_map ); - } - + } + return sim_days; } @@ -232,13 +232,13 @@ static int file_map_find_sim_time(const file_map_type * file_map , time_t sim_ti If the sim_time can not be found the function will return -1, that includes the case when the file in question is not a restart file at all, and no INTEHEAD headers can be found. - + Observe that the function requires on-the-second-equality; which is of course quite strict. Each report step only has one occurence of SEQNUM, but one INTEHEAD for each LGR; i.e. one should call iselect_rstblock() prior to - calling this function. + calling this function. */ @@ -255,13 +255,13 @@ static bool file_map_has_sim_time( const file_map_type * file_map , time_t sim_t int intehead_index = 0; while (true) { time_t itime = file_map_iget_restart_sim_date( file_map , intehead_index ); - + if (itime == sim_time) /* Perfect hit. */ return true; - + if (itime > sim_time) /* We have gone past the target_time - i.e. we do not have it. */ return false; - + intehead_index++; if (intehead_index == num_INTEHEAD) /* We have iterated through the whole thing without finding sim_time. */ return false; @@ -274,7 +274,7 @@ static int file_map_seqnum_index_from_sim_time( file_map_type * parent_map , tim int num_seqnum = file_map_get_num_named_kw( parent_map , SEQNUM_KW ); int seqnum_index = 0; file_map_type * seqnum_map; - + while (true) { seqnum_map = file_map_alloc_blockmap( parent_map , SEQNUM_KW , seqnum_index); @@ -287,7 +287,7 @@ static int file_map_seqnum_index_from_sim_time( file_map_type * parent_map , tim seqnum_index++; } } - + if (num_seqnum == seqnum_index) return -1; } @@ -315,17 +315,17 @@ bool ecl_file_has_sim_time( const ecl_file_type * ecl_file , time_t sim_time) { This function will determine the restart block corresponding to the world time @sim_time; if @sim_time can not be found the function will return 0. - + The returned index is the 'occurence number' in the restart file, i.e. in the (quite typical case) that not all report steps are - present the return value will not agree with report step. + present the return value will not agree with report step. The return value from this function can then be used to get a corresponding solution field directly, or the file map can restricted to this block. Direct access: - + int index = ecl_file_get_restart_index( ecl_file , sim_time ); if (index >= 0) { ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , index ); @@ -333,7 +333,7 @@ bool ecl_file_has_sim_time( const ecl_file_type * ecl_file , time_t sim_time) { } - Using block restriction: + Using block restriction: int index = ecl_file_get_restart_index( ecl_file , sim_time ); if (index >= 0) { @@ -341,10 +341,10 @@ bool ecl_file_has_sim_time( const ecl_file_type * ecl_file , time_t sim_time) { { ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , 0 ); .... - } + } } - - Specially in the case of LGRs the block restriction should be used. + + Specially in the case of LGRs the block restriction should be used. */ int ecl_file_get_restart_index( const ecl_file_type * ecl_file , time_t sim_time) { @@ -381,14 +381,14 @@ double ecl_file_iget_restart_sim_days( const ecl_file_type * restart_file , int /*****************************************************************/ -/* Select and open functions, observe that these functions should +/* Select and open functions, observe that these functions should only consider the global map. */ /* Will select restart block nr @seqnum_index - without considering - report_steps or simulation time. + report_steps or simulation time. */ bool ecl_file_iselect_rstblock( ecl_file_type * ecl_file , int seqnum_index ) { return ecl_file_select_block( ecl_file , SEQNUM_KW , seqnum_index ); @@ -397,10 +397,10 @@ bool ecl_file_iselect_rstblock( ecl_file_type * ecl_file , int seqnum_index ) { bool ecl_file_select_rstblock_sim_time( ecl_file_type * ecl_file , time_t sim_time) { int seqnum_index = file_map_seqnum_index_from_sim_time( ecl_file->global_map , sim_time ); - + if (seqnum_index >= 0) return ecl_file_iselect_rstblock( ecl_file , seqnum_index); - else + else return false; } @@ -410,17 +410,19 @@ bool ecl_file_select_rstblock_report_step( ecl_file_type * ecl_file , int report if ( global_index >= 0) { int seqnum_index = file_map_iget_occurence( ecl_file->global_map , global_index ); return ecl_file_iselect_rstblock( ecl_file , seqnum_index); - } else + } else return false; } /******************************************************************/ static ecl_file_type * ecl_file_open_rstblock_report_step__( const char * filename , int report_step , int flags) { - ecl_file_type * ecl_file = ecl_file_open__( filename , flags ); - if (!ecl_file_select_rstblock_report_step( ecl_file , report_step )) { - ecl_file_close( ecl_file ); - ecl_file = NULL; + ecl_file_type * ecl_file = ecl_file_open( filename , flags ); + if (ecl_file) { + if (!ecl_file_select_rstblock_report_step( ecl_file , report_step )) { + ecl_file_close( ecl_file ); + ecl_file = NULL; + } } return ecl_file; } @@ -433,10 +435,12 @@ ecl_file_type * ecl_file_open_rstblock_report_step( const char * filename , int /******************************************************************/ static ecl_file_type * ecl_file_open_rstblock_sim_time__( const char * filename , time_t sim_time, int flags ) { - ecl_file_type * ecl_file = ecl_file_open__( filename , flags ); - if (!ecl_file_select_rstblock_sim_time( ecl_file , sim_time)) { - ecl_file_close( ecl_file ); - ecl_file = NULL; + ecl_file_type * ecl_file = ecl_file_open( filename , flags ); + if (ecl_file) { + if (!ecl_file_select_rstblock_sim_time( ecl_file , sim_time)) { + ecl_file_close( ecl_file ); + ecl_file = NULL; + } } return ecl_file; } @@ -448,10 +452,12 @@ ecl_file_type * ecl_file_open_rstblock_sim_time( const char * filename , time_t /******************************************************************/ static ecl_file_type * ecl_file_iopen_rstblock__( const char * filename , int seqnum_index, int flags ) { - ecl_file_type * ecl_file = ecl_file_open__( filename , flags ); - if (!ecl_file_iselect_rstblock( ecl_file , seqnum_index )) { - ecl_file_close( ecl_file ); - ecl_file = NULL; + ecl_file_type * ecl_file = ecl_file_open( filename , flags ); + if (ecl_file) { + if (!ecl_file_iselect_rstblock( ecl_file , seqnum_index )) { + ecl_file_close( ecl_file ); + ecl_file = NULL; + } } return ecl_file; } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c b/ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c index ff22d852cd..bb3505afdb 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_rsthead.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rsthead.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -31,55 +31,67 @@ static time_t rsthead_date( int day , int month , int year) { time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw ) { - return rsthead_date( ecl_kw_iget_int( intehead_kw , INTEHEAD_DAY_INDEX) , - ecl_kw_iget_int( intehead_kw , INTEHEAD_MONTH_INDEX) , + return rsthead_date( ecl_kw_iget_int( intehead_kw , INTEHEAD_DAY_INDEX) , + ecl_kw_iget_int( intehead_kw , INTEHEAD_MONTH_INDEX) , ecl_kw_iget_int( intehead_kw , INTEHEAD_YEAR_INDEX) ); } +double ecl_rsthead_get_sim_days( const ecl_rsthead_type * header ) { + return header->sim_days; +} + ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence) { if (ecl_file_get_num_named_kw( rst_file , INTEHEAD_KW) > occurence) { const ecl_kw_type * intehead_kw = ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , occurence); - const ecl_kw_type * logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence); - const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence); - + ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); - + { const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); - + rsthead->day = data[INTEHEAD_DAY_INDEX]; rsthead->month = data[INTEHEAD_MONTH_INDEX]; rsthead->year = data[INTEHEAD_YEAR_INDEX]; rsthead->version = data[INTEHEAD_IPROG_INDEX]; rsthead->phase_sum = data[INTEHEAD_PHASE_INDEX]; - + rsthead->nx = data[INTEHEAD_NX_INDEX]; rsthead->ny = data[INTEHEAD_NY_INDEX]; rsthead->nz = data[INTEHEAD_NZ_INDEX]; rsthead->nactive = data[INTEHEAD_NACTIVE_INDEX]; - + rsthead->nwells = data[INTEHEAD_NWELLS_INDEX]; rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX]; rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX]; - + rsthead->nsconz = data[INTEHEAD_NSCONZ_INDEX]; rsthead->niconz = data[INTEHEAD_NICONZ_INDEX]; rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX]; - + rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX]; rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX]; rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX]; rsthead->nrsegz = data[INTEHEAD_NRSEGZ_INDEX]; - + // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); - + + if (ecl_file_get_num_named_kw(rst_file, DOUBHEAD_KW) > occurence) { + const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence); + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + } + + if (ecl_file_get_num_named_kw(rst_file, LOGIHEAD_KW) > occurence) { + const ecl_kw_type * logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence); + rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); + } else + rsthead->dualp = false; + + return rsthead; } else return NULL; @@ -91,6 +103,42 @@ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_type * rst_file) { } +ecl_rsthead_type * ecl_rsthead_alloc_empty() { + ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); + + rsthead->day = 0; + rsthead->month = 0; + rsthead->year = 0; + rsthead->version = 0; + rsthead->phase_sum = 0; + + rsthead->nx = 0; + rsthead->ny = 0; + rsthead->nz = 0; + rsthead->nactive = 0; + + rsthead->nwells = 0; + rsthead->niwelz = 0; + rsthead->nzwelz = 0; + + rsthead->nsconz = 0; + rsthead->niconz = 0; + rsthead->ncwmax = 0; + + rsthead->nisegz = 0; + rsthead->nsegmx = 0; + rsthead->nswlmx = 0; + rsthead->nrsegz = 0; + + rsthead->sim_time = 0; + + rsthead->dualp = false; + rsthead->sim_days = 0.0; + + return rsthead; +} + + void ecl_rsthead_fprintf( const ecl_rsthead_type * header , FILE * stream) { fprintf(stream , "nx %d \n",header->nx); fprintf(stream , "nwells %d \n",header->nwells); @@ -138,9 +186,9 @@ void ecl_rsthead_fprintf_struct( const ecl_rsthead_type * header , FILE * stream fprintf(stream , ".nz = %d,\n",header->nz); fprintf(stream , ".nactive = %d,\n",header->nactive); fprintf(stream , ".nwells = %d,\n",header->nwells); - fprintf(stream , ".niwelz = %d,\n",header->niwelz); + fprintf(stream , ".niwelz = %d,\n",header->niwelz); fprintf(stream , ".nzwelz = %d,\n",header->nzwelz); - fprintf(stream , ".niconz = %d,\n",header->niconz); + fprintf(stream , ".niconz = %d,\n",header->niconz); fprintf(stream , ".ncwmax = %d,\n",header->ncwmax); fprintf(stream , ".nisegz = %d,\n",header->nisegz); fprintf(stream , ".nsegmx = %d,\n",header->nsegmx); diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_smryfile.c b/ThirdParty/Ert/devel/libecl/src/ecl_smryfile.c index 143b435dec..473dc339de 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_smryfile.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_smryfile.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_rstfile.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rstfile.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /*****************************************************************/ @@ -27,10 +27,12 @@ bool ecl_file_select_smryblock( ecl_file_type * ecl_file , int report_step ) { ecl_file_type * ecl_file_open_smryblock( const char * filename , int report_step , int flags) { - ecl_file_type * ecl_file = ecl_file_open__( filename , flags ); - if (!ecl_file_select_smryblock( ecl_file , report_step )) { - ecl_file_close( ecl_file ); - ecl_file = NULL; + ecl_file_type * ecl_file = ecl_file_open( filename , flags ); + if (ecl_file) { + if (!ecl_file_select_smryblock( ecl_file , report_step )) { + ecl_file_close( ecl_file ); + ecl_file = NULL; + } } return ecl_file; } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_smspec.c b/ThirdParty/Ert/devel/libecl/src/ecl_smspec.c index 36bc9703ed..d95792dc2a 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_smspec.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_smspec.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_smspec.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_smspec.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <string.h> @@ -42,9 +42,9 @@ /** - This file implements the indexing into the ECLIPSE summary files. + This file implements the indexing into the ECLIPSE summary files. */ - + /* Supporting a new variable type: ------------------------------- @@ -68,7 +68,7 @@ specfic lookup method has seen less use[*]. The final step in supporting a new variable is to update the function ecl_smspec_fread_header(). - + If you want to support specific lookup of the new variable type you must add the necessary datastructures to the ecl_smspec_struct structure and then subsequently fill that structure in the big @@ -88,7 +88,7 @@ */ - + #define ECL_SMSPEC_ID 806647 #define PARAMS_GLOBAL_DEFAULT -99 @@ -105,10 +105,10 @@ struct ecl_smspec_struct { hash_type * well_var_index; /* Indexes for all well variables: {well1: {var1: index1 , var2: index2} , well2: {var1: index1 , var2: index2}} */ hash_type * well_completion_var_index; /* Indexes for completion indexes .*/ hash_type * group_var_index; /* Indexes for group variables.*/ - hash_type * field_var_index; + hash_type * field_var_index; hash_type * region_var_index; /* The stored index is an offset. */ hash_type * misc_var_index; /* Variables like 'TCPU' and 'NEWTON'. */ - hash_type * block_var_index; /* Block variables like BPR */ + hash_type * block_var_index; /* Block variables like BPR */ hash_type * gen_var_index; /* This is "everything" - things can either be found as gen_var("WWCT:OP_X") or as well_var("WWCT" , "OP_X") */ @@ -120,11 +120,12 @@ struct ecl_smspec_struct { /*-----------------------------------------------------------------*/ - int grid_dims[3]; /* Grid dimensions - in DIMENS[1,2,3] */ + int time_seconds; + int grid_dims[3]; /* Grid dimensions - in DIMENS[1,2,3] */ int num_regions; int Nwells , param_offset; int params_size; - const char * key_join_string; /* The string used to join keys when building gen_key keys - typically ":" - + const char * key_join_string; /* The string used to join keys when building gen_key keys - typically ":" - but arbitrary - NOT necessary to be able to invert the joining. */ char * header_file; /* FULL path to the currenbtly loaded header_file. */ @@ -132,13 +133,13 @@ struct ecl_smspec_struct { time_t sim_start_time; /* When did the simulation start - worldtime. */ int time_index; /* The fields time_index, day_index, month_index and year_index */ - int day_index; /* are used by the ecl_sum_data object to locate per. timestep */ - int month_index; /* time information. */ + int day_index; /* are used by the ecl_sum_data object to locate per. timestep */ + int month_index; /* time information. */ int year_index; bool has_lgr; float_vector_type * params_default; - - stringlist_type * restart_list; /* List of ECLBASE names of restart files this case has been restarted from (if any). */ + + stringlist_type * restart_list; /* List of ECLBASE names of restart files this case has been restarted from (if any). */ }; @@ -186,13 +187,13 @@ KEYWORDS = ['TIME','FOPR','FPR','FWCT','WOPR','WOPR,'WWCT','WWCT] VAR_TYPE:(WELL_NAME|GROUP_NAME|NUMBER):NUMBER Field var: VAR_TYPE -Misc var: VAR_TYPE +Misc var: VAR_TYPE Well var: VAR_TYPE:WELL_NAME Group var: VAR_TYPE:GROUP_NAME Block var: VAR_TYPE:i,j,k (where i,j,k is calculated form NUM) Region var VAR_TYPE:index (where index is NOT from the nums vector, it it is just an offset). Completion var: VAR_TYPE:WELL_NAME:NUM -.... +.... */ @@ -202,7 +203,7 @@ Completion var: VAR_TYPE:WELL_NAME:NUM types, when the kewyord name is in conflict with the default vector naming convention; all the variables mentioned in the list below are given the type ECL_SMSPEC_MISC_VAR. - + For instance the keyword 'NEWTON' starts with 'N' and is classified as a NETWORK type variable. However it should rather be classified as a MISC type variable. (What a fucking mess). @@ -221,6 +222,21 @@ static const char* special_vars[] = {"NEWTON", "STEPTYPE"}; +/* + The smspec_required_keywords variable contains a list of keywords + which are *absolutely* required in the SMSPEC file, but observe that + depending on the content of the "KEYWORDS" array other keywords + might bre requred as well - this typically includes the NUMS + keyword. Such 'second-order' dependencies are not accounted for with + this simple list. +*/ + +static const char* smspec_required_keywords[] = {WGNAMES_KW, + KEYWORDS_KW, + STARTDAT_KW, + UNITS_KW, + DIMENS_KW}; + /*****************************************************************/ @@ -240,15 +256,16 @@ static ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * k ecl_smspec->sim_start_time = -1; ecl_smspec->key_join_string = key_join_string; ecl_smspec->header_file = NULL; - + ecl_smspec->smspec_nodes = vector_alloc_new(); - - ecl_smspec->time_index = -1; - ecl_smspec->day_index = -1; - ecl_smspec->year_index = -1; - ecl_smspec->month_index = -1; - ecl_smspec->locked = false; - + + ecl_smspec->time_index = -1; + ecl_smspec->day_index = -1; + ecl_smspec->year_index = -1; + ecl_smspec->month_index = -1; + ecl_smspec->locked = false; + ecl_smspec->time_seconds = -1; + ecl_smspec->index_map = int_vector_alloc(0,0); ecl_smspec->restart_list = stringlist_alloc_new(); ecl_smspec->params_default = float_vector_alloc(0 , PARAMS_GLOBAL_DEFAULT); @@ -306,7 +323,7 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty int i; for (i=0; i < SUMMARY_RESTART_SIZE; i++) ecl_kw_iset_string8( restart_kw , i , ""); - + ecl_kw_fwrite( restart_kw , fortio ); ecl_kw_free( restart_kw ); } @@ -331,7 +348,7 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty ecl_kw_type * wgnames_kw = ecl_kw_alloc( WGNAMES_KW , num_nodes , ECL_CHAR_TYPE ); ecl_kw_type * units_kw = ecl_kw_alloc( UNITS_KW , num_nodes , ECL_CHAR_TYPE ); ecl_kw_type * nums_kw = NULL; - + if (smspec->need_nums) nums_kw = ecl_kw_alloc( NUMS_KW , num_nodes , ECL_INT_TYPE); { @@ -383,8 +400,8 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty if (nums_kw != NULL) ecl_kw_fwrite( nums_kw , fortio ); ecl_kw_fwrite( units_kw , fortio ); - - + + ecl_kw_free( keywords_kw ); ecl_kw_free( wgnames_kw ); ecl_kw_free( units_kw ); @@ -396,11 +413,11 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty ecl_kw_type * startdat_kw = ecl_kw_alloc( STARTDAT_KW , STARTDAT_SIZE , ECL_INT_TYPE ); int day,month,year; util_set_date_values( smspec->sim_start_time , &day, &month , &year); - + ecl_kw_iset_int( startdat_kw , STARTDAT_DAY_INDEX , day ); ecl_kw_iset_int( startdat_kw , STARTDAT_MONTH_INDEX , month ); ecl_kw_iset_int( startdat_kw , STARTDAT_YEAR_INDEX , year ); - + ecl_kw_fwrite( startdat_kw , fortio ); ecl_kw_free( startdat_kw ); } @@ -410,31 +427,47 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , bool fmt_file ) { char * filename = ecl_util_alloc_filename( NULL , ecl_case , ECL_SUMMARY_HEADER_FILE , fmt_file , 0 ); fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP); - + ecl_smspec_fortio_fwrite( smspec , fortio ); - + fortio_fclose( fortio ); free( filename ); } -ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , time_t sim_start , int nx , int ny , int nz) { +ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { ecl_smspec_type * ecl_smspec = ecl_smspec_alloc_empty( true , key_join_string ); - + ecl_smspec->grid_dims[0] = nx; ecl_smspec->grid_dims[1] = ny; ecl_smspec->grid_dims[2] = nz; ecl_smspec->sim_start_time = sim_start; - + { - smspec_node_type * time_node = smspec_node_alloc( ECL_SMSPEC_MISC_VAR , - NULL , - "TIME" , - "DAYS" , // There are significant hardcoded assumptions of days around; would have been cool to be able to set seconds. - key_join_string , - ecl_smspec->grid_dims , - 0 , - -1 , - 0 ); + smspec_node_type * time_node; + if (time_in_days) { + time_node = smspec_node_alloc( ECL_SMSPEC_MISC_VAR , + NULL , + "TIME" , + "DAYS" , + key_join_string , + ecl_smspec->grid_dims , + 0 , + -1 , + 0 ); + ecl_smspec->time_seconds = 3600 * 24; + } else { + time_node = smspec_node_alloc( ECL_SMSPEC_MISC_VAR , + NULL , + "TIME" , + "HOURS" , + key_join_string , + ecl_smspec->grid_dims , + 0 , + -1 , + 0 ); + ecl_smspec->time_seconds = 3600; + } + ecl_smspec_add_node( ecl_smspec , time_node ); ecl_smspec->time_index = smspec_node_get_params_index( time_node ); } @@ -468,12 +501,12 @@ static ecl_smspec_var_type ecl_smspec_identify_special_var( const char * var ) { break; } } - + return var_type; } -/* +/* See table 3.4 in the ECLIPSE file format reference manual. Observe that the combined ecl_sum style keys like e.g. WWCT:OP1 @@ -485,7 +518,6 @@ static ecl_smspec_var_type ecl_smspec_identify_special_var( const char * var ) { ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var) { ecl_smspec_var_type var_type = ecl_smspec_identify_special_var( var ); - int str_length = strlen(var); if (var_type == ECL_SMSPEC_INVALID_VAR) { switch(var[0]) { case('A'): @@ -529,12 +561,30 @@ ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var) { var_type = ECL_SMSPEC_NETWORK_VAR; break; case('R'): - if (((3 == str_length) && var[2] == 'F') || - ((4 == str_length) && var[3] == 'F')) { - var_type = ECL_SMSPEC_REGION_2_REGION_VAR; - } - else { - var_type = ECL_SMSPEC_REGION_VAR; + { + /* + The distinction between region-to-region variables and plain + region variables is less than clear: The current + interpretation is that the cases: + + 1. Any variable matching: + + a) Starts with 'R' + b) Has 'F' as the third character + + 2. The variable "RNLF" + + Get variable type ECL_SMSPEC_REGION_2_REGION_VAR. The rest + get the type ECL_SMSPEC_REGION_VAR. + */ + + if (util_string_equal( var , "RNLF")) + var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + else if (var[2] == 'F') + var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + else + var_type = ECL_SMSPEC_REGION_VAR; + } break; case('S'): @@ -559,7 +609,7 @@ static bool ecl_smspec_lgr_var_type( ecl_smspec_var_type var_type) { if ((var_type == ECL_SMSPEC_LOCAL_BLOCK_VAR) || (var_type == ECL_SMSPEC_LOCAL_WELL_VAR) || (var_type == ECL_SMSPEC_LOCAL_COMPLETION_VAR)) - + return true; else return false; @@ -646,10 +696,10 @@ static int ecl_smspec_get_global_grid_index(const ecl_smspec_type * smspec , int /** This function takes a fully initialized smspec_node instance, generates the corresponding key and inserts smspec_node instance in the main hash table - smspec->gen_var_index. + smspec->gen_var_index. The format strings used, i.e. VAR:WELL for well based variables is implicitly - defined through the format strings used in this function. + defined through the format strings used in this function. */ static void ecl_smspec_install_gen_keys( ecl_smspec_type * smspec , smspec_node_type * smspec_node ) { @@ -663,17 +713,17 @@ static void ecl_smspec_install_gen_keys( ecl_smspec_type * smspec , smspec_node_ /* Insert the (optional) extra mapping for block related variables and region_2_region variables: */ { const char * gen_key2 = smspec_node_get_gen_key2( smspec_node ); - if (gen_key2 != NULL) + if (gen_key2 != NULL) hash_insert_ref(smspec->gen_var_index , gen_key2 , smspec_node); } } static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node) { - /** + /** This large switch is for installing keys which have custom lookup paths, in addition to the lookup based on general keys. Examples - of this is e.g. well variables which can be looked up through: - + of this is e.g. well variables which can be looked up through: + ecl_smspec_get_well_var_index( smspec , well_name , var ); */ @@ -682,7 +732,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp const int num = smspec_node_get_num(smspec_node); const char * keyword = smspec_node_get_keyword(smspec_node); ecl_smspec_var_type var_type = smspec_node_get_var_type( smspec_node ); - + switch(var_type) { case(ECL_SMSPEC_COMPLETION_VAR): /* Three level indexing: variable -> well -> string(cell_nr)*/ @@ -715,7 +765,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp } break; case(ECL_SMSPEC_REGION_VAR): - if (!hash_has_key(ecl_smspec->region_var_index , keyword)) + if (!hash_has_key(ecl_smspec->region_var_index , keyword)) hash_insert_hash_owned_ref( ecl_smspec->region_var_index , keyword , hash_alloc() , hash_free__); { hash_type * var_hash = hash_get(ecl_smspec->region_var_index , keyword); @@ -748,7 +798,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp hash_insert_ref(block_hash , block_nr , smspec_node); } break; - /** + /** The variables below are ONLY accesable through the gen_key setup; but the must be mentioned in this switch statement, otherwise they will induce a hard failure in the default: target @@ -769,7 +819,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp break; } } - + /** The usage of this functon breaks down completely if LGR's are involved. */ @@ -858,7 +908,7 @@ static bool ecl_smspec_kw_equal(const ecl_file_type * header , const ecl_file_ty if (ecl_file_has_kw( header , kw)) { ecl_kw_type *ecl_kw1 = ecl_file_iget_named_kw(header, kw , 0); ecl_kw_type *ecl_kw2 = ecl_file_iget_named_kw(restart_header, kw , 0); - + return ecl_kw_block_equal( ecl_kw1 , ecl_kw2 , cmp_elements); } else return true; // None of the headers have this keyword - that is equality! @@ -872,7 +922,7 @@ static bool ecl_smspec_kw_equal(const ecl_file_type * header , const ecl_file_ty historical results is not internalized, i.e. it is essential that the historical case has identical header as the main case. This function compares the ecl_file represeantation of two SMSPEC - headers. + headers. Unfortunately there are legitimate reasons why some of the headers can be different; in particular new well can appear. In the code @@ -883,19 +933,19 @@ static bool ecl_smspec_kw_equal(const ecl_file_type * header , const ecl_file_ty static bool ecl_smspec_file_equal( const ecl_file_type * header1 , const ecl_file_type * header2) { if (! ecl_smspec_kw_equal( header1 , header2 , KEYWORDS_KW , 0)) return false; - + if (! ecl_smspec_kw_equal( header1 , header2 , STARTDAT_KW , 0)) return false; if (! ecl_smspec_kw_equal( header1 , header2 , UNITS_KW , 0)) return false; - + if (! ecl_smspec_kw_equal( header1 , header2 , DIMENS_KW , 4)) // Only the first four elements are compared. return false; - + if (!ecl_smspec_kw_equal( header1, header2 , LGRS_KW , 0)) return false; - + return true; } @@ -903,7 +953,7 @@ static bool ecl_smspec_file_equal( const ecl_file_type * header1 , const ecl_fil /** This will iterate backwards through the RESTART header in the SMSPEC files to find names of the case(s) this case has been - restarted from. + restarted from. The case names are internalized in the restart_list field of the ecl_smspec instance. The actual loading of the restart summary data @@ -917,9 +967,9 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi char * restart_base; int i; tmp_base[0] = '\0'; - for (i=0; i < ecl_kw_get_size( restart_kw ); i++) + for (i=0; i < ecl_kw_get_size( restart_kw ); i++) strcat( tmp_base , ecl_kw_iget_ptr( restart_kw , i )); - + restart_base = util_alloc_strip_copy( tmp_base ); if (strlen(restart_base)) { /* We ignore the empty ones. */ char * path; @@ -927,27 +977,29 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi util_alloc_file_components( ecl_smspec->header_file , &path , NULL , NULL ); smspec_header = ecl_util_alloc_exfilename( path , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0); - if (smspec_header == NULL) + if (smspec_header == NULL) fprintf(stderr,"Warning - the header file: %s refers to restart from case: %s - which was not found.... \n", ecl_smspec->header_file , restart_base); - + else { if (!util_same_file(smspec_header , ecl_smspec->header_file)) { /* Restart from the current case is ignored. */ - /* + /* Verify that this smspec_header is not already in the list of restart cases. Don't know if this is at all possible, but this test nevertheless prevents against a recursive death. */ if (!stringlist_contains( ecl_smspec->restart_list , restart_base)) { ecl_file_type * restart_header = ecl_file_open( smspec_header , 0); - - if (ecl_smspec_file_equal( header , restart_header)) { - stringlist_insert_copy( ecl_smspec->restart_list , 0 , restart_base ); - ecl_smspec_load_restart( ecl_smspec , restart_header); /* Recursive call */ - } else - fprintf(stderr,"** Warning: the historical case: %s is not compatible with the current case - ignored.\n" , - ecl_file_get_src_file( restart_header)); - - ecl_file_close( restart_header ); + if (restart_header) { + if (ecl_smspec_file_equal( header , restart_header)) { + stringlist_insert_copy( ecl_smspec->restart_list , 0 , restart_base ); + ecl_smspec_load_restart( ecl_smspec , restart_header); /* Recursive call */ + } else + fprintf(stderr,"** Warning: the historical case: %s is not compatible with the current case - ignored.\n" , + ecl_file_get_src_file( restart_header)); + + ecl_file_close( restart_header ); + } else + fprintf(stderr,"** Warning: failed to historical case:%s - ignored.\n", smspec_header); } } } @@ -958,13 +1010,13 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi } } - + void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node) { /* It is possible crate a node which is not fully specified, e.g. the well or group name can be left at NULL. In that case the node is - not installed in the different indexes. + not installed in the different indexes. */ // var_type == ECL_SMSPEC_INVALID_VAR?? if (smspec_node_get_gen_key1( smspec_node ) != NULL) { @@ -983,27 +1035,27 @@ static void ecl_smspec_set_params_size( ecl_smspec_type * ecl_smspec , int param -void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node){ +void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node){ if (!ecl_smspec->locked) { int internal_index = vector_get_size( ecl_smspec->smspec_nodes ); - + /* This IF test should only apply in write_mode. */ if (smspec_node_get_params_index( smspec_node ) < 0) { if (!ecl_smspec->write_mode) util_abort("%s: internal error \n",__func__); smspec_node_set_params_index( smspec_node , internal_index); - + if (internal_index >= ecl_smspec->params_size) ecl_smspec_set_params_size( ecl_smspec , internal_index + 1); } vector_append_owned_ref( ecl_smspec->smspec_nodes , smspec_node , smspec_node_free__ ); - + { int params_index = smspec_node_get_params_index( smspec_node ); - + /* This indexing must be used when writing. */ int_vector_iset( ecl_smspec->index_map , internal_index , params_index); - + float_vector_iset( ecl_smspec->params_default , params_index , smspec_node_get_default(smspec_node) ); } } else @@ -1030,12 +1082,25 @@ const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec return smspec->index_map; } +static bool ecl_smspec_check_header( ecl_file_type * header ) { + bool OK = true; + int num_required = sizeof( smspec_required_keywords ) / sizeof( smspec_required_keywords[0] ); + int i; + + for (i=0; i < num_required; i++) { + if (!ecl_file_has_kw( header , smspec_required_keywords[i])) { + OK = false; + break; + } + } + return OK; +} -static void ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * header_file , bool include_restart) { +static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * header_file , bool include_restart) { ecl_file_type * header = ecl_file_open( header_file , 0); - { + if (header && ecl_smspec_check_header( header )) { ecl_kw_type *wells = ecl_file_iget_named_kw(header, WGNAMES_KW , 0); ecl_kw_type *keywords = ecl_file_iget_named_kw(header, KEYWORDS_KW , 0); ecl_kw_type *startdat = ecl_file_iget_named_kw(header, STARTDAT_KW , 0); @@ -1048,17 +1113,17 @@ static void ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h ecl_kw_type *numlz = NULL; int params_index; ecl_smspec->num_regions = 0; - if (startdat == NULL) + if (startdat == NULL) util_abort("%s: could not locate STARTDAT keyword in header - aborting \n",__func__); - + if (ecl_file_has_kw(header , NUMS_KW)) nums = ecl_file_iget_named_kw(header , NUMS_KW , 0); - + if (ecl_file_has_kw( header , LGRS_KW )) {/* The file has LGR information. */ lgrs = ecl_file_iget_named_kw( header , LGRS_KW , 0 ); - numlx = ecl_file_iget_named_kw( header , NUMLX_KW , 0 ); - numly = ecl_file_iget_named_kw( header , NUMLY_KW , 0 ); - numlz = ecl_file_iget_named_kw( header , NUMLZ_KW , 0 ); + numlx = ecl_file_iget_named_kw( header , NUMLX_KW , 0 ); + numly = ecl_file_iget_named_kw( header , NUMLY_KW , 0 ); + numlz = ecl_file_iget_named_kw( header , NUMLZ_KW , 0 ); ecl_smspec->has_lgr = true; } else ecl_smspec->has_lgr = false; @@ -1069,14 +1134,14 @@ static void ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h date[STARTDAT_MONTH_INDEX] , date[STARTDAT_YEAR_INDEX]); } - + ecl_smspec->grid_dims[0] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NX_INDEX ); ecl_smspec->grid_dims[1] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NY_INDEX ); ecl_smspec->grid_dims[2] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NZ_INDEX ); ecl_smspec_set_params_size( ecl_smspec , ecl_kw_get_size(keywords)); - + ecl_util_get_file_type( header_file , &ecl_smspec->formatted , NULL ); - + { for (params_index=0; params_index < ecl_kw_get_size(wells); params_index++) { float default_value = PARAMS_GLOBAL_DEFAULT; @@ -1084,75 +1149,93 @@ static void ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h char * well = util_alloc_strip_copy(ecl_kw_iget_ptr(wells , params_index)); char * kw = util_alloc_strip_copy(ecl_kw_iget_ptr(keywords , params_index)); char * unit = util_alloc_strip_copy(ecl_kw_iget_ptr(units , params_index)); - char * lgr_name = NULL; + char * lgr_name = NULL; smspec_node_type * smspec_node; ecl_smspec_var_type var_type = ecl_smspec_identify_var_type( kw ); if (nums != NULL) num = ecl_kw_iget_int(nums , params_index); - if (ecl_smspec_lgr_var_type( var_type )) { + if (ecl_smspec_lgr_var_type( var_type )) { int lgr_i = ecl_kw_iget_int( numlx , params_index ); int lgr_j = ecl_kw_iget_int( numly , params_index ); int lgr_k = ecl_kw_iget_int( numlz , params_index ); lgr_name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgrs , params_index )); smspec_node = smspec_node_alloc_lgr( var_type , well , kw , unit , lgr_name , ecl_smspec->key_join_string , lgr_i , lgr_j , lgr_k , params_index, default_value); - } else + } else smspec_node = smspec_node_alloc( var_type , well , kw , unit , ecl_smspec->key_join_string , ecl_smspec->grid_dims , num , params_index , default_value); - + if (smspec_node != NULL) { /** OK - we know this is valid shit. */ ecl_smspec_add_node( ecl_smspec , smspec_node ); } - + free( kw ); free( well ); free( unit ); util_safe_free( lgr_name ); } } - } - ecl_smspec->header_file = util_alloc_realpath( header_file ); - if (include_restart) - ecl_smspec_load_restart( ecl_smspec , header ); - - ecl_file_close( header ); + + ecl_smspec->header_file = util_alloc_realpath( header_file ); + if (include_restart) + ecl_smspec_load_restart( ecl_smspec , header ); + + ecl_file_close( header ); + + return true; + } else + return false; } ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * key_join_string , bool include_restart) { ecl_smspec_type *ecl_smspec; - + { char *path; util_alloc_file_components(header_file , &path , NULL , NULL); ecl_smspec = ecl_smspec_alloc_empty(false , key_join_string); util_safe_free(path); } - - ecl_smspec_fread_header(ecl_smspec , header_file , include_restart); - - if (hash_has_key( ecl_smspec->misc_var_index , "TIME")) - ecl_smspec->time_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "TIME") ); - - if (hash_has_key(ecl_smspec->misc_var_index , "DAY")) { - ecl_smspec->day_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "DAY") ); - ecl_smspec->month_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "MONTH") ); - ecl_smspec->year_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "YEAR") ); - } - - if ((ecl_smspec->time_index == -1) && ( ecl_smspec->day_index == -1)) { - /* Unusable configuration. - - Seems the ECLIPSE file can also have time specified with - 'YEARS' as basic time unit; that mode is not supported. - */ - - util_abort("%s: Sorry the SMSPEC file seems to lack all time information, need either TIME, or DAY/MONTH/YEAR information. Can not proceed.",__func__); + + if (ecl_smspec_fread_header(ecl_smspec , header_file , include_restart)) { + + if (hash_has_key( ecl_smspec->misc_var_index , "TIME")) { + const smspec_node_type * time_node = hash_get(ecl_smspec->misc_var_index , "TIME"); + const char * time_unit = smspec_node_get_unit( time_node ); + ecl_smspec->time_index = smspec_node_get_params_index( time_node ); + + if (util_string_equal( time_unit , "DAYS")) + ecl_smspec->time_seconds = 3600 * 24; + else if (util_string_equal( time_unit , "HOURS")) + ecl_smspec->time_seconds = 3600; + else + util_abort("%s: time_unit:%s not recognized \n",__func__ , time_unit); + } + + if (hash_has_key(ecl_smspec->misc_var_index , "DAY")) { + ecl_smspec->day_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "DAY") ); + ecl_smspec->month_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "MONTH") ); + ecl_smspec->year_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "YEAR") ); + } + + if ((ecl_smspec->time_index == -1) && ( ecl_smspec->day_index == -1)) { + /* Unusable configuration. + + Seems the ECLIPSE file can also have time specified with + 'YEARS' as basic time unit; that mode is not supported. + */ + + util_abort("%s: Sorry the SMSPEC file seems to lack all time information, need either TIME, or DAY/MONTH/YEAR information. Can not proceed.",__func__); + return NULL; + } + return ecl_smspec; + } else { + /** Failed to load from disk. */ + ecl_smspec_free( ecl_smspec ); return NULL; } - - return ecl_smspec; } @@ -1172,7 +1255,7 @@ int ecl_smspec_get_num_regions(const ecl_smspec_type * ecl_smspec) { /******************************************************************/ -/* +/* For each type of summary data (according to the types in ecl_smcspec_var_type there are a set accessor functions: @@ -1272,7 +1355,7 @@ const smspec_node_type * ecl_smspec_get_field_var_node(const ecl_smspec_type * e const smspec_node_type * node = NULL; if (hash_has_key(ecl_smspec->field_var_index , var)) node = hash_get(ecl_smspec->field_var_index , var); - + return node; } @@ -1296,7 +1379,7 @@ bool ecl_smspec_has_field_var(const ecl_smspec_type * ecl_smspec , const char *v /** Observe that block_nr is represented as char literal, i.e. "2345". This is because it will be used as a hash key. - + This is the final low level function which actually consults the hash tables. */ @@ -1331,7 +1414,7 @@ const smspec_node_type * ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type bool ecl_smspec_has_block_var(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr) { const smspec_node_type * node = ecl_smspec_get_block_var_node( ecl_smspec , block_var , block_nr ); NODE_RETURN_EXISTS(node); -} +} bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k) { @@ -1343,7 +1426,7 @@ bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type * ecl_smspec , const cha int ecl_smspec_get_block_var_params_index(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr) { const smspec_node_type * node = ecl_smspec_get_block_var_node( ecl_smspec , block_var , block_nr ); NODE_RETURN_INDEX(node); -} +} int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k) { @@ -1366,11 +1449,11 @@ const smspec_node_type * ecl_smspec_get_region_var_node(const ecl_smspec_type * if (hash_has_key(ecl_smspec->region_var_index , region_var)) { char * nr_str = util_alloc_sprintf( "%d" , region_nr ); hash_type * nr_hash = hash_get(ecl_smspec->region_var_index , region_var); - if (hash_has_key( nr_hash , nr_str)) + if (hash_has_key( nr_hash , nr_str)) node = hash_get( nr_hash , nr_str ); free( nr_str ); } - + return node; } @@ -1394,7 +1477,7 @@ const smspec_node_type * ecl_smspec_get_misc_var_node(const ecl_smspec_type * ec if (hash_has_key(ecl_smspec->misc_var_index , var)) node = hash_get(ecl_smspec->misc_var_index , var); - + return node; } @@ -1420,7 +1503,7 @@ const smspec_node_type * ecl_smspec_get_well_completion_var_node(const ecl_smspe char * cell_str = util_alloc_sprintf("%d" , cell_nr); if (hash_has_key(ecl_smspec->well_completion_var_index , well)) { hash_type * cell_hash = hash_get(ecl_smspec->well_completion_var_index , well); - + if (hash_has_key(cell_hash , cell_str)) { hash_type * var_hash = hash_get(cell_hash , cell_str); if (hash_has_key(var_hash , var)) @@ -1472,7 +1555,7 @@ int ecl_smspec_get_general_var_params_index(const ecl_smspec_type * ecl_smspec , bool ecl_smspec_has_general_var(const ecl_smspec_type * ecl_smspec , const char * lookup_kw) { const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_smspec , lookup_kw ); NODE_RETURN_EXISTS( node ); -} +} /** DIES if the lookup_kw is not present. */ @@ -1483,7 +1566,7 @@ const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec /*****************************************************************/ -/* +/* Pure indexed lookup - these functions can be used after one of the ecl_smspec_get_xxx_index() functions has been used first. */ @@ -1511,6 +1594,10 @@ const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec /*****************************************************************/ +int ecl_smspec_get_time_seconds( const ecl_smspec_type * ecl_smspec ) { + return ecl_smspec->time_seconds; +} + int ecl_smspec_get_time_index( const ecl_smspec_type * ecl_smspec ) { return ecl_smspec->time_index; } @@ -1563,9 +1650,6 @@ void ecl_smspec_free__(void * __ecl_smspec) { ecl_smspec_free( ecl_smspec ); } -int ecl_smspec_get_sim_days_index( const ecl_smspec_type * smspec ) { - return smspec->time_index; -} int ecl_smspec_get_date_day_index( const ecl_smspec_type * smspec ) { return smspec->day_index; @@ -1609,7 +1693,7 @@ bool ecl_smspec_general_is_total( const ecl_smspec_type * smspec , const char * unfortunately not as useful as one might think because ECLIPSE is quite stupid; it will for instance happily give you the WOPR for a water injector or WWIR for an oil producer. - + The function can be called several times with different patterns, the stringlist is not cleared on startup; the keys in the list are unique - keys are not added multiple times. If pattern == NULL all @@ -1620,7 +1704,7 @@ bool ecl_smspec_general_is_total( const ecl_smspec_type * smspec , const char * void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys) { hash_type * ex_keys = hash_alloc( ); int i; - for (i=0; i < stringlist_get_size( keys ); i++) + for (i=0; i < stringlist_get_size( keys ); i++) hash_insert_int( ex_keys , stringlist_iget( keys , i ) , 1); { @@ -1634,7 +1718,7 @@ void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec } hash_iter_free( iter ); } - + hash_free( ex_keys ); } @@ -1658,12 +1742,12 @@ const char * ecl_smspec_get_join_string( const ecl_smspec_type * smspec) { -/** +/** Returns a stringlist instance with all the (valid) well names. It is the responsability of the calling scope to free the stringlist with stringlist_free(); - + If @pattern is different from NULL only wells which 'match' the pattern is included; if @pattern == NULL all wells are included. The match is done with function fnmatch() - @@ -1674,12 +1758,12 @@ stringlist_type * ecl_smspec_alloc_well_list( const ecl_smspec_type * smspec , c stringlist_type * well_list = stringlist_alloc_new( ); { hash_iter_type * iter = hash_iter_alloc( smspec->well_var_index ); - + while (!hash_iter_is_complete( iter )) { const char * well_name = hash_iter_get_next_key( iter ); if (pattern == NULL) stringlist_append_copy( well_list , well_name ); - else if (util_fnmatch( pattern , well_name) == 0) + else if (util_fnmatch( pattern , well_name) == 0) stringlist_append_copy( well_list , well_name ); } hash_iter_free(iter); @@ -1689,7 +1773,7 @@ stringlist_type * ecl_smspec_alloc_well_list( const ecl_smspec_type * smspec , c } -/** +/** Returns a stringlist instance with all the (valid) group names. It is the responsability of the calling scope to free the stringlist with stringlist_free(); @@ -1699,12 +1783,12 @@ stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , stringlist_type * group_list = stringlist_alloc_new( ); { hash_iter_type * iter = hash_iter_alloc( smspec->group_var_index ); - + while (!hash_iter_is_complete( iter )) { const char * group_name = hash_iter_get_next_key( iter ); if (pattern == NULL) stringlist_append_copy( group_list , group_name ); - else if (util_fnmatch( pattern , group_name) == 0) + else if (util_fnmatch( pattern , group_name) == 0) stringlist_append_copy( group_list , group_name ); } hash_iter_free(iter); @@ -1715,7 +1799,7 @@ stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , -/** +/** Returns a stringlist instance with all the well variables. It is the responsability of the calling scope to free the stringlist with stringlist_free(); diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_sum.c b/ThirdParty/Ert/devel/libecl/src/ecl_sum.c index c49f65f021..a120097ffd 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_sum.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_sum.c @@ -79,7 +79,7 @@ combined to create a unique key; and the corresponding index is used to lookup a numerical value from the PARAMS vector with actual data. - + These matters are documented further in the ecl_smspec.c and ecl_sum_data.c files. */ @@ -104,7 +104,7 @@ struct ecl_sum_struct { char * abs_path; /* Absolute path. */ char * base; /* Only the basename. */ char * ecl_case; /* This is the current case, with optional path component. == path + base*/ - char * ext; /* Only to support selective loading of formatted|unformatted and unified|multiple. (can be NULL) */ + char * ext; /* Only to support selective loading of formatted|unformatted and unified|multiple. (can be NULL) */ }; @@ -129,7 +129,7 @@ void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { util_safe_free( ecl_sum->ext ); { char *path , *base, *ext; - + util_alloc_file_components( ecl_case , &path , &base , &ext); ecl_sum->ecl_case = util_alloc_string_copy( ecl_case ); @@ -140,7 +140,7 @@ void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { ecl_sum->abs_path = util_alloc_abs_path( path ); else ecl_sum->abs_path = util_alloc_cwd(); - + util_safe_free( base ); util_safe_free( path ); util_safe_free( ext ); @@ -151,7 +151,7 @@ void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key_join_string) { ecl_sum_type * ecl_sum = util_malloc( sizeof * ecl_sum ); UTIL_TYPE_ID_INIT( ecl_sum , ECL_SUM_ID ); - + ecl_sum->ecl_case = NULL; ecl_sum->path = NULL; ecl_sum->base = NULL; @@ -159,7 +159,7 @@ static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key ecl_sum->abs_path = NULL; ecl_sum_set_case( ecl_sum , input_arg ); ecl_sum->key_join_string = util_alloc_string_copy( key_join_string ); - + ecl_sum->smspec = NULL; ecl_sum->data = NULL; @@ -167,69 +167,72 @@ static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key } -static void ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type * data_files , bool include_restart) { +static bool ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type * data_files , bool include_restart) { if (ecl_sum->data != NULL) ecl_sum_free_data( ecl_sum ); + ecl_sum->data = ecl_sum_data_alloc( ecl_sum->smspec ); - ecl_sum_data_fread( ecl_sum->data , data_files ); - - if (include_restart) { - const char * path = ecl_sum->path; - const stringlist_type * restart_cases = ecl_smspec_get_restart_list( ecl_sum->smspec ); - stringlist_type * restart_files = stringlist_alloc_new(); - - int restart_nr; - for (restart_nr = 0; restart_nr < stringlist_get_size( restart_cases ); restart_nr++) { - ecl_util_alloc_summary_data_files(path , stringlist_iget( restart_cases , restart_nr ) , ecl_sum->fmt_case , restart_files ); - ecl_sum_data_fread_restart( ecl_sum->data , restart_files ); + if (ecl_sum_data_fread( ecl_sum->data , data_files )) { + if (include_restart) { + const char * path = ecl_sum->path; + const stringlist_type * restart_cases = ecl_smspec_get_restart_list( ecl_sum->smspec ); + stringlist_type * restart_files = stringlist_alloc_new(); + + int restart_nr; + for (restart_nr = 0; restart_nr < stringlist_get_size( restart_cases ); restart_nr++) { + ecl_util_alloc_summary_data_files(path , stringlist_iget( restart_cases , restart_nr ) , ecl_sum->fmt_case , restart_files ); + ecl_sum_data_fread_restart( ecl_sum->data , restart_files ); + } + stringlist_free( restart_files ); } - stringlist_free( restart_files ); - } - + return true; + } else + return false; } -static void ecl_sum_fread(ecl_sum_type * ecl_sum , const char *header_file , const stringlist_type *data_files , bool include_restart) { - +static bool ecl_sum_fread(ecl_sum_type * ecl_sum , const char *header_file , const stringlist_type *data_files , bool include_restart) { ecl_sum->smspec = ecl_smspec_fread_alloc( header_file , ecl_sum->key_join_string , include_restart); - { + if (ecl_sum->smspec) { bool fmt_file; ecl_util_get_file_type( header_file , &fmt_file , NULL); ecl_sum_set_fmt_case( ecl_sum , fmt_file ); - } - ecl_sum_fread_data( ecl_sum , data_files , include_restart ); + } else + return false; - { + if (ecl_sum_fread_data( ecl_sum , data_files , include_restart )) { ecl_file_enum file_type = ecl_util_get_file_type( stringlist_iget( data_files , 0 ) , NULL , NULL); - + if (file_type == ECL_SUMMARY_FILE) ecl_sum_set_unified( ecl_sum , false ); else if (file_type == ECL_UNIFIED_SUMMARY_FILE) ecl_sum_set_unified( ecl_sum , true); else util_abort("%s: what the fuck? \n",__func__); - } + } else + return false; + + return true; } static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart) { char * header_file; stringlist_type * summary_file_list = stringlist_alloc_new(); - + bool caseOK = false; - + ecl_util_alloc_summary_files( ecl_sum->path , ecl_sum->base , ecl_sum->ext , &header_file , summary_file_list ); if ((header_file != NULL) && (stringlist_get_size( summary_file_list ) > 0)) { - ecl_sum_fread( ecl_sum , header_file , summary_file_list , include_restart ); - caseOK = true; + caseOK = ecl_sum_fread( ecl_sum , header_file , summary_file_list , include_restart ); } util_safe_free( header_file ); stringlist_free( summary_file_list ); - + return caseOK; } - + /** This will explicitly load the summary specified by @header_file and @@ -240,8 +243,8 @@ static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart) { initializing the data_files list with files from the restarted case. */ - - + + ecl_sum_type * ecl_sum_fread_alloc(const char *header_file , const stringlist_type *data_files , const char * key_join_string) { ecl_sum_type * ecl_sum = ecl_sum_alloc__( header_file , key_join_string ); ecl_sum_fread( ecl_sum , header_file , data_files , false ); @@ -281,19 +284,19 @@ smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default -ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days) { - return ecl_sum_data_add_new_tstep( ecl_sum->data , report_step , sim_days ); +ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_seconds) { + return ecl_sum_data_add_new_tstep( ecl_sum->data , report_step , sim_seconds ); } -ecl_sum_type * ecl_sum_alloc_writer( const char * ecl_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , int nx , int ny , int nz) { +ecl_sum_type * ecl_sum_alloc_writer( const char * ecl_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { ecl_sum_type * ecl_sum = ecl_sum_alloc__( ecl_case , key_join_string ); ecl_sum_set_unified( ecl_sum , unified ); ecl_sum_set_fmt_case( ecl_sum , fmt_output ); - ecl_sum->smspec = ecl_smspec_alloc_writer( key_join_string , sim_start , nx , ny , nz ); + ecl_sum->smspec = ecl_smspec_alloc_writer( key_join_string , sim_start , time_in_days , nx , ny , nz ); ecl_sum->data = ecl_sum_data_alloc_writer( ecl_sum->smspec ); - + return ecl_sum; } @@ -330,14 +333,14 @@ void ecl_sum_free( ecl_sum_type * ecl_sum ) { if (ecl_sum->smspec != NULL) ecl_smspec_free( ecl_sum->smspec ); - + util_safe_free( ecl_sum->path ); util_safe_free( ecl_sum->ext ); util_safe_free( ecl_sum->abs_path ); free( ecl_sum->base ); free( ecl_sum->ecl_case ); - + free( ecl_sum->key_join_string ); free( ecl_sum ); } @@ -410,7 +413,7 @@ bool ecl_sum_case_exists( const char * input_file ) { util_safe_free( extension ); util_safe_free( smspec_file ); stringlist_free( data_files ); - + return case_exists; } @@ -450,8 +453,8 @@ double ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time) { /*****************************************************************/ /* Well variables */ -bool ecl_sum_has_well_var(const ecl_sum_type * ecl_sum , const char * well , const char *var) { - return ecl_smspec_has_well_var(ecl_sum->smspec , well , var); +bool ecl_sum_has_well_var(const ecl_sum_type * ecl_sum , const char * well , const char *var) { + return ecl_smspec_has_well_var(ecl_sum->smspec , well , var); } double ecl_sum_get_well_var(const ecl_sum_type * ecl_sum , int time_index , const char * well , const char *var) { @@ -473,8 +476,8 @@ double ecl_sum_get_well_var_from_sim_days( const ecl_sum_type * ecl_sum , double /*****************************************************************/ /* Group variables */ -bool ecl_sum_has_group_var(const ecl_sum_type * ecl_sum , const char * group , const char *var) { - return ecl_smspec_has_group_var( ecl_sum->smspec , group , var); +bool ecl_sum_has_group_var(const ecl_sum_type * ecl_sum , const char * group , const char *var) { + return ecl_smspec_has_group_var( ecl_sum->smspec , group , var); } double ecl_sum_get_group_var(const ecl_sum_type * ecl_sum , int time_index , const char * group , const char *var) { @@ -496,8 +499,8 @@ double ecl_sum_get_group_var_from_sim_days( const ecl_sum_type * ecl_sum , doubl /*****************************************************************/ /* Field variables */ -bool ecl_sum_has_field_var(const ecl_sum_type * ecl_sum , const char *var) { - return ecl_smspec_has_field_var( ecl_sum->smspec , var); +bool ecl_sum_has_field_var(const ecl_sum_type * ecl_sum , const char *var) { + return ecl_smspec_has_field_var( ecl_sum->smspec , var); } double ecl_sum_get_field_var(const ecl_sum_type * ecl_sum , int time_index , const char * var) { @@ -519,8 +522,8 @@ double ecl_sum_get_field_var_from_sim_days( const ecl_sum_type * ecl_sum , doubl /*****************************************************************/ /* Block variables */ -bool ecl_sum_has_block_var(const ecl_sum_type * ecl_sum , const char * block_var , int block_nr) { - return ecl_smspec_has_block_var( ecl_sum->smspec , block_var , block_nr ); +bool ecl_sum_has_block_var(const ecl_sum_type * ecl_sum , const char * block_var , int block_nr) { + return ecl_smspec_has_block_var( ecl_sum->smspec , block_var , block_nr ); } double ecl_sum_get_block_var(const ecl_sum_type * ecl_sum , int time_index , const char * block_var , int block_nr) { @@ -559,8 +562,8 @@ double ecl_sum_get_block_var_ijk_from_sim_days( const ecl_sum_type * ecl_sum , d region_nr: [1...num_regions] (NOT C-based indexing) */ -bool ecl_sum_has_region_var(const ecl_sum_type * ecl_sum , const char *var , int region_nr ) { - return ecl_smspec_has_region_var( ecl_sum->smspec , var , region_nr); +bool ecl_sum_has_region_var(const ecl_sum_type * ecl_sum , const char *var , int region_nr ) { + return ecl_smspec_has_region_var( ecl_sum->smspec , var , region_nr); } double ecl_sum_get_region_var(const ecl_sum_type * ecl_sum , int time_index , const char *var , int region_nr) { @@ -583,12 +586,12 @@ double ecl_sum_get_region_var_from_sim_days( const ecl_sum_type * ecl_sum , doub /*****************************************************************/ /* Misc variables */ -int ecl_sum_get_misc_var_index(const ecl_sum_type * ecl_sum , const char *var) { - return ecl_smspec_get_misc_var_params_index( ecl_sum->smspec , var ); +int ecl_sum_get_misc_var_index(const ecl_sum_type * ecl_sum , const char *var) { + return ecl_smspec_get_misc_var_params_index( ecl_sum->smspec , var ); } -bool ecl_sum_has_misc_var(const ecl_sum_type * ecl_sum , const char *var) { - return ecl_smspec_has_misc_var( ecl_sum->smspec , var ); +bool ecl_sum_has_misc_var(const ecl_sum_type * ecl_sum , const char *var) { + return ecl_smspec_has_misc_var( ecl_sum->smspec , var ); } double ecl_sum_get_misc_var(const ecl_sum_type * ecl_sum , int time_index , const char *var) { @@ -631,11 +634,11 @@ int ecl_sum_get_general_var_params_index(const ecl_sum_type * ecl_sum , const ch } -bool ecl_sum_has_general_var(const ecl_sum_type * ecl_sum , const char * lookup_kw) { - return ecl_smspec_has_general_var( ecl_sum->smspec , lookup_kw); +bool ecl_sum_has_general_var(const ecl_sum_type * ecl_sum , const char * lookup_kw) { + return ecl_smspec_has_general_var( ecl_sum->smspec , lookup_kw); } -bool ecl_sum_has_key(const ecl_sum_type * ecl_sum , const char * lookup_kw) { +bool ecl_sum_has_key(const ecl_sum_type * ecl_sum , const char * lookup_kw) { return ecl_sum_has_general_var( ecl_sum , lookup_kw ); } @@ -646,6 +649,11 @@ double ecl_sum_get_general_var(const ecl_sum_type * ecl_sum , int time_index , c } +void ecl_sum_dump_line_to_csv_file(const ecl_sum_type * ecl_sum, time_t sim_time, const ecl_sum_vector_type * key_words, FILE *fp){ + ecl_sum_data_write_csv_file(ecl_sum->data, sim_time, key_words, fp); +} + + double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var) { const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , var ); @@ -836,7 +844,7 @@ time_t ecl_sum_iget_sim_time( const ecl_sum_type * ecl_sum , int index ) { return ecl_sum_data_iget_sim_time( ecl_sum->data , index ); } -const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum) { +const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum) { return ecl_sum_data_get_sim_time( ecl_sum->data ); } @@ -876,12 +884,17 @@ void ecl_sum_fmt_init_csv( ecl_sum_fmt_type * fmt ) { -void ecl_sum_fmt_init_summary_x( ecl_sum_fmt_type * fmt ) { +void ecl_sum_fmt_init_summary_x( const ecl_sum_type * ecl_sum , ecl_sum_fmt_type * fmt ) { fmt->locale = NULL; fmt->sep = ""; fmt->date_fmt = "%d/%m/%Y "; fmt->value_fmt = " %15.6g "; - fmt->days_fmt = "%7.2f "; + + if (util_string_equal( ecl_sum_get_unit( ecl_sum , "TIME") , "DAYS")) + fmt->days_fmt = "%7.2f "; + else + fmt->days_fmt = "%7.4f "; + fmt->header_fmt = " %15s "; fmt->newline = "\n"; @@ -905,52 +918,52 @@ void ecl_sum_fmt_init_summary_x( ecl_sum_fmt_type * fmt ) { static void __ecl_sum_fprintf_line( const ecl_sum_type * ecl_sum , FILE * stream , int internal_index , const bool_vector_type * has_var , const int_vector_type * var_index , char * date_string , const ecl_sum_fmt_type * fmt) { fprintf(stream , fmt->days_fmt , ecl_sum_iget_sim_days(ecl_sum , internal_index)); - fprintf(stream , fmt->sep ); + fprintf(stream , "%s", fmt->sep ); - { + { struct tm ts; time_t sim_time = ecl_sum_iget_sim_time(ecl_sum , internal_index ); util_localtime( &sim_time , &ts); strftime( date_string , DATE_STRING_LENGTH - 1 , fmt->date_fmt , &ts); - fprintf(stream , date_string ); - } + fprintf(stream , "%s", date_string ); + } { int ivar; - for (ivar = 0; ivar < int_vector_size( var_index ); ivar++) { + for (ivar = 0; ivar < int_vector_size( var_index ); ivar++) { if (bool_vector_iget( has_var , ivar )) { - fprintf(stream , fmt->sep); + fprintf(stream , "%s", fmt->sep); fprintf(stream , fmt->value_fmt , ecl_sum_iget(ecl_sum , internal_index, int_vector_iget( var_index , ivar ))); - } - } + } + } } - - fprintf(stream , fmt->newline); + + fprintf(stream , "%s", fmt->newline); } static void ecl_sum_fprintf_header( const ecl_sum_type * ecl_sum , const stringlist_type * key_list , const bool_vector_type * has_var , FILE * stream, const ecl_sum_fmt_type * fmt) { - fprintf(stream , fmt->date_header); - { + fprintf(stream , "%s", fmt->date_header); + { int i; for (i=0; i < stringlist_get_size( key_list ); i++) - if (bool_vector_iget( has_var , i )) { - fprintf(stream , fmt->sep); + if (bool_vector_iget( has_var , i )) { + fprintf(stream , "%s", fmt->sep); fprintf(stream , fmt->header_fmt , stringlist_iget( key_list , i )); } } - fprintf( stream , fmt->newline); + fprintf( stream , "%s", fmt->newline); if (fmt->print_dash) { - fprintf(stream , fmt->date_dash); - + fprintf(stream , "%s", fmt->date_dash); + { int i; for (i=0; i < stringlist_get_size( key_list ); i++) if (bool_vector_iget( has_var , i )) - fprintf(stream , fmt->value_dash); + fprintf(stream , "%s", fmt->value_dash); } - fprintf( stream , fmt->newline); + fprintf( stream , "%s", fmt->newline); } } @@ -964,7 +977,7 @@ void ecl_sum_fprintf(const ecl_sum_type * ecl_sum , FILE * stream , const string char * current_locale = NULL; if (fmt->locale != NULL) current_locale = setlocale(LC_NUMERIC , fmt->locale); - + { int ivar; for (ivar = 0; ivar < stringlist_get_size( var_list ); ivar++) { @@ -977,7 +990,7 @@ void ecl_sum_fprintf(const ecl_sum_type * ecl_sum , FILE * stream , const string } } } - + if (fmt->print_header) ecl_sum_fprintf_header( ecl_sum , var_list , has_var , stream , fmt); @@ -1175,10 +1188,10 @@ void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , c /*****************************************************************/ -/* +/* The functions below are extremly simple functions which only serve as an easy access to the smspec_alloc_xxx_key() functions which - know how to create the various composite keys. + know how to create the various composite keys. */ char * ecl_sum_alloc_well_key( const ecl_sum_type * ecl_sum , const char * keyword , const char * wgname) { @@ -1198,7 +1211,7 @@ bool ecl_sum_is_oil_producer( const ecl_sum_type * ecl_sum , const char * well) if (wopt > 0) oil_producer = true; } - + return oil_producer; } @@ -1206,7 +1219,7 @@ bool ecl_sum_is_oil_producer( const ecl_sum_type * ecl_sum , const char * well) bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2) { if (ecl_sum1 == ecl_sum2) - return true; + return true; else return ecl_sum_data_report_step_equal( ecl_sum1->data , ecl_sum2->data ); } @@ -1214,7 +1227,7 @@ bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_ty bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2) { if (ecl_sum1 == ecl_sum2) - return true; + return true; else return ecl_sum_data_report_step_compatible( ecl_sum1->data , ecl_sum2->data ); } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c b/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c index 86362beac7..ba27897629 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_sum_data.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_sum_data.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <string.h> @@ -34,14 +34,15 @@ #include <ert/ecl/ecl_file.h> #include <ert/ecl/ecl_endian_flip.h> #include <ert/ecl/ecl_kw_magic.h> +#include <ert/ecl/ecl_sum_vector.h> /* - This file implements the type ecl_sum_data_type. The data structure + This file implements the type ecl_sum_data_type. The data structure is involved with holding all the actual summary data (i.e. the PARAMS vectors in ECLIPSE speak), in addition the time-information - with MINISTEPS / REPORT_STEPS and so on is implemented here. + with MINISTEPS / REPORT_STEPS and so on is implemented here. This file has no information about how to index into the PARAMS vector, i.e. at which location can the WWCT for well P6 be found, @@ -62,7 +63,7 @@ ------------------ SEQHDR \ - MINISTEP 0 | + MINISTEP 0 | PARAMS ..... | MINISTEP 1 |==> This is REPORT STEP 1, in file BASE.S00001 PARAMS ..... | @@ -92,7 +93,7 @@ * When using multiple files we can read off the report number from the filename, for unified files this is IMPOSSIBLE, and we just have to assume that the first block corresponds to - report_step 1 and then count afterwards. + report_step 1 and then count afterwards. * When asking for a summary variable at a particular REPORT STEP (as we do in enkf) it is ambigous as to which ministep within @@ -101,7 +102,7 @@ use the last ministep in the block. * There is no BASE.SOOOO file - + * The report steps are halfopen intervals in the "wrong way": (....] @@ -116,7 +117,7 @@ underlying partial differential equation, i.e. the length of the timesteps is controlled by the simulator itself - there is no finer temporal resolution. - + The user has told the simulator to store (i.e. save to file results) the results at reportsteps. A reportstep will typically consist of several ministeps. The timeline below shows a simulation @@ -125,8 +126,8 @@ S0001 S0002 ||------|------|------------|------------------||----------------------|----------------------|| - M1 M2 M3 M4 M5 M6 - + M1 M2 M3 M4 M5 M6 + The first reportstep consist of four ministeps, the second reportstep consits of only two ministeps. As a user you have no control over the length/number of ministeps apart from: @@ -163,7 +164,7 @@ S0000 S0001 ||--------------|---------------|------------X-------------|| M1 M2 /|\ M3 - | + | | We have enteeed the sim_days/sim_time cooresponding to the location @@ -179,9 +180,9 @@ ecl_smspec_set_rate_var() function in ecl_smspec.c. - + Indexing and _get() versus _iget() - ---------------------------------- + ---------------------------------- As already mentionded the set of ministeps is not necessarrily a continous series, we can easily have a series of ministeps with "holes" in it, and the series can also start on a non-zero @@ -196,11 +197,11 @@ data by giving an internal (not that internal ...) index. In ecl_sum_data.c the latter functions have _iget(): - + ecl_sum_data_get_xxx : Expects the time direction given as a ministep_nr. ecl_sum_data_iget_xxx: Expects the time direction given as an internal index. -*/ +*/ @@ -211,14 +212,14 @@ struct ecl_sum_data_struct { ecl_smspec_type * smspec; /* A shared reference - only used for providing good error messages. */ vector_type * data; /* Vector of ecl_sum_tstep_type instances. */ int first_ministep; - int last_ministep; + int last_ministep; double days_start; double sim_length; int_vector_type * report_first_index ; /* Indexed by report_step - giving first internal_index in report_step. */ - int_vector_type * report_last_index; /* Indexed by report_step - giving last internal_index in report_step. */ + int_vector_type * report_last_index; /* Indexed by report_step - giving last internal_index in report_step. */ int first_report_step; int last_report_step; - time_t __min_time; /* An internal member used during the load of + time_t __min_time; /* An internal member used during the load of restarted cases; see doc in ecl_sum_data_append_tstep. */ bool index_valid; time_interval_type * sim_time; /* The time interval sim_time goes from the first time value where we have @@ -250,13 +251,13 @@ struct ecl_sum_data_struct { static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) { int_vector_reset( data->report_first_index); int_vector_reset( data->report_last_index); - + data->first_report_step = 1024 * 1024; data->last_report_step = -1024 * 1024; data->days_start = 0; data->sim_length = -1; data->first_ministep = INVALID_MINISTEP_NR; - data->last_ministep = INVALID_MINISTEP_NR; + data->last_ministep = INVALID_MINISTEP_NR; data->index_valid = false; time_interval_reopen( data->sim_time ); } @@ -267,8 +268,8 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { data->data = vector_alloc_new(); data->smspec = smspec; data->__min_time = 0; - - data->report_first_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR ); + + data->report_first_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR ); data->report_last_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR ); data->sim_time = time_interval_alloc_open(); @@ -280,17 +281,17 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { /** This function will take a report as input , and update the two pointers ministep1 and ministep2 with the range of the report step - (in terms of ministeps). + (in terms of ministeps). Calling this function with report_step == 2 for the example documented at the top of the file will yield: *ministep1 = 3 and *ministep2 = 7. If you are only interested in one of the limits you - can pass in NULL for the other limit, i.e. + can pass in NULL for the other limit, i.e. - xxx(data , report_step , NULL , &ministep2); + xxx(data , report_step , NULL , &ministep2); to get the last step. - + If the supplied report_step is invalid the function will set both return values to -1 (the return value from safe_iget). In that case it is the responsability of the calling scope to check the return @@ -308,9 +309,9 @@ static const ecl_sum_tstep_type * ecl_sum_data_iget_ministep( const ecl_sum_data void ecl_sum_data_report2internal_range(const ecl_sum_data_type * data , int report_step , int * index1 , int * index2 ){ if (index1 != NULL) *index1 = int_vector_safe_iget( data->report_first_index , report_step ); - + if (index2 != NULL) - *index2 = int_vector_safe_iget( data->report_last_index , report_step ); + *index2 = int_vector_safe_iget( data->report_last_index , report_step ); } @@ -331,7 +332,7 @@ static void ecl_sum_data_fwrite_report__( const ecl_sum_data_type * data , int r { int index , index1 , index2; - + ecl_sum_data_report2internal_range( data , report_step , &index1 , &index2); for (index = index1; index <= index2; index++) { const ecl_sum_tstep_type * tstep = ecl_sum_data_iget_ministep( data , index ); @@ -345,9 +346,9 @@ static void ecl_sum_data_fwrite_report__( const ecl_sum_data_type * data , int r static void ecl_sum_data_fwrite_multiple_step( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , int report_step) { char * filename = ecl_util_alloc_filename( NULL , ecl_case , ECL_UNIFIED_SUMMARY_FILE , fmt_case , 0 ); fortio_type * fortio = fortio_open_readwrite( filename , fmt_case , ECL_ENDIAN_FLIP ); - + ecl_sum_data_fwrite_report__( data , report_step , fortio ); - + fortio_fclose( fortio ); free(filename); } @@ -356,7 +357,7 @@ static void ecl_sum_data_fwrite_multiple_step( const ecl_sum_data_type * data , static void ecl_sum_data_fwrite_unified_step( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , int report_step) { char * filename = ecl_util_alloc_filename( NULL , ecl_case , ECL_UNIFIED_SUMMARY_FILE , fmt_case , 0 ); fortio_type * fortio = fortio_open_readwrite( filename , fmt_case , ECL_ENDIAN_FLIP ); - + int current_step = 1; if (report_step > 1) { while (true) { @@ -370,15 +371,15 @@ static void ecl_sum_data_fwrite_unified_step( const ecl_sum_data_type * data , c } } } - + if (current_step == report_step) { // We found the position: long size = fortio_ftell( fortio ); - + util_ftruncate( fortio_get_FILE( fortio ) , size ); ecl_sum_data_fwrite_report__( data , report_step , fortio ); } else util_abort("%s: hmm could not locate the position for report step:%d in summary file:%s \n",__func__ , report_step , filename); - + fortio_fclose( fortio ); free( filename ); } @@ -389,12 +390,12 @@ static void ecl_sum_data_fwrite_unified( const ecl_sum_data_type * data , const char * filename = ecl_util_alloc_filename( NULL , ecl_case , ECL_UNIFIED_SUMMARY_FILE , fmt_case , 0 ); fortio_type * fortio = fortio_open_writer( filename , fmt_case , ECL_ENDIAN_FLIP ); int report_step; - + for (report_step = data->first_report_step; report_step <= data->last_report_step; report_step++) { if (ecl_sum_data_has_report_step( data , report_step )) ecl_sum_data_fwrite_report__( data , report_step , fortio ); - } - + } + fortio_fclose( fortio ); free( filename ); } @@ -407,14 +408,14 @@ static void ecl_sum_data_fwrite_multiple( const ecl_sum_data_type * data , const if (ecl_sum_data_has_report_step( data , report_step )) { char * filename = ecl_util_alloc_filename( NULL , ecl_case , ECL_SUMMARY_FILE , fmt_case , report_step ); fortio_type * fortio = fortio_open_writer( filename , fmt_case , ECL_ENDIAN_FLIP ); - + ecl_sum_data_fwrite_report__( data , report_step , fortio ); - + fortio_fclose( fortio ); free( filename ); } - } - + } + } @@ -451,8 +452,8 @@ double ecl_sum_data_get_first_day( const ecl_sum_data_type * data) { return data actually been loaded) to the last loaded simulation step. */ -double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) { - return data->sim_length; +double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) { + return data->sim_length; } @@ -466,7 +467,7 @@ double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) { have summary data for the requested date/days value. In the case of a restarted case, where the original case is missing - this will return false if the input values are in the region after simulation - start with no data. + start with no data. */ bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time) { @@ -527,7 +528,7 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) { time_t data_start_time = time_interval_get_start( data->sim_time ); time_t sim_end = time_interval_get_end( data->sim_time ); - + if (!ecl_sum_data_check_sim_time( data , sim_time )) { fprintf(stderr , "Simulation start: "); util_fprintf_date( ecl_smspec_get_start_time( data->smspec ) , stderr ); fprintf(stderr , "Data start......: "); util_fprintf_date( data_start_time , stderr ); @@ -535,8 +536,8 @@ static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data fprintf(stderr , "Requested date .: "); util_fprintf_date( sim_time , stderr ); util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data_start_time , sim_end); } - - /* + + /* The moment we have passed the intial test we MUST find a valid ministep index, however care should be taken that there can perfectly well be 'holes' in the time domain, because of e.g. the @@ -546,7 +547,7 @@ static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data int low_index = 0; int high_index = vector_get_size( data->data ); int internal_index = INVALID_MINISTEP_NR; - + while (internal_index < 0) { if (low_index == high_index) @@ -554,7 +555,7 @@ static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data else { int center_index = 0.5*( low_index + high_index ); const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , center_index ); - + if ((high_index - low_index) == 1) { /* Degenerate special case. */ if (sim_time < ecl_sum_tstep_get_sim_time( ministep )) @@ -570,7 +571,7 @@ static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data const ecl_sum_tstep_type * prev_step = ecl_sum_data_iget_ministep( data , center_index - 1 ); prev_time = ecl_sum_tstep_get_sim_time( prev_step ); } - + if (prev_time < sim_time) internal_index = center_index; /* Found it */ else @@ -594,7 +595,7 @@ int ecl_sum_data_get_index_from_sim_days( const ecl_sum_data_type * data , doubl /** This function will take a true time 'sim_time' as input. The ministep indices bracketing this sim_time is identified, and the - corresponding weights are calculated. + corresponding weights are calculated. The actual value we are interested in can then be computed with the ecl_sum_data_interp_get() function: @@ -609,8 +610,8 @@ int ecl_sum_data_get_index_from_sim_days( const ecl_sum_data_type * data , doubl ecl_sum_data_init_interp_from_sim_time( data , sim_time , &ministep1 , &ministep2 , &weight1 , &weight2); return ecl_sum_data_interp_get( data , ministep1 , ministep2 , weight1 , weight2 , param_index ); } - - + + For further explanation (in particular for which keywords the function should be used), consult documentation at the top of this file. @@ -624,8 +625,8 @@ void ecl_sum_data_init_interp_from_sim_time( const ecl_sum_data_type * data , ti const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data , index2 ); const ecl_sum_tstep_type * ministep1; time_t sim_time2 = ecl_sum_tstep_get_sim_time( ministep2 ); - - + + index1 = index2; while (true) { index1--; @@ -638,12 +639,12 @@ void ecl_sum_data_init_interp_from_sim_time( const ecl_sum_data_type * data , ti if (index1 == 0) util_abort("%s: Hmm internal error?? \n",__func__); } - + { double weight2 = (sim_time - ecl_sum_tstep_get_sim_time( ministep1 )); double weight1 = -(sim_time - ecl_sum_tstep_get_sim_time( ministep2 )); - - + + *_index1 = index1; *_index2 = index2; *_weight1 = weight1 / ( weight1 + weight2 ); @@ -664,7 +665,7 @@ void ecl_sum_data_init_interp_from_sim_days( const ecl_sum_data_type * data , do static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , int ministep_nr , ecl_sum_tstep_type * tstep) { - /* + /* Here the tstep is just appended naively, the vector will be sorted by ministep_nr before the data instance is returned. */ @@ -681,8 +682,8 @@ static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , int ministep the initial simulation: Simulation 1: T1-------------TR------------T2 - | - Simulation 2: \-----------------------T3 + | + Simulation 2: \-----------------------T3 In the time interval [TR,T2] we have data from two simulations, we @@ -691,14 +692,14 @@ static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , int ministep have been performed by the scope calling this function; when a ministep has arrived here it will be added. */ - + if (data->__min_time == 0) data->__min_time = ecl_sum_tstep_get_sim_time( tstep ); else { if (ecl_sum_tstep_get_sim_time( tstep ) < data->__min_time) data->__min_time = ecl_sum_tstep_get_sim_time( tstep ); } - + vector_append_owned_ref( data->data , tstep , ecl_sum_tstep_free__); data->index_valid = false; } @@ -706,15 +707,15 @@ static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , int ministep static void ecl_sum_data_update_end_info( ecl_sum_data_type * sum_data ) { const ecl_sum_tstep_type * last_ministep = vector_get_last_const( sum_data->data ); - + sum_data->last_ministep = ecl_sum_tstep_get_ministep( last_ministep ); sum_data->sim_length = ecl_sum_tstep_get_sim_days( last_ministep ); time_interval_update_end( sum_data->sim_time , ecl_sum_tstep_get_sim_time( last_ministep )); } - + static int cmp_ministep( const void * arg1 , const void * arg2) { const ecl_sum_tstep_type * ministep1 = ecl_sum_tstep_safe_cast_const( arg1 ); - const ecl_sum_tstep_type * ministep2 = ecl_sum_tstep_safe_cast_const( arg2 ); + const ecl_sum_tstep_type * ministep2 = ecl_sum_tstep_safe_cast_const( arg2 ); time_t time1 = ecl_sum_tstep_get_sim_time( ministep1 ); time_t time2 = ecl_sum_tstep_get_sim_time( ministep2 ); @@ -731,19 +732,19 @@ static int cmp_ministep( const void * arg1 , const void * arg2) { static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { /* Clear the existing index (if any): */ ecl_sum_data_clear_index( sum_data ); - + /* - Sort the internal storage vector after sim_time. + Sort the internal storage vector after sim_time. */ vector_sort( sum_data->data , cmp_ministep ); - + /* Identify various global first and last values. */ { const ecl_sum_tstep_type * first_ministep = ecl_sum_data_iget_ministep( sum_data , 0 ); sum_data->first_ministep = ecl_sum_tstep_get_ministep( first_ministep ); - /* + /* In most cases the days_start and data_start_time will agree with the global simulation start; however in the case where we have loaded a summary case from a restarted simulation where @@ -754,14 +755,14 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { time_interval_update_start( sum_data->sim_time , ecl_sum_tstep_get_sim_time( first_ministep )); } ecl_sum_data_update_end_info( sum_data ); - + /* Build up the report -> ministep mapping. */ { int internal_index; for (internal_index = 0; internal_index < vector_get_size( sum_data->data ); internal_index++) { const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( sum_data , internal_index ); int report_step = ecl_sum_tstep_get_report(ministep); - + /* Indexing internal_index - report_step */ { int current_first_index = int_vector_safe_iget( sum_data->report_first_index , report_step ); @@ -771,7 +772,7 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { if (internal_index < current_first_index) int_vector_iset( sum_data->report_first_index , report_step , internal_index); } - + { int current_last_index = int_vector_safe_iget( sum_data->report_last_index , report_step ); if (current_last_index < 0) @@ -780,7 +781,7 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { if (internal_index > current_last_index) int_vector_iset( sum_data->report_last_index , report_step , internal_index); } - + sum_data->first_report_step = util_int_min( sum_data->first_report_step , report_step ); sum_data->last_report_step = util_int_max( sum_data->last_report_step , report_step ); } @@ -796,15 +797,15 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { will also be returned, so the calling scope can call ecl_sum_tstep_iset() to set elements in the tstep. */ - -ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_days) { + +ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_seconds) { int ministep_nr = vector_get_size( data->data ); - ecl_sum_tstep_type * tstep = ecl_sum_tstep_alloc_new( report_step , ministep_nr , sim_days , data->smspec ); + ecl_sum_tstep_type * tstep = ecl_sum_tstep_alloc_new( report_step , ministep_nr , sim_seconds , data->smspec ); ecl_sum_tstep_type * prev_tstep = NULL; if (vector_get_size( data->data ) > 0) prev_tstep = vector_get_last( data->data ); - + ecl_sum_data_append_tstep__( data , ministep_nr , tstep ); { bool rebuild_index = true; @@ -815,12 +816,12 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int index, otherwise we call ecl_sum_data_build_index() to get a full recalculation of the index. */ - + if (prev_tstep != NULL) { if (ecl_sum_tstep_get_report( prev_tstep ) == ecl_sum_tstep_get_report( tstep )) { // Same report step if (ecl_sum_tstep_get_sim_days( prev_tstep ) < ecl_sum_tstep_get_sim_days( tstep )) { // This tstep will become the new latest tstep int internal_index = vector_get_size( data->data ) - 1; - + ecl_sum_data_update_end_info( data ); int_vector_iset( data->report_last_index , report_step , internal_index ); rebuild_index = false; @@ -831,7 +832,7 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int ecl_sum_data_build_index( data ); } ecl_smspec_lock( data->smspec ); - + return tstep; } @@ -863,13 +864,13 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int calling routine will read the unified summary file partly. */ -static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , - time_t load_end , - int report_step , - const ecl_file_type * ecl_file , +static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , + time_t load_end , + int report_step , + const ecl_file_type * ecl_file , const ecl_smspec_type * smspec) { - - + + int num_ministep = ecl_file_get_num_named_kw( ecl_file , PARAMS_KW); if (num_ministep > 0) { int ikw; @@ -881,16 +882,16 @@ static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , { ecl_sum_tstep_type * tstep; int ministep_nr = ecl_kw_iget_int( ministep_kw , 0 ); - tstep = ecl_sum_tstep_alloc_from_file( report_step , + tstep = ecl_sum_tstep_alloc_from_file( report_step , ministep_nr , - params_kw , + params_kw , ecl_file_get_src_file( ecl_file ), smspec ); - + if (tstep != NULL) { if (load_end == 0 || (ecl_sum_tstep_get_sim_time( tstep ) < load_end)) ecl_sum_data_append_tstep__( data , ministep_nr , tstep ); - else + else /* This tstep is in a time-period overlapping with data we already have; discard this. */ ecl_sum_tstep_free( tstep ); @@ -901,76 +902,87 @@ static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , } - +static bool ecl_sum_data_check_file( ecl_file_type * ecl_file ) { + if (ecl_file_has_kw( ecl_file , PARAMS_KW ) && + (ecl_file_get_num_named_kw( ecl_file , PARAMS_KW ) == ecl_file_get_num_named_kw( ecl_file , MINISTEP_KW))) + return true; + else + return false; +} /* Observe that this can be called several times (but not with the same - data - that will die). + data - that will die). Warning: The index information of the ecl_sum_data instance has __NOT__ been updated when leaving this function. That is done with a call to ecl_sum_data_build_index(). */ -static void ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , const stringlist_type * filelist) { - ecl_file_enum file_type; - +static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , const stringlist_type * filelist) { if (stringlist_get_size( filelist ) == 0) - util_abort("%s: internal error - function called with empty list of data files.\n",__func__); - - file_type = ecl_util_get_file_type( stringlist_iget( filelist , 0 ) , NULL , NULL); - if ((stringlist_get_size( filelist ) > 1) && (file_type != ECL_SUMMARY_FILE)) - util_abort("%s: internal error - when calling with more than one file - you can not supply a unified file - come on?! \n",__func__); + return false; + { - int filenr; - if (file_type == ECL_SUMMARY_FILE) { - - /* Not unified. */ - for (filenr = 0; filenr < stringlist_get_size( filelist ); filenr++) { - const char * data_file = stringlist_iget( filelist , filenr); - ecl_file_enum file_type; - int report_step; - file_type = ecl_util_get_file_type( data_file , NULL , &report_step); - /** - ECLIPSE starts a report step by writing an empty summary - file, therefor we must verify that the ecl_file instance - returned by ecl_file_fread_alloc() is different from NULL - before adding it to the ecl_sum_data instance. - */ - if (file_type != ECL_SUMMARY_FILE) - util_abort("%s: file:%s has wrong type \n",__func__ , data_file); - { - ecl_file_type * ecl_file = ecl_file_open( data_file , 0); - ecl_sum_data_add_ecl_file( data , load_end , report_step , ecl_file , data->smspec); + ecl_file_enum file_type = ecl_util_get_file_type( stringlist_iget( filelist , 0 ) , NULL , NULL); + if ((stringlist_get_size( filelist ) > 1) && (file_type != ECL_SUMMARY_FILE)) + util_abort("%s: internal error - when calling with more than one file - you can not supply a unified file - come on?! \n",__func__); + + { + int filenr; + if (file_type == ECL_SUMMARY_FILE) { + + /* Not unified. */ + for (filenr = 0; filenr < stringlist_get_size( filelist ); filenr++) { + const char * data_file = stringlist_iget( filelist , filenr); + ecl_file_enum file_type; + int report_step; + file_type = ecl_util_get_file_type( data_file , NULL , &report_step); + if (file_type != ECL_SUMMARY_FILE) + util_abort("%s: file:%s has wrong type \n",__func__ , data_file); + { + ecl_file_type * ecl_file = ecl_file_open( data_file , 0); + if (ecl_file && ecl_sum_data_check_file( ecl_file )) { + ecl_sum_data_add_ecl_file( data , load_end , report_step , ecl_file , data->smspec); + ecl_file_close( ecl_file ); + } + } + } + } else if (file_type == ECL_UNIFIED_SUMMARY_FILE) { + ecl_file_type * ecl_file = ecl_file_open( stringlist_iget(filelist ,0 ) , 0); + if (ecl_file && ecl_sum_data_check_file( ecl_file )) { + int report_step = 1; /* <- ECLIPSE numbering - starting at 1. */ + while (true) { + /* + Observe that there is a number discrepancy between ECLIPSE + and the ecl_file_select_smryblock() function. ECLIPSE + starts counting report steps at 1; whereas the first + SEQHDR block in the unified summary file is block zero (in + ert counting). + */ + if (ecl_file_select_smryblock( ecl_file , report_step - 1)) { + ecl_sum_data_add_ecl_file( data , load_end , report_step , ecl_file , data->smspec); + report_step++; + } else break; + } ecl_file_close( ecl_file ); } - } - } else if (file_type == ECL_UNIFIED_SUMMARY_FILE) { - ecl_file_type * ecl_file = ecl_file_open( stringlist_iget(filelist ,0 ) , 0); - int report_step = 1; /* <- ECLIPSE numbering - starting at 1. */ - while (true) { - /* - Observe that there is a number discrepancy between ECLIPSE - and the ecl_file_select_smryblock() function. ECLIPSE - starts counting report steps at 1; whereas the first - SEQHDR block in the unified summary file is block zero (in - ert counting). - */ - if (ecl_file_select_smryblock( ecl_file , report_step - 1)) { - ecl_sum_data_add_ecl_file( data , load_end , report_step , ecl_file , data->smspec); - report_step++; - } else break; - } - ecl_file_close( ecl_file ); - } else - util_abort("%s: invalid file type:%s \n",__func__ , ecl_util_file_type_name(file_type )); - } - ecl_sum_data_build_index( data ); + } else + util_abort("%s: invalid file type:%s \n",__func__ , ecl_util_file_type_name(file_type )); + } + + if (ecl_sum_data_get_length( data ) > 0) { + ecl_sum_data_build_index( data ); + return true; + } else + return false; + + } } -void ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist) { - ecl_sum_data_fread__( data , 0 , filelist ); +bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist) { + return ecl_sum_data_fread__( data , 0 , filelist ); } @@ -1012,7 +1024,7 @@ ecl_sum_data_type * ecl_sum_data_fread_alloc( ecl_smspec_type * smspec , const s } -void ecl_sum_data_summarize(const ecl_sum_data_type * data , FILE * stream) { +void ecl_sum_data_summarize(const ecl_sum_data_type * data , FILE * stream) { fprintf(stream , "REPORT INDEX DATE DAYS\n"); fprintf(stream , "---------------------------------------------------------------\n"); { @@ -1048,7 +1060,7 @@ bool ecl_sum_data_has_report_step(const ecl_sum_data_type * data , int report_st */ int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_step ) { - return int_vector_safe_iget( data->report_last_index , report_step ); + return int_vector_safe_iget( data->report_last_index , report_step ); } @@ -1062,7 +1074,7 @@ int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_st int ecl_sum_data_iget_report_start( const ecl_sum_data_type * data , int report_step ) { - return int_vector_safe_iget( data->report_first_index , report_step ); + return int_vector_safe_iget( data->report_first_index , report_step ); } @@ -1086,7 +1098,7 @@ int ecl_sum_data_iget_mini_step(const ecl_sum_data_type * data , int internal_in -/** +/** This will look up a value based on an internal index. The internal index will ALWAYS run in the interval [0,num_ministep), without any holes. @@ -1095,16 +1107,16 @@ int ecl_sum_data_iget_mini_step(const ecl_sum_data_type * data , int internal_in double ecl_sum_data_iget( const ecl_sum_data_type * data , int time_index , int params_index ) { const ecl_sum_tstep_type * ministep_data = ecl_sum_data_iget_ministep( data , time_index ); - return ecl_sum_tstep_iget( ministep_data , params_index); + return ecl_sum_tstep_iget( ministep_data , params_index); } /** This function will form a weight average of the two ministeps @ministep1 and @ministep2. The weights and the ministep indices - should (typically) be determined by the + should (typically) be determined by the - ecl_sum_data_init_interp_from_sim_xxx() + ecl_sum_data_init_interp_from_sim_xxx() functions. The function will typically the last function called when we seek a reservoir state variable at an intermediate time @@ -1112,13 +1124,43 @@ double ecl_sum_data_iget( const ecl_sum_data_type * data , int time_index , int */ double ecl_sum_data_interp_get(const ecl_sum_data_type * data , int time_index1 , int time_index2 , double weight1 , double weight2 , int params_index) { - const ecl_sum_tstep_type * ministep_data1 = ecl_sum_data_iget_ministep( data , time_index1 ); - const ecl_sum_tstep_type * ministep_data2 = ecl_sum_data_iget_ministep( data , time_index2 ); - + const ecl_sum_tstep_type * ministep_data1 = ecl_sum_data_iget_ministep( data , time_index1 ); + const ecl_sum_tstep_type * ministep_data2 = ecl_sum_data_iget_ministep( data , time_index2 ); + return ecl_sum_tstep_iget( ministep_data1 , params_index ) * weight1 + ecl_sum_tstep_iget( ministep_data2 , params_index ) * weight2; } +void ecl_sum_data_write_csv_file(const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, FILE *fp){ + int num_keywords = ecl_sum_vector_get_size(keylist); + double weight1 , weight2; + int time_index1 , time_index2; + double value = 0.0; + int i; + + ecl_sum_data_init_interp_from_sim_time( data , sim_time , &time_index1 , &time_index2 , &weight1 , &weight2); + for(i = 0; i< num_keywords; i++ ){ + bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i); + int params_index = ecl_sum_vector_iget_param_index(keylist , i); + if(is_rate){ + int time_index; + if (sim_time == time_interval_get_start( data->sim_time )) + time_index = 0; + else + time_index = ecl_sum_data_get_index_from_sim_time( data , sim_time ); + + value = ecl_sum_data_iget( data , time_index , params_index); + } else { + value = ecl_sum_data_interp_get( data , time_index1 , time_index2 , weight1 , weight2 , params_index); + + } + if(i == 0){ + fprintf(fp , "%f",value); + }else{ + fprintf(fp , ",%f",value); + } + } +} @@ -1133,14 +1175,14 @@ double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t s []<------------]<--------------]<-----------] t0 t1 t2 t3 - + However - as indicated on the figure above there is a zero measure point right at the start which corresponds to time_index == 0; this is to ensure that there is correspondance with the ECLIPSE results if you ask for a value interpolated to the starting time. */ - if (sim_time == time_interval_get_start( data->sim_time )) + if (sim_time == time_interval_get_start( data->sim_time )) time_index = 0; else time_index = ecl_sum_data_get_index_from_sim_time( data , sim_time ); @@ -1150,7 +1192,7 @@ double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t s /* Interpolated lookup based on two (hopefully) consecutive ministeps. */ double weight1 , weight2; int time_index1 , time_index2; - + ecl_sum_data_init_interp_from_sim_time( data , sim_time , &time_index1 , &time_index2 , &weight1 , &weight2); return ecl_sum_data_interp_get( data , time_index1 , time_index2 , weight1 , weight2 , params_index); @@ -1171,19 +1213,19 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , doub for (i=1; i < int_vector_size( data->report_last_index ); i++) { int ministep_index = int_vector_iget( data->report_last_index , i ); const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index ); - + double_vector_iset( days_map , i , ecl_sum_tstep_get_sim_days( ministep )); int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep )); } - + { /** Hmmmm - double == comparison ... */ int index = double_vector_index_sorted( days_map , sim_days ); - + if (index >= 0) report_step = int_vector_iget( report_map , index ); } - + int_vector_free( report_map ); double_vector_free( days_map ); return report_step; @@ -1193,14 +1235,14 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , doub /** Will go through the data and find the report step which EXACTLY matches the input sim_time. If no report step matches exactly the - function will return -1. + function will return -1. Observe that by default the report steps consist of half-open time intervals like this: (t1, t2]. However the first report step (i.e. report step 1, is a fully inclusive interval: [t0 , t1] where t0 is the simulation start time. That is not implemented here; meaning that if you supply the start time as @sim_time argument you - will get -1 and not 0 as you might expect. + will get -1 and not 0 as you might expect. It would certainly be possible to detect the start_time input argument and special case the return, but the opposite would be @@ -1211,7 +1253,7 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , doub int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time_t sim_time) { - + if (!ecl_sum_data_check_sim_time(data , sim_time)) return -1; @@ -1225,19 +1267,19 @@ int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time for (i=1; i < int_vector_size( data->report_last_index ); i++) { int ministep_index = int_vector_iget( data->report_last_index , i ); const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index ); - + time_t_vector_iset( time_map , i , ecl_sum_tstep_get_sim_time( ministep )); int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep )); - + } - + { int index = time_t_vector_index_sorted( time_map , sim_time ); - + if (index >= 0) report_step = int_vector_iget( report_map , index ); } - + int_vector_free( report_map ); time_t_vector_free( time_map ); return report_step; @@ -1371,7 +1413,7 @@ int ecl_sum_data_get_length( const ecl_sum_data_type * data ) { bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2) { bool equal = true; if (int_vector_size( data1->report_last_index ) == int_vector_size(data2->report_last_index)) { - int i; + int i; for (i = 0; i < int_vector_size( data1->report_last_index ); i++) { int time_index1 = int_vector_iget( data1->report_last_index , i ); int time_index2 = int_vector_iget( data2->report_last_index , i ); @@ -1379,7 +1421,7 @@ bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl if ((time_index1 != INVALID_MINISTEP_NR) && (time_index2 != INVALID_MINISTEP_NR)) { const ecl_sum_tstep_type * ministep1 = ecl_sum_data_iget_ministep( data1 , time_index1 ); const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data2 , time_index2 ); - + if (!ecl_sum_tstep_sim_time_equal( ministep1 , ministep2)) { equal = false; break; @@ -1399,7 +1441,7 @@ bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2) { bool compatible = true; int min_size = util_int_min( int_vector_size( data1->report_last_index ) , int_vector_size( data2->report_last_index)); - int i; + int i; for (i = 0; i < min_size; i++) { int time_index1 = int_vector_iget( data1->report_last_index , i ); int time_index2 = int_vector_iget( data2->report_last_index , i ); @@ -1407,12 +1449,12 @@ bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , cons if ((time_index1 != INVALID_MINISTEP_NR) && (time_index2 != INVALID_MINISTEP_NR)) { const ecl_sum_tstep_type * ministep1 = ecl_sum_data_iget_ministep( data1 , time_index1 ); const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data2 , time_index2 ); - + if (!ecl_sum_tstep_sim_time_equal( ministep1 , ministep2)) { compatible = false; break; } - } - } + } + } return compatible; } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_sum_tstep.c b/ThirdParty/Ert/devel/libecl/src/ecl_sum_tstep.c index e982a24106..11efcc4fca 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_sum_tstep.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_sum_tstep.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ecl_sum_tstep.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ecl_sum_tstep.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <time.h> @@ -35,19 +35,19 @@ summary information for all summary vectors at one instant in time. If we view the summary data as this: - -Header direction: ecl_smspec DAYS WWCT:OP_3 FOPT BPR:15,10,25 + +Header direction: ecl_smspec DAYS WWCT:OP_3 FOPT BPR:15,10,25 -------------------------------------------- /|\ 0.00 0.00 0.00 256.00 <-- One timestep ecl_sum_tstep | 10.00 0.56 10.00 255.00 Time direction: ecl_sum_data 20.00 0.61 18.70 253.00 | 30.00 0.63 21.20 251.00 | ... - \|/ 90.00 0.80 39.70 244.00 + \|/ 90.00 0.80 39.70 244.00 -------------------------------------------- The ecl_sum_tstep structure corresponds to one 'horizontal line' in - the summary data. + the summary data. These timesteps correspond exactly to the simulators timesteps, i.e. when convergence is poor they are closely spaced. In the @@ -59,13 +59,13 @@ Header direction: ecl_smspec DAYS WWCT:OP_3 FOPT BPR:15,10,25 struct ecl_sum_tstep_struct { UTIL_TYPE_ID_DECLARATION; float * data; /* A memcpy copy of the PARAMS vector in ecl_kw instance - the raw data. */ - time_t sim_time; /* The true time (i.e. 20.th of october 2010) of corresponding to this timestep. */ + time_t sim_time; /* The true time (i.e. 20.th of october 2010) of corresponding to this timestep. */ int ministep; /* The ECLIPSE internal time-step number; one ministep per numerical timestep. */ int report_step; /* The report step this time-step is part of - in general there can be many timestep for each report step. */ - double sim_days; /* Accumulated simulation time up to this ministep. */ + double sim_seconds; /* Accumulated simulation time up to this ministep. */ int data_size; /* Number of elements in data - only used for checking indices. */ int internal_index; /* Used for lookups of the next / previous ministep based on an existing ministep. */ - const ecl_smspec_type * smspec; /* The smespec header information for this tstep - must be compatible. */ + const ecl_smspec_type * smspec; /* The smespec header information for this tstep - must be compatible. */ }; @@ -76,7 +76,7 @@ static ecl_sum_tstep_type * ecl_sum_tstep_alloc( int report_step , int ministep_ tstep->report_step = report_step; tstep->ministep = ministep_nr; tstep->data_size = ecl_smspec_get_params_size( smspec ); - tstep->data = util_calloc( tstep->data_size , sizeof * tstep->data ); + tstep->data = util_calloc( tstep->data_size , sizeof * tstep->data ); return tstep; } @@ -106,13 +106,14 @@ void ecl_sum_tstep_free__( void * __ministep) { element like e.g. the FOPT or GGPR:NAME - on the other hand the time information is strictly required and the summary file will fall to pieces if it is missing. - + The time can be provided in using (at least) two different keywords: - DAYS: The data vector will contain the number of days since the - simulation start. - + DAYS/HOURS: The data vector will contain the number of + days/hours since the simulation start (hours in the case + of lab units). + DAY,MONTH,YEAR: The data vector will contain the true date of the tstep. @@ -120,16 +121,16 @@ void ecl_sum_tstep_free__( void * __ministep) { will select the DAYS variety if both are present. */ -static void ecl_sum_tstep_set_time_info_from_days( ecl_sum_tstep_type * tstep , time_t sim_start , float sim_days) { - tstep->sim_days = sim_days; +static void ecl_sum_tstep_set_time_info_from_seconds( ecl_sum_tstep_type * tstep , time_t sim_start , float sim_seconds) { + tstep->sim_seconds = sim_seconds; tstep->sim_time = sim_start; - util_inplace_forward_days( &tstep->sim_time , tstep->sim_days ); + util_inplace_forward_seconds( &tstep->sim_time , tstep->sim_seconds ); } static void ecl_sum_tstep_set_time_info_from_date( ecl_sum_tstep_type * tstep , time_t sim_start , time_t sim_time) { tstep->sim_time = sim_time; - tstep->sim_days = util_difftime_days( sim_start , tstep->sim_time); + tstep->sim_seconds = util_difftime_seconds( sim_start , tstep->sim_time); } @@ -137,21 +138,22 @@ static void ecl_sum_tstep_set_time_info( ecl_sum_tstep_type * tstep , const ecl_ int date_day_index = ecl_smspec_get_date_day_index( smspec ); int date_month_index = ecl_smspec_get_date_month_index( smspec ); int date_year_index = ecl_smspec_get_date_year_index( smspec ); - int sim_days_index = ecl_smspec_get_sim_days_index( smspec ); + int sim_time_index = ecl_smspec_get_time_index( smspec ); time_t sim_start = ecl_smspec_get_start_time( smspec ); - if (sim_days_index >= 0) { - float sim_days = tstep->data[ sim_days_index ]; - ecl_sum_tstep_set_time_info_from_days( tstep , sim_start , sim_days ); + if (sim_time_index >= 0) { + float sim_time = tstep->data[ sim_time_index ]; + double sim_seconds = sim_time * ecl_smspec_get_time_seconds( smspec ); + ecl_sum_tstep_set_time_info_from_seconds( tstep , sim_start , sim_seconds ); } else if ( date_day_index >= 0) { int sec = 0; int min = 0; int hour = 0; - + int day = util_roundf(tstep->data[date_day_index]); int month = util_roundf(tstep->data[date_month_index]); int year = util_roundf(tstep->data[date_year_index]); - + time_t sim_time = util_make_datetime(sec , min , hour , day , month , year); ecl_sum_tstep_set_time_info_from_date( tstep , sim_start , sim_time ); } else @@ -169,19 +171,19 @@ static void ecl_sum_tstep_set_time_info( ecl_sum_tstep_type * tstep , const ecl_ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step , int ministep_nr , - const ecl_kw_type * params_kw , - const char * src_file , + const ecl_kw_type * params_kw , + const char * src_file , const ecl_smspec_type * smspec) { int data_size = ecl_kw_get_size( params_kw ); - + if (data_size == ecl_smspec_get_params_size( smspec )) { ecl_sum_tstep_type * ministep = ecl_sum_tstep_alloc( report_step , ministep_nr , smspec); ecl_kw_get_memcpy_data( params_kw , ministep->data ); ecl_sum_tstep_set_time_info( ministep , smspec ); return ministep; } else { - /* + /* This is actually a fatal error / bug; the difference in smspec header structure should have been detected already in the ecl_smspec_load_restart() function and the restart case @@ -197,13 +199,13 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step , Should be called in write mode. */ -ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , float sim_days , const ecl_smspec_type * smspec ) { +ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , float sim_seconds , const ecl_smspec_type * smspec ) { ecl_sum_tstep_type * tstep = ecl_sum_tstep_alloc( report_step , ministep , smspec ); const float_vector_type * default_data = ecl_smspec_get_params_default( smspec ); float_vector_memcpy_data( tstep->data , default_data ); - ecl_sum_tstep_set_time_info_from_days( tstep , ecl_smspec_get_start_time( smspec ) , sim_days ); - ecl_sum_tstep_iset( tstep , ecl_smspec_get_time_index( smspec ) , sim_days ); + ecl_sum_tstep_set_time_info_from_seconds( tstep , ecl_smspec_get_start_time( smspec ) , sim_seconds ); + ecl_sum_tstep_iset( tstep , ecl_smspec_get_time_index( smspec ) , sim_seconds / ecl_smspec_get_time_seconds( smspec ) ); return tstep; } @@ -226,7 +228,11 @@ time_t ecl_sum_tstep_get_sim_time(const ecl_sum_tstep_type * ministep) { double ecl_sum_tstep_get_sim_days(const ecl_sum_tstep_type * ministep) { - return ministep->sim_days; + return ministep->sim_seconds / (24 * 3600); +} + +double ecl_sum_tstep_get_sim_seconds(const ecl_sum_tstep_type * ministep) { + return ministep->sim_seconds; } int ecl_sum_tstep_get_report(const ecl_sum_tstep_type * ministep) { diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_sum_vector.c b/ThirdParty/Ert/devel/libecl/src/ecl_sum_vector.c new file mode 100644 index 0000000000..cc02bf1523 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/src/ecl_sum_vector.c @@ -0,0 +1,94 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ecl_sum_vector.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <ert/ecl/ecl_sum_vector.h> +#include <ert/ecl/ecl_sum.h> +#include <ert/ecl/ecl_smspec.h> + +#include <ert/util/util.h> +#include <ert/util/vector.h> +#include <ert/util/type_macros.h> +#include <ert/util/int_vector.h> +#include <ert/util/bool_vector.h> + + +#define ECL_SUM_VECTOR_TYPE_ID 8756667078 + +struct ecl_sum_vector_struct { + int_vector_type * node_index_list; + bool_vector_type * is_rate_list; + const ecl_sum_type * ecl_sum; +}; + +void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){ + int_vector_free(ecl_sum_vector->node_index_list); + bool_vector_free(ecl_sum_vector->is_rate_list); +} + +ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum){ + ecl_sum_vector_type * ecl_sum_vector = util_malloc( sizeof * ecl_sum_vector ); + ecl_sum_vector->ecl_sum = ecl_sum; + ecl_sum_vector->node_index_list = int_vector_alloc(0,0); + ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false); + return ecl_sum_vector; +} + + +bool ecl_sum_vector_add_key( ecl_sum_vector_type * ecl_sum_vector, const char * key){ + if (ecl_sum_has_general_var( ecl_sum_vector->ecl_sum , key)) { + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); + int params_index = smspec_node_get_params_index( node ); + bool is_rate_key = smspec_node_is_rate( node); + + int_vector_append(ecl_sum_vector->node_index_list, params_index); + bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key); + return true; + } else + return false; +} + + + +void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char * pattern){ + stringlist_type * keylist = ecl_sum_alloc_matching_general_var_list(ecl_sum_vector->ecl_sum , pattern); + + int num_keywords = stringlist_get_size(keylist); + int i; + for(i = 0; i < num_keywords ;i++){ + const char * key = stringlist_iget(keylist, i); + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); + int params_index = smspec_node_get_params_index( node ); + bool is_rate_key = smspec_node_is_rate( node); + + int_vector_append(ecl_sum_vector->node_index_list, params_index); + bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key); + } + stringlist_free(keylist); +} + +int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector){ + return int_vector_size(ecl_sum_vector->node_index_list); +} + +bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index){ + return bool_vector_iget(ecl_sum_vector->is_rate_list, index); +} + +int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index){ + return int_vector_iget(ecl_sum_vector->node_index_list, index); +} diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_util.c b/ThirdParty/Ert/devel/libecl/src/ecl_util.c index 77d66cdc0c..ad32fe86aa 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_util.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_util.c @@ -1206,12 +1206,12 @@ int ecl_util_get_month_nr(const char * month_name) { time_t ecl_util_get_start_date(const char * data_file) { - parser_type * parser = parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n"); + basic_parser_type * parser = basic_parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n"); time_t start_date = -1; FILE * stream = util_fopen(data_file , "r"); char * buffer; - if (!parser_fseek_string( parser , stream , "START" , true , true)) /* Seeks case insensitive. */ + if (!basic_parser_fseek_string( parser , stream , "START" , true , true)) /* Seeks case insensitive. */ util_abort("%s: sorry - could not find START in DATA file %s \n",__func__ , data_file); { @@ -1219,7 +1219,7 @@ time_t ecl_util_get_start_date(const char * data_file) { int buffer_size; /* Look for terminating '/' */ - if (!parser_fseek_string( parser , stream , "/" , false , true)) + if (!basic_parser_fseek_string( parser , stream , "/" , false , true)) util_abort("%s: sorry - could not find \"/\" termination of START keyword in data_file: \n",__func__ , data_file); buffer_size = (util_ftell(stream) - start_pos) ; @@ -1231,7 +1231,7 @@ time_t ecl_util_get_start_date(const char * data_file) { { - stringlist_type * tokens = parser_tokenize_buffer( parser , buffer , true ); + stringlist_type * tokens = basic_parser_tokenize_buffer( parser , buffer , true ); int day, year, month_nr; if ( util_sscanf_int( stringlist_iget( tokens , 0 ) , &day) && util_sscanf_int( stringlist_iget(tokens , 2) , &year)) { month_nr = ecl_util_get_month_nr(stringlist_iget( tokens , 1)); @@ -1242,21 +1242,21 @@ time_t ecl_util_get_start_date(const char * data_file) { } free( buffer ); - parser_free( parser ); + basic_parser_free( parser ); fclose(stream); return start_date; } -static int ecl_util_get_num_parallel_cpu__(parser_type* parser, FILE* stream, const char * data_file) { +static int ecl_util_get_num_parallel_cpu__(basic_parser_type* parser, FILE* stream, const char * data_file) { int num_cpu = 1; char * buffer; long int start_pos = util_ftell( stream ); int buffer_size; /* Look for terminating '/' */ - if (!parser_fseek_string( parser , stream , "/" , false , true)) + if (!basic_parser_fseek_string( parser , stream , "/" , false , true)) util_abort("%s: sorry - could not find \"/\" termination of PARALLEL keyword in data_file: \n",__func__ , data_file); buffer_size = (util_ftell(stream) - start_pos) ; @@ -1266,7 +1266,7 @@ static int ecl_util_get_num_parallel_cpu__(parser_type* parser, FILE* stream, co buffer[buffer_size] = '\0'; { - stringlist_type * tokens = parser_tokenize_buffer( parser , buffer , true ); + stringlist_type * tokens = basic_parser_tokenize_buffer( parser , buffer , true ); if (stringlist_get_size( tokens ) > 0) { const char * num_cpu_string = stringlist_iget( tokens , 0 ); @@ -1283,11 +1283,11 @@ static int ecl_util_get_num_parallel_cpu__(parser_type* parser, FILE* stream, co -static int ecl_util_get_num_slave_cpu__(parser_type* parser, FILE* stream, const char * data_file) { +static int ecl_util_get_num_slave_cpu__(basic_parser_type* parser, FILE* stream, const char * data_file) { int num_cpu = 0; int linecount = 0; - parser_fseek_string( parser , stream , "\n" , true , true); /* Go to next line after the SLAVES keyword*/ + basic_parser_fseek_string( parser , stream , "\n" , true , true); /* Go to next line after the SLAVES keyword*/ while (true) { char * buffer = util_fscanf_alloc_line( stream , NULL); @@ -1296,7 +1296,7 @@ static int ecl_util_get_num_slave_cpu__(parser_type* parser, FILE* stream, const util_abort("%s: Did not find ending \"/\" character after SLAVES keyword, aborting \n", __func__); { - stringlist_type * tokens = parser_tokenize_buffer( parser , buffer , true ); + stringlist_type * tokens = basic_parser_tokenize_buffer( parser , buffer , true ); if (stringlist_get_size(tokens) > 0 ) { const char * first_item = stringlist_iget(tokens, 0); @@ -1322,34 +1322,34 @@ static int ecl_util_get_num_slave_cpu__(parser_type* parser, FILE* stream, const int ecl_util_get_num_cpu(const char * data_file) { int num_cpu = 1; - parser_type * parser = parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n"); + basic_parser_type * parser = basic_parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n"); FILE * stream = util_fopen(data_file , "r"); - if (parser_fseek_string( parser , stream , "PARALLEL" , true , true)) { /* Seeks case insensitive. */ + if (basic_parser_fseek_string( parser , stream , "PARALLEL" , true , true)) { /* Seeks case insensitive. */ num_cpu = ecl_util_get_num_parallel_cpu__(parser, stream, data_file); - } else if (parser_fseek_string( parser , stream , "SLAVES" , true , true)) { /* Seeks case insensitive. */ + } else if (basic_parser_fseek_string( parser , stream , "SLAVES" , true , true)) { /* Seeks case insensitive. */ num_cpu = ecl_util_get_num_slave_cpu__(parser, stream, data_file) + 1; fprintf(stderr, "Information: \"SLAVES\" option found, returning %d number of CPUs", num_cpu); } - parser_free( parser ); + basic_parser_free( parser ); fclose(stream); return num_cpu; } -ecl_unit_enum ecl_util_get_unit_set(const char * data_file) { - ecl_unit_enum units = ECL_METRIC_UNITS; - parser_type * parser = parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n"); +ert_ecl_unit_enum ecl_util_get_unit_set(const char * data_file) { + ert_ecl_unit_enum units = ERT_ECL_METRIC_UNITS; + basic_parser_type * parser = basic_parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n"); FILE * stream = util_fopen(data_file , "r"); - if (parser_fseek_string( parser , stream , "FIELD" , true , true)) { /* Seeks case insensitive. */ - units = ECL_FIELD_UNITS; - } else if (parser_fseek_string( parser , stream , "LAB" , true , true)) { /* Seeks case insensitive. */ - units = ECL_LAB_UNITS; + if (basic_parser_fseek_string( parser , stream , "FIELD" , true , true)) { /* Seeks case insensitive. */ + units = ERT_ECL_FIELD_UNITS; + } else if (basic_parser_fseek_string( parser , stream , "LAB" , true , true)) { /* Seeks case insensitive. */ + units = ERT_ECL_LAB_UNITS; } - parser_free( parser ); + basic_parser_free( parser ); fclose(stream); return units; } @@ -1534,4 +1534,10 @@ const char * ecl_util_type_enum_iget( int index, int * value) { return util_enum_iget( index , ECL_TYPE_ENUM_SIZE , (const util_enum_element_type []) { ECL_TYPE_ENUM_DEFS }, value); } +void ecl_util_set_date_values(time_t t , int * mday , int * month , int * year) { + return util_set_date_values(t,mday,month,year); +} + #endif + + diff --git a/ThirdParty/Ert/devel/libecl/src/fault_block.c b/ThirdParty/Ert/devel/libecl/src/fault_block.c index 8691e323f7..cb84df721e 100644 --- a/ThirdParty/Ert/devel/libecl/src/fault_block.c +++ b/ThirdParty/Ert/devel/libecl/src/fault_block.c @@ -1,25 +1,27 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'fault_block.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'fault_block.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <ert/util/type_macros.h> #include <ert/util/int_vector.h> #include <ert/geometry/geo_util.h> +#include <ert/geometry/geo_polygon.h> +#include <ert/geometry/geo_polygon_collection.h> #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_kw.h> @@ -55,7 +57,7 @@ static fault_block_type * fault_block_alloc( const fault_block_layer_type * pare block->grid = fault_block_layer_get_grid( parent_layer ); block->k = fault_block_layer_get_k( parent_layer ); block->block_id = block_id; - + block->i_list = int_vector_alloc(0,0); block->j_list = int_vector_alloc(0,0); block->global_index_list = int_vector_alloc(0,0); @@ -66,7 +68,7 @@ static fault_block_type * fault_block_alloc( const fault_block_layer_type * pare int fault_block_get_size( const fault_block_type * block ) { - return int_vector_size( block->i_list ); + return int_vector_size( block->i_list ); } @@ -120,7 +122,7 @@ static void fault_block_assert_center( fault_block_type * fault_block ) { int index; double xc = 0; double yc = 0; - + for (index = 0; index < int_vector_size( fault_block->i_list ); index++) { int i = int_vector_iget( fault_block->i_list , index); int j = int_vector_iget( fault_block->j_list , index); @@ -131,7 +133,7 @@ static void fault_block_assert_center( fault_block_type * fault_block ) { xc += x; yc += y; } - + fault_block->xc = xc / int_vector_size( fault_block->i_list ); fault_block->yc = yc / int_vector_size( fault_block->i_list ); } @@ -184,71 +186,114 @@ bool fault_block_trace_edge( const fault_block_type * block , double_vector_type { int start_i = fault_block_iget_i( block , 0 ); int start_j = fault_block_iget_j( block , 0 ); - + layer_trace_block_edge(fault_block_layer_get_layer( block->parent_layer ) , start_i , start_j , block->block_id , corner_list , cell_list); } - - double_vector_reset( x_list ); - double_vector_reset( y_list ); - for (c=0; c < struct_vector_get_size( corner_list ); c++) { - double x,y,z; - int_point2d_type ij; - struct_vector_iget( corner_list , c , &ij ); - - ecl_grid_get_corner_xyz( block->grid , ij.i , ij.j , block->k , &x , &y , &z); - double_vector_append( x_list , x); - double_vector_append( y_list , y); + + if (x_list && y_list) { + double_vector_reset( x_list ); + double_vector_reset( y_list ); + for (c=0; c < struct_vector_get_size( corner_list ); c++) { + double x,y,z; + int_point2d_type ij; + struct_vector_iget( corner_list , c , &ij ); + + ecl_grid_get_corner_xyz( block->grid , ij.i , ij.j , block->k , &x , &y , &z); + double_vector_append( x_list , x); + double_vector_append( y_list , y); + } } - + struct_vector_free( corner_list ); return true; } else return false; } +static bool fault_block_neighbour_xpolyline( const fault_block_type * block , int i1, int j1, int i2 , int j2, const geo_polygon_collection_type * polylines) { + int g1 = ecl_grid_get_global_index3( block->grid , i1 , j1 , block->k ); + int g2 = ecl_grid_get_global_index3( block->grid , i2 , j2 , block->k ); + double x1,y1,z1; + double x2,y2,z2; + ecl_grid_get_xyz1( block->grid , g1 , &x1 , &y1 , &z1); + ecl_grid_get_xyz1( block->grid , g2 , &x2 , &y2 , &z2); -void fault_block_list_neighbours( const fault_block_type * block, int_vector_type * neighbour_list) { - int_vector_reset( neighbour_list ); { - int_vector_type * cell_list = int_vector_alloc(0,0); - double_vector_type * x_list = double_vector_alloc(0,0); - double_vector_type * y_list = double_vector_alloc(0,0); - - fault_block_trace_edge( block , x_list , y_list , cell_list ); - { - int c; - layer_type * layer = fault_block_layer_get_layer( block->parent_layer ); - for (c = 0; c < int_vector_size( cell_list ); c++) { - int j = int_vector_iget( cell_list , c) / layer_get_nx(layer); - int i = int_vector_iget( cell_list , c) % layer_get_nx(layer); - - if (i > 0) { - int neighbour_id = layer_iget_cell_value(layer , i - 1, j); - int_vector_append( neighbour_list , neighbour_id ); + int polyline_index = 0; + bool intersection = false; + while (true) { + if (polyline_index >= geo_polygon_collection_size(polylines)) + break; + + { + const geo_polygon_type * polyline = geo_polygon_collection_iget_polygon( polylines , polyline_index ); + if (geo_polygon_segment_intersects( polyline , x1,y1,x2,y2 )) { + intersection = true; + break; } + } - if (i < (layer_get_nx( layer) - 1)) { - int neighbour_id = layer_iget_cell_value(layer , i + 1, j); - int_vector_append( neighbour_list , neighbour_id ); - } + polyline_index++; + } - if (j > 0) { - int neighbour_id = layer_iget_cell_value(layer , i, j - 1); - int_vector_append( neighbour_list , neighbour_id ); - } + return intersection; + } +} - if (j < (layer_get_ny( layer) - 1)) { - int neighbour_id = layer_iget_cell_value(layer , i, j + 1); - int_vector_append( neighbour_list , neighbour_id ); - } - } - } +static bool fault_block_connected_neighbour( const fault_block_type * block , int i1 , int j1 , int i2 , int j2 , bool connected_only , const geo_polygon_collection_type * polylines ) { + const layer_type * layer = fault_block_layer_get_layer( block->parent_layer ); + if ((i2 < 0) || (i2 >= layer_get_nx( layer ))) + return false; - double_vector_free( x_list ); - double_vector_free( y_list ); - int_vector_free( cell_list ); + if ((j2 < 0) || (j2 >= layer_get_ny( layer ))) + return false; + + /* + Inactive cells do "not exist" - can not be connected neighbour + with an inactive cell. + */ + if (!ecl_grid_cell_active3( block->grid , i2,j2,block->k)) + return false; + + { + int cell_id = layer_iget_cell_value( layer , i1 , j1 ); + int neighbour_id = layer_iget_cell_value(layer , i2 , j2); + if (cell_id == neighbour_id) + return false; + + if (!connected_only) + return true; + + return (layer_cell_contact( layer , i1 , j1 , i2 , j2) && !fault_block_neighbour_xpolyline( block , i1,j1,i2,j2,polylines )); + } +} + + + +void fault_block_list_neighbours( const fault_block_type * block, bool connected_only , const geo_polygon_collection_type * polylines , int_vector_type * neighbour_list) { + int_vector_reset( neighbour_list ); + { + int c; + layer_type * layer = fault_block_layer_get_layer( block->parent_layer ); + for (c = 0; c < int_vector_size( block->i_list ); c++) { + int i = int_vector_iget( block->i_list , c); + int j = int_vector_iget( block->j_list , c); + + if (fault_block_connected_neighbour( block , i , j , i - 1 , j , connected_only , polylines )) + int_vector_append( neighbour_list , layer_iget_cell_value( layer , i - 1 , j)); + + if (fault_block_connected_neighbour( block , i , j , i + 1 , j , connected_only , polylines )) + int_vector_append( neighbour_list , layer_iget_cell_value( layer , i + 1 , j)); + + if (fault_block_connected_neighbour( block , i , j , i , j - 1, connected_only , polylines )) + int_vector_append( neighbour_list , layer_iget_cell_value( layer , i , j - 1)); + + if (fault_block_connected_neighbour( block , i , j , i , j + 1, connected_only , polylines )) + int_vector_append( neighbour_list , layer_iget_cell_value( layer , i , j + 1)); + + } } int_vector_select_unique( neighbour_list ); int_vector_del_value( neighbour_list , 0 ); @@ -259,9 +304,9 @@ void fault_block_list_neighbours( const fault_block_type * block, int_vector_typ void fault_block_copy_content(fault_block_type * target_block , const fault_block_type * src_block ) { int b; - for (b = 0; b < int_vector_size( src_block->i_list ); b++) + for (b = 0; b < int_vector_size( src_block->i_list ); b++) fault_block_add_cell( target_block , int_vector_iget( src_block->i_list , b) , int_vector_iget( src_block->j_list , b)); - + } diff --git a/ThirdParty/Ert/devel/libecl/src/fault_block_layer.c b/ThirdParty/Ert/devel/libecl/src/fault_block_layer.c index 22811d23cd..0c458eb470 100644 --- a/ThirdParty/Ert/devel/libecl/src/fault_block_layer.c +++ b/ThirdParty/Ert/devel/libecl/src/fault_block_layer.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'fault_block_layer.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'fault_block_layer.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <ert/util/type_macros.h> @@ -29,7 +29,7 @@ #define FAULT_BLOCK_LAYER_ID 2297476 -/* +/* The fault_block object is implemented as a separate object type in the fault_block.c file; however the fault blocks should be closely linked to the layer object in the fault_block_layer structure - it @@ -68,10 +68,10 @@ fault_block_type * fault_block_layer_add_block( fault_block_layer_type * layer , if (int_vector_safe_iget( layer->block_map , block_id) < 0) { fault_block_type * block = fault_block_alloc( layer , block_id ); int storage_index = vector_get_size( layer->blocks ); - + int_vector_iset( layer->block_map , block_id , storage_index ); vector_append_owned_ref( layer->blocks , block , fault_block_free__ ); - + return block; } else return NULL; @@ -95,9 +95,9 @@ void fault_block_layer_scan_layer( fault_block_layer_type * fault_layer , layer_ int c; int block_id = fault_block_layer_get_next_id( fault_layer ); fault_block_type * fault_block = fault_block_layer_add_block( fault_layer , block_id ); - for (c=0; c < int_vector_size( i_list ); c++) + for (c=0; c < int_vector_size( i_list ); c++) fault_block_add_cell( fault_block , int_vector_iget( i_list , c ), int_vector_iget( j_list , c )); - + } } } @@ -113,7 +113,7 @@ void fault_block_layer_scan_layer( fault_block_layer_type * fault_layer , layer_ retained; the fault_block_layer instance gets new block id numbers, including a nonzero value for the cells which have value zero in the keyword. - + - The blocks in the fault_block_layer instance are guaranteed to be singly connected. @@ -127,7 +127,7 @@ void fault_block_layer_scan_layer( fault_block_layer_type * fault_layer , layer_ bool fault_block_layer_scan_kw( fault_block_layer_type * layer , const ecl_kw_type * fault_block_kw) { bool assign_zero = true; - + if (ecl_kw_get_size( fault_block_kw) != ecl_grid_get_global_size(layer->grid)) return false; else if (ecl_kw_get_type( fault_block_kw ) != ECL_INT_TYPE) @@ -141,18 +141,18 @@ bool fault_block_layer_scan_kw( fault_block_layer_type * layer , const ecl_kw_ty for (i=0; i < ecl_grid_get_nx( layer->grid ); i++) { int g = ecl_grid_get_global_index3( layer->grid , i , j , layer->k ); int block_id = ecl_kw_iget_int( fault_block_kw , g ); - - + + if (block_id > 0) { layer_iset_cell_value( work_layer , i , j , block_id ); max_block_id = util_int_max( block_id , max_block_id ); } } } - + if (assign_zero) layer_replace_cell_values( work_layer , 0 , max_block_id + 1); - + fault_block_layer_scan_layer( layer , work_layer ); layer_free( work_layer ); return true; @@ -189,7 +189,7 @@ bool fault_block_layer_load_kw( fault_block_layer_type * layer , const ecl_kw_ty } } } - + return true; } } @@ -297,7 +297,7 @@ void fault_block_layer_free( fault_block_layer_type * layer ) { int_vector_free( layer->block_map ); vector_free( layer->blocks ); layer_free( layer->layer ); - free(layer); + free(layer); } @@ -305,7 +305,7 @@ void fault_block_layer_free__( void * arg ) { fault_block_layer_type * layer = fault_block_layer_safe_cast( arg ); fault_block_layer_free( layer ); } - + void fault_block_layer_insert_block_content( fault_block_layer_type * layer , const fault_block_type * src_block) { int next_block_id = fault_block_layer_get_next_id( layer ); diff --git a/ThirdParty/Ert/devel/libecl/src/fortio.c b/ThirdParty/Ert/devel/libecl/src/fortio.c index 68dcdef697..82b182f27a 100644 --- a/ThirdParty/Ert/devel/libecl/src/fortio.c +++ b/ThirdParty/Ert/devel/libecl/src/fortio.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'fortio.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'fortio.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -51,7 +51,7 @@ Where the "400" head and tail is the number of bytes in the following record. Fortran IO handles this transparently, but when mixing with other programming languages care must be taken. This file implements functionality to read and write these fortran generated files -transparently. The three functions: +transparently. The three functions: 1. fortio_fopen() 2. fortio_fread_record() @@ -65,47 +65,54 @@ fwrite() from the standard library. #define READ_MODE_TXT "r" #define READ_MODE_BINARY "rb" #define WRITE_MODE_TXT "w" -#define WRITE_MODE_BINARY "wb" +#define WRITE_MODE_BINARY "wb" #define READ_WRITE_MODE_TXT "r+" #define READ_WRITE_MODE_BINARY "r+b" #define APPEND_MODE_TXT "a" -#define APPEND_MODE_BINARY "ab" +#define APPEND_MODE_BINARY "ab" struct fortio_struct { UTIL_TYPE_ID_DECLARATION; FILE * stream; char * filename; - bool endian_flip_header; + bool endian_flip_header; bool fmt_file; /* This is not really used by the fortio instance - but it is very convenient to store it here. */ const char * fopen_mode; bool stream_owner; - - /* Internal variables used during partial read.*/ - int active_header; - int rec_nr; + + /* + The internal variable read_size is used in the functions + fortio_fseek() and fortio_read_at_eof() - if-and-only-if - the + file is opened in read only mode. + + Observe that the semantics of the fortio_fseek() function depends + on whether the file is writable. + */ + bool readable; + offset_type read_size; }; UTIL_IS_INSTANCE_FUNCTION( fortio , FORTIO_ID ); UTIL_SAFE_CAST_FUNCTION( fortio, FORTIO_ID ); -static fortio_type * fortio_alloc__(const char *filename , bool fmt_file , bool endian_flip_header , bool stream_owner) { +static fortio_type * fortio_alloc__(const char *filename , bool fmt_file , bool endian_flip_header , bool stream_owner , bool readable) { fortio_type * fortio = util_malloc(sizeof * fortio ); UTIL_TYPE_ID_INIT( fortio, FORTIO_ID ); fortio->filename = util_alloc_string_copy(filename); fortio->endian_flip_header = endian_flip_header; - fortio->active_header = 0; - fortio->rec_nr = 0; fortio->fmt_file = fmt_file; fortio->stream_owner = stream_owner; + fortio->read_size = 0; + fortio->readable = readable; return fortio; } /** - Helper function for fortio_is_fortran_stream__(). + Helper function for fortio_is_fortran_stream__(). */ static bool __read_int(FILE * stream , int * value, bool endian_flip) { @@ -139,7 +146,7 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) { if (util_fseek(stream , (offset_type) header , SEEK_CUR) == 0) { if (__read_int(stream , &tail , endian_flip)) { cont = true; - /* + /* OK - now we have read a header and a tail - it might be a fortran file. */ @@ -148,7 +155,7 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) { /* This is (most probably) a fortran file */ is_fortran_stream = true; if (strict_checking) - cont = true; + cont = true; else cont = false; } @@ -160,7 +167,7 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) { } } } - } + } } } while (cont); util_fseek(stream , init_pos , SEEK_SET); @@ -170,68 +177,41 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) { /** This function tries (using some heuristic) to guess whether a - particular file is a Fortran file. To complicate the matters - further we make no assumptions regarding endian ness, if it is - indeed determined that this is fortran file, the endian ness is - returned by reference (if it is not recognized as a fortran file, - the returned endian ness will be garbage). + particular file is a Fortran file. The heuristic algorithm which is used is as follows: - + 1. Read four bytes as an integer (header) 2. Skip that number of bytes forward. 3. Read four bytes again (tail). - Now, when this is done we do the following tests: + Now, when this is done we do the following test: - 1. If header == tail. This is (probably) a fortran file, however - if header == 0, we might have a normal file with two - consequitive zeroes. In that case it is difficult to determine, - and we continue. + If header == tail. This is (probably) a fortran file, however if + header == 0, we might have a normal file with two consequitive + zeroes. In that case it is difficult to determine, and we continue. - 2. If header != tail we try to reinterpret header with an endian - swap and read a new tail. If they are now equal we repeat test1, or - return false (i.e. *not* a fortran file). */ -bool fortio_is_fortran_file(const char * filename, bool * _endian_flip) { +bool fortio_looks_like_fortran_file(const char * filename, bool endian_flip) { FILE * stream = util_fopen(filename , "rb"); - bool endian_flip = false; bool is_fortran_stream = fortio_is_fortran_stream__(stream , endian_flip); - if (!is_fortran_stream) { - endian_flip = !endian_flip; - is_fortran_stream = fortio_is_fortran_stream__(stream , endian_flip); - } - - *_endian_flip = endian_flip; fclose(stream); return is_fortran_stream; } -/** - This function tries to determine automatically whether a certain - file has endian flip or not. - - Observe that the return value is whether we managed to determine the - endian-ness or not, whereas the endian_flip flag is returned by - reference. - - To be able to determine endianness the file *must* be a binary - fortran file - this is essentially the return value. -*/ - -bool fortio_guess_endian_flip(const char * filename , bool * _endian_flip) { - return fortio_is_fortran_file(filename , _endian_flip); +static void fortio_init_size(fortio_type * fortio) { + fortio->read_size = util_fd_size( fortio_fileno( fortio )); } - -fortio_type * fortio_alloc_FILE_wrapper(const char *filename , bool endian_flip_header , bool fmt_file , FILE * stream) { - fortio_type * fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , false); +fortio_type * fortio_alloc_FILE_wrapper(const char *filename , bool endian_flip_header , bool fmt_file , bool readable , FILE * stream) { + fortio_type * fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , false , readable); fortio->stream = stream; + fortio_init_size( fortio ); return fortio; } @@ -312,9 +292,10 @@ static FILE * fortio_fopen_append( const char * filename , bool fmt_file ) { fortio_type * fortio_open_reader(const char *filename , bool fmt_file , bool endian_flip_header) { FILE * stream = fortio_fopen_read( filename , fmt_file ); if (stream) { - fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true); + fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true , true); fortio->stream = stream; fortio->fopen_mode = fortio_fopen_read_mode( fmt_file ); + fortio_init_size( fortio ); return fortio; } else return NULL; @@ -326,9 +307,10 @@ fortio_type * fortio_open_reader(const char *filename , bool fmt_file , bool end fortio_type * fortio_open_writer(const char *filename , bool fmt_file , bool endian_flip_header ) { FILE * stream = fortio_fopen_write( filename , fmt_file ); if (stream) { - fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header, true); + fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header, true , false); fortio->stream = stream; fortio->fopen_mode = fortio_fopen_write_mode( fmt_file ); + fortio_init_size( fortio ); return fortio; } else return NULL; @@ -339,9 +321,10 @@ fortio_type * fortio_open_writer(const char *filename , bool fmt_file , bool end fortio_type * fortio_open_readwrite(const char *filename , bool fmt_file , bool endian_flip_header) { FILE * stream = fortio_fopen_readwrite( filename , fmt_file ); if (stream) { - fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true); + fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true , true); fortio->stream = stream; fortio->fopen_mode = fortio_fopen_readwrite_mode( fmt_file ); + fortio_init_size( fortio ); return fortio; } else return NULL; @@ -351,9 +334,12 @@ fortio_type * fortio_open_readwrite(const char *filename , bool fmt_file , bool fortio_type * fortio_open_append(const char *filename , bool fmt_file , bool endian_flip_header) { FILE * stream = fortio_fopen_append( filename , fmt_file ); if (stream) { - fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true); + fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true , false); + fortio->stream = stream; fortio->fopen_mode = fortio_fopen_append_mode( fmt_file ); + fortio_init_size( fortio ); + return fortio; } else return NULL; @@ -433,22 +419,23 @@ bool fortio_is_fortio_file(fortio_type * fortio) { offset_type init_pos = fortio_ftell(fortio); int elm_read; bool is_fortio_file = false; - elm_read = fread(&fortio->active_header , sizeof(fortio->active_header) , 1 , fortio->stream); + int record_size; + elm_read = fread(&record_size , sizeof(record_size) , 1 , fortio->stream); if (elm_read == 1) { int trailer; if (fortio->endian_flip_header) - util_endian_flip_vector(&fortio->active_header , sizeof fortio->active_header , 1); + util_endian_flip_vector(&record_size , sizeof record_size , 1); - if (fortio_fseek(fortio , (offset_type) fortio->active_header , SEEK_CUR) == 0) { - if (fread(&trailer , sizeof(fortio->active_header) , 1 , fortio->stream) == 1) { + if (fortio_fseek(fortio , (offset_type) record_size , SEEK_CUR) == 0) { + if (fread(&trailer , sizeof(record_size) , 1 , fortio->stream) == 1) { if (fortio->endian_flip_header) util_endian_flip_vector(&trailer , sizeof trailer , 1); - - if (trailer == fortio->active_header) + + if (trailer == record_size) is_fortio_file = true; } - } + } } fortio_fseek(fortio , init_pos , SEEK_SET); @@ -465,24 +452,25 @@ bool fortio_is_fortio_file(fortio_type * fortio) { int fortio_init_read(fortio_type *fortio) { int elm_read; - elm_read = fread(&fortio->active_header , sizeof(fortio->active_header) , 1 , fortio->stream); + int record_size; + + elm_read = fread(&record_size , sizeof(record_size) , 1 , fortio->stream); if (elm_read == 1) { if (fortio->endian_flip_header) - util_endian_flip_vector(&fortio->active_header , sizeof fortio->active_header , 1); + util_endian_flip_vector(&record_size , sizeof record_size , 1); - fortio->rec_nr++; - return fortio->active_header; - } else + return record_size; + } else return -1; } -void fortio_data_fskip(fortio_type* fortio, const int element_size, const int element_count, const int block_count) { - int headers = block_count * 4; - int trailers = block_count * 4; - int bytes_to_skip = headers + trailers + (element_size * element_count); +bool fortio_data_fskip(fortio_type* fortio, const int element_size, const int element_count, const int block_count) { + int headers = block_count * 4; + int trailers = block_count * 4; + int bytes_to_skip = headers + trailers + (element_size * element_count); - fortio_fseek(fortio, bytes_to_skip, SEEK_CUR); + return fortio_fseek(fortio, bytes_to_skip, SEEK_CUR); } @@ -501,34 +489,40 @@ void fortio_data_fseek(fortio_type* fortio, offset_type data_offset, size_t data } -void fortio_complete_read(fortio_type *fortio) { +bool fortio_complete_read(fortio_type *fortio , int record_size) { int trailer; - trailer = util_fread_int( fortio->stream ); - - if (fortio->endian_flip_header) - util_endian_flip_vector(&trailer , sizeof trailer , 1); - - if (trailer != fortio->active_header) { - fprintf(stderr,"%s: fatal error reading record:%d in file: %s - aborting \n",__func__ , fortio->rec_nr , fortio->filename); - util_abort("%s: Header: %d Trailer: %d \n",__func__ , fortio->active_header , trailer); + size_t read_count = fread(&trailer , sizeof trailer , 1 , fortio->stream ); + + if (read_count == 1) { + if (fortio->endian_flip_header) + util_endian_flip_vector(&trailer , sizeof trailer , 1); + + if (record_size == trailer) + return true; } - fortio->active_header = 0; + + return false; } /** This function reads one record from the fortio stream, and fills - the buffer with the content. The return value is the number of bytes read. + the buffer with the content. The return value is the number of + bytes read; the function will return -1 on failure. */ -int fortio_fread_record(fortio_type *fortio, char *buffer) { - fortio_init_read(fortio); - { - int record_size = fortio->active_header; /* This is reset in fortio_complete_read - must store it for the return. */ - util_fread(buffer , 1 , fortio->active_header , fortio->stream , __func__); - fortio_complete_read(fortio); - return record_size; +static int fortio_fread_record(fortio_type *fortio , char *buffer) { + int record_size = fortio_init_read(fortio); + if (record_size >= 0) { + size_t items_read = fread(buffer , 1 , record_size , fortio->stream); + if (items_read == record_size) { + bool complete_ok = fortio_complete_read(fortio , record_size); + if (!complete_ok) + record_size = -1; + } else + record_size = -1; /* Failure */ } + return record_size; } @@ -541,38 +535,53 @@ int fortio_fread_record(fortio_type *fortio, char *buffer) { transparent, low-level way. */ -void fortio_fread_buffer(fortio_type * fortio, char * buffer , int buffer_size) { - int bytes_read = 0; - while (bytes_read < buffer_size) { - char * buffer_ptr = &buffer[bytes_read]; - bytes_read += fortio_fread_record(fortio , buffer_ptr); +bool fortio_fread_buffer(fortio_type * fortio, char * buffer , int buffer_size) { + int total_bytes_read = 0; + + while (true) { + char * buffer_ptr = &buffer[total_bytes_read]; + int bytes_read = fortio_fread_record(fortio , buffer_ptr); + + if (bytes_read < 0) + break; + else { + total_bytes_read += bytes_read; + if (total_bytes_read >= buffer_size) + break; + } } - if (bytes_read > buffer_size) - util_abort("%s: hmmmm - something is broken. The individual records in %s did not sum up to the expected buffer size \n",__func__ , fortio->filename); + if (total_bytes_read == buffer_size) + return true; + + if (total_bytes_read < buffer_size) + return false; + + util_abort("%s: internal inconsistency: buffer_size:%d read %d bytes \n",__func__ , buffer_size , total_bytes_read); + return false; } int fortio_fskip_record(fortio_type *fortio) { int record_size = fortio_init_read(fortio); fortio_fseek(fortio , (offset_type) record_size , SEEK_CUR); - fortio_complete_read(fortio); + fortio_complete_read(fortio , record_size); return record_size; } void fortio_fskip_buffer(fortio_type * fortio, int buffer_size) { int bytes_skipped = 0; - while (bytes_skipped < buffer_size) + while (bytes_skipped < buffer_size) bytes_skipped += fortio_fskip_record(fortio); - if (bytes_skipped > buffer_size) + if (bytes_skipped > buffer_size) util_abort("%s: hmmmm - something is broken. The individual records in %s did not sum up to the expected buffer size \n",__func__ , fortio->filename); } void fortio_copy_record(fortio_type * src_stream , fortio_type * target_stream , int buffer_size , void * buffer , bool *at_eof) { int bytes_read; - int record_size = fortio_init_read(src_stream); + int record_size = fortio_init_read(src_stream); fortio_init_write(target_stream , record_size); bytes_read = 0; @@ -585,12 +594,12 @@ void fortio_copy_record(fortio_type * src_stream , fortio_type * target_stream , util_fread(buffer , 1 , bytes , src_stream->stream , __func__); util_fwrite(buffer , 1 , bytes , target_stream->stream , __func__); - + bytes_read += bytes; } - fortio_complete_read(src_stream); - fortio_complete_write(target_stream); + fortio_complete_read(src_stream , record_size); + fortio_complete_write(target_stream , record_size); if (feof(src_stream->stream)) *at_eof = true; @@ -603,38 +612,35 @@ void fortio_copy_record(fortio_type * src_stream , fortio_type * target_stream , void fortio_init_write(fortio_type *fortio , int record_size) { int file_header; - fortio->active_header = record_size; - file_header = fortio->active_header; + file_header = record_size; if (fortio->endian_flip_header) util_endian_flip_vector(&file_header , sizeof file_header , 1); util_fwrite_int( file_header , fortio->stream ); - fortio->rec_nr++; } -void fortio_complete_write(fortio_type *fortio) { - int file_header = fortio->active_header; +void fortio_complete_write(fortio_type *fortio , int record_size) { + int file_header = record_size; if (fortio->endian_flip_header) util_endian_flip_vector(&file_header , sizeof file_header , 1); util_fwrite_int( file_header , fortio->stream ); - fortio->active_header = 0; } void fortio_fwrite_record(fortio_type *fortio, const char *buffer , int record_size) { fortio_init_write(fortio , record_size); util_fwrite( buffer , 1 , record_size , fortio->stream , __func__); - fortio_complete_write(fortio); + fortio_complete_write(fortio , record_size); } void * fortio_fread_alloc_record(fortio_type * fortio) { void * buffer; - fortio_init_read(fortio); - buffer = util_malloc(fortio->active_header ); - util_fread(buffer , 1 , fortio->active_header , fortio->stream , __func__); - fortio_complete_read(fortio); + int record_size = fortio_init_read(fortio); + buffer = util_malloc( record_size ); + util_fread(buffer , 1 , record_size , fortio->stream , __func__); + fortio_complete_read(fortio , record_size); return buffer; } @@ -651,8 +657,8 @@ static fortio_status_type fortio_check_record( FILE * stream , bool endian_flip else { if (endian_flip) util_endian_flip_vector(&header , sizeof header , 1); - - if (util_fseek( stream , (offset_type) header , SEEK_CUR ) != 0) + + if (util_fseek( stream , (offset_type) header , SEEK_CUR ) != 0) /* The fseek() failed - i.e. the data section was not sufficiently long. */ status = FORTIO_MISSING_DATA; else { @@ -660,14 +666,14 @@ static fortio_status_type fortio_check_record( FILE * stream , bool endian_flip if (read_count == 1) { if (endian_flip) util_endian_flip_vector(&tail , sizeof tail , 1); - + if (tail == header) /* All OK */ status = FORTIO_OK; - else if ( tail != header ) + else if ( tail != header ) /* The numerical value of the tail did not agree with the header. */ status = FORTIO_HEADER_MISMATCH; - } else + } else /* The file ended before we could read the tail mark. */ status = FORTIO_MISSING_TAIL; } @@ -698,7 +704,7 @@ fortio_status_type fortio_check_buffer( FILE * stream , bool endian_flip , size_ return record_status; } - + fortio_status_type fortio_check_file( const char * filename , bool endian_flip) { if (util_file_exists( filename )) { @@ -730,12 +736,52 @@ offset_type fortio_ftell( const fortio_type * fortio ) { } -int fortio_fseek( fortio_type * fortio , offset_type offset , int whence) { +static bool fortio_fseek__(fortio_type * fortio , offset_type offset , int whence) { int fseek_return = util_fseek( fortio->stream , offset , whence ); - /* - if fseek_return != 0 -> util_abort(). - */ - return fseek_return; + if (fseek_return == 0) + return true; + else + return false; + +} + +/* + The semantics of this function depends on the readbale flag of the + fortio structure: + + readable == false: Ordinary fseek() semantics. + + readable == true: The function will only seek within the range of + the file, and fail if you try to seek beyond the EOF marker. + +*/ + + +bool fortio_fseek( fortio_type * fortio , offset_type offset , int whence) { + if (!fortio->readable) + return fortio_fseek__( fortio , offset , whence ); + else { + offset_type new_offset = 0; + + switch (whence) { + case( SEEK_CUR ): + new_offset = fortio_ftell( fortio ) + offset; + break; + case (SEEK_END): + new_offset = fortio->read_size + offset; + break; + case (SEEK_SET): + new_offset = offset; + break; + default: + util_abort("%s: invalid seek flag \n",__func__); + } + + if (new_offset <= fortio->read_size) + return fortio_fseek__( fortio , new_offset , SEEK_SET ); + else + return false; + } } @@ -744,11 +790,25 @@ int fortio_fileno( fortio_type * fortio ) { } +/* + It is massively undefined behaviour to call this function for a file + which has been updated; in that case the util_fd_size() function + will return the size of the file *when it was opened*. +*/ + +bool fortio_read_at_eof( fortio_type * fortio ) { + + if (fortio_ftell(fortio) == fortio->read_size) + return true; + else + return false; + +} + /*****************************************************************/ void fortio_fflush(fortio_type * fortio) { fflush( fortio->stream); } FILE * fortio_get_FILE(const fortio_type *fortio) { return fortio->stream; } -int fortio_get_record_size(const fortio_type *fortio) { return fortio->active_header; } //bool fortio_endian_flip(const fortio_type *fortio) { return fortio->endian_flip_header; } bool fortio_fmt_file(const fortio_type *fortio) { return fortio->fmt_file; } void fortio_rewind(const fortio_type *fortio) { util_rewind(fortio->stream); } diff --git a/ThirdParty/Ert/devel/libecl/src/layer.c b/ThirdParty/Ert/devel/libecl/src/layer.c index 4e9f8f66aa..45dd8db976 100644 --- a/ThirdParty/Ert/devel/libecl/src/layer.c +++ b/ThirdParty/Ert/devel/libecl/src/layer.c @@ -1,21 +1,22 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'layer.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'layer.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> +#include <math.h> #include <ert/util/type_macros.h> #include <ert/util/int_vector.h> @@ -27,9 +28,13 @@ typedef struct { - int cell_value; - int edges[4]; -} cell_type; + int cell_value; + int edges[4]; + bool bottom_barrier; + bool left_barrier; + bool active; +} cell_type; + struct layer_struct { @@ -50,19 +55,26 @@ layer_type * layer_alloc(int nx , int ny) { layer->nx = nx; layer->ny = ny; layer->cell_sum = 0; - layer->data = util_malloc( (layer->nx + 1)* (layer->ny + 1) * sizeof * layer->data ); { - int g; - for (g=0; g < (layer->nx + 1)*(layer->ny + 1); g++) { - cell_type * cell = &layer->data[g]; - cell->cell_value = 0; - cell->edges[RIGHT_EDGE] = 0; - cell->edges[LEFT_EDGE] = 0; - cell->edges[TOP_EDGE] = 0; - cell->edges[BOTTOM_EDGE] = 0; + int data_size = (layer->nx + 1)* (layer->ny + 1); + layer->data = util_malloc( data_size * sizeof * layer->data ); + { + int g; + for (g=0; g < data_size; g++) { + cell_type * cell = &layer->data[g]; + cell->cell_value = 0; + cell->edges[RIGHT_EDGE] = 0; + cell->edges[LEFT_EDGE] = 0; + cell->edges[TOP_EDGE] = 0; + cell->edges[BOTTOM_EDGE] = 0; + + cell->active = true; + cell->bottom_barrier = false; + cell->left_barrier = false; + } } } - + return layer; } @@ -73,24 +85,67 @@ void layer_free( layer_type * layer ) { free( layer->data ); free(layer); } - + + static int layer_get_global_cell_index( const layer_type * layer , int i , int j) { if ((i < 0) || (i >= layer->nx)) util_abort("%s: invalid i value:%d Valid range: [0,%d) \n",__func__ , i , layer->nx); if ((j < 0) || (j >= layer->ny)) util_abort("%s: invalid j value:%d Valid range: [0,%d) \n",__func__ , j , layer->ny); - + return i + j*(layer->nx + 1); } +static int layer_get_global_cell_index__( const layer_type * layer , int i , int j) { + if ((i < 0) || (i > layer->nx)) + util_abort("%s: invalid i value:%d Valid range: [0,%d] \n",__func__ , i , layer->nx); + + if ((j < 0) || (j > layer->ny)) + util_abort("%s: invalid j value:%d Valid range: [0,%d] \n",__func__ , j , layer->ny); + + return i + j*(layer->nx + 1); +} + + +static cell_type* layer_iget_cell( const layer_type * layer , int i , int j) { + int g = layer_get_global_cell_index( layer , i , j ); + return &layer->data[g]; +} + +/* + To be able to update barriers on the edge we need access to the i = + nx and j = ny cells. +*/ +static cell_type* layer_iget_cell__( const layer_type * layer , int i , int j) { + int g = layer_get_global_cell_index__( layer , i , j ); + return &layer->data[g]; +} + + +bool layer_iget_left_barrier( const layer_type * layer, int i , int j) { + cell_type * cell = layer_iget_cell(layer , i,j); + return cell->left_barrier; +} + + +bool layer_iget_bottom_barrier( const layer_type * layer, int i , int j) { + cell_type * cell = layer_iget_cell(layer,i,j); + return cell->bottom_barrier; +} + int layer_iget_cell_value( const layer_type * layer, int i , int j) { int g = layer_get_global_cell_index( layer , i , j ); return layer->data[g].cell_value; } +bool layer_iget_active( const layer_type * layer, int i , int j) { + int g = layer_get_global_cell_index( layer , i , j ); + return layer->data[g].active; +} + int layer_get_cell_sum( const layer_type * layer ) { return layer->cell_sum; @@ -115,10 +170,10 @@ int layer_get_ny( const layer_type * layer ) { void layer_iset_cell_value( layer_type * layer , int i , int j , int value) { int g = layer_get_global_cell_index( layer , i , j ); cell_type * cell = &layer->data[g]; - + layer->cell_sum += (value - cell->cell_value); cell->cell_value = value; - + if (i > 0) { int neighbour_value = layer_iget_cell_value( layer , i - 1 , j); @@ -140,7 +195,7 @@ void layer_iset_cell_value( layer_type * layer , int i , int j , int value) { cell->edges[RIGHT_EDGE] = value; } else cell->edges[RIGHT_EDGE] = value; - + if (j < (layer->ny - 1)) { int neighbour_value = layer_iget_cell_value( layer , i , j + 1); @@ -151,8 +206,8 @@ void layer_iset_cell_value( layer_type * layer , int i , int j , int value) { cell->edges[TOP_EDGE] = -value; } else cell->edges[TOP_EDGE] = -value; - - + + if (j > 0) { int neighbour_value = layer_iget_cell_value( layer , i , j - 1); if (value == neighbour_value) { @@ -169,10 +224,11 @@ void layer_iset_cell_value( layer_type * layer , int i , int j , int value) { static int layer_get_global_edge_index( const layer_type * layer , int i , int j , edge_dir_enum dir) { if ((i < 0) || (j < 0)) util_abort("%s: invalid value for i,j \n",__func__); - + if ((i > layer->nx) || (j > layer->ny)) util_abort("%s: invalid value for i,j \n",__func__); + if (i == layer->nx) { if (j == layer->ny) util_abort("%s: invalid value for i,j \n",__func__); @@ -196,14 +252,14 @@ static int layer_get_global_edge_index( const layer_type * layer , int i , int j int layer_iget_edge_value( const layer_type * layer , int i , int j , edge_dir_enum dir) { - int g = layer_get_global_edge_index( layer , i , j , dir); + int g = layer_get_global_edge_index( layer , i , j , dir); cell_type * cell = &layer->data[g]; return cell->edges[dir]; } bool layer_cell_on_edge( const layer_type * layer , int i , int j) { - int g = layer_get_global_cell_index( layer , i , j); + int g = layer_get_global_cell_index( layer , i , j); cell_type * cell = &layer->data[g]; if (cell->cell_value == cell->edges[LEFT_EDGE]) @@ -214,7 +270,7 @@ bool layer_cell_on_edge( const layer_type * layer , int i , int j) { return true; if (cell->cell_value == cell->edges[TOP_EDGE]) return true; - + return false; } @@ -239,7 +295,7 @@ static bool point_equal(int_point2d_type * p1 , int_point2d_type *p2) { RIGHT_EDGE -> TOP_EDGE{i,j} , RIGHT_EDGE{i,j+1} , BOTTOM_EDGE{i+1 , j+1} TOP_EDGE -> LEFT_EDGE{i,j} , TOP_EDGE{i-1,j} , RIGHT_EDGE{i-1,j+1} LEFT_EDGE -> BOTTOM_EDGE{i,j} , LEFT_EDGE{i,j-1} , TOP_EDGE{i-1 , j-1} - + */ @@ -250,8 +306,8 @@ static void layer_trace_block_edge__( const layer_type * layer , int_point2d_typ current_point.i = i; current_point.j = j; next_point = current_point; - - if (dir == BOTTOM_EDGE) + + if (dir == BOTTOM_EDGE) point_shift( &next_point , 1 , 0 ); else if (dir == RIGHT_EDGE) { point_shift( ¤t_point , 1 , 0 ); @@ -267,9 +323,9 @@ static void layer_trace_block_edge__( const layer_type * layer , int_point2d_typ int cell_index = i + j*layer->nx; int_vector_append( cell_list , cell_index ); } - + if ( !point_equal(&start_point , &next_point) ) { - + if (dir == BOTTOM_EDGE) { if (layer_iget_edge_value( layer , i,j,RIGHT_EDGE) == value) layer_trace_block_edge__( layer , start_point , i , j , value , RIGHT_EDGE , corner_list , cell_list); @@ -277,9 +333,9 @@ static void layer_trace_block_edge__( const layer_type * layer , int_point2d_typ layer_trace_block_edge__( layer , start_point , i + 1 , j , value , BOTTOM_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i + 1 , j - 1 , LEFT_EDGE) == -value) layer_trace_block_edge__( layer , start_point , i + 1 , j -1 , value , LEFT_EDGE , corner_list , cell_list); - else + else util_abort("%s: dir == BOTTOM_EDGE \n",__func__); - } + } if (dir == RIGHT_EDGE) { @@ -289,7 +345,7 @@ static void layer_trace_block_edge__( const layer_type * layer , int_point2d_typ layer_trace_block_edge__( layer , start_point , i , j + 1, value , RIGHT_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i + 1 , j + 1 ,BOTTOM_EDGE) == value) layer_trace_block_edge__( layer , start_point , i + 1 , j + 1, value , BOTTOM_EDGE , corner_list , cell_list); - else + else util_abort("%s: dir == RIGHT_EDGE \n",__func__); } @@ -301,11 +357,11 @@ static void layer_trace_block_edge__( const layer_type * layer , int_point2d_typ layer_trace_block_edge__( layer , start_point , i - 1 , j , value , TOP_EDGE , corner_list , cell_list); else if (layer_iget_edge_value( layer , i - 1 , j + 1 ,RIGHT_EDGE) == value) layer_trace_block_edge__( layer , start_point , i - 1 , j + 1, value , RIGHT_EDGE , corner_list , cell_list); - else + else util_abort("%s: dir == TOP_EDGE \n",__func__); } - + if (dir == LEFT_EDGE) { if (layer_iget_edge_value( layer , i , j , BOTTOM_EDGE) == value) layer_trace_block_edge__( layer , start_point , i , j , value , BOTTOM_EDGE , corner_list , cell_list); @@ -325,7 +381,7 @@ static void layer_trace_block_edge__( const layer_type * layer , int_point2d_typ static void layer_fprintf_dash( const layer_type * layer , FILE * stream, int i1 , int i2) { int i; fprintf(stream," --"); - for (i=i1; i <= i2; i++) + for (i=i1; i <= i2; i++) fprintf(stream , "----"); fprintf(stream , "----\n"); } @@ -334,7 +390,7 @@ static void layer_fprintf_dash( const layer_type * layer , FILE * stream, int i1 static void layer_fprintf_header( const layer_type * layer , FILE * stream, int i1 , int i2) { int i; fprintf(stream," "); - for (i=i1; i <= i2; i++) + for (i=i1; i <= i2; i++) fprintf(stream , " %3d" , i); fprintf(stream , "\n"); } @@ -344,12 +400,12 @@ void layer_fprintf_box( const layer_type * layer , FILE * stream , int i1 , int int i,j; layer_fprintf_header( layer , stream , i1 , i2); layer_fprintf_dash( layer , stream , i1 , i2); - + for (j=j2; j >= j1; j--) { fprintf(stream , " %3d | " , j); for (i=i1; i <= i2; i++) { - int g = layer_get_global_cell_index( layer , i , j); + int g = layer_get_global_cell_index( layer , i , j); cell_type * cell = &layer->data[g]; fprintf(stream , " %3d" , cell->cell_value); } @@ -367,9 +423,9 @@ void layer_fprintf( const layer_type * layer , FILE * stream) { void layer_fprintf_cell( const layer_type * layer , int i , int j , FILE * stream) { - int g = layer_get_global_cell_index( layer , i , j); + int g = layer_get_global_cell_index( layer , i , j); cell_type * cell = &layer->data[g]; - + fprintf(stream , " i:%d j:%d \n",i,j); fprintf(stream , " *--- %4d ---* \n",cell->edges[TOP_EDGE]); fprintf(stream , " | | \n"); @@ -380,13 +436,13 @@ void layer_fprintf_cell( const layer_type * layer , int i , int j , FILE * strea static bool layer_find_edge( const layer_type * layer , int *i , int *j , int value) { - int g = layer_get_global_cell_index( layer , *i , *j); + int g = layer_get_global_cell_index( layer , *i , *j); cell_type * cell = &layer->data[g]; if (cell->cell_value == value) { while (!layer_cell_on_edge( layer , *i , *j)) (*i) += 1; - + return true; } else return false; @@ -394,16 +450,16 @@ static bool layer_find_edge( const layer_type * layer , int *i , int *j , int va bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_j , int value , struct_vector_type * corner_list , int_vector_type * cell_list) { - int g = layer_get_global_cell_index( layer , start_i , start_j); + int g = layer_get_global_cell_index( layer , start_i , start_j); cell_type * cell = &layer->data[g]; if ((cell->cell_value == value)) { int i = start_i; int j = start_j; - + if (layer_find_edge( layer , &i , &j , value)) { int_point2d_type start_corner; - g = layer_get_global_cell_index( layer , i , j); + g = layer_get_global_cell_index( layer , i , j); cell = &layer->data[g]; start_corner.i = i; @@ -411,7 +467,7 @@ bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_ struct_vector_reset( corner_list ); int_vector_reset( cell_list ); - + if (cell->edges[BOTTOM_EDGE] == value) { point_shift( &start_corner , 0 , 0 ); layer_trace_block_edge__(layer , start_corner , i , j , value , BOTTOM_EDGE , corner_list , cell_list); @@ -426,19 +482,19 @@ bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_ layer_trace_block_edge__(layer , start_corner , i , j , value , LEFT_EDGE , corner_list , cell_list); } else util_abort("%s: what the fuck - internal error \n",__func__); - + int_vector_select_unique( cell_list ); return true; } - } - + } + return false; } - + static void layer_trace_block_content__( layer_type * layer , bool erase , int i , int j , int value , bool * visited , int_vector_type * i_list , int_vector_type * j_list) { - int g = layer_get_global_cell_index( layer , i , j); + int g = layer_get_global_cell_index( layer , i , j); cell_type * cell = &layer->data[g]; if (cell->cell_value != value || visited[g]) return; @@ -446,7 +502,7 @@ static void layer_trace_block_content__( layer_type * layer , bool erase , int i visited[g] = true; if (erase) layer_iset_cell_value( layer , i , j , 0); - + int_vector_append( i_list , i ); int_vector_append( j_list , j ); @@ -461,7 +517,7 @@ static void layer_trace_block_content__( layer_type * layer , bool erase , int i if (j < (layer->ny - 1)) layer_trace_block_content__( layer , erase , i , j + 1, value , visited , i_list , j_list); - + } } @@ -472,7 +528,7 @@ static bool * layer_alloc_visited_mask( const layer_type * layer ) { int g; for (g = 0; g < total_size; g++) visited[g] = false; - + return visited; } @@ -481,7 +537,7 @@ static bool * layer_alloc_visited_mask( const layer_type * layer ) { bool layer_trace_block_content( layer_type * layer , bool erase , int start_i , int start_j , int value , int_vector_type * i_list, int_vector_type * j_list) { bool start_tracing = false; - int g = layer_get_global_cell_index( layer , start_i , start_j); + int g = layer_get_global_cell_index( layer , start_i , start_j); cell_type * cell = &layer->data[g]; if ((value == 0) && (cell->cell_value != 0)) @@ -496,7 +552,7 @@ bool layer_trace_block_content( layer_type * layer , bool erase , int start_i , int_vector_reset( i_list ); int_vector_reset( j_list ); layer_trace_block_content__(layer , erase , start_i , start_j , value , visited , i_list , j_list ); - + free( visited ); return true; } else @@ -519,3 +575,211 @@ int layer_replace_cell_values( layer_type * layer , int old_value , int new_valu return replace_count; } + + +static void layer_assert_cell_index( const layer_type * layer , int i , int j ) { + if ((i < 0) || (j < 0)) + util_abort("%s: invalid value for i,j i:%d [0,%d) j:%d [0,%d) \n",__func__ , i , layer->nx , j , layer->ny); + + if ((i >= layer->nx) || (j >= layer->ny)) + util_abort("%s: invalid value for i,j i:%d [0,%d) j:%d [0,%d) \n",__func__ , i , layer->nx , j , layer->ny); + +} + + + +bool layer_cell_contact( const layer_type * layer , int i1 , int j1 , int i2 , int j2) { + layer_assert_cell_index( layer , i1 , j1 ); + layer_assert_cell_index( layer , i2 , j2 ); + { + + if ((abs(i1 - i2) == 1) && (j1 == j2)) { + int i = util_int_max( i1,i2 ); + const cell_type * cell = layer_iget_cell( layer , i , j1 ); + return !cell->left_barrier; + } + + if ((i1 == i2) && (abs(j1 - j2) == 1)) { + int j = util_int_max( j1 , j2 ); + const cell_type * cell = layer_iget_cell( layer , i1 , j ); + return !cell->bottom_barrier; + } + + return false; + } +} + + +void layer_add_ijbarrier( layer_type * layer , int i1 , int j1 , int i2 , int j2 ) { + if ((j1 == j2) || (i1 == i2)) { + if (i1 == i2) { + int j; + int jmin = util_int_min(j1,j2); + int jmax = util_int_max(j1,j2); + + for (j=jmin; j < jmax; j++) { + cell_type * cell = layer_iget_cell__( layer , i1 , j ); + cell->left_barrier = true; + } + } else { + int i; + int imin = util_int_min(i1,i2); + int imax = util_int_max(i1,i2); + + for (i=imin; i < imax; i++) { + cell_type * cell = layer_iget_cell__( layer , i , j1 ); + cell->bottom_barrier = true; + } + } + } else + util_abort("%s: fatal error must have i1 == i2 || j1 == j2 \n",__func__); + +} + + + +void layer_add_barrier( layer_type * layer , int c1 , int c2) { + int dimx = layer->nx + 1; + int j1 = c1 / dimx; + int i1 = c1 % dimx; + + int j2 = c2 / dimx; + int i2 = c2 % dimx; + + layer_add_ijbarrier( layer , i1 , j1 , i2 , j2 ); +} + + + +/* + Line is parameterized as: ax + by + c = 0 +*/ +static double distance_to_line(double a , double b , double c , int i , int j) { + double x0 = 1.0 * i; + double y0 = 1.0 * j; + + + return fabs(a*x0 + b*y0 + c) / sqrt(a*a + b*b); +} + + + + +void layer_add_interp_barrier( layer_type * layer , int c1 , int c2) { + int dimx = layer->nx + 1; + int j1 = c1 / dimx; + int i1 = c1 % dimx; + + int j2 = c2 / dimx; + int i2 = c2 % dimx; + + if ((j1 == j2) || (i1 == i2)) + layer_add_barrier( layer , c1 , c2 ); + else { + int di = abs(i2 - i1) / (i2 - i1); + int dj = abs(j2 - j1) / (j2 - j1); + double a = 1.0 * (j2 - j1) / (i2 - i1); + double b = 1.0 * (j1 - a*i1); + + int i = i1; + int j = j1; + int c = c1; + + while (c != c2) { + double dx = distance_to_line( a , -1 , b , i + di , j ); + double dy = distance_to_line( a , -1 , b , i , j + dj); + + if (dx <= dy) + i += di; + else + j += dj; + + layer_add_barrier( layer , c , i + j*dimx); + c = i + j*dimx; + } + } +} + + +void layer_memcpy(layer_type * target_layer , const layer_type * src_layer) { + if ((target_layer->nx == src_layer->nx) && (target_layer->ny == src_layer->ny)) { + size_t data_size = target_layer->nx * target_layer->ny * sizeof(cell_type); + memcpy(target_layer->data , src_layer->data , data_size ); + target_layer->cell_sum = src_layer->cell_sum; + } else + util_abort("%s: fatal error - tried to copy elements between layers of different size\n",__func__); +} + + +static void layer_assign__( layer_type * layer, int value) { + int i,j; + for (j=0; j < layer->ny; j++) { + for (i=0; i < layer->nx; i++) { + cell_type * cell = layer_iget_cell( layer , i , j ); + cell->cell_value = value; + { + int e; + for (e=0; e < 4; e++) + cell->edges[e] = 0; + } + } + } + layer->cell_sum = value * layer->nx*layer->ny; +} + +void layer_clear_cells( layer_type * layer) { + layer_assign__(layer , 0 ); +} + +void layer_assign( layer_type * layer, int value) { + layer_assign__( layer , value ); +} + + + +void layer_update_connected_cells( layer_type * layer , int i , int j , int org_value , int new_value) { + if (org_value != new_value) { + if (layer_iget_cell_value( layer , i , j ) == org_value) { + layer_iset_cell_value( layer , i , j , new_value); + + if (i < (layer->nx - 1) && layer_cell_contact( layer , i,j,i+1,j)) + layer_update_connected_cells( layer , i + 1 , j , org_value , new_value); + + if (i > 0 && layer_cell_contact( layer , i,j,i-1,j)) + layer_update_connected_cells( layer , i - 1 , j , org_value , new_value); + + if (j < (layer->ny - 1) && layer_cell_contact( layer , i,j,i,j+1)) + layer_update_connected_cells( layer , i , j + 1, org_value , new_value); + + if (j > 0 && layer_cell_contact( layer , i,j,i,j-1)) + layer_update_connected_cells( layer , i , j - 1, org_value , new_value); + } + } +} + + +void layer_cells_equal( const layer_type * layer , int value , int_vector_type * i_list , int_vector_type * j_list) { + int i,j; + for (j=0; j < layer->ny; j++) { + for (i=0; i < layer->nx; i++) { + cell_type * cell = layer_iget_cell( layer , i , j ); + if (cell->cell_value == value) { + int_vector_append( i_list , i ); + int_vector_append( j_list , j ); + } + } + } +} + + + + +void layer_update_active( layer_type * layer , const ecl_grid_type * grid , int k) { + int i,j; + for (j=0; j< ecl_grid_get_ny( grid ); j++) { + for (i=0; i < ecl_grid_get_nx( grid ); i++) { + cell_type * cell = layer_iget_cell( layer , i , j ); + cell->active = ecl_grid_cell_active3( grid , i , j , k ); + } + } +} diff --git a/ThirdParty/Ert/devel/libecl/src/point.c b/ThirdParty/Ert/devel/libecl/src/point.c index fc2435ab6f..ebeabeee14 100644 --- a/ThirdParty/Ert/devel/libecl/src/point.c +++ b/ThirdParty/Ert/devel/libecl/src/point.c @@ -53,9 +53,9 @@ void point_mapaxes_invtransform( point_type * p , const double origo[2], const d void point_compare( const point_type *p1 , const point_type * p2, bool * equal) { const double tolerance = 0.001; - double diff_x = (abs(p1->x - p2->x) / abs(p1->x + p2->x + 1)); - double diff_y = (abs(p1->y - p2->y) / abs(p1->y + p2->y + 1)); - double diff_z = (abs(p1->z - p2->z) / abs(p1->z + p2->z + 1)); + double diff_x = (fabs(p1->x - p2->x) / fabs(p1->x + p2->x + 1)); + double diff_y = (fabs(p1->y - p2->y) / fabs(p1->y + p2->y + 1)); + double diff_z = (fabs(p1->z - p2->z) / fabs(p1->z + p2->z + 1)); if (diff_x + diff_y + diff_z > tolerance) *equal = false; diff --git a/ThirdParty/Ert/devel/libecl/src/smspec_node.c b/ThirdParty/Ert/devel/libecl/src/smspec_node.c index 1c85b371be..554d025574 100644 --- a/ThirdParty/Ert/devel/libecl/src/smspec_node.c +++ b/ThirdParty/Ert/devel/libecl/src/smspec_node.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'smspec_node.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'smspec_node.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <string.h> @@ -44,7 +44,7 @@ file; the content is based on the smspec vectors WGNAMES, KEYWORDS, UNIT and NUMS. The index field of this struct points to where the actual data can be found in the PARAMS vector of the *.Snnnn / *.UNSMRY files; - probably the most important field. + probably the most important field. */ #define SMSPEC_TYPE_ID 61550451 @@ -52,7 +52,7 @@ struct smspec_node_struct { UTIL_TYPE_ID_DECLARATION; - char * gen_key1; /* The main composite key, i.e. WWCT:OP3 for this element. */ + char * gen_key1; /* The main composite key, i.e. WWCT:OP3 for this element. */ char * gen_key2; /* Some of the ijk based elements will have both a xxx:i,j,k and a xxx:num key. Some of the region_2_region elements will have both a xxx:num and a xxx:r2-r2 key. Mostly NULL. */ ecl_smspec_var_type var_type; /* The variable type */ char * wgname; /* The value of the WGNAMES vector for this element. */ @@ -83,7 +83,7 @@ struct smspec_node_struct { #define ECL_SUM_KEYFMT_BLOCK_IJK "%s%s%d,%d,%d" #define ECL_SUM_KEYFMT_BLOCK_NUM "%s%s%d" #define ECL_SUM_KEYFMT_LOCAL_BLOCK "%s%s%s%s%d,%d,%d" -#define ECL_SUM_KEYFMT_COMPLETION_IJK "%s%s%s%s%d,%d,%d" +#define ECL_SUM_KEYFMT_COMPLETION_IJK "%s%s%s%s%d,%d,%d" #define ECL_SUM_KEYFMT_COMPLETION_NUM "%s%s%s%s%d" #define ECL_SUM_KEYFMT_LOCAL_COMPLETION "%s%s%s%s%s%s%d,%d,%d" #define ECL_SUM_KEYFMT_GROUP "%s%s%s" @@ -99,49 +99,49 @@ UTIL_SAFE_CAST_FUNCTION( smspec_node , SMSPEC_TYPE_ID ) char * smspec_alloc_block_num_key( const char * join_string , const char * keyword , int num) { return util_alloc_sprintf(ECL_SUM_KEYFMT_BLOCK_NUM, - keyword , - join_string , + keyword , + join_string , num ); } char * smspec_alloc_local_block_key( const char * join_string , const char * keyword , const char * lgr_name , int i , int j , int k) { - return util_alloc_sprintf(ECL_SUM_KEYFMT_LOCAL_BLOCK , - keyword , - join_string , - lgr_name , - join_string , + return util_alloc_sprintf(ECL_SUM_KEYFMT_LOCAL_BLOCK , + keyword , + join_string , + lgr_name , + join_string , i,j,k); } char * smspec_alloc_region_key( const char * join_string , const char * keyword , int num) { - return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION , - keyword , - join_string , + return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION , + keyword , + join_string , num ); } char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2) { return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_R1R2, keyword, - join_string, - r1, + join_string, + r1, r2); } char * smspec_alloc_region_2_region_num_key( const char * join_string , const char * keyword , int num) { - return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_NUM, - keyword , - join_string , + return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_NUM, + keyword , + join_string , num); } - + char * smspec_alloc_block_ijk_key( const char * join_string , const char * keyword , int i , int j , int k) { - return util_alloc_sprintf(ECL_SUM_KEYFMT_BLOCK_IJK , + return util_alloc_sprintf(ECL_SUM_KEYFMT_BLOCK_IJK , keyword, - join_string , + join_string , i,j,k); } @@ -149,11 +149,11 @@ char * smspec_alloc_block_ijk_key( const char * join_string , const char * keywo char * smspec_alloc_completion_ijk_key( const char * join_string , const char * keyword, const char * wgname , int i , int j , int k) { if (wgname != NULL) - return util_alloc_sprintf( ECL_SUM_KEYFMT_COMPLETION_IJK , - keyword , - join_string , - wgname , - join_string , + return util_alloc_sprintf( ECL_SUM_KEYFMT_COMPLETION_IJK , + keyword , + join_string , + wgname , + join_string , i , j , k ); else return NULL; @@ -164,10 +164,10 @@ char * smspec_alloc_completion_ijk_key( const char * join_string , const char * char * smspec_alloc_completion_num_key( const char * join_string , const char * keyword, const char * wgname , int num) { if (wgname != NULL) return util_alloc_sprintf(ECL_SUM_KEYFMT_COMPLETION_NUM, - keyword , - join_string , - wgname , - join_string , + keyword , + join_string , + wgname , + join_string , num ); else return NULL; @@ -181,10 +181,10 @@ char * smspec_alloc_completion_num_key( const char * join_string , const char * */ static char * smspec_alloc_wgname_key( const char * join_string , const char * keyword , const char * wgname) { - if (wgname != NULL) + if (wgname != NULL) return util_alloc_sprintf(ECL_SUM_KEYFMT_WELL, - keyword , - join_string , + keyword , + join_string , wgname ); else return NULL; @@ -200,11 +200,11 @@ char * smspec_alloc_well_key( const char * join_string , const char * keyword , char * smspec_alloc_segment_key( const char * join_string , const char * keyword , const char * wgname , int num) { if (wgname != NULL) - return util_alloc_sprintf(ECL_SUM_KEYFMT_SEGMENT , - keyword , - join_string , - wgname , - join_string , + return util_alloc_sprintf(ECL_SUM_KEYFMT_SEGMENT , + keyword , + join_string , + wgname , + join_string , num ); else return NULL; @@ -213,11 +213,11 @@ char * smspec_alloc_segment_key( const char * join_string , const char * keyword char * smspec_alloc_local_well_key( const char * join_string , const char * keyword , const char * lgr_name , const char * wgname) { if (wgname != NULL) - return util_alloc_sprintf( ECL_SUM_KEYFMT_LOCAL_WELL , - keyword , - join_string , - lgr_name , - join_string , + return util_alloc_sprintf( ECL_SUM_KEYFMT_LOCAL_WELL , + keyword , + join_string , + lgr_name , + join_string , wgname); else return NULL; @@ -225,12 +225,12 @@ char * smspec_alloc_local_well_key( const char * join_string , const char * keyw char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k) { if (wgname != NULL) - return util_alloc_sprintf(ECL_SUM_KEYFMT_LOCAL_COMPLETION , - keyword , - join_string , - lgr_name , + return util_alloc_sprintf(ECL_SUM_KEYFMT_LOCAL_COMPLETION , + keyword , + join_string , + lgr_name , join_string , - wgname , + wgname , join_string , i,j,k); else @@ -244,7 +244,7 @@ static void smspec_node_set_keyword( smspec_node_type * smspec_node , const char // This function can __ONLY__ be called on time; run-time chaning of keyword is not // allowed. if (smspec_node->keyword == NULL) - smspec_node->keyword = util_alloc_substring_copy( keyword , 0 , 8); + smspec_node->keyword = util_alloc_substring_copy( keyword , 0 , 8); else util_abort("%s: fatal error - attempt to change keyword runtime detected - aborting\n",__func__); } @@ -262,9 +262,9 @@ static char LAST_CHAR(const char * s) { } static void smspec_node_set_flags( smspec_node_type * smspec_node) { - /* + /* Check if this is a rate variabel - that info is used when - interpolating results to true_time between ministeps. + interpolating results to true_time between ministeps. */ { const char *rate_vars[] = {"OPR" , "GPR" , "WPR" , "GOR" , "WCT"}; @@ -280,7 +280,7 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { } smspec_node->rate_variable = is_rate; } - + { if (LAST_CHAR(smspec_node->keyword) == 'H') smspec_node->historical = true; @@ -291,7 +291,7 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { variable represents a total accumulated quantity. Only the last three characters in the variable is considered (i.e. the leading 'W', 'G' or 'F' is discarded). - + The list below is all the keyowrds with 'Total' in the information from the tables 2.7 - 2.11 in the ECLIPSE fileformat documentation. Have skipped some of the most exotic keywords. @@ -300,7 +300,7 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { bool is_total = false; if (smspec_node->var_type == ECL_SMSPEC_WELL_VAR || smspec_node->var_type == ECL_SMSPEC_GROUP_VAR || smspec_node->var_type == ECL_SMSPEC_FIELD_VAR) { const char *total_vars[] = {"OPT" , "GPT" , "WPT" , "OPTF" , "OPTS" , "OIT" , "OVPT" , "OVIT" , "MWT" , "WIT" , - "WVPT" , "WVIT" , "GMT" , "GPTF" , "GIT" , "SGT" , "GST" , "FGT" , "GCT" , "GIMT" , + "WVPT" , "WVIT" , "GMT" , "GPTF" , "GIT" , "SGT" , "GST" , "FGT" , "GCT" , "GIMT" , "WGPT" , "WGIT" , "EGT" , "EXGT" , "GVPT" , "GVIT" , "LPT" , "VPT" , "VIT" }; int num_total_vars = sizeof( total_vars ) / sizeof( total_vars[0] ); @@ -324,15 +324,15 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { /* Check if this node needs the nums field; if at least one of the nodes need the NUMS field must be stored when writing a SMSPEC - file. + file. */ { - if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR || - smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR || + if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR || + smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR || smspec_node->var_type == ECL_SMSPEC_REGION_VAR || smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR || smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR || - smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR) + smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR) smspec_node->need_nums = true; else smspec_node->need_nums = false; @@ -357,15 +357,15 @@ float smspec_node_get_default( const smspec_node_type * smspec_node ) { smspec_node_type * smspec_node_alloc_new(int params_index, float default_value) { smspec_node_type * node = util_malloc( sizeof * node ); - + UTIL_TYPE_ID_INIT( node , SMSPEC_TYPE_ID); node->params_index = params_index; smspec_node_set_default( node , default_value ); node->wgname = NULL; node->num = SMSPEC_NUMS_INVALID; - node->ijk = NULL; - + node->ijk = NULL; + node->gen_key1 = NULL; node->gen_key2 = NULL; @@ -373,8 +373,8 @@ smspec_node_type * smspec_node_alloc_new(int params_index, float default_value) node->unit = NULL; node->keyword = NULL; node->lgr_name = NULL; - node->lgr_ijk = NULL; - + node->lgr_ijk = NULL; + smspec_node_set_invalid_flags( node ); return node; // This is NOT usable } @@ -382,7 +382,7 @@ smspec_node_type * smspec_node_alloc_new(int params_index, float default_value) /** Observe that the wellname can have max 8 characters; anything - beyond that is silently dropped. + beyond that is silently dropped. */ static void smspec_node_set_wgname( smspec_node_type * index , const char * wgname ) { @@ -390,7 +390,7 @@ static void smspec_node_set_wgname( smspec_node_type * index , const char * wgna util_safe_free( index->wgname ); index->wgname = NULL; } else { - if (strlen(wgname) > 8) + if (strlen(wgname) > 8) index->wgname = util_realloc_substring_copy(index->wgname , wgname , 8); else index->wgname = util_realloc_string_copy(index->wgname , wgname ); @@ -407,7 +407,7 @@ static void smspec_node_set_lgr_name( smspec_node_type * index , const char * lg static void smspec_node_set_lgr_ijk( smspec_node_type * index , int lgr_i , int lgr_j , int lgr_k) { if (index->lgr_ijk == NULL) index->lgr_ijk = util_calloc( 3 , sizeof * index->lgr_ijk ); - + index->lgr_ijk[0] = lgr_i; index->lgr_ijk[1] = lgr_j; index->lgr_ijk[2] = lgr_k; @@ -417,12 +417,12 @@ static void smspec_node_set_lgr_ijk( smspec_node_type * index , int lgr_i , int static void smspec_node_set_num( smspec_node_type * index , const int grid_dims[3] , int num) { if (num == SMSPEC_NUMS_INVALID) util_abort("%s: explicitly trying to set nums == SMSPEC_NUMS_INVALID - seems like a bug?!\n",__func__); - + index->num = num; if ((index->var_type == ECL_SMSPEC_COMPLETION_VAR) || (index->var_type == ECL_SMSPEC_BLOCK_VAR)) { int global_index = num - 1; index->ijk = util_calloc( 3 , sizeof * index->ijk ); - + index->ijk[2] = global_index / ( grid_dims[0] * grid_dims[1] ); global_index -= index->ijk[2] * (grid_dims[0] * grid_dims[1]); index->ijk[1] = global_index / grid_dims[0] ; global_index -= index->ijk[1] * grid_dims[0]; index->ijk[0] = global_index; @@ -447,37 +447,37 @@ static void smspec_node_set_gen_keys( smspec_node_type * smspec_node , const cha switch( smspec_node->var_type) { case(ECL_SMSPEC_COMPLETION_VAR): // KEYWORD:WGNAME:NUM - smspec_node->gen_key1 = smspec_alloc_completion_num_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num); - smspec_node->gen_key2 = smspec_alloc_completion_ijk_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->ijk[0], smspec_node->ijk[1], smspec_node->ijk[2]); + smspec_node->gen_key1 = smspec_alloc_completion_ijk_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->ijk[0], smspec_node->ijk[1], smspec_node->ijk[2]); + smspec_node->gen_key2 = smspec_alloc_completion_num_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num); break; case(ECL_SMSPEC_FIELD_VAR): // KEYWORD smspec_node->gen_key1 = util_alloc_string_copy( smspec_node->keyword ); break; case(ECL_SMSPEC_GROUP_VAR): - // KEYWORD:WGNAME + // KEYWORD:WGNAME smspec_node->gen_key1 = smspec_alloc_group_key( key_join_string , smspec_node->keyword , smspec_node->wgname); break; case(ECL_SMSPEC_WELL_VAR): - // KEYWORD:WGNAME + // KEYWORD:WGNAME smspec_node->gen_key1 = smspec_alloc_well_key( key_join_string , smspec_node->keyword , smspec_node->wgname); break; case(ECL_SMSPEC_REGION_VAR): // KEYWORD:NUM smspec_node->gen_key1 = smspec_alloc_region_key( key_join_string , smspec_node->keyword , smspec_node->num); break; - case (ECL_SMSPEC_SEGMENT_VAR): - // KEYWORD:WGNAME:NUM - smspec_node->gen_key1 = smspec_alloc_segment_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num); + case (ECL_SMSPEC_SEGMENT_VAR): + // KEYWORD:WGNAME:NUM + smspec_node->gen_key1 = smspec_alloc_segment_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num); break; case(ECL_SMSPEC_REGION_2_REGION_VAR): // KEYWORDS:RXF:NUM and RXF:R1-R2 - smspec_node->gen_key1 = smspec_alloc_region_2_region_num_key( key_join_string , smspec_node->keyword , smspec_node->num); { int r1 = smspec_node->num % 32768; int r2 = ((smspec_node->num-r1) / 32768)-10; - smspec_node->gen_key2 = smspec_alloc_region_2_region_r1r2_key( key_join_string , smspec_node->keyword , r1, r2); + smspec_node->gen_key1 = smspec_alloc_region_2_region_r1r2_key( key_join_string , smspec_node->keyword , r1, r2); } + smspec_node->gen_key2 = smspec_alloc_region_2_region_num_key( key_join_string , smspec_node->keyword , smspec_node->num); break; case(ECL_SMSPEC_MISC_VAR): // KEYWORD @@ -486,8 +486,8 @@ static void smspec_node_set_gen_keys( smspec_node_type * smspec_node , const cha break; case(ECL_SMSPEC_BLOCK_VAR): // KEYWORD:NUM - smspec_node->gen_key1 = smspec_alloc_block_num_key( key_join_string , smspec_node->keyword , smspec_node->num); - smspec_node->gen_key2 = smspec_alloc_block_ijk_key( key_join_string , smspec_node->keyword , smspec_node->ijk[0], smspec_node->ijk[1], smspec_node->ijk[2]); + smspec_node->gen_key1 = smspec_alloc_block_ijk_key( key_join_string , smspec_node->keyword , smspec_node->ijk[0], smspec_node->ijk[1], smspec_node->ijk[2]); + smspec_node->gen_key2 = smspec_alloc_block_num_key( key_join_string , smspec_node->keyword , smspec_node->num); break; case(ECL_SMSPEC_LOCAL_WELL_VAR): /** KEYWORD:LGR:WGNAME */ @@ -495,23 +495,23 @@ static void smspec_node_set_gen_keys( smspec_node_type * smspec_node , const cha break; case(ECL_SMSPEC_LOCAL_BLOCK_VAR): /* KEYWORD:LGR:i,j,k */ - smspec_node->gen_key1 = smspec_alloc_local_block_key( key_join_string , - smspec_node->keyword , - smspec_node->lgr_name , - smspec_node->lgr_ijk[0] , - smspec_node->lgr_ijk[1] , + smspec_node->gen_key1 = smspec_alloc_local_block_key( key_join_string , + smspec_node->keyword , + smspec_node->lgr_name , + smspec_node->lgr_ijk[0] , + smspec_node->lgr_ijk[1] , smspec_node->lgr_ijk[2] ); break; case(ECL_SMSPEC_LOCAL_COMPLETION_VAR): /* KEYWORD:LGR:WELL:i,j,k */ - smspec_node->gen_key1 = smspec_alloc_local_completion_key( key_join_string , - smspec_node->keyword , - smspec_node->lgr_name , - smspec_node->wgname , + smspec_node->gen_key1 = smspec_alloc_local_completion_key( key_join_string , + smspec_node->keyword , + smspec_node->lgr_name , + smspec_node->wgname , smspec_node->lgr_ijk[0], smspec_node->lgr_ijk[1], smspec_node->lgr_ijk[2]); - + break; default: util_abort("%s: internal error - should not be here? \n" , __func__); @@ -539,20 +539,20 @@ static void smspec_node_common_init( smspec_node_type * node , ecl_smspec_var_ty -bool smspec_node_init( smspec_node_type * smspec_node, - ecl_smspec_var_type var_type , - const char * wgname , - const char * keyword , - const char * unit , - const char * key_join_string , - const int grid_dims[3] , +bool smspec_node_init( smspec_node_type * smspec_node, + ecl_smspec_var_type var_type , + const char * wgname , + const char * keyword , + const char * unit , + const char * key_join_string , + const int grid_dims[3] , int num) { - + bool initOK = true; bool wgnameOK = true; if ((wgname != NULL) && (IS_DUMMY_WELL(wgname))) wgnameOK = false; - + smspec_node_common_init( smspec_node , var_type , keyword , unit ); switch (var_type) { case(ECL_SMSPEC_COMPLETION_VAR): @@ -565,14 +565,14 @@ bool smspec_node_init( smspec_node_type * smspec_node, break; case(ECL_SMSPEC_GROUP_VAR): /* Group variable : WGNAME */ - if (wgnameOK) + if (wgnameOK) smspec_node_set_wgname( smspec_node , wgname ); else initOK = false; break; case(ECL_SMSPEC_WELL_VAR): /* Well variable : WGNAME */ - if (wgnameOK) + if (wgnameOK) smspec_node_set_wgname( smspec_node , wgname ); else initOK = false; @@ -613,7 +613,7 @@ bool smspec_node_init( smspec_node_type * smspec_node, smspec_node_set_gen_keys( smspec_node , key_join_string ); return initOK; } - + /** This function will allocate a smspec_node instance, and initialize all the elements. Observe that the function can return NULL, in the @@ -630,12 +630,12 @@ bool smspec_node_init( smspec_node_type * smspec_node, -smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , - const char * wgname , - const char * keyword , - const char * unit , - const char * key_join_string , - const int grid_dims[3] , +smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , + const char * wgname , + const char * keyword , + const char * unit , + const char * key_join_string , + const int grid_dims[3] , int num , int param_index, float default_value) { /* Well and group names in the wgname parameter is quite messy. The @@ -643,10 +643,10 @@ smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , o The ECLIPSE SMSPEC files are very verbose, and contain many entries like this: - + KEYWORD : "WWCT" WGNAME : ":+:+:+:+" - + i.e. the keyword indicates that this is a perfectly legitimate well variable, however the special wgname value ":+:+:+:+" shows that this just a rubbish entry. We do not want to @@ -666,7 +666,7 @@ smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , at all, e.g. like "FOPT" - the wgname input value is ignored completely. */ - + smspec_node_type * smspec_node = smspec_node_alloc_new( param_index , default_value ); if (smspec_node_init( smspec_node , var_type , wgname , keyword , unit , key_join_string , grid_dims, num)) return smspec_node; @@ -678,20 +678,20 @@ smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , -bool smspec_node_init_lgr( smspec_node_type * smspec_node , - ecl_smspec_var_type var_type , - const char * wgname , - const char * keyword , - const char * unit , - const char * lgr , - const char * key_join_string , +bool smspec_node_init_lgr( smspec_node_type * smspec_node , + ecl_smspec_var_type var_type , + const char * wgname , + const char * keyword , + const char * unit , + const char * lgr , + const char * key_join_string , int lgr_i, int lgr_j , int lgr_k ) { bool initOK = true; bool wgnameOK = true; if ((wgname != NULL) && (IS_DUMMY_WELL(wgname))) wgnameOK = false; - + smspec_node_common_init( smspec_node , var_type , keyword , unit ); switch (var_type) { case(ECL_SMSPEC_LOCAL_WELL_VAR): @@ -723,17 +723,17 @@ bool smspec_node_init_lgr( smspec_node_type * smspec_node , -smspec_node_type * smspec_node_alloc_lgr( ecl_smspec_var_type var_type , - const char * wgname , - const char * keyword , - const char * unit , - const char * lgr , - const char * key_join_string , +smspec_node_type * smspec_node_alloc_lgr( ecl_smspec_var_type var_type , + const char * wgname , + const char * keyword , + const char * unit , + const char * lgr , + const char * key_join_string , int lgr_i, int lgr_j , int lgr_k, int param_index , float default_value) { - + smspec_node_type * smspec_node = smspec_node_alloc_new( param_index , default_value ); - if (smspec_node_init_lgr( smspec_node , var_type , wgname , keyword , lgr , unit , key_join_string , lgr_i, lgr_j , lgr_k)) + if (smspec_node_init_lgr( smspec_node , var_type , wgname , keyword , unit , lgr , key_join_string , lgr_i, lgr_j , lgr_k)) return smspec_node; else { smspec_node_free( smspec_node ); @@ -805,11 +805,11 @@ bool smspec_node_is_rate( const smspec_node_type * smspec_node ) { } -bool smspec_node_is_total( const smspec_node_type * smspec_node ){ +bool smspec_node_is_total( const smspec_node_type * smspec_node ){ return smspec_node->total_variable; } -bool smspec_node_is_historical( const smspec_node_type * smspec_node ){ +bool smspec_node_is_historical( const smspec_node_type * smspec_node ){ return smspec_node->historical; } @@ -821,7 +821,7 @@ const char * smspec_node_get_unit( const smspec_node_type * smspec_node) { void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit ) { // ECLIPSE Standard: Max eight characters - everything beyond is silently dropped util_safe_free( smspec_node->unit ); - smspec_node->unit = util_alloc_substring_copy( unit , 0 , 8); + smspec_node->unit = util_alloc_substring_copy( unit , 0 , 8); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_fault_block_layer.c b/ThirdParty/Ert/devel/libecl/tests/ecl_fault_block_layer.c index a7a7a2b6d4..08917065df 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_fault_block_layer.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_fault_block_layer.c @@ -21,6 +21,8 @@ #include <ert/util/test_util.h> +#include <ert/geometry/geo_polygon_collection.h> + #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_kw.h> #include <ert/ecl/fault_block_layer.h> @@ -138,6 +140,7 @@ void test_export( const ecl_grid_type * grid) { void test_neighbours( const ecl_grid_type * grid) { const int k = 0; fault_block_layer_type * layer = fault_block_layer_alloc( grid , k ); + geo_polygon_collection_type * polylines = geo_polygon_collection_alloc(); ecl_kw_type * ecl_kw = ecl_kw_alloc("FAULTBLK" , ecl_grid_get_global_size( grid ) , ECL_INT_TYPE ); ecl_kw_iset_int( ecl_kw , 0 , 1); @@ -153,14 +156,14 @@ void test_neighbours( const ecl_grid_type * grid) { fault_block_type * block = fault_block_layer_get_block( layer , 1 ); test_assert_int_equal( 0 , int_vector_size( neighbours )); - fault_block_list_neighbours( block , neighbours ); + fault_block_list_neighbours( block , false , polylines , neighbours ); test_assert_int_equal( 0 , int_vector_size( neighbours )); } { fault_block_type * block = fault_block_layer_get_block( layer , 2 ); - fault_block_list_neighbours( block , neighbours ); + fault_block_list_neighbours( block , false , polylines , neighbours ); test_assert_int_equal( 1 , int_vector_size( neighbours )); test_assert_true( int_vector_contains( neighbours , 3 )); } @@ -169,7 +172,7 @@ void test_neighbours( const ecl_grid_type * grid) { } - + geo_polygon_collection_free( polylines ); fault_block_layer_free( layer ); ecl_kw_free( ecl_kw ); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_file.c b/ThirdParty/Ert/devel/libecl/tests/ecl_file.c index ad8722275a..37c5802436 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_file.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_file.c @@ -1,19 +1,20 @@ + /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -24,6 +25,7 @@ #include <ert/util/test_work_area.h> #include <ert/ecl/ecl_file.h> +#include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_endian_flip.h> @@ -51,7 +53,7 @@ void test_flags( const char * filename) { void test_close_stream2(const char * src_file , const char * target_file ) { util_copy_file( src_file , target_file ); ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM ); - + ecl_file_load_all( ecl_file ); unlink( target_file ); ecl_kw_type * kw2 = ecl_file_iget_kw( ecl_file , 2 ); @@ -64,7 +66,7 @@ void test_loadall(const char * src_file , const char * target_file ) { util_copy_file( src_file , target_file ); { ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM ); - + test_assert_true( ecl_file_load_all( ecl_file ) ); ecl_file_close( ecl_file ); } @@ -72,7 +74,7 @@ void test_loadall(const char * src_file , const char * target_file ) { { ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM ); unlink( target_file ); - + test_assert_false( ecl_file_load_all( ecl_file ) ); ecl_file_close( ecl_file ); } @@ -88,18 +90,18 @@ void test_close_stream1(const char * src_file , const char * target_file ) { ecl_kw_type * kw1 = ecl_file_iget_kw( ecl_file , 1 ); unlink( target_file ); ecl_kw_type * kw1b = ecl_file_iget_kw( ecl_file , 1 ); - + test_assert_not_NULL( kw0 ); test_assert_not_NULL( kw1 ); test_assert_ptr_equal( kw1 , kw1b ); - + ecl_kw_type * kw2 = ecl_file_iget_kw( ecl_file , 2 ); test_assert_NULL( kw2 ); - + test_assert_false( ecl_file_writable( ecl_file )); ecl_file_close( ecl_file ); - + } @@ -126,22 +128,51 @@ void test_writable(const char * src_file ) { } + +void test_truncated() { + test_work_area_type * work_area = test_work_area_alloc("ecl_file_truncated" ); + { + ecl_grid_type * grid = ecl_grid_alloc_rectangular(20,20,20,1,1,1,NULL); + ecl_grid_fwrite_EGRID( grid , "TEST.EGRID", true); + ecl_grid_free( grid ); + } + { + ecl_file_type * ecl_file = ecl_file_open("TEST.EGRID" , 0 ); + test_assert_true( ecl_file_is_instance( ecl_file ) ); + ecl_file_close( ecl_file ); + } + + { + offset_type file_size = util_file_size( "TEST.EGRID"); + FILE * stream = util_fopen("TEST.EGRID" , "r+"); + util_ftruncate( stream , file_size / 2 ); + fclose( stream ); + } + { + ecl_file_type * ecl_file = ecl_file_open("TEST.EGRID" , 0 ); + test_assert_NULL( ecl_file ); + } + test_work_area_free( work_area ); +} + + int main( int argc , char ** argv) { const char * src_file = argv[1]; const char * target_file = argv[2]; - + { test_work_area_type * work_area = test_work_area_alloc("ecl_file"); - + test_work_area_install_file( work_area , src_file ); test_flags( src_file ); test_loadall(src_file , target_file ); - + test_close_stream1( src_file , target_file); test_close_stream2( src_file , target_file); test_writable( src_file ); test_work_area_free( work_area ); } + test_truncated(); exit(0); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_fortio.c b/ThirdParty/Ert/devel/libecl/tests/ecl_fortio.c index 6ac5d1ad01..c722d49abd 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_fortio.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_fortio.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_fortio.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_fortio.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -25,7 +25,7 @@ #include <ert/ecl/fortio.h> #include <ert/ecl/ecl_endian_flip.h> - + void test_existing_read(const char * filename) { fortio_type * fortio = fortio_open_reader( filename , false , ECL_ENDIAN_FLIP); test_assert_not_NULL( fortio ); @@ -49,7 +49,7 @@ void test_fortio_is_instance(const char * filename ) { void test_fortio_safe_cast(const char * filename ) { - void * i_am_a_fortio = fortio_open_reader( filename , false , ECL_ENDIAN_FLIP); + void * i_am_a_fortio = fortio_open_reader( filename , false , ECL_ENDIAN_FLIP); test_assert_not_NULL( i_am_a_fortio ); fortio_type * fortio = fortio_safe_cast(i_am_a_fortio); test_assert_true(fortio_is_instance(fortio)); @@ -82,12 +82,14 @@ void test_write( const char * filename , bool path_exists) { void test_wrapper( const char * filename ) { FILE * stream = util_fopen( filename , "r"); - fortio_type * fortio = fortio_alloc_FILE_wrapper( filename , false , false , stream ); + fortio_type * fortio = fortio_alloc_FILE_wrapper( filename , false , false , false , stream ); + test_assert_not_NULL( fortio ); test_assert_false( fortio_fclose_stream( fortio )); test_assert_false( fortio_fopen_stream( fortio )); test_assert_true( fortio_stream_is_open( fortio )); fortio_free_FILE_wrapper( fortio ); + fclose( stream ); } @@ -103,28 +105,205 @@ void test_open_close_read( const char * filename ) { test_assert_true( fortio_fopen_stream( fortio )); test_assert_true( fortio_stream_is_open( fortio )); test_assert_false( fortio_fopen_stream( fortio )); - + fortio_fclose( fortio ); } +void test_fread_truncated_data() { + test_work_area_type * work_area = test_work_area_alloc("fortio_truncated" ); + { + const size_t buffer_size = 1000; + void * buffer = util_malloc( buffer_size ); + { + fortio_type * fortio = fortio_open_writer( "PRESSURE" , false , true ); + + fortio_fwrite_record( fortio , buffer , buffer_size ); + fortio_fwrite_record( fortio , buffer , buffer_size ); + + fortio_fseek( fortio , 0 , SEEK_SET); + util_ftruncate( fortio_get_FILE(fortio) , 2 * buffer_size - 100 ); + fortio_fclose( fortio ); + } + + test_assert_long_equal( util_file_size( "PRESSURE") , 2*buffer_size - 100); + + { + fortio_type * fortio = fortio_open_reader( "PRESSURE" , false , true ); + test_assert_true( fortio_fread_buffer( fortio , buffer , buffer_size )); + test_assert_false( fortio_fread_buffer( fortio , buffer , buffer_size )); + fortio_fclose( fortio ); + } + free( buffer ); + } + test_work_area_free( work_area ); +} + +void test_fread_truncated_head() { + test_work_area_type * work_area = test_work_area_alloc("fortio_truncated" ); + { + { + FILE * stream = util_fopen("PRESSURE" , "w"); + fclose( stream ); + } + + { + fortio_type * fortio = fortio_open_reader( "PRESSURE" , false , true ); + void * buffer = NULL; + int buffer_size = 10; + test_assert_false( fortio_fread_buffer( fortio , buffer , buffer_size )); + test_assert_true( fortio_read_at_eof( fortio )); + fortio_fclose( fortio ); + } + } + test_work_area_free( work_area ); +} + + +void test_fread_truncated_tail() { + test_work_area_type * work_area = test_work_area_alloc("fortio_truncated2" ); + { + const size_t buffer_size = 1000; + void * buffer = util_malloc( buffer_size ); + { + fortio_type * fortio = fortio_open_writer( "PRESSURE" , false , true ); + + fortio_fwrite_record( fortio , buffer , buffer_size ); + fortio_fseek( fortio , 0 , SEEK_SET); + util_ftruncate( fortio_get_FILE(fortio) , buffer_size + 4); + fortio_fclose( fortio ); + } + + test_assert_long_equal( util_file_size( "PRESSURE") , buffer_size + 4); + + { + fortio_type * fortio = fortio_open_reader( "PRESSURE" , false , true ); + test_assert_false( fortio_fread_buffer( fortio , buffer , buffer_size )); + fortio_fclose( fortio ); + } + free( buffer ); + } + test_work_area_free( work_area ); +} + + +void test_fread_invalid_tail() { + test_work_area_type * work_area = test_work_area_alloc("fortio_invalid" ); + int record_size = 10; + void * buffer = util_malloc( record_size ); + { + FILE * stream = util_fopen("PRESSURE" , "w"); + + util_fwrite(&record_size , sizeof record_size , 1 , stream , __func__); + util_fwrite(buffer , 1 , record_size , stream , __func__); + util_fwrite(&record_size , sizeof record_size , 1 , stream , __func__); + + + util_fwrite(&record_size , sizeof record_size , 1 , stream , __func__); + util_fwrite(buffer , 1 , record_size , stream , __func__); + record_size += 1; + util_fwrite(&record_size , sizeof record_size , 1 , stream , __func__); + + fclose(stream); + } + { + fortio_type * fortio = fortio_open_reader( "PRESSURE" , false , false ); + record_size -= 1; + test_assert_true( fortio_fread_buffer( fortio , buffer , record_size )); + test_assert_false( fortio_fread_buffer( fortio , buffer , record_size )); + fortio_fclose( fortio ); + } + + free( buffer ); + test_work_area_free( work_area ); +} + + + +void test_at_eof() { + test_work_area_type * work_area = test_work_area_alloc("fortio_truncated2" ); + { + fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true); + void * buffer = util_malloc( 100 ); + + fortio_fwrite_record( fortio , buffer , 100); + free( buffer ); + + fortio_fclose( fortio ); + } + { + fortio_type * fortio = fortio_open_reader("PRESSURE" , false , true); + + test_assert_false( fortio_read_at_eof( fortio )); + fortio_fseek( fortio , 50 , SEEK_SET ); + test_assert_false( fortio_read_at_eof( fortio )); + fortio_fseek( fortio , 0 , SEEK_END ); + test_assert_true( fortio_read_at_eof( fortio )); + + fortio_fclose( fortio ); + } + + test_work_area_free( work_area ); +} + + +void test_fseek() { + test_work_area_type * work_area = test_work_area_alloc("fortio_fseek" ); + { + fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true); + void * buffer = util_malloc( 100 ); + + fortio_fwrite_record( fortio , buffer , 100); + free( buffer ); + + fortio_fclose( fortio ); + } + { + fortio_type * fortio = fortio_open_reader("PRESSURE" , false , true); + + + printf("Starting fssek test \n"); + test_assert_true( fortio_fseek( fortio , 0 , SEEK_SET )); + test_assert_true( fortio_fseek( fortio , 0 , SEEK_END )); + test_assert_false( fortio_fseek( fortio , 100000 , SEEK_END)); + test_assert_false( fortio_fseek( fortio , 100000 , SEEK_SET)); + + fortio_fclose( fortio ); + } + + test_work_area_free( work_area ); +} + + + + int main( int argc , char ** argv) { - const char * file = argv[1]; - - test_fortio_is_instance( file ); - test_fortio_safe_cast( file ); - test_assert_util_abort("fortio_safe_cast", test_fortio_unsafe_cast, NULL); - test_existing_read( file ); - test_not_existing_read( ); - test_open_close_read( file ); - test_wrapper( file ); - test_write( "/tmp/path/does/not/exist" , false ); + util_install_signals(); { - test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" ); - util_make_path("path"); - test_write( "path/file.x" , true ); - test_work_area_free( work_area ); + const char * file = argv[1]; + + test_fortio_is_instance( file ); + test_fortio_safe_cast( file ); + test_assert_util_abort("fortio_safe_cast", test_fortio_unsafe_cast, NULL); + test_existing_read( file ); + test_not_existing_read( ); + test_open_close_read( file ); + test_wrapper( file ); + test_fread_truncated_head(); + test_fread_truncated_data(); + test_fread_truncated_tail(); + test_fread_invalid_tail(); + test_fseek(); + test_at_eof(); + + test_write( "/tmp/path/does/not/exist" , false ); + { + test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" ); + util_make_path("path"); + test_write( "path/file.x" , true ); + test_work_area_free( work_area ); + } + + exit(0); } - - exit(0); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_grid_DEPTHZ.c b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_DEPTHZ.c index fddbb8acdb..77c4981f81 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_grid_DEPTHZ.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_DEPTHZ.c @@ -136,7 +136,7 @@ void test_compare() { for (int i = 0; i < nx*ny; i++) { int g2 = k*nx*ny + i; int g1 = (k- 1)*nx*ny + i; - TOPS[g2] = TOPS[g1]; + TOPS[g2] = TOPS[g1] + DZ[g2]; } } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_grid_fwrite.c b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_fwrite.c index 4425f2b180..8b458255c4 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_grid_fwrite.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_fwrite.c @@ -28,7 +28,7 @@ void test_fwrite_EGRID(ecl_grid_type * grid ) { test_work_area_type * work_area = test_work_area_alloc("grid-has-mapaxes"); - ecl_grid_fwrite_EGRID( grid , "TEST.EGRID"); + ecl_grid_fwrite_EGRID( grid , "TEST.EGRID", true); { ecl_grid_type * copy = ecl_grid_alloc( "TEST.EGRID" ); test_assert_true( ecl_grid_compare( grid , copy , false , false , true )); diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_grid_layer_contains.c b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_layer_contains.c new file mode 100644 index 0000000000..64a5e5db87 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_layer_contains.c @@ -0,0 +1,53 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ecl_grid_layer_contains' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#include <stdlib.h> +#include <stdbool.h> + +#include <ert/util/test_util.h> + +#include <ert/ecl/ecl_grid.h> + + +void test_layer(const ecl_grid_type * grid ) { + int g; + + for (g=0; g < ecl_grid_get_global_size( grid ); g += 25) { + double x,y,z; + int i,j,k; + + ecl_grid_get_xyz1( grid , g , &x , &y , &z ); + ecl_grid_get_ijk1( grid , g , &i , &j , &k); + { + int find_i , find_j; + test_assert_true( ecl_grid_get_ij_from_xy( grid , x , y , k , &find_i , &find_j )); + test_assert_int_equal( i , find_i ); + test_assert_int_equal( j , find_j ); + } + + } +} + + + +int main(int argc , char ** argv) { + ecl_grid_type * grid = ecl_grid_alloc( argv[1] ); + test_layer( grid ); + ecl_grid_free( grid ); +} + diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_kw_cmp_string.c b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_cmp_string.c index 11648d209f..934a931654 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_kw_cmp_string.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_cmp_string.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_kw_cmp_string.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_kw_cmp_string.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -26,9 +26,9 @@ void test_cmp_string() { ecl_kw_type * ecl_kw = ecl_kw_alloc( "HEADER" , 1 , ECL_CHAR_TYPE ); - + ecl_kw_iset_string8( ecl_kw , 0 , "ABCD"); - + test_assert_int_equal( 0 , strcmp( ecl_kw_iget_char_ptr( ecl_kw , 0 ) , "ABCD ")); test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD")); test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD ")); @@ -37,12 +37,12 @@ void test_cmp_string() { test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , "Different")); test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , "")); test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , "")); - + } int main(int argc , char ** argv) { test_cmp_string(); - + exit(0); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_kw_fread.c b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_fread.c new file mode 100644 index 0000000000..69871c8562 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_fread.c @@ -0,0 +1,83 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'ecl_kw_init.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <stdbool.h> + +#include <ert/util/test_util.h> +#include <ert/util/util.h> +#include <ert/util/test_work_area.h> + +#include <ert/ecl/ecl_kw.h> +#include <ert/ecl/fortio.h> + + +void test_truncated(const char * filename , offset_type truncate_size) { + { + FILE * stream = util_fopen(filename , "r+"); + util_ftruncate( stream , truncate_size); + fclose( stream ); + } + { + fortio_type * fortio = fortio_open_reader( filename , false , true ); + ecl_kw_type * kw2 = ecl_kw_fread_alloc( fortio ); + test_assert_NULL( kw2 ); + fortio_fclose(fortio); + } +} + + +void test_fread_alloc() { + test_work_area_type * work_area = test_work_area_alloc("ecl_kw_fread" ); + { + ecl_kw_type * kw1 = ecl_kw_alloc( "INT" , 100 , ECL_INT_TYPE ); + int i; + for (i=0; i < 100; i++) + ecl_kw_iset_int( kw1 , i , i ); + { + fortio_type * fortio = fortio_open_writer("INT" , false , true ); + ecl_kw_fwrite( kw1 , fortio ); + fortio_fclose( fortio ); + } + { + fortio_type * fortio = fortio_open_reader("INT" , false , true ); + ecl_kw_type * kw2 = ecl_kw_fread_alloc( fortio ); + test_assert_true( ecl_kw_is_instance( kw2 )); + test_assert_true( ecl_kw_equal( kw1 , kw2 )); + ecl_kw_free( kw2 ); + fortio_fclose( fortio ); + } + + { + offset_type file_size = util_file_size("INT"); + test_truncated("INT" , file_size - 4 ); + test_truncated("INT" , file_size - 25 ); + test_truncated("INT" , 5 ); + test_truncated("INT" , 0 ); + } + ecl_kw_free( kw1 ); + } + test_work_area_free( work_area ); +} + + +int main(int argc , char ** argv) { + test_fread_alloc(); + exit(0); +} + + diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_kw_init.c b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_init.c index f65a0bf464..79da2ef774 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_kw_init.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_init.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_kw_init.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_kw_init.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -30,7 +30,7 @@ void test_int() { ecl_kw_type * kw = ecl_kw_alloc("KW" , N , ECL_INT_TYPE); for (i=0; i < N; i++) test_assert_int_equal( 0 , ecl_kw_iget_int( kw , i )); - + ecl_kw_free( kw ); } @@ -41,7 +41,7 @@ void test_double() { ecl_kw_type * kw = ecl_kw_alloc("KW" , N , ECL_DOUBLE_TYPE); for (i=0; i < N; i++) test_assert_double_equal( 0 , ecl_kw_iget_double( kw , i )); - + ecl_kw_free( kw ); } @@ -52,7 +52,7 @@ void test_float() { ecl_kw_type * kw = ecl_kw_alloc("KW" , N , ECL_FLOAT_TYPE); for (i=0; i < N; i++) test_assert_int_equal( 0 , ecl_kw_iget_float( kw , i )); - + ecl_kw_free( kw ); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_layer.c b/ThirdParty/Ert/devel/libecl/tests/ecl_layer.c index 0a77e57fef..e6420cecc4 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_layer.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_layer.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'ecl_layer.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ecl_layer.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -143,7 +143,7 @@ void test_edge() { test_assert_int_equal( layer_iget_edge_value(layer , 3 , 2 , BOTTOM_EDGE) , 100); test_assert_int_equal( layer_iget_edge_value(layer , 3 , 2 , RIGHT_EDGE) , 100); test_assert_int_equal( layer_iget_edge_value(layer , 3 , 2 , TOP_EDGE) , -100); - + layer_iset_cell_value( layer , 1 , 2 , 100); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 2 , LEFT_EDGE) , 0); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 2 , BOTTOM_EDGE) , 100); @@ -154,7 +154,7 @@ void test_edge() { test_assert_int_equal( layer_iget_edge_value(layer , 1 , 2 , BOTTOM_EDGE) , 100); test_assert_int_equal( layer_iget_edge_value(layer , 1 , 2 , RIGHT_EDGE) , 0); test_assert_int_equal( layer_iget_edge_value(layer , 1 , 2 , TOP_EDGE) , -100); - + layer_iset_cell_value( layer , 2 , 3 , 100); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 2 , LEFT_EDGE) , 0); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 2 , BOTTOM_EDGE) , 100); @@ -177,7 +177,7 @@ void test_edge() { test_assert_int_equal( layer_iget_edge_value(layer , 2 , 1 , BOTTOM_EDGE) , 100); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 1 , RIGHT_EDGE) , 100); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 1 , TOP_EDGE) , 0); - + layer_iset_cell_value(layer , 2,2,100); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 2 , LEFT_EDGE) , 0); test_assert_int_equal( layer_iget_edge_value(layer , 2 , 2 , BOTTOM_EDGE) , 0); @@ -211,37 +211,37 @@ void test_walk() { test_assert_int_equal( int_vector_size( cell_list ) , 1 ); { int_point2d_type point; - - struct_vector_iget( corner_list , 0 , &point); + + struct_vector_iget( corner_list , 0 , &point); test_assert_int_equal( 4 , point.i ); test_assert_int_equal( 4 , point.j ); - struct_vector_iget( corner_list , 1 , &point); + struct_vector_iget( corner_list , 1 , &point); test_assert_int_equal( 5 , point.i ); test_assert_int_equal( 4 , point.j ); - struct_vector_iget( corner_list , 2 , &point); + struct_vector_iget( corner_list , 2 , &point); test_assert_int_equal( 5 , point.i ); test_assert_int_equal( 5 , point.j ); - struct_vector_iget( corner_list , 3 , &point); + struct_vector_iget( corner_list , 3 , &point); test_assert_int_equal( 4 , point.i ); test_assert_int_equal( 5 , point.j ); } - + { int i,j; int_vector_type * true_cell_list = int_vector_alloc(0,0); for (j= 3; j < 7; j++) { for (i = 3; i < 7; i++) { - layer_iset_cell_value( layer , i , j , 100 ); + layer_iset_cell_value( layer , i , j , 100 ); if (i == 3 || j == 3) int_vector_append( true_cell_list , i + j*layer_get_nx( layer )); if (i == 6 || j == 6) int_vector_append( true_cell_list , i + j*layer_get_nx( layer )); - + } } int_vector_select_unique( true_cell_list ); @@ -256,7 +256,7 @@ void test_walk() { test_assert_true( int_vector_equal( cell_list , true_cell_list )); int_vector_free( true_cell_list ); } - + int_vector_free( cell_list ); struct_vector_free( corner_list ); layer_free( layer ); @@ -270,12 +270,12 @@ void test_content1() { for (j=4; j < 8; j++) for (i=4; i < 8; i++) layer_iset_cell_value( layer , i , j , 1 ); - + test_assert_int_equal( 16 , layer_get_cell_sum( layer )); { int_vector_type * i_list = int_vector_alloc(0,0); int_vector_type * j_list = int_vector_alloc(0,0); - + test_assert_false( layer_trace_block_content( layer , false , 4,4, 10 , i_list , j_list)); test_assert_true( layer_trace_block_content( layer , false , 4,4, 1 , i_list , j_list )); test_assert_int_equal( 16 , int_vector_size( i_list )); @@ -288,11 +288,11 @@ void test_content1() { test_assert_int_equal( int_vector_iget(i_list , i + j*4) , j + 4); test_assert_int_equal( int_vector_iget(j_list , i + j*4) , j + 4); } - - + + test_assert_true( layer_trace_block_content( layer , false , 4,4, 0 , i_list , j_list )); test_assert_int_equal( 16 , int_vector_size( i_list )); - + test_assert_true( layer_trace_block_content( layer ,true , 4,4, 0 , i_list , j_list )); test_assert_int_equal( 16 , int_vector_size( i_list )); test_assert_int_equal( 0 , layer_get_cell_sum( layer )); @@ -300,7 +300,7 @@ void test_content1() { int_vector_free( i_list ); int_vector_free( j_list ); } - + layer_free( layer ); } @@ -311,7 +311,7 @@ void test_content2() { int i,j; for (j=0; j < 5; j++) layer_iset_cell_value( layer , 2 , j , 1 ); - + for (i=0; i < 5; i++) layer_iset_cell_value( layer , i , 2 , 1 ); @@ -321,7 +321,7 @@ void test_content2() { int_vector_type * j_list = int_vector_alloc(0,0); int_vector_type * cell_list = int_vector_alloc(0,0); struct_vector_type * corner_list = struct_vector_alloc( sizeof(int_point2d_type) ); - + for (j=0; j < 5; j++) { for (i=0; i < 5; i++) { @@ -333,7 +333,7 @@ void test_content2() { } } - } + } struct_vector_free( corner_list ); int_vector_free( i_list ); @@ -342,7 +342,7 @@ void test_content2() { } test_assert_int_equal( 0 , layer_get_cell_sum( layer )); - + layer_free( layer ); } @@ -365,6 +365,33 @@ void test_replace() { +void test_interp_barrier() { + layer_type * layer = layer_alloc(10,10); + + layer_add_interp_barrier( layer , 0 , 22 ); + + layer_free( layer ); +} + + + +void test_copy( ) { + layer_type * layer1 = layer_alloc(10,10); + layer_type * layer2 = layer_alloc(10,10); + + layer_iset_cell_value( layer1 , 5,5,10 ); + layer_memcpy( layer2 , layer1 ); + + test_assert_int_equal( 10 , layer_iget_edge_value( layer2 , 5,5,BOTTOM_EDGE)); + test_assert_int_equal( 10 , layer_iget_edge_value( layer2 , 5,5,RIGHT_EDGE)); + test_assert_int_equal( -10 , layer_iget_edge_value( layer2 , 5,5,TOP_EDGE)); + test_assert_int_equal( -10 , layer_iget_edge_value( layer2 , 5,5,LEFT_EDGE)); + + layer_free( layer2 ); + layer_free( layer1 ); +} + + int main(int argc , char ** argv) { test_create(); test_get_invalid_cell(); @@ -375,4 +402,6 @@ int main(int argc , char ** argv) { test_content1(); test_content2(); test_replace(); + test_interp_barrier(); + test_copy(); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_nnc_export.c b/ThirdParty/Ert/devel/libecl/tests/ecl_nnc_export.c index c8c7c34d58..27fd3eda9b 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_nnc_export.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_nnc_export.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more detals. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more detals. */ #include <stdlib.h> #include <stdbool.h> @@ -27,6 +27,7 @@ #include <ert/ecl/ecl_nnc_export.h> #include <ert/ecl/ecl_kw_magic.h> + int count_kw_data( const ecl_file_type * file , ecl_grid_type * grid , const char * kw1 , const char * kw2) { int i,j; int count = 0; @@ -34,7 +35,7 @@ int count_kw_data( const ecl_file_type * file , ecl_grid_type * grid , const cha for (i=0; i < ecl_file_get_num_named_kw( file , kw1 ); i++) { ecl_kw_type * ecl_kw1 = ecl_file_iget_named_kw( file , kw1 , i ); ecl_kw_type * ecl_kw2 = NULL; - + if (kw2) ecl_kw2 = ecl_file_iget_named_kw(file , kw2 , i); @@ -44,21 +45,21 @@ int count_kw_data( const ecl_file_type * file , ecl_grid_type * grid , const cha ecl_grid_type * igrid; if (i == 0) igrid = grid; - else + else igrid = ecl_grid_iget_lgr( grid , i - 1); - global_size = ecl_grid_get_global_size( igrid ); + global_size = ecl_grid_get_global_size( igrid ); for (j=0; j < ecl_kw_get_size( ecl_kw1 ); j++) { int g1 = ecl_kw_iget_int( ecl_kw1 , j ); int g2 = ecl_kw_iget_int( ecl_kw2 , j ); - + if (g1 <= global_size && g2 <= global_size) count +=1; } } else count += ecl_kw_get_size( ecl_kw1 ); - + } } return count; @@ -70,13 +71,13 @@ void test_count(const char * name) { char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1); ecl_grid_type * grid = ecl_grid_alloc( grid_file_name ); ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 ); - + int num_nnc = 0; num_nnc = count_kw_data( grid_file , grid , "NNC1" , "NNC2"); num_nnc += count_kw_data( grid_file , grid , "NNCG" , NULL); num_nnc += count_kw_data( grid_file , grid , "NNA1" , NULL); - + test_assert_int_equal( num_nnc , ecl_nnc_export_get_size( grid )); free(grid_file_name); @@ -85,11 +86,24 @@ void test_count(const char * name) { } +void test_nnc_export_missing_TRANX(const char * name ) { + char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1); + char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false , -1); + if (util_entry_exists(init_file_name)) { + ecl_grid_type * grid = ecl_grid_alloc( grid_file_name ); + ecl_file_type * init_file = ecl_file_open( init_file_name , 0); + ecl_nnc_type * nnc_data1 = util_calloc( ecl_nnc_export_get_size( grid ) , sizeof * nnc_data1 ); + int count = ecl_nnc_export(grid, init_file, nnc_data1); + int i; + test_assert_int_equal( count , 0 ); + for (i=0; i < count; i++) + test_assert_double_equal( nnc_data1[i].trans , ERT_ECL_DEFAULT_NNC_TRANS ); + } +} - -void test_export(const char * name) { +void test_export(const char * name, bool have_tran_data) { char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1); - char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false , -1); + char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false , -1); if (util_entry_exists(init_file_name)) { ecl_grid_type * grid = ecl_grid_alloc( grid_file_name ); ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 ); @@ -112,7 +126,11 @@ void test_export(const char * name) { int lgr_nr1 = ecl_kw_iget_int( nnchead , NNCHEAD_LGR_INDEX); int lgr_nr2 = ecl_kw_iget_int( nnchead , NNCHEAD_LGR_INDEX); ecl_kw_type * nnc_tran = ecl_nnc_export_get_tranx_kw( grid , init_file , lgr_nr1 , lgr_nr2); - + if (!have_tran_data) { + test_assert_NULL(nnc_tran); + return; + } + test_assert_not_NULL( nnc_tran ); test_assert_int_equal( ecl_kw_get_size( nnc1_kw ) , ecl_kw_get_size( nnc_tran )); { @@ -121,12 +139,12 @@ void test_export(const char * name) { int i = 0; if (lgr_nr1 > 0) lgr = ecl_grid_get_lgr_from_lgr_nr( grid , lgr_nr1 ); - + while (i < ecl_kw_get_size( nnc1_kw) ) { int g1 = ecl_kw_iget_int( nnc1_kw , i) - 1; int g2 = ecl_kw_iget_int( nnc2_kw , i) - 1; - if (g1 < ecl_grid_get_global_size( lgr ) && + if (g1 < ecl_grid_get_global_size( lgr ) && g2 < ecl_grid_get_global_size( lgr )) { nnc_data1[ i + nnc_offset ].grid_nr1 = lgr_nr1; nnc_data1[ i + nnc_offset ].grid_nr2 = lgr_nr2; @@ -140,8 +158,8 @@ void test_export(const char * name) { nnc_offset += num_nnc; } } - - + + if (ecl_file_has_kw( grid_file, NNCL_KW)) { ecl_kw_type * nncl_kw = ecl_file_iget_named_kw( grid_file , NNCL_KW , 0 ); ecl_kw_type * nncg_kw = ecl_file_iget_named_kw( grid_file , NNCG_KW , 0 ); @@ -150,7 +168,7 @@ void test_export(const char * name) { int lgr_nr2 = ecl_kw_iget_int( nnchead , NNCHEAD_LGR_INDEX); ecl_kw_type * nnc_tran = ecl_nnc_export_get_tranx_kw( grid , init_file , 0 , lgr_nr2); int i; - + test_assert_int_equal( ecl_kw_get_size( nncl_kw ) , ecl_kw_get_size( nnc_tran )); for (i=0; i < ecl_kw_get_size( nncl_kw); i++) { nnc_data1[ i + nnc_offset ].grid_nr1 = lgr_nr1; @@ -173,7 +191,7 @@ void test_export(const char * name) { int lgr_nr2 = ecl_kw_iget_int( nnchead , NNCHEADA_ILOC2_INDEX ); ecl_kw_type * nnc_tran; int i; - + nnc_tran = ecl_nnc_export_get_tranx_kw( grid , init_file , lgr_nr1 , lgr_nr2); test_assert_not_NULL(nnc_tran); test_assert_int_equal( ecl_kw_get_size( nnc1_kw ) , ecl_kw_get_size( nnc_tran ) ); @@ -192,42 +210,27 @@ void test_export(const char * name) { ecl_nnc_sort( nnc_data1 , nnc_offset ); } - ecl_nnc_export( grid , init_file , nnc_data2 ); - - if (0) { + { + int export_size = ecl_nnc_export( grid , init_file , nnc_data2 ); + test_assert_int_equal( export_size , ecl_nnc_export_get_size( grid )); + } + + { int i; int size = ecl_nnc_export_get_size( grid ); - for (i=0; i < size; i++) { - if ((i % 1000) == 0) - printf("%d / %d \n",i , size); - - if (ecl_nnc_cmp( &nnc_data1[i] , &nnc_data2[i]) != 0) { - printf("Comparing: %d 1:(%d,%d) 2:(%d,%d) 1:(%d,%d) 2:(%d,%d) %g , %g\n", - i , - nnc_data1[i].grid_nr1 , - nnc_data1[i].grid_nr2 , - nnc_data2[i].grid_nr1 , - nnc_data2[i].grid_nr2, - nnc_data1[i].global_index1 , - nnc_data1[i].global_index2 , - nnc_data2[i].global_index1 , - nnc_data2[i].global_index2, - nnc_data1[i].trans , - nnc_data2[i].trans); - } + for (i=0; i < size; i++) test_assert_int_equal( 0 , ecl_nnc_cmp( &nnc_data1[i] , &nnc_data2[i])); - } } test_assert_int_equal( 0 , memcmp( nnc_data1 , nnc_data2 , ecl_nnc_export_get_size( grid ) * sizeof * nnc_data2 )); - + free( nnc_data2 ); free( nnc_data1 ); ecl_grid_free( grid ); ecl_file_close( grid_file ); ecl_file_close( init_file ); - } else + } else fprintf(stderr," Could not find init file:%s - export test skipped \n",init_file_name); - + free(grid_file_name); free(init_file_name); } @@ -249,25 +252,25 @@ void test_cmp() { .grid_nr2 = 1, .global_index1 = 1, .global_index2 = 1 }; - + ecl_nnc_type nnc4 = {.grid_nr1 = 4, // nnc4 > nnc1 .grid_nr2 = 2, // nnc4 > nnc2 .global_index1 = 1, .global_index2 = 1 }; - + ecl_nnc_type nnc5 = {.grid_nr1 = 4, // nnc5 > nnc4 - .grid_nr2 = 2, + .grid_nr2 = 2, .global_index1 = 3, .global_index2 = 1 }; ecl_nnc_type nnc6 = {.grid_nr1 = 4, // nnc6 > nnc5 - .grid_nr2 = 2, + .grid_nr2 = 2, .global_index1 = 3, .global_index2 = 5 }; - + test_assert_int_equal( 0 , ecl_nnc_cmp( &nnc1 , &nnc2 )); test_assert_int_equal( 1 , ecl_nnc_cmp( &nnc3 , &nnc1 )); test_assert_int_equal( 1 , ecl_nnc_cmp( &nnc4 , &nnc1 )); @@ -283,7 +286,7 @@ void test_sort() { int i; for (i=0; i < N; i++) { ecl_nnc_type nnc = {.grid_nr1 = (i % 19), - .grid_nr2 = (i % 3), + .grid_nr2 = (i % 3), .global_index1 = (i % 7), .global_index2 = (i % 13)}; nnc_list[i] = nnc; @@ -291,9 +294,9 @@ void test_sort() { ecl_nnc_sort( nnc_list , N ); for (i=0; i < (N - 1); i++) test_assert_int_equal( -1 , ecl_nnc_cmp(&nnc_list[i] , &nnc_list[i+1])); - + free( nnc_list ); - + } @@ -301,18 +304,26 @@ void test_sort() { void install_SIGNALS(void) { signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ signal(SIGINT , util_abort_signal); /* Control C */ - signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. + signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ } int main(int argc, char ** argv) { - + const char * base = argv[1]; + bool have_tran_data; install_SIGNALS(); - test_cmp( ); - test_sort(); - test_count( base ); - test_export( base ); - exit(0); + + if (util_sscanf_bool( argv[2] , &have_tran_data)) { + test_cmp( ); + test_sort(); + test_count( base ); + test_export( base, have_tran_data ); + if (!have_tran_data) + test_nnc_export_missing_TRANX(base); + + exit(0); + } else + test_error_exit("Failed to parse input:%s as bool" , argv[2]); } diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_rft.c b/ThirdParty/Ert/devel/libecl/tests/ecl_rft.c index 5a71d86bc5..4ae87f99cd 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_rft.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_rft.c @@ -23,9 +23,29 @@ #include <ert/util/util.h> #include <ert/ecl/ecl_rft_file.h> - - - +#include <ert/util/vector.h> +#include <ert/util/int_vector.h> +#include <ert/util/test_work_area.h> +#include <ert/ecl/ecl_rft_node.h> + + +void test_rft_read_write(const char * rft_file){ + ecl_rft_file_type * rft = ecl_rft_file_alloc( rft_file ); + ecl_rft_node_type ** nodes =(ecl_rft_node_type **) malloc(sizeof(ecl_rft_node_type *) * 3); + int size = ecl_rft_file_get_size(rft); + for(int i =0;i<size;i++){ + ecl_rft_node_type * rft_node = ecl_rft_file_iget_node(rft, i); + nodes[i] =rft_node; + } + ecl_rft_node_type * old_node = ecl_rft_file_iget_node(rft, 0); + ecl_rft_node_type * new_node = ecl_rft_node_alloc_new("DUMMY", "R", ecl_rft_node_get_date(old_node), ecl_rft_node_get_days(old_node)); + nodes[2]=new_node; + test_work_area_type * work_area = test_work_area_alloc("RFT_RW"); + + ecl_rft_file_update("eclipse.rft", nodes,3, ERT_ECL_METRIC_UNITS); + test_work_area_free(work_area); + free(nodes); +} // Hardcoded GURBAT values void test_rft( const char * rft_file ) { @@ -135,8 +155,11 @@ int main( int argc , char ** argv) { const char * rft_file = argv[1]; const char * mode_string = argv[2]; + if (strcmp( mode_string , "RFT") == 0) test_rft( rft_file ); + else if (strcmp( mode_string , "RFT_RW") == 0) + test_rft_read_write(rft_file); else if (strcmp( mode_string , "PLT") == 0) test_plt( rft_file ); else if (strcmp( mode_string , "MSW-PLT") == 0) diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c b/ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c index af33502b9b..f5ebc8b655 100644 --- a/ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -65,7 +65,7 @@ int main( int argc , char ** argv) { const char * case1 = argv[1]; ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":"); - + test_assert_true( ecl_sum_is_instance( ecl_sum1 )); test_time_range( ecl_sum1 ); test_days( ecl_sum1 ); diff --git a/ThirdParty/Ert/devel/libecl/tests/tests.cmake b/ThirdParty/Ert/devel/libecl/tests/tests.cmake index bd7c8e525c..d540312d5b 100644 --- a/ThirdParty/Ert/devel/libecl/tests/tests.cmake +++ b/ThirdParty/Ert/devel/libecl/tests/tests.cmake @@ -7,6 +7,12 @@ target_link_libraries( ecl_coarse_test ecl test_util ) add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 ) +add_executable( ecl_grid_layer_contains ecl_grid_layer_contains.c ) +target_link_libraries( ecl_grid_layer_contains ecl test_util ) +add_test( ecl_grid_layer_contains1 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_layer_contains ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ) +add_test( ecl_grid_layer_contains2 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_layer_contains ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Mariner/MARINER.EGRID ) + + add_executable( ecl_restart_test ecl_restart_test.c ) target_link_libraries( ecl_restart_test ecl test_util ) add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ) @@ -15,14 +21,19 @@ add_executable( ecl_kw_init ecl_kw_init.c ) target_link_libraries( ecl_kw_init ecl test_util ) add_test( ecl_kw_init ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_init ) +add_executable( ecl_kw_fread ecl_kw_fread.c ) +target_link_libraries( ecl_kw_fread ecl test_util ) +add_test( ecl_kw_fread ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_fread ) + add_executable( ecl_nnc_export ecl_nnc_export.c ) target_link_libraries( ecl_nnc_export ecl test_util ) -add_test (ecl_nnc_export1 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ) -add_test (ecl_nnc_export2 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC ) -add_test (ecl_nnc_export3 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3) -add_test (ecl_nnc_export4 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUAL_DIFF ) -add_test (ecl_nnc_export5 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO ) -add_test (ecl_nnc_export6 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/nestedLGRcase/TESTCASE_NESTEDLGR) +add_test (ecl_nnc_export1 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE TRUE) +add_test (ecl_nnc_export2 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC TRUE) +add_test (ecl_nnc_export3 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3 TRUE) +add_test (ecl_nnc_export4 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUAL_DIFF TRUE) +add_test (ecl_nnc_export5 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO TRUE) +add_test (ecl_nnc_export6 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/nestedLGRcase/TESTCASE_NESTEDLGR TRUE) +add_test (ecl_nnc_export7 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/TYRIHANS/BASE20150218_MULTFLT FALSE) add_executable( ecl_nnc_export_get_tran ecl_nnc_export_get_tran.c ) target_link_libraries( ecl_nnc_export_get_tran ecl test_util ) @@ -240,6 +251,7 @@ add_test( ecl_rsthead ${EXECUTABLE_OUTPUT_PATH}/ecl_rsthead ${PROJECT_SOURCE_DIR add_executable( ecl_rft ecl_rft.c ) target_link_libraries( ecl_rft ecl test_util ) add_test( ecl_rft_rft ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT RFT) +add_test( ecl_rft_rft_rw ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT RFT_RW) add_test( ecl_rft_plt ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/RFT/TEST1_1A.RFT PLT) add_test( ecl_rft_plt ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/RFT/RFT2.RFT MSW-PLT) @@ -333,6 +345,7 @@ set_property( TEST ecl_region2region PROPERTY LABELS StatoilData) set_property( TEST ecl_grid_case PROPERTY LABELS StatoilData) set_property( TEST ecl_rft_rft PROPERTY LABELS StatoilData) set_property( TEST ecl_rft_plt PROPERTY LABELS StatoilData) +set_property( TEST ecl_rft_rft_rw PROPERTY LABELS StatoilData) set_property( TEST ecl_sum_case_exists PROPERTY LABELS StatoilData) set_property( TEST ecl_grid_volume1 PROPERTY LABELS StatoilData) set_property( TEST ecl_grid_volume2 PROPERTY LABELS StatoilData) @@ -348,6 +361,7 @@ set_property( TEST ecl_nnc_export3 PROPERTY LABELS StatoilData ) set_property( TEST ecl_nnc_export4 PROPERTY LABELS StatoilData ) set_property( TEST ecl_nnc_export5 PROPERTY LABELS StatoilData ) set_property( TEST ecl_nnc_export6 PROPERTY LABELS StatoilData ) +set_property( TEST ecl_nnc_export7 PROPERTY LABELS StatoilData ) set_property( TEST ecl_nnc_export_get_tran PROPERTY LABELS StatoilData ) set_property( TEST ecl_grid_cell_contains2 PROPERTY LABELS StatoilData ) set_property( TEST ecl_grid_copy_statoil1 PROPERTY LABELS StatoilData ) @@ -355,3 +369,5 @@ set_property( TEST ecl_grid_copy_statoil2 PROPERTY LABELS StatoilData ) set_property( TEST ecl_grid_copy_statoil3 PROPERTY LABELS StatoilData ) set_property( TEST ecl_grid_copy_statoil4 PROPERTY LABELS StatoilData ) set_property( TEST ecl_layer_statoil PROPERTY LABELS StatoilData ) +set_property( TEST ecl_grid_layer_contains1 PROPERTY LABELS StatoilData ) +set_property( TEST ecl_grid_layer_contains2 PROPERTY LABELS StatoilData ) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt b/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt index de72420ba1..e5a5e0d173 100644 --- a/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt @@ -1,6 +1,8 @@ add_executable( segment_info segment_info.c ) add_executable( CF_dump well_CF_dump.c ) -set(program_list segment_info CF_dump) +add_executable( ri_well_test ri_well_test.c ) + +set(program_list segment_info CF_dump ri_well_test) foreach(prog ${program_list}) target_link_libraries( ${prog} ecl_well ecl) if (USE_RUNPATH) diff --git a/ThirdParty/Ert/devel/libecl_well/applications/ri_well_test.c b/ThirdParty/Ert/devel/libecl_well/applications/ri_well_test.c new file mode 100644 index 0000000000..66e4b8d830 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl_well/applications/ri_well_test.c @@ -0,0 +1,52 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'well_CF_dump.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#include <ert/ecl/ecl_grid.h> +#include <ert/ecl_well/well_state.h> +#include <ert/ecl_well/well_info.h> + +/* + This is a small test program which will load the well information in + the same way as Resinsight does it. +*/ + +void usage() { + printf("ri_well_test CASE.EGRID CASE.UNRST / { CASE.X1 CASE.X2 ... CASE.Xn } \n"); + exit(1); +} + + +int main( int argc , char ** argv ) { + if (argc < 3) + usage(); + else { + char * grid_file = argv[1]; + ecl_grid_type * grid = ecl_grid_alloc( grid_file ); + well_info_type * well_info = well_info_alloc( grid ); + int ifile; + for (ifile = 2; ifile < argc; ifile++) { + const char * rst_file = argv[ifile]; + printf("Loading restart file: %s \n",rst_file); + well_info_load_rstfile( well_info , rst_file , true ); + } + + ecl_grid_free( grid ); + well_info_free( well_info ); + } +} diff --git a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_const.h b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_const.h index 014ab2fcf1..d71db29076 100644 --- a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_const.h +++ b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_const.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'well_const.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'well_const.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -46,19 +46,20 @@ extern "C" { /* Observe that the values given as _ITEM are not indices which can be directly used in the IWEL or ICON keywords; an offset must be - added. + added. */ #define IWEL_HEADI_ITEM 0 #define IWEL_HEADJ_ITEM 1 #define IWEL_HEADK_ITEM 2 #define IWEL_CONNECTIONS_ITEM 4 -#define IWEL_TYPE_ITEM 6 +#define IWEL_GROUP_ITEM 5 +#define IWEL_TYPE_ITEM 6 #define IWEL_STATUS_ITEM 10 -#define IWEL_LGR_ITEM 42 +#define IWEL_LGR_ITEM 42 #define IWEL_SEGMENTED_WELL_NR_ITEM 70 -#define IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE -1 +#define IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE -1 #define ISEG_OUTLET_ITEM 1 #define ISEG_BRANCH_ITEM 3 @@ -66,8 +67,8 @@ extern "C" { #define ICON_IC_ITEM 0 #define ICON_I_ITEM 1 #define ICON_J_ITEM 2 -#define ICON_K_ITEM 3 -#define ICON_STATUS_ITEM 5 +#define ICON_K_ITEM 3 +#define ICON_STATUS_ITEM 5 #define ICON_DIRECTION_ITEM 13 #define ICON_SEGMENT_ITEM 14 @@ -75,7 +76,7 @@ extern "C" { #define ICON_DIRY 2 #define ICON_DIRZ 3 #define ICON_FRACX 4 -#define ICON_FRACY 5 +#define ICON_FRACY 5 #define ICON_DEFAULT_DIR_VALUE 0 #define ICON_DEFAULT_DIR_TARGET ICON_DIRZ @@ -100,16 +101,14 @@ extern "C" { #define IWEL_OIL_INJECTOR 2 #define IWEL_WATER_INJECTOR 3 #define IWEL_GAS_INJECTOR 4 - + typedef enum { - UNDOCUMENTED_ZERO = 0, - PRODUCER = 10, - WATER_INJECTOR = 22, - GAS_INJECTOR = 21, - OIL_INJECTOR = 78 + ERT_UNDOCUMENTED_ZERO = 0, + ERT_PRODUCER = 10, + ERT_WATER_INJECTOR = 22, + ERT_GAS_INJECTOR = 21, + ERT_OIL_INJECTOR = 78 } well_type_enum; - - #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_info.h b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_info.h index 1f45f1f10d..05f8b8b3e2 100644 --- a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_info.h +++ b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_info.h @@ -45,7 +45,7 @@ extern "C" { well_state_type * well_info_get_state_from_time( const well_info_type * well_info , const char * well_name , time_t sim_time); well_state_type * well_info_get_state_from_report( const well_info_type * well_info , const char * well_name , int report_step ); - well_state_type * well_info_iget_state_from_report( const well_info_type * well_info , const char * well_name , int time_index); + well_state_type * well_info_iget_state( const well_info_type * well_info , const char * well_name , int time_index); well_state_type * well_info_iiget_state( const well_info_type * well_info , int well_index , int time_index); #ifdef __cplusplus diff --git a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h index 1a68edd76b..5d421c38b1 100644 --- a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h +++ b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h @@ -49,7 +49,7 @@ extern "C" { int well_nr); bool well_state_add_MSW( well_state_type * well_state , - const ecl_file_type * rst_file , + ecl_file_type * rst_file , int well_nr, bool load_segment_information); diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_conn.c b/ThirdParty/Ert/devel/libecl_well/src/well_conn.c index b22c188aa8..99ce962cb1 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_conn.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_conn.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'well_conn.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'well_conn.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -35,7 +35,7 @@ /* Observe that when the (ijk) values are initialized they are shifted to zero offset values, to be aligned with the rest of the - ert libraries. + ert libraries. */ #define WELL_CONN_TYPE_ID 702052013 @@ -46,12 +46,12 @@ struct well_conn_struct { int j; int k; well_conn_dir_enum dir; - bool open; + bool open; int segment_id; // -1: Ordinary well bool matrix_connection; // k >= nz => fracture (and k -= nz ) double connection_factor; }; - + bool well_conn_equal( const well_conn_type *conn1 , const well_conn_type * conn2) { @@ -95,7 +95,7 @@ static well_conn_type * well_conn_alloc__( int i , int j , int k , double connec conn->open = open; conn->dir = dir; conn->connection_factor = connection_factor; - + conn->matrix_connection = matrix_connection; if (segment_id == CONN_NORMAL_WELL_SEGMENT_VALUE) conn->segment_id = WELL_CONN_NORMAL_WELL_SEGMENT_ID; @@ -137,14 +137,14 @@ well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , double co /* Observe that the (ijk) and branch values are shifted to zero offset to be - aligned with the rest of the ert libraries. + aligned with the rest of the ert libraries. */ -well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , - const ecl_kw_type * scon_kw , - const ecl_rsthead_type * header , - int well_nr , +well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , + const ecl_kw_type * scon_kw , + const ecl_rsthead_type * header , + int well_nr , int conn_nr ) { - + const int icon_offset = header->niconz * ( header->ncwmax * well_nr + conn_nr ); int IC = ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_ITEM ); if (IC > 0) { @@ -153,11 +153,10 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_ITEM ) - 1; int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1; double connection_factor = -1; - int segment_id = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET; bool matrix_connection = true; bool open; well_conn_dir_enum dir = well_conn_fracX; - + /* Set the status */ { int int_status = ecl_kw_iget_int( icon_kw , icon_offset + ICON_STATUS_ITEM ); @@ -166,8 +165,8 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , else open = false; } - - + + /* Set the K value and fracture flag. */ { if (header->dualp) { @@ -178,14 +177,14 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , } } } - - + + /* Set the direction flag */ { int int_direction = ecl_kw_iget_int( icon_kw , icon_offset + ICON_DIRECTION_ITEM ); if (int_direction == ICON_DEFAULT_DIR_VALUE) int_direction = ICON_DEFAULT_DIR_TARGET; - + switch (int_direction) { case(ICON_DIRX): dir = well_conn_dirX; @@ -206,21 +205,24 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , util_abort("%s: icon direction value:%d not recognized\n",__func__ , int_direction); } } - + if (scon_kw) { const int scon_offset = header->nsconz * ( header->ncwmax * well_nr + conn_nr ); connection_factor = ecl_kw_iget_as_double(scon_kw , scon_offset + SCON_CF_ITEM); } - - conn = well_conn_alloc__(i,j,k,connection_factor,dir,open,segment_id,matrix_connection); - + + { + int segment_id = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET; + conn = well_conn_alloc__(i,j,k,connection_factor,dir,open,segment_id,matrix_connection); + } + /** For multisegmented wells ONLY the global part of the restart file has segment information, i.e. the ?SEG keywords. Consequently iseg_kw will be NULL for the part of a MSW + LGR well. */ - + return conn; } else return NULL; /* IC < 0: Connection not in current LGR. */ @@ -241,7 +243,7 @@ void well_conn_free__( void * arg ) { well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr) { const int iwel_offset = header->niwelz * well_nr; int conn_i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM ) - 1; - + if (conn_i >= 0) { //well_conn_type * conn = util_malloc( sizeof * conn ); int conn_j = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADJ_ITEM ) - 1; @@ -257,7 +259,7 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e matrix_connection = false; } } - + if (matrix_connection) return well_conn_alloc( conn_i , conn_j , conn_k , connection_factor , open , well_conn_dirZ ); else diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_conn_collection.c b/ThirdParty/Ert/devel/libecl_well/src/well_conn_collection.c index b2fad00fcb..f9306af310 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_conn_collection.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_conn_collection.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'well_conn_collection.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'well_conn_collection.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -51,7 +51,7 @@ well_conn_collection_type * well_conn_collection_alloc() { /* The collection takes ownership of the connection object and frees it - when the collection is discarded. + when the collection is discarded. */ void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_type * conn) { @@ -59,7 +59,7 @@ void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_ty } /* - The collection only stores a refernce to the object, which will be destroyed by 'someone else'. + The collection only stores a refernce to the object, which will be destroyed by 'someone else'. */ void well_conn_collection_add_ref( well_conn_collection_type * wellcc , well_conn_type * conn) { @@ -100,23 +100,23 @@ well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wel } -int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , - const ecl_kw_type * iwel_kw , - const ecl_kw_type * icon_kw , - const ecl_kw_type * scon_kw , - int iwell , +int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , + const ecl_kw_type * iwel_kw , + const ecl_kw_type * icon_kw , + const ecl_kw_type * scon_kw , + int iwell , const ecl_rsthead_type * rst_head) { - + const int iwel_offset = rst_head->niwelz * iwell; int num_connections = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_ITEM ); int iconn; for (iconn = 0; iconn < num_connections; iconn++) { - well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , scon_kw , rst_head , iwell , iconn ); + well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , scon_kw , rst_head , iwell , iconn ); if (conn) well_conn_collection_add( wellcc , conn ); } return num_connections; - + } diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_info.c b/ThirdParty/Ert/devel/libecl_well/src/well_info.c index b499cb92a5..3bdaa07c42 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_info.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_info.c @@ -56,7 +56,7 @@ time. The well_state.c file contains further documentation of the concepts connections, branches and segments. - + WELL1 | | @@ -98,7 +98,7 @@ a) It is perforated both in LGR1 and LGR2 in addition to the global grid. - + b) It has two branches. In the well_state instance this will be represented as: @@ -108,8 +108,8 @@ ii) The well_path instances corresponding to the two LGRs will have one branch only, whereas the well_path - corrseponding to the global grid will have two branches. - + corrseponding to the global grid will have two branches. + In pseudo json: well_state = { @@ -120,12 +120,12 @@ {well_path : LGR1 {branch : 0 [(1,5),(1,4),(1,3),(1,2),(1,1),(2,1),(3,1)] } } - {well_path : LGR2 : + {well_path : LGR2 : {branch : 0 [(0,1),(1,1),(2,1)]} } } - - + + [*] Observe that wells in LGR is quite constrained in ECLIPSE; the current libwell implementation handles the illustrated case - but it might be too complex for ECLIPSE. diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_state.c b/ThirdParty/Ert/devel/libecl_well/src/well_state.c index efcbd267b0..ca1a811955 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_state.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_state.c @@ -54,7 +54,7 @@ Connections, segments and branches +-----+ | | <- Wellhead | | - +-----+ _________ Segment 2 + +-----+ _________ Segment 2 |\ / | \/ Segment 1 Segment 0 | \-----0---------------0--<----------------------O <-- Branch: 0 @@ -66,7 +66,7 @@ Connections, segments and branches \ Segment 5 \ \ - \ Segment 4 Segment 3 + \ Segment 4 Segment 3 \-<--O-------<-------O----------------<------------O <-- Branch: 1 | | | | +-----+ +-----+ +-----+ +-----+ @@ -98,7 +98,7 @@ marked as Segment0 ... Segment5. The segments themselves are quite abstract objects not directly linked to the grid, but indriectly through the connections. In the figure the segment <-> connection links are as follows: - + Segment0: C0, C1 Segment1: C2 Segment2: C3 @@ -107,7 +107,7 @@ links are as follows: Segment5: C7 Each segment has an outlet segment, which will link the segments -together into a geometry. +together into a geometry. The connection can in general be both to the main global grid, and to an LGR. Hence all questions about connections must be LGR aware. This @@ -126,7 +126,7 @@ coupledte implementation these objects are modelled as such: if (connections) { well_conn_type * conn = well_conn_collection_iget( connections , 0 ); printf("Have %d connections \n",well_conn_collection_get_size( connections ); - } + } The connections to the global grid are stored with the 'LGR' name given by the symbole ECL_GRID_GLOBAL_GRID, or alternatively the @@ -139,21 +139,21 @@ coupledte implementation these objects are modelled as such: the well_state object for information about segments and branches: if (well_state_is_MSW( well_state )) { - well_segment_collection_type * segments = well_state_get_segments( well_state ); + well_segment_collection_type * segments = well_state_get_segments( well_state ); well_branch_collection_type * branches = well_state_get_branches( well_state ); int branch_nr; - - for (branch_nr = 0; branch_nr < well_branch_collection_get_size( branches ); branch_nr++) { + + for (branch_nr = 0; branch_nr < well_branch_collection_get_size( branches ); branch_nr++) { well_segment_type * segment = well_branch_collection_iget_start_segment( branches , branhc_nr ); while (segment) { - // Inspect the current segment. + // Inspect the current segment. segment = well_segment_get_outlet( segment ); } } } - - + + */ @@ -203,7 +203,7 @@ well_state_type * well_state_alloc(const char * well_name , int global_well_nr , well_state->is_MSW_well = false; /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ - if ((type == UNDOCUMENTED_ZERO) && open) + if ((type == ERT_UNDOCUMENTED_ZERO) && open) util_abort("%s: Invalid type value for open wells.\n",__func__ ); return well_state; } @@ -271,24 +271,24 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons well_type_enum well_state_translate_ecl_type_int(int int_type) { - well_type_enum type = UNDOCUMENTED_ZERO; + well_type_enum type = ERT_UNDOCUMENTED_ZERO; switch (int_type) { /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ case(IWEL_UNDOCUMENTED_ZERO): - type = UNDOCUMENTED_ZERO; + type = ERT_UNDOCUMENTED_ZERO; break; case(IWEL_PRODUCER): - type = PRODUCER; + type = ERT_PRODUCER; break; case(IWEL_OIL_INJECTOR): - type = OIL_INJECTOR; + type = ERT_OIL_INJECTOR; break; case(IWEL_GAS_INJECTOR): - type = GAS_INJECTOR; + type = ERT_GAS_INJECTOR; break; case(IWEL_WATER_INJECTOR): - type = WATER_INJECTOR; + type = ERT_WATER_INJECTOR; break; default: util_abort("%s: Invalid type value %d\n",__func__ , int_type); @@ -313,7 +313,7 @@ static void well_state_add_connections__( well_state_type * well_state , const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0); const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0); - + well_state_add_wellhead( well_state , header , iwel_kw , well_nr , grid_name , grid_nr ); if (!well_state_has_grid_connections( well_state , grid_name )) @@ -324,7 +324,7 @@ static void well_state_add_connections__( well_state_type * well_state , well_conn_collection_type * wellcc = hash_get( well_state->connections , grid_name ); if (ecl_file_has_kw( rst_file , SCON_KW)) scon_kw = ecl_file_iget_named_kw( rst_file , SCON_KW , 0); - + well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw , well_nr , header ); } ecl_rsthead_free( header ); @@ -371,7 +371,7 @@ void well_state_add_connections( well_state_type * well_state , bool well_state_add_MSW( well_state_type * well_state , - const ecl_file_type * rst_file , + ecl_file_type * rst_file , int well_nr, bool load_segment_information) { @@ -380,23 +380,23 @@ bool well_state_add_MSW( well_state_type * well_state , const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0); const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0); well_rseg_loader_type * rseg_loader = NULL; - + int segment_count; if (ecl_file_has_kw( rst_file , RSEG_KW )) { if (load_segment_information) rseg_loader = well_rseg_loader_alloc(rst_file); - + segment_count = well_segment_collection_load_from_kw( well_state->segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head, - load_segment_information , + load_segment_information , &well_state->is_MSW_well); - - + + if (segment_count > 0) { hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections ); while (!hash_iter_is_complete( grid_iter )) { @@ -410,15 +410,15 @@ bool well_state_add_MSW( well_state_type * well_state , well_segment_collection_add_branches( well_state->segments , well_state->branches ); } ecl_rsthead_free( rst_head ); - + if (rseg_loader != NULL) { well_rseg_loader_free(rseg_loader); } - + return true; } - } else - return false; + } + return false; } @@ -445,7 +445,7 @@ well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const e { char * name; bool open; - well_type_enum type = UNDOCUMENTED_ZERO; + well_type_enum type = ERT_UNDOCUMENTED_ZERO; { int int_state = ecl_kw_iget_int( global_iwel_kw , iwel_offset + IWEL_STATUS_ITEM ); if (int_state > 0) @@ -470,7 +470,7 @@ well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const e well_state_add_connections( well_state , grid , ecl_file , global_well_nr); if (ecl_file_has_kw( ecl_file , ISEG_KW)) well_state_add_MSW( well_state , ecl_file , global_well_nr , load_segment_information); - + } ecl_rsthead_free( global_header ); diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_ts.c b/ThirdParty/Ert/devel/libecl_well/src/well_ts.c index dbf15442d5..89cdeb2b10 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_ts.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_ts.c @@ -1,25 +1,25 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** The wells can typically change configuration during a simulation, new completions can be added, the well can be shut for a period, it - can change purpose from injector to producer and so on. + can change purpose from injector to producer and so on. The well_ts datastructure is used to hold the complete history of one well; for each new report step a new well_state object is added @@ -32,7 +32,7 @@ well_state0 well_state1 well_state2 well_state3 [-------------x---------------x-------------x--------------] 0030 0060 0070 0090 - + The well in this example is added at report step 30; after that we have well_state information from each of the reported report steps 60,70 and 90. If we query the well_ts object for well state @@ -43,10 +43,10 @@ o If we ask for the well state at step 30 we will get the well_state0 object; if we ask for the well state at step 75 we will get the well_state2 object. - + o If we ask for the well_state before the well has appeared the first time we will get NULL. - + o The restart files have no meta information of when the simulation ended, so there is no way to detect it if you ask for the well state way beyond the end of the simulation. If you @@ -77,7 +77,7 @@ typedef struct { UTIL_TYPE_ID_DECLARATION; int report_nr; - time_t sim_time; + time_t sim_time; well_state_type * well_state; // The well_node instance owns the well_state instance. } well_node_type; @@ -85,7 +85,7 @@ typedef struct { struct well_ts_struct { UTIL_TYPE_ID_DECLARATION; char * well_name; - vector_type * ts; + vector_type * ts; }; /******************************************************************/ @@ -124,7 +124,7 @@ static int well_node_time_cmp( const void * arg1 , const void * arg2) { return 0; else return 1; - + } @@ -154,48 +154,48 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , return 0; else { - const well_node_type * first_node = vector_iget_const( well_ts->ts , 0 ); - const well_node_type * last_node = vector_get_last_const( well_ts->ts ); - + const well_node_type * first_node = vector_iget_const( well_ts->ts , 0 ); + const well_node_type * last_node = vector_get_last_const( well_ts->ts ); + if (use_report) { if (report_step < first_node->report_nr) return -1; // Before the start - + if (report_step >= last_node->report_nr) return size - 1; // After end } else { if (sim_time < first_node->sim_time) return -1; // Before the start - + if (sim_time >= last_node->sim_time) return size - 1; // After end } - - // Binary search + + // Binary search { int lower_index = 0; int upper_index = size - 1; - + while (true) { int center_index = (lower_index + upper_index) / 2; - const well_node_type * center_node = vector_iget_const( well_ts->ts , center_index ); + const well_node_type * center_node = vector_iget_const( well_ts->ts , center_index ); double cmp; if (use_report) cmp = center_node->report_nr - report_step; else cmp = difftime( center_node->sim_time , sim_time ); - + if (cmp > 0) { if ((center_index - lower_index) == 1) // We found an interval of length 1 return lower_index; - else + else upper_index = center_index; - + } else { - + if ((upper_index - center_index) == 1) // We found an interval of length 1 return center_index; - else + else lower_index = center_index; } } @@ -204,7 +204,7 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , } /* - + Index: 0 1 2 |----------------|-----------------| Value: 0 50 76 @@ -223,14 +223,14 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t if (index < (vector_get_size( well_ts->ts ) - 1)) next_node = vector_iget( well_ts->ts , index + 1); - + if (use_report) { if (index < 0) { if (report_step >= node->report_nr) OK = false; } else { if (report_step < node->report_nr) - OK = false; + OK = false; else { if (next_node != NULL) if (next_node->report_nr <= report_step) @@ -243,14 +243,14 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t OK = false; } else { if (sim_time < node->sim_time) - OK = false; + OK = false; else { if (next_node != NULL) if (next_node->sim_time <= sim_time) OK = false; } } - + if (!OK) util_abort("%s: holy rider - internal error \n",__func__); } @@ -266,7 +266,7 @@ void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state ) { if (vector_get_size( well_ts->ts ) > 1) { const well_node_type * last_node = vector_get_last_const(well_ts->ts ); - if (new_node->sim_time < last_node->sim_time) + if (new_node->sim_time < last_node->sim_time) // The new node is chronologically before the previous node; // i.e. we must sort the nodes in time. This should probably happen // quite seldom: @@ -315,7 +315,7 @@ well_state_type * well_ts_get_state_from_report( const well_ts_type * well_ts , int index = well_ts_get_index( well_ts , report_step , -1 , true ); if (index < 0) return NULL; - else + else return well_ts_iget_state( well_ts , index ); } diff --git a/ThirdParty/Ert/devel/libecl_well/tests/well_state.c b/ThirdParty/Ert/devel/libecl_well/tests/well_state.c index 9131c3ebe7..e8a4e94e63 100644 --- a/ThirdParty/Ert/devel/libecl_well/tests/well_state.c +++ b/ThirdParty/Ert/devel/libecl_well/tests/well_state.c @@ -30,11 +30,11 @@ int main(int argc , char ** argv) { test_install_SIGNALS(); - test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_UNDOCUMENTED_ZERO) , UNDOCUMENTED_ZERO); - test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_PRODUCER) , PRODUCER); - test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_WATER_INJECTOR) , WATER_INJECTOR); - test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_GAS_INJECTOR) , GAS_INJECTOR); - test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_OIL_INJECTOR) , OIL_INJECTOR); + test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_UNDOCUMENTED_ZERO) , ERT_UNDOCUMENTED_ZERO); + test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_PRODUCER) , ERT_PRODUCER); + test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_WATER_INJECTOR) , ERT_WATER_INJECTOR); + test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_GAS_INJECTOR) , ERT_GAS_INJECTOR); + test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_OIL_INJECTOR) , ERT_OIL_INJECTOR); { const char * well_name = "WELL"; @@ -42,7 +42,7 @@ int main(int argc , char ** argv) { int global_well_nr = 67; time_t valid_from = -1; bool open = false; - well_type_enum type = GAS_INJECTOR; + well_type_enum type = ERT_GAS_INJECTOR; well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from); test_assert_true( well_state_is_instance( well_state) ); diff --git a/ThirdParty/Ert/devel/libecl_well/tests/well_state_load.c b/ThirdParty/Ert/devel/libecl_well/tests/well_state_load.c index e96d505f98..b27c39c187 100644 --- a/ThirdParty/Ert/devel/libecl_well/tests/well_state_load.c +++ b/ThirdParty/Ert/devel/libecl_well/tests/well_state_load.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'well_state_load.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'well_state_load.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -43,7 +43,7 @@ int main(int argc , char ** argv) { int report_nr = 100; time_t valid_from = -1; bool open = false; - well_type_enum type = GAS_INJECTOR; + well_type_enum type = ERT_GAS_INJECTOR; int global_well_nr = 0; bool load_segment_information = true; @@ -51,16 +51,16 @@ int main(int argc , char ** argv) { well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from); test_assert_true( well_state_is_instance( well_state) ); well_state_add_connections( well_state , grid , rst_file , 0 ); - + test_assert_true( well_state_has_grid_connections( well_state , ECL_GRID_GLOBAL_GRID )); test_assert_false( well_state_has_grid_connections( well_state , "???" )); test_assert_true( well_state_has_global_connections( well_state )); - + well_state_add_MSW( well_state , rst_file , global_well_nr , load_segment_information ); { const well_segment_collection_type * segments = well_state_get_segments( well_state ); const well_branch_collection_type * branches = well_state_get_branches( well_state ); - + if (well_state_is_MSW( well_state )) { test_assert_true( ecl_file_has_kw( rst_file , ISEG_KW )); test_assert_int_not_equal( well_segment_collection_get_size( segments ) , 0); diff --git a/ThirdParty/Ert/devel/libecl_well/tests/well_state_load_missing_RSEG.c b/ThirdParty/Ert/devel/libecl_well/tests/well_state_load_missing_RSEG.c index 21187458af..d5768314da 100644 --- a/ThirdParty/Ert/devel/libecl_well/tests/well_state_load_missing_RSEG.c +++ b/ThirdParty/Ert/devel/libecl_well/tests/well_state_load_missing_RSEG.c @@ -43,7 +43,7 @@ int main(int argc , char ** argv) { int report_nr = 100; time_t valid_from = -1; bool open = false; - well_type_enum type = GAS_INJECTOR; + well_type_enum type = ERT_GAS_INJECTOR; int global_well_nr = 0; bool load_segment_information = false; diff --git a/ThirdParty/Ert/devel/libecl_well/tests/well_ts.c b/ThirdParty/Ert/devel/libecl_well/tests/well_ts.c index 73c3404751..6de48ad200 100644 --- a/ThirdParty/Ert/devel/libecl_well/tests/well_ts.c +++ b/ThirdParty/Ert/devel/libecl_well/tests/well_ts.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -34,19 +34,19 @@ int main(int argc , char ** argv) { stringlist_type * file_list = stringlist_alloc_new( ); ecl_grid_type * grid = ecl_grid_alloc( grid_file ); ecl_util_select_filelist( NULL , case_path , ECL_RESTART_FILE , false , file_list); - + printf("Searching in:%s \n",case_path); test_assert_int_equal( 4 , stringlist_get_size( file_list )); stringlist_sort( file_list , (string_cmp_ftype *) util_strcmp_int ); - - + + { int i; for (i=0; i < stringlist_get_size( file_list); i++) { char * ext; char * target_ext = util_alloc_sprintf("X%04d" , i); util_alloc_file_components( stringlist_iget( file_list , i ) , NULL , NULL , &ext); - + test_assert_string_equal( ext , target_ext); free( ext ); free( target_ext ); @@ -61,12 +61,12 @@ int main(int argc , char ** argv) { } well_info_free( well_info ); } - + { well_info_type * well_info = well_info_alloc( grid ); int i; stringlist_reverse( file_list ); - for (i=0; i < stringlist_get_size( file_list ); i++) + for (i=0; i < stringlist_get_size( file_list ); i++) well_info_load_rstfile( well_info , stringlist_iget(file_list , i), true); well_info_free( well_info ); } diff --git a/ThirdParty/Ert/devel/libeclxx/CMakeLists.txt b/ThirdParty/Ert/devel/libeclxx/CMakeLists.txt new file mode 100644 index 0000000000..df9670eb2d --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory( src ) + +if (BUILD_TESTS) + add_subdirectory( tests ) +endif() diff --git a/ThirdParty/Ert/devel/libeclxx/include/ert/ecl/EclKW.hpp b/ThirdParty/Ert/devel/libeclxx/include/ert/ecl/EclKW.hpp new file mode 100644 index 0000000000..471e49a7fe --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/include/ert/ecl/EclKW.hpp @@ -0,0 +1,97 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM 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. + + OPM 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 for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef OPM_ERT_ECL_KW +#define OPM_ERT_ECL_KW + +#include <string> +#include <memory> +#include <vector> +#include <stdexcept> +#include <iostream> + + +#include <ert/ecl/ecl_kw.h> +#include <ert/ecl/ecl_util.h> +#include <ert/ecl/FortIO.hpp> + + + +namespace ERT { + template <typename T> + class EclKW + { + public: + EclKW(const std::string& kw, int size_); + EclKW() { ; } + + static EclKW load(FortIO& fortio); + + size_t size() const { + return static_cast<size_t>( ecl_kw_get_size( m_kw.get() )); + } + + T& operator[](size_t index) { + return *( static_cast<T *>( ecl_kw_iget_ptr( m_kw.get() , index) )); + } + + + void fwrite(FortIO& fortio) const { + ecl_kw_fwrite( m_kw.get() , fortio.getPointer() ); + } + + + void assignVector(const std::vector<T>& data) { + if (data.size() == size()) + ecl_kw_set_memcpy_data( m_kw.get() , data.data() ); + else + throw std::invalid_argument("Size error"); + } + + ecl_kw_type * getPointer() const { + return m_kw.get(); + } + + private: + EclKW(ecl_kw_type * c_ptr) { + reset(c_ptr); + } + + void reset(ecl_kw_type * c_ptr) { + m_kw.reset( c_ptr , ecl_kw_free); + } + + + static EclKW checkedLoad(FortIO& fortio, ecl_type_enum expectedType) { + ecl_kw_type * c_ptr = ecl_kw_fread_alloc( fortio.getPointer() ); + if (c_ptr) { + if (ecl_kw_get_type( c_ptr ) == expectedType) + return EclKW( c_ptr ); + else + throw std::invalid_argument("Type error"); + } else + throw std::invalid_argument("fread kw failed - EOF?"); + } + + + std::shared_ptr<ecl_kw_type> m_kw; + }; +} + +#endif diff --git a/ThirdParty/Ert/devel/libeclxx/include/ert/ecl/FortIO.hpp b/ThirdParty/Ert/devel/libeclxx/include/ert/ecl/FortIO.hpp new file mode 100644 index 0000000000..35329f7f64 --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/include/ert/ecl/FortIO.hpp @@ -0,0 +1,48 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM 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. + + OPM 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 for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef OPM_ERT_FORTIO_KW +#define OPM_ERT_FORTIO_KW + +#include <fstream> +#include <string> +#include <memory> + +#include <ert/ecl/fortio.h> +#include <ert/ecl/ecl_endian_flip.h> + + + + +namespace ERT { + class FortIO + { + public: + FortIO(const std::string& filename , std::ios_base::openmode mode , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP); + fortio_type * getPointer() const; + void close(); + void reset() const; + + private: + std::shared_ptr<fortio_type> m_fortio; + }; +} + + +#endif diff --git a/ThirdParty/Ert/devel/libeclxx/src/CMakeLists.txt b/ThirdParty/Ert/devel/libeclxx/src/CMakeLists.txt new file mode 100644 index 0000000000..1c3549a3b5 --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/src/CMakeLists.txt @@ -0,0 +1,23 @@ +set( source_files + EclKW.cpp + FortIO.cpp ) + +set( header_files + EclKW.hpp + FortIO.hpp ) + + +add_library( eclxx ${LIBRARY_TYPE} ${source_files} ) +set_target_properties( eclxx PROPERTIES VERSION 1.0 SOVERSION 1.0 ) +if (USE_RUNPATH) + add_runpath( eclxx ) +endif() +target_link_libraries( eclxx ecl ) + + +if (INSTALL_ERT) + install(TARGETS eclxx DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/ecl/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libeclxx/src/EclKW.cpp b/ThirdParty/Ert/devel/libeclxx/src/EclKW.cpp new file mode 100644 index 0000000000..acb8ebb532 --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/src/EclKW.cpp @@ -0,0 +1,39 @@ +#include <ert/ecl/EclKW.hpp> + + +namespace ERT { + template <> + EclKW<int>::EclKW(const std::string& kw, int size_) { + ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_INT_TYPE ); + reset( c_ptr ); + } + + template <> + EclKW<float>::EclKW(const std::string& kw, int size_) { + ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_FLOAT_TYPE ); + reset( c_ptr ); + } + + template <> + EclKW<double>::EclKW(const std::string& kw, int size_) { + ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_DOUBLE_TYPE ); + reset( c_ptr ); + } + + + + template <> + EclKW<double> EclKW<double>::load(FortIO& fortio) { + return checkedLoad(fortio , ECL_DOUBLE_TYPE); + } + + template <> + EclKW<int> EclKW<int>::load(FortIO& fortio) { + return checkedLoad(fortio , ECL_INT_TYPE); + } + + template <> + EclKW<float> EclKW<float>::load(FortIO& fortio) { + return checkedLoad(fortio , ECL_FLOAT_TYPE); + } +} diff --git a/ThirdParty/Ert/devel/libeclxx/src/FortIO.cpp b/ThirdParty/Ert/devel/libeclxx/src/FortIO.cpp new file mode 100644 index 0000000000..2af298854b --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/src/FortIO.cpp @@ -0,0 +1,57 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM 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. + + OPM 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 for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <stdexcept> + +#include <ert/ecl/fortio.h> +#include <ert/util/util.h> + +#include <ert/ecl/FortIO.hpp> + +namespace ERT { + + FortIO::FortIO(const std::string& filename , std::ios_base::openmode mode , bool fmt_file , bool endian_flip_header) { + if (mode == std::ios_base::in) { + if (util_file_exists( filename.c_str() )) { + fortio_type * c_ptr = fortio_open_reader( filename.c_str() , fmt_file , endian_flip_header); + m_fortio.reset( c_ptr , fortio_fclose ); + } else + throw std::invalid_argument("File " + filename + " does not exist"); + } else { + fortio_type * c_ptr = fortio_open_writer( filename.c_str() , fmt_file , endian_flip_header); + m_fortio.reset( c_ptr , fortio_fclose ); + } + } + + + void FortIO::close() { + if (m_fortio) + m_fortio.reset( ); + } + + + + + fortio_type * FortIO::getPointer() const { + return m_fortio.get(); + } + +} + + diff --git a/ThirdParty/Ert/devel/libeclxx/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libeclxx/tests/CMakeLists.txt new file mode 100644 index 0000000000..a5b6e85030 --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/tests/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(eclxx_kw eclxx_kw.cpp) +target_link_libraries(eclxx_kw eclxx test_util util) +add_test(eclxx_kw ${EXECUTABLE_OUTPUT_PATH}/eclxx_kw) + +add_executable(eclxx_fortio eclxx_fortio.cpp) +target_link_libraries(eclxx_fortio eclxx test_util util) +add_test(eclxx_fortio ${EXECUTABLE_OUTPUT_PATH}/eclxx_fortio) diff --git a/ThirdParty/Ert/devel/libeclxx/tests/eclxx_fortio.cpp b/ThirdParty/Ert/devel/libeclxx/tests/eclxx_fortio.cpp new file mode 100644 index 0000000000..de803316f0 --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/tests/eclxx_fortio.cpp @@ -0,0 +1,96 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM 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. + + OPM 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 for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <stdexcept> +#include <fstream> + + +#include <ert/util/test_work_area.h> + +#include <ert/util/test_util.hpp> +#include <ert/ecl/EclKW.hpp> +#include <ert/ecl/FortIO.hpp> + + + +void test_fortio() { + test_work_area_type * work_area = test_work_area_alloc("fortio"); + + ERT::FortIO fortio("new_file" , std::fstream::out ); + { + std::vector<int> data; + for (size_t i=0; i < 1000; i++) + data.push_back(i); + + fortio_fwrite_record( fortio.getPointer() , reinterpret_cast<char *>(data.data()) , 1000 * 4 ); + } + fortio.close(); + + fortio = ERT::FortIO("new_file" , std::fstream::in ); + { + std::vector<int> data; + for (size_t i=0; i < 1000; i++) + data.push_back(99); + + test_assert_true( fortio_fread_buffer( fortio.getPointer() , reinterpret_cast<char *>(data.data()) , 1000 * 4 ) ); + for (size_t i =0; i < 1000; i++) + test_assert_size_t_equal(data[i], i); + + } + fortio.close(); + test_work_area_free( work_area ); + + test_assert_throw( ERT::FortIO fortio("file/does/not/exists" , std::fstream::in) , std::invalid_argument ); +} + + +void test_fortio_kw() { + test_work_area_type * work_area = test_work_area_alloc("fortio_kw"); + ERT::EclKW<int> kw("XYZ" , 1000); + for (size_t i =0 ; i < kw.size(); i++) + kw[i] = i; + + { + ERT::FortIO fortio("new_file" , std::fstream::out ); + kw.fwrite( fortio ); + fortio.close(); + } + + { + ERT::FortIO fortio("new_file" , std::fstream::in ); + ERT::EclKW<int> kw2 = ERT::EclKW<int>::load( fortio ); + fortio.close( ); + for (size_t i =0 ; i < kw.size(); i++) + test_assert_int_equal( kw[i] , kw2[i]); + + + fortio = ERT::FortIO("new_file" , std::fstream::in ); + test_assert_throw( ERT::EclKW<float>::load(fortio) , std::invalid_argument ); + fortio.close(); + } + + test_work_area_free( work_area ); +} + + + +int main(int argc , char ** argv) { + test_fortio(); + test_fortio_kw(); +} diff --git a/ThirdParty/Ert/devel/libeclxx/tests/eclxx_kw.cpp b/ThirdParty/Ert/devel/libeclxx/tests/eclxx_kw.cpp new file mode 100644 index 0000000000..7741170c07 --- /dev/null +++ b/ThirdParty/Ert/devel/libeclxx/tests/eclxx_kw.cpp @@ -0,0 +1,47 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM 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. + + OPM 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 for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <stdexcept> +#include <fstream> + +#include <ert/util/test_util.h> +#include <ert/util/test_work_area.h> +#include <ert/ecl/EclKW.hpp> +#include <ert/ecl/FortIO.hpp> + + +void test_kw() { + ERT::EclKW<int> kw("XYZ" , 1000); + test_assert_size_t_equal( kw.size() , 1000 ); + + kw[0] = 1; + kw[10] = 77; + + test_assert_int_equal( kw[0] , 1 ); + test_assert_int_equal( kw[10] , 77 ); +} + + + + + + +int main (int argc, char **argv) { + test_kw(); +} diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt index dfb31fc396..fa883a25be 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt @@ -1,33 +1,23 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) include_directories( ${PLPLOT_HEADER} ) -set( SITE_CONFIG_FILE /project/res/etc/ERT/site-config CACHE FILEPATH "Path to global ERT Configuration file") - set( src_list main.c enkf_tui_main.c enkf_tui_fs.c enkf_tui_ranking.c enkf_tui_misc.c enkf_tui_table.c enkf_tui_plot.c enkf_tui_plot_rft.c enkf_tui_plot_util.c enkf_tui_run.c enkf_tui_util.c enkf_tui_init.c enkf_tui_export.c enkf_tui_analysis.c enkf_tui_QC.c enkf_tui_help.c enkf_tui_simple.c ert_tui_jobs.c enkf_tui_workflow.c) -#exec_program( svnversion ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE SVN_VERSION) -#exec_program( date OUTPUT_VARIABLE COMPILE_TIME_STAMP) - -#exec_program( svnversion ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE SVN_VERSION) -#exec_program( date OUTPUT_VARIABLE COMPILE_TIME_STAMP) -#file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/build_timestamp.h "#define SVN_VERSION \"${SVN_VERSION}\"\n#define COMPILE_TIME_STAMP \"${COMPILE_TIME_STAMP}\"\n" ) - - -#add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build_timestamp.h COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/timestamp.cmake ) -#add_custom_target( timestamp ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/build_timestep.h ) -#set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/build_timestamp.h -# PROPERTIES GENERATED TRUE -# HEADER_FILE_ONLY TRUE) - - execute_process(COMMAND date "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE BUILD_TIME ) string(STRIP ${BUILD_TIME} BUILD_TIME) -execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/git_commit.sh "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_COMMIT) -string(STRIP ${GIT_COMMIT} GIT_COMMIT) +find_package(Git) +if(GIT_EXECUTABLE) + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_COMMIT) + string(STRIP "${GIT_COMMIT}" GIT_COMMIT) +else() + set(GIT_COMMIT) +endif() -set_source_files_properties( main.c PROPERTIES COMPILE_DEFINITIONS "COMPILE_TIME_STAMP=\"${BUILD_TIME}\";GIT_COMMIT=\"${GIT_COMMIT}\";SITE_CONFIG_FILE=\"${SITE_CONFIG_FILE}\"") +set_source_files_properties( main.c PROPERTIES COMPILE_DEFINITIONS "COMPILE_TIME_STAMP=\"${BUILD_TIME}\";GIT_COMMIT=\"${GIT_COMMIT}\"") add_executable( ert ${src_list} ) target_link_libraries( ert enkf sched rms ecl config plot job_queue analysis ert_util ) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c index 59cc23597f..0455e5cb4b 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c @@ -53,7 +53,6 @@ #include <ert/enkf/plot_config.h> #include <ert/enkf/member_config.h> #include <ert/enkf/enkf_analysis.h> -#include <ert/enkf/obs_tstep_list.h> #include <ert/enkf/pca_plot_data.h> #include <enkf_tui_util.h> diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_fs.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_fs.c index 8a6fd4529a..022ea728e7 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_fs.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_fs.c @@ -284,7 +284,7 @@ void enkf_tui_fs_copy_ensemble(void * arg) *newline = 0; } - if (target_case && (strlen(target_case))) { + if (strlen(target_case)) { char * report_step_to_as_char = util_scanf_int_with_limits_return_char("Target report step",prompt_len , 0 , last_report); if (strlen(report_step_to_as_char)) { util_sscanf_int(report_step_to_as_char , &report_step_to); @@ -335,7 +335,7 @@ void enkf_tui_fs_copy_ensemble_of_parameters(void * arg) *newline = 0; } - if (target_case && strlen(target_case)) { + if (strlen(target_case)) { char * report_step_to_as_char = util_scanf_int_with_limits_return_char("Target report step",prompt_len , 0 , last_report); if(strlen(report_step_to_as_char) !=0){ util_sscanf_int(report_step_to_as_char , &report_step_to); diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c index 36ccaa82b5..afdc843418 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_tui_main.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_tui_main.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -45,7 +45,7 @@ -/** +/** The main loop. */ @@ -56,7 +56,7 @@ void enkf_tui_main_menu(void * arg) { enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); menu_type * menu = menu_alloc("Main menu" , "Quit" , "qQ"); - + menu_add_item(menu , "Manage cases" , "cC" , enkf_tui_fs_menu , enkf_main , NULL); menu_add_item(menu , "Run, restart or analyse experiment" , "rR" , enkf_tui_run_menu , enkf_main , NULL); menu_add_item(menu , "Quality check" , "uU" , enkf_tui_QC_menu , enkf_main , NULL); @@ -66,7 +66,7 @@ void enkf_tui_main_menu(void * arg) { menu_add_item(menu , "Table of results" , "tT" , enkf_tui_table_menu , enkf_main , NULL); menu_add_item(menu , "Miscellanous" , "mM" , enkf_tui_misc_menu , enkf_main , NULL); menu_add_item(menu , "Workflows" , "wW" , enkf_tui_workflow_menu , enkf_main , NULL); - menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_main , enkf_main , NULL); + menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_main , enkf_main , NULL); menu_add_item(menu , "Simple menu" , "sS" , enkf_tui_simple_menu , enkf_main , NULL); menu_run(menu); menu_free(menu); diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c index 620045d4e3..16718f59a7 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c @@ -88,7 +88,7 @@ void enkf_tui_workflow_list( void * arg ) { else printf(" "); - printf( stringlist_iget( name_list , i )); + printf("%s", stringlist_iget( name_list , i )); } } stringlist_free( name_list ); diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/git_commit.sh b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/git_commit.sh deleted file mode 100644 index b5cb7aed6c..0000000000 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/git_commit.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cd "$1" -git rev-parse HEAD \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c index b0e616221c..072d36b8de 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c @@ -27,6 +27,7 @@ #include <ert/util/stringlist.h> #include <ert/enkf/enkf_fs.h> +#include <ert/enkf/site_config.h> #include <ert/enkf/enkf_main.h> #include <ert/enkf/enkf_types.h> #include <ert/enkf/enkf_sched.h> @@ -136,7 +137,7 @@ int main (int argc , char ** argv) { printf("Documentation : %s \n","http://ert.nr.no"); printf("git commit : %s \n",GIT_COMMIT); printf("compile time : %s \n",COMPILE_TIME_STAMP); - printf("site config : %s \n",SITE_CONFIG_FILE); + printf("site config : %s \n", site_config_get_location()); enkf_main_install_SIGNALS(); /* Signals common to both tui and gui. */ signal(SIGINT , util_abort_signal); /* Control C - tui only. */ @@ -144,8 +145,7 @@ int main (int argc , char ** argv) { enkf_usage(); exit(1); } else { - const char * site_config_file = SITE_CONFIG_FILE; /* The variable SITE_CONFIG_FILE should be defined on compilation ... */ - const char * model_config_file = argv[1]; + const char * model_config_file = argv[1]; stringlist_type * workflow_list = stringlist_alloc_new(); parse_workflows( argc , argv , workflow_list ); @@ -158,7 +158,7 @@ int main (int argc , char ** argv) { } enkf_welcome( model_config_file ); { - enkf_main_type * enkf_main = enkf_main_bootstrap(site_config_file , model_config_file , true , true); + enkf_main_type * enkf_main = enkf_main_bootstrap(model_config_file , true , true); enkf_main_run_workflows( enkf_main , workflow_list ); enkf_tui_main_menu(enkf_main); enkf_main_free(enkf_main); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h index 3a37cb2e33..c10ccb908c 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'analysis_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'analysis_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -29,7 +29,8 @@ extern "C" { #include <ert/util/rng.h> #include <ert/util/stringlist.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/analysis/analysis_module.h> @@ -49,11 +50,11 @@ void analysis_config_load_internal_modules( analysis_config_ty void analysis_config_reload_module( analysis_config_type * config , const char * module_name); bool analysis_config_get_module_option( const analysis_config_type * config , long flag); bool analysis_config_load_external_module( analysis_config_type * config , const char * user_name , const char * lib_name); -void analysis_config_load_all_external_modules_from_config ( analysis_config_type * analysis_config, const config_type * config); +void analysis_config_load_all_external_modules_from_config ( analysis_config_type * analysis_config, const config_content_type * config); stringlist_type * analysis_config_alloc_module_names( analysis_config_type * config ); const char * analysis_config_get_log_path( const analysis_config_type * config ); -void analysis_config_init( analysis_config_type * analysis , const config_type * config); +void analysis_config_init( analysis_config_type * analysis , const config_content_type * config); analysis_config_type * analysis_config_alloc( rng_type * rng ); void analysis_config_free( analysis_config_type * ); bool analysis_config_get_merge_observations(const analysis_config_type * ); @@ -85,7 +86,7 @@ void analysis_config_set_penalised_press( analysis_config_type void analysis_config_set_log_path(analysis_config_type * config , const char * log_path ); void analysis_config_set_std_cutoff( analysis_config_type * config , double std_cutoff ); double analysis_config_get_std_cutoff( const analysis_config_type * config ); -void analysis_config_add_config_items( config_type * config ); +void analysis_config_add_config_items( config_parser_type * config ); void analysis_config_fprintf_config( analysis_config_type * config , FILE * stream); bool analysis_config_select_module( analysis_config_type * config , const char * module_name ); @@ -106,9 +107,14 @@ int analysis_config_get_min_realisations( const analysis_conf bool analysis_config_have_enough_realisations( const analysis_config_type * config , int realisations); void analysis_config_set_stop_long_running( analysis_config_type * config, bool stop_long_running ); bool analysis_config_get_stop_long_running( const analysis_config_type * config); -void analysis_config_set_max_runtime( analysis_config_type * config, int max_runtime ); -int analysis_config_get_max_runtime( const analysis_config_type * config ); +void analysis_config_set_max_runtime( analysis_config_type * config, int max_runtime ); +int analysis_config_get_max_runtime( const analysis_config_type * config ); const char * analysis_config_get_active_module_name( const analysis_config_type * config ); +bool analysis_config_get_std_scale_correlated_obs( const analysis_config_type * config); +void analysis_config_set_std_scale_correlated_obs( analysis_config_type * config, bool std_scale_correlated_obs); + +double analysis_config_get_global_std_scaling(const analysis_config_type * config); +void analysis_config_set_global_std_scaling(analysis_config_type * config, double global_std_scaling); UTIL_IS_INSTANCE_HEADER( analysis_config ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h index abd36f6325..41e2af7756 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h @@ -1,28 +1,30 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'analysis_iter_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'analysis_iter_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ANALYSIS_ITER_CONFIG_H__ #define __ANALYSIS_ITER_CONFIG_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> typedef struct analysis_iter_config_struct analysis_iter_config_type; @@ -35,12 +37,12 @@ typedef struct analysis_iter_config_struct analysis_iter_config_type; analysis_iter_config_type * analysis_iter_config_alloc(); void analysis_iter_config_free( analysis_iter_config_type * config ); const char * analysis_iter_config_iget_case( analysis_iter_config_type * config , int iter); - void analysis_iter_config_add_config_items( config_type * config ); - void analysis_iter_config_init(analysis_iter_config_type * iter_config , const config_type * config); + void analysis_iter_config_add_config_items( config_parser_type * config ); + void analysis_iter_config_init(analysis_iter_config_type * iter_config , const config_content_type * config); bool analysis_iter_config_case_fmt_set( const analysis_iter_config_type * config ); bool analysis_iter_config_num_iterations_set( const analysis_iter_config_type * config ); -#ifdef __cplusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/block_obs.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/block_obs.h index 1281309ebb..8ef7f66ef2 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/block_obs.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/block_obs.h @@ -77,9 +77,8 @@ double block_obs_iget_value(const block_obs_type * block_obs, int index ); double block_obs_iget_std(const block_obs_type * block_obs, int index ); void block_obs_iget_ijk(const block_obs_type * block_obs , int block_nr , int * i , int * j , int * k); double block_obs_iget_data( const block_obs_type * block_obs, const void * state , int iobs , node_id_type node_id ); - -void block_obs_scale_std(block_obs_type * block_obs, double scale_factor); -void block_obs_scale_std__(void * block_obs, double scale_factor); +double block_obs_iget_std_scaling(const block_obs_type * block_obs, int index ); +void block_obs_update_std_scale(block_obs_type * block_obs, double scale_factor, const active_list_type * active_list); void block_obs_append_field_obs( block_obs_type * block_obs , int i , int j , int k , double value , double std); void block_obs_append_summary_obs( block_obs_type * block_obs , int i , int j , int k , const char * sum_key , double value , double std); @@ -89,6 +88,7 @@ UTIL_IS_INSTANCE_HEADER(block_obs); VOID_MEASURE_HEADER(block_obs); VOID_USER_GET_OBS_HEADER(block_obs); VOID_CHI2_HEADER(block_obs); +VOID_UPDATE_STD_SCALE_HEADER(block_obs); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h index 0e7973a889..a200cb4cbb 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'config_keys.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'config_keys.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -25,8 +25,8 @@ extern "C" { /* These keys are used as options in KEY:VALUE statements */ #define BASE_SURFACE_KEY "BASE_SURFACE" -#define DEFINE_KEY "DEFINE" -#define DYNAMIC_KEY "DYNAMIC" +#define DEFINE_KEY "DEFINE" +#define DYNAMIC_KEY "DYNAMIC" #define ECL_FILE_KEY "ECL_FILE" #define FORWARD_INIT_KEY "FORWARD_INIT" #define GENERAL_KEY "GENERAL" @@ -43,7 +43,7 @@ extern "C" { #define OUTPUT_FORMAT_KEY "OUTPUT_FORMAT" #define OUTPUT_TRANSFORM_KEY "OUTPUT_TRANSFORM" #define PARAMETER_KEY "PARAMETER" -#define REPORT_STEPS_KEY "REPORT_STEPS" +#define REPORT_STEPS_KEY "REPORT_STEPS" #define RESULT_FILE_KEY "RESULT_FILE" #define TEMPLATE_KEY "TEMPLATE" @@ -55,32 +55,33 @@ extern "C" { #define ANALYSIS_SELECT_KEY "ANALYSIS_SELECT" #define CASE_TABLE_KEY "CASE_TABLE" #define CONTAINER_KEY "CONTAINER" +#define CUSTOM_KW_KEY "CUSTOM_KW" #define DATA_FILE_KEY "DATA_FILE" -#define DATA_KW_KEY "DATA_KW" +#define DATA_KW_KEY "DATA_KW" #define DBASE_TYPE_KEY "DBASE_TYPE" #define DBASE_TYPE_KEY "DBASE_TYPE" -#define DELETE_RUNPATH_KEY "DELETE_RUNPATH" +#define DELETE_RUNPATH_KEY "DELETE_RUNPATH" #define ECLBASE_KEY "ECLBASE" #define END_DATE_KEY "END_DATE" #define ENKF_BOOTSTRAP_KEY "ENKF_BOOTSTRAP" #define ENKF_PEN_PRESS_KEY "ENKF_PEN_PRESS" #define ENKF_ALPHA_KEY "ENKF_ALPHA" #define ENKF_CROSS_VALIDATION_KEY "ENKF_CROSS_VALIDATION" -#define ENKF_CV_FOLDS_KEY "ENKF_CV_FOLDS" +#define ENKF_CV_FOLDS_KEY "ENKF_CV_FOLDS" #define ENKF_FORCE_NCOMP_KEY "ENKF_FORCE_NCOMP" -#define ENKF_NCOMP_KEY "ENKF_NCOMP" -#define ENKF_SCALING_KEY "ENKF_SCALING" -#define ENKF_KERNEL_REG_KEY "ENKF_KERNEL_REGRESSION" -#define ENKF_KERNEL_FUNC_KEY "ENKF_KERNEL_FUNCTION" -#define ENKF_KERNEL_PARAM_KEY "ENKF_KERNEL_PARAM" -#define ENKF_LOCAL_CV_KEY "ENKF_LOCAL_CV" +#define ENKF_NCOMP_KEY "ENKF_NCOMP" +#define ENKF_SCALING_KEY "ENKF_SCALING" +#define ENKF_KERNEL_REG_KEY "ENKF_KERNEL_REGRESSION" +#define ENKF_KERNEL_FUNC_KEY "ENKF_KERNEL_FUNCTION" +#define ENKF_KERNEL_PARAM_KEY "ENKF_KERNEL_PARAM" +#define ENKF_LOCAL_CV_KEY "ENKF_LOCAL_CV" #define ENKF_MERGE_OBSERVATIONS_KEY "ENKF_MERGE_OBSERVATIONS" #define ENKF_MODE_KEY "ENKF_MODE" #define ENKF_RERUN_KEY "ENKF_RERUN" #define ENKF_SCHED_FILE_KEY "ENKF_SCHED_FILE" #define ENKF_TRUNCATION_KEY "ENKF_TRUNCATION" -#define ENSPATH_KEY "ENSPATH" -#define ITER_CASE_KEY "ITER_CASE" +#define ENSPATH_KEY "ENSPATH" +#define ITER_CASE_KEY "ITER_CASE" #define ITER_COUNT_KEY "ITER_COUNT" #define ITER_RETRY_COUNT_KEY "ITER_RETRY_COUNT" #define FIELD_KEY "FIELD" @@ -89,21 +90,21 @@ extern "C" { #define GEN_KW_KEY "GEN_KW" #define GEN_KW_TAG_FORMAT_KEY "GEN_KW_TAG_FORMAT" #define GEN_KW_EXPORT_FILE_KEY "GEN_KW_EXPORT_FILE" -#define GEN_PARAM_KEY "GEN_PARAM" +#define GEN_PARAM_KEY "GEN_PARAM" #define GRID_KEY "GRID" #define HISTORY_SOURCE_KEY "HISTORY_SOURCE" #define HOSY_TYPE_KEY "HOST_TYPE" -#define IGNORE_SCHEDULE_KEY "IGNORE_SCHEDULE" +#define IGNORE_SCHEDULE_KEY "IGNORE_SCHEDULE" #define IMAGE_TYPE_KEY "IMAGE_TYPE" -#define IMAGE_VIEWER_KEY "IMAGE_VIEWER" +#define IMAGE_VIEWER_KEY "IMAGE_VIEWER" #define INIT_SECTION_KEY "INIT_SECTION" #define INSTALL_JOB_KEY "INSTALL_JOB" #define INSTALL_JOB_DIRECTORY_KEY "INSTALL_JOB_DIRECTORY" #define JOB_SCRIPT_KEY "JOB_SCRIPT" #define JOBNAME_KEY "JOBNAME" -#define KEEP_RUNPATH_KEY "KEEP_RUNPATH" +#define KEEP_RUNPATH_KEY "KEEP_RUNPATH" #define LICENSE_PATH_KEY "LICENSE_PATH" -#define LOAD_SEED_KEY "LOAD_SEED" +#define LOAD_SEED_KEY "LOAD_SEED" #define LOCAL_CONFIG_KEY "LOCAL_CONFIG" #define LOG_FILE_KEY "LOG_FILE" #define LOG_LEVEL_KEY "LOG_LEVEL" @@ -111,33 +112,33 @@ extern "C" { #define LSF_RESOURCES_KEY "LSF_RESOURCES" #define LSF_SERVER_KEY "LSF_SERVER" #define TORQUE_QUEUE_KEY "TORQUE_QUEUE" -#define MAX_RESAMPLE_KEY "MAX_RESAMPLE" +#define MAX_RESAMPLE_KEY "MAX_RESAMPLE" #define MAX_RUNNING_LOCAL_KEY "MAX_RUNNING_LOCAL" #define MAX_RUNNING_LSF_KEY "MAX_RUNNING_LSF" #define MAX_RUNNING_RSH_KEY "MAX_RUNNING_RSH" -#define MAX_SUBMIT_KEY "MAX_SUBMIT" -#define NUM_REALIZATIONS_KEY "NUM_REALIZATIONS" -#define MIN_REALIZATIONS_KEY "MIN_REALIZATIONS" +#define MAX_SUBMIT_KEY "MAX_SUBMIT" +#define NUM_REALIZATIONS_KEY "NUM_REALIZATIONS" +#define MIN_REALIZATIONS_KEY "MIN_REALIZATIONS" #define OBS_CONFIG_KEY "OBS_CONFIG" #define OBS_CONFIG_KEY "OBS_CONFIG" #define PLOT_DRIVER_KEY "PLOT_DRIVER" -#define PLOT_ERRORBAR_MAX_KEY "PLOT_ERRORBAR_MAX" +#define PLOT_ERRORBAR_MAX_KEY "PLOT_ERRORBAR_MAX" #define PLOT_ERRORBAR_KEY "PLOT_ERRORBAR" -#define PLOT_HEIGHT_KEY "PLOT_HEIGHT" -#define PLOT_PATH_KEY "PLOT_PATH" +#define PLOT_HEIGHT_KEY "PLOT_HEIGHT" +#define PLOT_PATH_KEY "PLOT_PATH" #define PLOT_REFCASE_KEY "PLOT_REFCASE" #define PLOT_REFCASE_LIST_KEY "PLOT_REFCASE_LIST" -#define PLOT_WIDTH_KEY "PLOT_WIDTH" +#define PLOT_WIDTH_KEY "PLOT_WIDTH" #define PRE_CLEAR_RUNPATH_KEY "PRE_CLEAR_RUNPATH" #define QUEUE_SYSTEM_KEY "QUEUE_SYSTEM" -#define QUEUE_OPTION_KEY "QUEUE_OPTION" -#define QC_PATH_KEY "QC_PATH" +#define QUEUE_OPTION_KEY "QUEUE_OPTION" +#define QC_PATH_KEY "QC_PATH" #define QC_WORKFLOW_KEY "QC_WORKFLOW" #define REFCASE_KEY "REFCASE" #define REFCASE_LIST_KEY "REFCASE_LIST" #define REPORT_CONTEXT_KEY "REPORT_CONTEXT" #define REPORT_SEARCH_PATH_KEY "REPORT_SEARCH_PATH" -#define REPORT_LARGE_KEY "REPORT_LARGE" +#define REPORT_LARGE_KEY "REPORT_LARGE" #define REPORT_LIST_KEY "REPORT_LIST" #define REPORT_PATH_KEY "REPORT_PATH" #define REPORT_WELL_LIST_KEY "REPORT_WELL_LIST" @@ -146,7 +147,7 @@ extern "C" { #define RERUN_START_KEY "RERUN_START" #define RSH_COMMAND_KEY "RSH_COMMAND" #define RSH_HOST_KEY "RSH_HOST" -#define RUNPATH_FILE_KEY "RUNPATH_FILE" +#define RUNPATH_FILE_KEY "RUNPATH_FILE" #define RUNPATH_KEY "RUNPATH" #define ITER_RUNPATH_KEY "ITER_RUNPATH" #define RERUN_PATH_KEY "RERUN_PATH" @@ -162,21 +163,22 @@ extern "C" { #define SETENV_KEY "SETENV" #define STATIC_KW_KEY "ADD_STATIC_KW" #define STD_CUTOFF_KEY "STD_CUTOFF" -#define SUMMARY_KEY "SUMMARY" +#define SUMMARY_KEY "SUMMARY" #define SURFACE_KEY "SURFACE" #define UPDATE_LOG_PATH_KEY "UPDATE_LOG_PATH" #define UPDATE_PATH_KEY "UPDATE_PATH" #define UPDATE_RESULTS_KEY "UPDATE_RESULTS" #define SINGLE_NODE_UPDATE_KEY "SINGLE_NODE_UPDATE" #define STORE_SEED_KEY "STORE_SEED" -#define UMASK_KEY "UMASK" +#define UMASK_KEY "UMASK" #define WORKFLOW_JOB_DIRECTORY_KEY "WORKFLOW_JOB_DIRECTORY" -#define LOAD_WORKFLOW_KEY "LOAD_WORKFLOW" +#define LOAD_WORKFLOW_KEY "LOAD_WORKFLOW" #define LOAD_WORKFLOW_JOB_KEY "LOAD_WORKFLOW_JOB" #define STOP_LONG_RUNNING_KEY "STOP_LONG_RUNNING" #define MAX_RUNTIME_KEY "MAX_RUNTIME" #define TIME_MAP_KEY "TIME_MAP" - +#define EXT_JOB_SEARCH_PATH_KEY "EXT_JOB_SEARCH_PATH" +#define STD_SCALE_CORRELATED_OBS_KEY "STD_SCALE_CORRELATED_OBS" #define CONFIG_BOOL_STRING( var ) (var) ? "TRUE" : "FALSE" diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw.h new file mode 100644 index 0000000000..9eaf5cc430 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw.h @@ -0,0 +1,53 @@ +#ifndef __CUSTOM_KW_H__ +#define __CUSTOM_KW_H__ +#ifdef __cplusplus +extern "C" { +#endif + +#include <ert/util/util.h> +#include <ert/util/bool_vector.h> +#include <ert/util/double_vector.h> +#include <ert/util/buffer.h> + +#include <ert/ecl/ecl_sum.h> +#include <ert/ecl/ecl_file.h> + +#include <ert/enkf/enkf_macros.h> +#include <ert/enkf/custom_kw_config.h> + + typedef struct custom_kw_struct custom_kw_type; + + custom_kw_type * custom_kw_alloc(const custom_kw_config_type * config); + void custom_kw_free(custom_kw_type * custom_kw); + custom_kw_config_type * custom_kw_get_config(const custom_kw_type * custom_kw); + const stringlist_type * custom_kw_get_data(const custom_kw_type * custom_kw); + bool custom_kw_key_is_null(const custom_kw_type * custom_kw, char * key); + double custom_kw_iget_as_double(const custom_kw_type * custom_kw, int index); + const char * custom_kw_iget_as_string(const custom_kw_type * custom_kw, int index); + + bool custom_kw_fload(custom_kw_type * custom_kw, const char * filename); + bool custom_kw_forward_load(custom_kw_type * custom_kw, const char * ecl_file, const ecl_sum_type * ecl_sum, const ecl_file_type * restart_file , int report_step); + + bool custom_kw_write_to_buffer(const custom_kw_type * custom_kw, buffer_type * buffer, int report_step, state_enum state); + void custom_kw_read_from_buffer(const custom_kw_type * custom_kw, buffer_type * buffer, enkf_fs_type * fs, int report_step, state_enum state); + void custom_kw_ecl_write(const custom_kw_type * custom_kw, const char * run_path, const char * base_file, void * filestream); + void custom_kw_serialize(const custom_kw_type * custom_kw, node_id_type node_id, const active_list_type * active_list, matrix_type * A, int row_offset, int column); + void custom_kw_deserialize(custom_kw_type * custom_kw, node_id_type node_id, const active_list_type * active_list, const matrix_type * A, int row_offset , int column); + + + UTIL_SAFE_CAST_HEADER(custom_kw); + UTIL_SAFE_CAST_HEADER_CONST(custom_kw); + VOID_USER_GET_HEADER(custom_kw); + VOID_ALLOC_HEADER(custom_kw); + VOID_FREE_HEADER(custom_kw); + VOID_FORWARD_LOAD_HEADER(custom_kw) + VOID_FLOAD_HEADER(custom_kw) + VOID_ECL_WRITE_HEADER(custom_kw); + VOID_READ_FROM_BUFFER_HEADER(custom_kw); + VOID_WRITE_TO_BUFFER_HEADER(custom_kw); + VOID_SERIALIZE_HEADER(custom_kw) + VOID_DESERIALIZE_HEADER(custom_kw) +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw_config.h new file mode 100644 index 0000000000..48d1387d9f --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw_config.h @@ -0,0 +1,41 @@ +#ifndef __CUSTOM_KW_CONFIG_H__ +#define __CUSTOM_KW_CONFIG_H__ +#ifdef __cplusplus +extern "C" { +#endif +#include <stdbool.h> + +#include <ert/util/stringlist.h> +#include <ert/util/util.h> +#include <ert/util/bool_vector.h> + +#include <ert/enkf/enkf_fs_type.h> +#include <ert/enkf/enkf_types.h> +#include <ert/enkf/enkf_macros.h> + + typedef struct custom_kw_config_struct custom_kw_config_type; + + custom_kw_config_type * custom_kw_config_alloc_empty(const char * key, const char * result_file, const char * output_file); + void custom_kw_config_free(custom_kw_config_type * config); + const char * custom_kw_config_get_name(const custom_kw_config_type * config); + char * custom_kw_config_get_result_file(const custom_kw_config_type * config); + char * custom_kw_config_get_output_file(const custom_kw_config_type * config); + bool custom_kw_config_parse_result_file(custom_kw_config_type * config, const char * result_file, stringlist_type * result); + void custom_kw_config_serialize(custom_kw_config_type * config, stringlist_type * config_set); + void custom_kw_config_deserialize(custom_kw_config_type * config, stringlist_type * config_set); + bool custom_kw_config_has_key(const custom_kw_config_type * config, const char * key); + bool custom_kw_config_key_is_double(const custom_kw_config_type * config, const char * key); + int custom_kw_config_index_of_key(const custom_kw_config_type * config, const char * key); + int custom_kw_config_size(const custom_kw_config_type * config); + stringlist_type * custom_kw_config_get_keys(const custom_kw_config_type * config); + + + UTIL_IS_INSTANCE_HEADER(custom_kw_config); + UTIL_SAFE_CAST_HEADER(custom_kw_config); + UTIL_SAFE_CAST_HEADER_CONST(custom_kw_config); + VOID_FREE_HEADER(custom_kw_config) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw_config_set.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw_config_set.h new file mode 100644 index 0000000000..481adf6eb8 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/custom_kw_config_set.h @@ -0,0 +1,30 @@ +#ifndef __CUSTOM_KW_CONFIG_SET_H__ +#define __CUSTOM_KW_CONFIG_SET_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <ert/enkf/custom_kw_config.h> +#include <ert/util/type_macros.h> + +#include <ert/enkf/enkf_types.h> + + typedef struct custom_kw_config_set_struct custom_kw_config_set_type; + + custom_kw_config_set_type * custom_kw_config_set_alloc(); + custom_kw_config_set_type * custom_kw_config_set_alloc_from_file(const char * filename); + void custom_kw_config_set_free(custom_kw_config_set_type * set); + void custom_kw_config_set_add_config(custom_kw_config_set_type * set, const custom_kw_config_type * config); + void custom_kw_config_set_update_config(custom_kw_config_set_type * set, custom_kw_config_type * config); + void custom_kw_config_set_reset(custom_kw_config_set_type * set); + stringlist_type * custom_kw_config_set_get_keys_alloc(custom_kw_config_set_type * set); + void custom_kw_config_set_fwrite(custom_kw_config_set_type * set, const char * filename); + bool custom_kw_config_set_fread(custom_kw_config_set_type * set, const char * filename); + + UTIL_IS_INSTANCE_HEADER(custom_kw_config_set); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h index 4530587dc1..4155fd1d65 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ECL_CONFIG_H__ @@ -26,7 +26,8 @@ extern "C" { #include <ert/util/path_fmt.h> #include <ert/util/ui_return.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_sum.h> @@ -48,7 +49,7 @@ extern "C" { const char * ecl_config_get_schedule_file( const ecl_config_type * ecl_config ); const char * ecl_config_get_schedule_target(const ecl_config_type * ); bool ecl_config_has_schedule( const ecl_config_type * ecl_config ); - + void ecl_config_set_eclbase( ecl_config_type * ecl_config , const char * eclbase_fmt ); ui_return_type * ecl_config_validate_eclbase( const ecl_config_type * ecl_config , const char * eclbase_fmt ); const path_fmt_type * ecl_config_get_eclbase_fmt(const ecl_config_type * ); @@ -62,18 +63,18 @@ extern "C" { void ecl_config_set_grid( ecl_config_type * ecl_config , const char * grid_file ); const char * ecl_config_get_gridfile( const ecl_config_type * ecl_config ); - ecl_grid_type * ecl_config_get_grid(const ecl_config_type * ); + ecl_grid_type * ecl_config_get_grid(const ecl_config_type * ); ui_return_type * ecl_config_validate_grid( const ecl_config_type * ecl_config , const char * grid_file ); bool ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcase); ui_return_type * ecl_config_validate_refcase( const ecl_config_type * ecl_config , const char * refcase ); const ecl_sum_type * ecl_config_get_refcase(const ecl_config_type * ecl_config); bool ecl_config_has_refcase( const ecl_config_type * ecl_config ); - ecl_refcase_list_type * ecl_config_get_refcase_list( const ecl_config_type * ecl_config ); + ecl_refcase_list_type * ecl_config_get_refcase_list( const ecl_config_type * ecl_config ); /*****************************************************************/ - void ecl_config_static_kw_init( ecl_config_type * ecl_config , const config_type * config ); + void ecl_config_static_kw_init( ecl_config_type * ecl_config , const config_content_type * config ); bool ecl_config_active( const ecl_config_type * config ); time_t ecl_config_get_end_date( const ecl_config_type * ecl_config ); time_t ecl_config_get_start_date( const ecl_config_type * ecl_config ); @@ -81,13 +82,13 @@ extern "C" { const char * ecl_config_get_schedule_prediction_file( const ecl_config_type * ecl_config ); void ecl_config_set_schedule_prediction_file( ecl_config_type * ecl_config , const char * schedule_prediction_file ); sched_file_type * ecl_config_get_sched_file(const ecl_config_type * ); - + int ecl_config_get_num_cpu( const ecl_config_type * ecl_config ); - void ecl_config_init( ecl_config_type * ecl_config , const config_type * config); + void ecl_config_init( ecl_config_type * ecl_config , const config_content_type * config); void ecl_config_free( ecl_config_type *); bool ecl_config_include_static_kw(const ecl_config_type * , const char * ); - void ecl_config_add_static_kw(ecl_config_type *, const char *); + void ecl_config_add_static_kw(ecl_config_type *, const char *); ecl_io_config_type * ecl_config_get_io_config(const ecl_config_type * ); bool ecl_config_get_formatted(const ecl_config_type * ); @@ -103,7 +104,7 @@ extern "C" { stringlist_type * ecl_config_get_static_kw_list( const ecl_config_type * ecl_config ); void ecl_config_fprintf_config( const ecl_config_type * ecl_config , FILE * stream ); ecl_config_type * ecl_config_alloc( ); - void ecl_config_add_config_items( config_type * config ); + void ecl_config_add_config_items( config_parser_type * config ); const char * ecl_config_get_depth_unit( const ecl_config_type * ecl_config ); const char * ecl_config_get_pressure_unit( const ecl_config_type * ecl_config ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_config_node.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_config_node.h index f4877b1aea..86fb4a9e68 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_config_node.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_config_node.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_config_node.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_config_node.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ENKF_CONFIG_NODE_H__ @@ -24,7 +24,7 @@ extern "C" { #include <ert/util/stringlist.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/ecl/ecl_grid.h> @@ -48,88 +48,91 @@ extern "C" { enkf_config_node_type * enkf_config_node_new_GEN_PARAM( const char * key , bool forward_init); enkf_config_node_type * enkf_config_node_new_GEN_DATA( const char * key , bool forward_init); + enkf_config_node_type * enkf_config_node_new_custom_kw(const char * key, const char * result_file, const char * output_file); void enkf_config_node_update_min_std( enkf_config_node_type * config_node , const char * min_std_file ); - enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM( const char * node_key , - bool forward_init , - gen_data_file_format_type input_format , - gen_data_file_format_type output_format , - const char * init_file_fmt , + enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM( const char * node_key , + bool forward_init , + gen_data_file_format_type input_format , + gen_data_file_format_type output_format , + const char * init_file_fmt , const char * ert_outfile_fmt); - - - enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_state( const char * key, - bool forward_init , + + + enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_state( const char * key, + bool forward_init , gen_data_file_format_type input_format, gen_data_file_format_type output_format, - const char * init_file_fmt , - const char * template_ecl_file , + const char * init_file_fmt , + const char * template_ecl_file , const char * template_data_key , - const char * enkf_outfile_fmt , - const char * enkf_infile_fmt , + const char * enkf_outfile_fmt , + const char * enkf_infile_fmt , const char * min_std_file); - - enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_result( const char * key , + + enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_result( const char * key , gen_data_file_format_type input_format, const char * enkf_infile_fmt ); - void enkf_config_node_update_GEN_PARAM( enkf_config_node_type * config_node, + void enkf_config_node_update_GEN_PARAM( enkf_config_node_type * config_node, gen_data_file_format_type input_format, gen_data_file_format_type output_format, - const char * init_file_fmt , - const char * template_ecl_file , + const char * init_file_fmt , + const char * template_ecl_file , const char * template_data_key , - const char * enkf_outfile_fmt , + const char * enkf_outfile_fmt , const char * min_std_file); - void enkf_config_node_update_GEN_DATA_result( enkf_config_node_type * config_node, + void enkf_config_node_update_GEN_DATA_result( enkf_config_node_type * config_node, gen_data_file_format_type input_format, const char * enkf_infile_fmt ); - - - void enkf_config_node_update_GEN_DATA_state( enkf_config_node_type * config_node, + + + void enkf_config_node_update_GEN_DATA_state( enkf_config_node_type * config_node, gen_data_file_format_type input_format, gen_data_file_format_type output_format, - const char * init_file_fmt , - const char * template_ecl_file , + const char * init_file_fmt , + const char * template_ecl_file , const char * template_data_key , const char * enkf_outfile_fmt , - const char * enkf_infile_fmt , + const char * enkf_infile_fmt , const char * min_std_file); - - + + enkf_config_node_type * enkf_config_node_new_surface( const char * key , bool forward_init); - - - void enkf_config_node_update_surface( enkf_config_node_type * config_node , - const char * base_surface , - const char * init_file_fmt , - const char * output_file , + + + void enkf_config_node_update_surface( enkf_config_node_type * config_node , + const char * base_surface , + const char * init_file_fmt , + const char * output_file , const char * min_std_file ); - - + + void enkf_config_node_update_gen_kw( enkf_config_node_type * config_node , const char * enkf_outfile_fmt , /* The include file created by ERT for the forward model. */ - const char * template_file , + const char * template_file , const char * parameter_file , const char * min_std_file , const char * init_file_fmt ); - + + void enkf_config_node_update_custom_kw(enkf_config_node_type * config_node, const char * result_file, const char * output_file); + enkf_config_node_type * enkf_config_node_alloc(enkf_var_type , ert_impl_type , bool , const char * , const char * , - const char * , - const char * , + const char * , + const char * , void * ); @@ -139,23 +142,23 @@ extern "C" { void enkf_config_node_update_state_field( enkf_config_node_type * config_node , int truncation , double value_min , double value_max ); - void enkf_config_node_update_parameter_field( enkf_config_node_type * config_node , - const char * enkf_outfile_fmt , - const char * init_file_fmt , - const char * min_std_file , + void enkf_config_node_update_parameter_field( enkf_config_node_type * config_node , + const char * enkf_outfile_fmt , + const char * init_file_fmt , + const char * min_std_file , int truncation , double value_min , double value_max , - const char * init_transform , + const char * init_transform , const char * output_transform ); - void enkf_config_node_update_general_field( enkf_config_node_type * config_node , - const char * enkf_outfile_fmt , - const char * enkf_infile_fmt , - const char * init_file_fmt , - const char * min_std_file , + void enkf_config_node_update_general_field( enkf_config_node_type * config_node , + const char * enkf_outfile_fmt , + const char * enkf_infile_fmt , + const char * init_file_fmt , + const char * min_std_file , int truncation , - double value_min , - double value_max , + double value_min , + double value_max , const char * init_transform , const char * input_transform , const char * output_transform ); @@ -167,7 +170,7 @@ extern "C" { enkf_config_node_type * enkf_config_node_new_gen_kw( const char * key , const char * tag_fmt , bool forward_init); enkf_config_node_type * enkf_config_node_alloc_field( const char * key , ecl_grid_type * ecl_grid, field_trans_table_type * trans_table, bool forward_init); bool enkf_config_node_is_valid( const enkf_config_node_type * config_node ); - int enkf_config_node_get_data_size( const enkf_config_node_type * node , int report_step); + int enkf_config_node_get_data_size( const enkf_config_node_type * node , int report_step); char * enkf_config_node_alloc_infile(const enkf_config_node_type * , int ); char * enkf_config_node_alloc_outfile(const enkf_config_node_type * , int ); int enkf_config_node_get_num_obs( const enkf_config_node_type * config_node ); @@ -193,7 +196,7 @@ extern "C" { void enkf_config_node_set_internalize(enkf_config_node_type * node, int report_step); bool enkf_config_node_internalize(const enkf_config_node_type * node, int report_step); - + void enkf_config_node_fprintf_config( const enkf_config_node_type * config_node , FILE * stream ); enkf_config_node_type * enkf_config_node_container_iget( const enkf_config_node_type * node , int index); int enkf_config_node_container_size( const enkf_config_node_type * node ); @@ -212,12 +215,13 @@ extern "C" { void enkf_config_node_set_forward_init(enkf_config_node_type * config_node, bool forward_init); /*****************************************************************/ - - void enkf_config_node_add_GEN_DATA_config_schema( config_type * config ); - void enkf_config_node_add_GEN_PARAM_config_schema( config_type * config ); + + void enkf_config_node_add_GEN_DATA_config_schema( config_parser_type * config ); + void enkf_config_node_add_CUSTOM_KW_config_schema( config_parser_type * config ); + void enkf_config_node_add_GEN_PARAM_config_schema( config_parser_type * config ); enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM_from_config( const config_content_node_type * config_node ); enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_from_config( const config_content_node_type * node ); - + UTIL_IS_INSTANCE_HEADER( enkf_config_node ); UTIL_SAFE_CAST_HEADER(enkf_config_node); VOID_FREE_HEADER(enkf_config_node); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h index 6ea901f240..f07ecf3272 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h @@ -37,7 +37,9 @@ extern "C" { #include <ert/enkf/cases_config.h> #include <ert/enkf/state_map.h> #include <ert/enkf/misfit_ensemble_typedef.h> - +#include <ert/enkf/summary_key_set.h> +#include <ert/enkf/custom_kw_config_set.h> + const char * enkf_fs_get_mount_point( const enkf_fs_type * fs ); const char * enkf_fs_get_root_path( const enkf_fs_type * fs ); const char * enkf_fs_get_case_name( const enkf_fs_type * fs ); @@ -98,12 +100,20 @@ extern "C" { FILE * enkf_fs_open_excase_tstep_file( const enkf_fs_type * fs , const char * input_name , int tstep ); FILE * enkf_fs_open_excase_member_file( const enkf_fs_type * fs , const char * input_name , int iens ); - time_map_type * enkf_fs_alloc_readonly_time_map( const char * mount_point ); - state_map_type * enkf_fs_alloc_readonly_state_map( const char * mount_point ); - state_map_type * enkf_fs_get_state_map( const enkf_fs_type * fs ); - time_map_type * enkf_fs_get_time_map( const enkf_fs_type * fs ); - cases_config_type * enkf_fs_get_cases_config( const enkf_fs_type * fs); - misfit_ensemble_type * enkf_fs_get_misfit_ensemble( const enkf_fs_type * fs ); + time_map_type * enkf_fs_alloc_readonly_time_map( const char * mount_point ); + state_map_type * enkf_fs_alloc_readonly_state_map( const char * mount_point ); + summary_key_set_type * enkf_fs_alloc_readonly_summary_key_set( const char * mount_point ); + state_map_type * enkf_fs_get_state_map( const enkf_fs_type * fs ); + time_map_type * enkf_fs_get_time_map( const enkf_fs_type * fs ); + cases_config_type * enkf_fs_get_cases_config( const enkf_fs_type * fs); + misfit_ensemble_type * enkf_fs_get_misfit_ensemble( const enkf_fs_type * fs ); + summary_key_set_type * enkf_fs_get_summary_key_set( const enkf_fs_type * fs ); + custom_kw_config_set_type * enkf_fs_get_custom_kw_config_set( const enkf_fs_type * fs ); + + void enkf_fs_increase_write_count(enkf_fs_type * fs); + void enkf_fs_decrease_write_count(enkf_fs_type * fs); + int enkf_fs_get_write_count(const enkf_fs_type * fs); + UTIL_SAFE_CAST_HEADER( enkf_fs ); UTIL_IS_INSTANCE_HEADER( enkf_fs ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_macros.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_macros.h index 693b3abb01..dc59bee84c 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_macros.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_macros.h @@ -291,14 +291,22 @@ void obs_prefix ## _measure__(const void * void_obs , const void * state , node #define VOID_MEASURE_HEADER(obs_prefix) void obs_prefix ## _measure__(const void * , const void * , node_id_type , meas_data_type * , const active_list_type *) +/*****************************************************************/ + +#define VOID_UPDATE_STD_SCALE(prefix)\ +void prefix ## _update_std_scale__( void * void_obs , double std_multiplier , const active_list_type * active_list) { \ + prefix ## _type * obs = prefix ## _safe_cast( void_obs ); \ + prefix ## _update_std_scale( obs , std_multiplier , active_list ); \ +} + +#define VOID_UPDATE_STD_SCALE_HEADER(prefix) void prefix ## _update_std_scale__(void * void_obs , double std_multiplier , const active_list_type * active_list); /*****************************************************************/ #define VOID_CHI2(obs_prefix, state_prefix) \ double obs_prefix ## _chi2__(const void * void_obs , const void * void_state, node_id_type node_id) { \ const obs_prefix ## _type * obs = obs_prefix ## _safe_cast_const( void_obs ); \ - const state_prefix ## _type * state = state_prefix ## _safe_cast_const( void_state ); \ - return obs_prefix ## _chi2(obs , state , node_id); \ + return obs_prefix ## _chi2(obs , void_state , node_id); \ } #define VOID_CHI2_HEADER(obs_prefix) double obs_prefix ## _chi2__(const void * , const void *, node_id_type); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h index 98e8c29e27..c05c042696 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_main.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_main.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ENKF_MAIN_H__ @@ -62,9 +62,9 @@ extern "C" { #include <ert/enkf/pca_plot_data.h> #include <ert/enkf/field_config.h> #include <ert/enkf/ert_run_context.h> - + /*****************************************************************/ - + typedef struct enkf_main_struct enkf_main_type; ui_return_type * enkf_main_set_eclbase( enkf_main_type * enkf_main , const char * eclbase_fmt); ui_return_type * enkf_main_set_data_file( enkf_main_type * enkf_main , const char * data_file ); @@ -88,7 +88,7 @@ extern "C" { void enkf_main_del_unused_static(enkf_main_type * , int ); const char * enkf_main_get_data_file(const enkf_main_type * ); const char ** enkf_main_get_well_list_ref(const enkf_main_type * , int *); - + bool enkf_main_get_endian_swap(const enkf_main_type * ); bool enkf_main_get_fmt_file(const enkf_main_type * ); @@ -114,12 +114,12 @@ extern "C" { bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_type init_mode, int iter); void enkf_main_run_exp(enkf_main_type * enkf_main , - bool_vector_type * iactive , + bool_vector_type * iactive , bool simulate); - + void enkf_main_run_assimilation(enkf_main_type * enkf_main , - bool_vector_type * iactive , + bool_vector_type * iactive , int init_step_parameters , int start_report , state_enum start_state); @@ -130,18 +130,18 @@ extern "C" { void enkf_main_set_state_run_path(const enkf_main_type * , int ); void enkf_main_set_state_eclbase(const enkf_main_type * , int ); void enkf_main_interactive_set_runpath__(void * ); - enkf_main_type * enkf_main_bootstrap(const char * , const char * , bool strict, bool verbose); + enkf_main_type * enkf_main_bootstrap(const char * model_config, bool strict, bool verbose); void enkf_main_create_new_config( const char * config_file , const char * storage_path , const char * case_name , const char * dbase_type , int num_realizations); - + enkf_node_type ** enkf_main_get_node_ensemble(const enkf_main_type * enkf_main , const char * key , int report_step , state_enum load_state); void enkf_main_node_mean( const enkf_node_type ** ensemble , int ens_size , enkf_node_type * mean ); void enkf_main_node_std( const enkf_node_type ** ensemble , int ens_size , const enkf_node_type * mean , enkf_node_type * std); - + ert_impl_type enkf_main_impl_type(const enkf_main_type *, const char * ); enkf_state_type * enkf_main_iget_state(const enkf_main_type * , int ); enkf_state_type ** enkf_main_get_ensemble( enkf_main_type * enkf_main); const enkf_state_type ** enkf_main_get_ensemble_const( const enkf_main_type * enkf_main); - + const enkf_config_node_type * enkf_main_get_config_node(const enkf_main_type * , const char *); const sched_file_type * enkf_main_get_sched_file(const enkf_main_type *); ranking_table_type * enkf_main_get_ranking_table( const enkf_main_type * enkf_main ); @@ -154,8 +154,7 @@ extern "C" { model_config_type * enkf_main_get_model_config( const enkf_main_type * ); local_config_type * enkf_main_get_local_config( const enkf_main_type * enkf_main ); plot_config_type * enkf_main_get_plot_config( const enkf_main_type * enkf_main ); - void enkf_main_load_obs( enkf_main_type * enkf_main , const char * obs_config_file ); - void enkf_main_reload_obs( enkf_main_type * enkf_main); + void enkf_main_load_obs( enkf_main_type * enkf_main , const char * obs_config_file , bool clear_existing); enkf_obs_type * enkf_main_get_obs(const enkf_main_type * ); bool enkf_main_have_obs( const enkf_main_type * enkf_main ); analysis_config_type * enkf_main_get_analysis_config(const enkf_main_type * ); @@ -165,28 +164,28 @@ extern "C" { const char * enkf_main_get_image_viewer(const enkf_main_type * ); const char * enkf_main_get_plot_driver(const enkf_main_type * enkf_main ); const char * enkf_main_get_image_type(const enkf_main_type * enkf_main); - - - -pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_main , - local_obsdata_type * obs_data, + + + +pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_main , + local_obsdata_type * obs_data, double truncation_or_ncomp); - + void enkf_main_list_users( set_type * users , const char * executable ); const ext_joblist_type * enkf_main_get_installed_jobs( const enkf_main_type * enkf_main ); - + subst_list_type * enkf_main_get_data_kw( const enkf_main_type * enkf_main ); void enkf_main_clear_data_kw( enkf_main_type * enkf_main ); site_config_type * enkf_main_get_site_config( const enkf_main_type * enkf_main ); void enkf_main_resize_ensemble( enkf_main_type * enkf_main , int new_ens_size ); void enkf_main_get_observations( const enkf_main_type * enkf_main, const char * user_key , int obs_count , time_t * obs_time , double * y , double * std); int enkf_main_get_observation_count( const enkf_main_type * enkf_main, const char * user_key ); - + keep_runpath_type enkf_main_iget_keep_runpath( const enkf_main_type * enkf_main , int iens ); void enkf_main_iset_keep_runpath( enkf_main_type * enkf_main , int iens , keep_runpath_type keep_runpath); - + /*****************************************************************/ void enkf_main_install_SIGNALS(void); const char * enkf_main_get_SVN_VERSION( void ); @@ -199,45 +198,45 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_ qc_module_type * enkf_main_get_qc_module( const enkf_main_type * enkf_main ); bool enkf_main_has_QC_workflow( const enkf_main_type * enkf_main ); - void enkf_main_get_PC( const matrix_type * S, + void enkf_main_get_PC( const matrix_type * S, const matrix_type * dObs, - double truncation , - int ncomp , - matrix_type * PC , + double truncation , + int ncomp , + matrix_type * PC , matrix_type * PC_obs, double_vector_type * singular_values); - - void enkf_main_init_PC( const enkf_main_type * enkf_main , - const local_obsdata_type * obsdata , - double truncation_or_ncomp , - matrix_type * PC , + + void enkf_main_init_PC( const enkf_main_type * enkf_main , + const local_obsdata_type * obsdata , + double truncation_or_ncomp , + matrix_type * PC , matrix_type * PC_obs , double_vector_type * singular_values); - - void enkf_main_fprintf_PC(const char * filename , - matrix_type * PC , + + void enkf_main_fprintf_PC(const char * filename , + matrix_type * PC , matrix_type * PC_obs); - - + + void enkf_main_set_verbose( enkf_main_type * enkf_main , bool verbose); bool enkf_main_get_verbose( const enkf_main_type * enkf_main ); ert_workflow_list_type * enkf_main_get_workflow_list( enkf_main_type * enkf_main ); void enkf_main_run_workflows( enkf_main_type * enkf_main , const stringlist_type * workflows); bool enkf_main_run_workflow( enkf_main_type * enkf_main , const char * workflow); - + enkf_main_type * enkf_main_alloc_empty( ); rng_config_type * enkf_main_get_rng_config( const enkf_main_type * enkf_main ); void enkf_main_rng_init( enkf_main_type * enkf_main); - + char * enkf_main_alloc_abs_path_to_init_file(const enkf_main_type * enkf_main, const enkf_config_node_type * enkf_config_node); bool enkf_main_export_field(const enkf_main_type * enkf_main, - const char * kw, + const char * kw, const char * path, bool_vector_type * iactive, field_file_format_type file_type, @@ -253,7 +252,7 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_ state_enum state, enkf_fs_type * fs); - + void enkf_main_load_from_forward_model_with_fs(enkf_main_type * enkf_main, int iter , const bool_vector_type * iactive, stringlist_type ** realizations_msg_list, enkf_fs_type * fs); void enkf_main_load_from_forward_model(enkf_main_type * enkf_main, int iter , const bool_vector_type * iactive, stringlist_type ** realizations_msg_list); void enkf_main_load_from_forward_model_from_gui(enkf_main_type * enkf_main, int iter , bool_vector_type * iactive, enkf_fs_type * fs); @@ -350,13 +349,13 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_ ert_run_context_type * enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT(const enkf_main_type * enkf_main , enkf_fs_type * fs , const bool_vector_type * iactive , init_mode_type init_mode , int iter); ert_run_context_type * enkf_main_alloc_ert_run_context_INIT_ONLY(const enkf_main_type * enkf_main , enkf_fs_type * fs , const bool_vector_type * iactive , init_mode_type init_mode , int iter); - ert_run_context_type * enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( const enkf_main_type * enkf_main , - enkf_fs_type * fs , + ert_run_context_type * enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( const enkf_main_type * enkf_main , + enkf_fs_type * fs , const bool_vector_type * iactive , - init_mode_type init_mode , + init_mode_type init_mode , state_enum init_state_parameter , state_enum init_state_dynamic , - int step1 , + int step1 , int step2 , int iter); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h index ccd4d50f5f..10a349b4bd 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_obs.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_obs.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ENKF_OBS_H__ @@ -37,82 +37,65 @@ extern "C" { #include <ert/enkf/obs_data.h> #include <ert/enkf/time_map.h> #include <ert/enkf/obs_vector.h> -#include <ert/enkf/local_obsset.h> #include <ert/enkf/enkf_types.h> #include <ert/enkf/local_obsdata_node.h> #include <ert/enkf/local_obsdata.h> bool enkf_obs_have_obs( const enkf_obs_type * enkf_obs ); - const char * enkf_obs_get_config_file( const enkf_obs_type * enkf_obs); - enkf_obs_type * enkf_obs_alloc( ); - + enkf_obs_type * enkf_obs_alloc( const history_type * history , + time_map_type * external_time_map , + const ecl_grid_type * grid , + const ecl_sum_type * refcase, + ensemble_config_type * ensemble_config ); + void enkf_obs_free( enkf_obs_type * enkf_obs); - + obs_vector_type * enkf_obs_iget_vector(const enkf_obs_type * obs, int index); obs_vector_type * enkf_obs_get_vector(const enkf_obs_type * , const char * ); - void enkf_obs_add_obs_vector(enkf_obs_type * enkf_obs, const char * key, const obs_vector_type * vector); - - void enkf_obs_load(enkf_obs_type * enkf_obs, - const history_type * history , - time_map_type * external_time_map, + void enkf_obs_add_obs_vector(enkf_obs_type * enkf_obs, + const obs_vector_type * vector); + + bool enkf_obs_load(enkf_obs_type * enkf_obs, const char * config_file, - const ecl_grid_type * grid , - const ecl_sum_type * refcase , - double std_cutoff , - ensemble_config_type * ensemble_config); - - void enkf_obs_reload( enkf_obs_type * enkf_obs , - const history_type * history , - time_map_type * external_time_map, - const ecl_grid_type * grid , - const ecl_sum_type * refcase , - double std_cutoff , - ensemble_config_type * ensemble_config ); - - void enkf_obs_get_obs_and_measure( - const enkf_obs_type * enkf_obs, - enkf_fs_type * fs, - const int_vector_type * step_list , - state_enum state, - const int_vector_type * ens_active_list, - meas_data_type * meas_data, - obs_data_type * obs_data, - const local_obsset_type * obsset); - - + double std_cutoff); + void enkf_obs_clear( enkf_obs_type * enkf_obs ); + void enkf_obs_get_obs_and_measure_node( const enkf_obs_type * enkf_obs, enkf_fs_type * fs, - const local_obsdata_node_type * obs_node , + const local_obsdata_node_type * obs_node , state_enum state, - const int_vector_type * ens_active_list , + const int_vector_type * ens_active_list , meas_data_type * meas_data, obs_data_type * obs_data); - + void enkf_obs_get_obs_and_measure_data(const enkf_obs_type * enkf_obs, enkf_fs_type * fs, - const local_obsdata_type * local_obsdata , + const local_obsdata_type * local_obsdata , state_enum state, - const int_vector_type * ens_active_list , + const int_vector_type * ens_active_list , meas_data_type * meas_data, obs_data_type * obs_data); stringlist_type * enkf_obs_alloc_typed_keylist( enkf_obs_type * enkf_obs , obs_impl_type ); hash_type * enkf_obs_alloc_data_map(enkf_obs_type * enkf_obs); - + const obs_vector_type * enkf_obs_user_get_vector(const enkf_obs_type * obs , const char * full_key, char ** index_key ); bool enkf_obs_has_key(const enkf_obs_type * , const char * ); int enkf_obs_get_size( const enkf_obs_type * obs ); - + hash_iter_type * enkf_obs_alloc_iter( const enkf_obs_type * enkf_obs ); stringlist_type * enkf_obs_alloc_keylist(enkf_obs_type * enkf_obs ); stringlist_type * enkf_obs_alloc_matching_keylist(const enkf_obs_type * enkf_obs , const char * input_string); time_t enkf_obs_iget_obs_time(const enkf_obs_type * enkf_obs , int report_step); - void enkf_obs_fprintf_config( const enkf_obs_type * enkf_obs , FILE * stream); void enkf_obs_scale_std(enkf_obs_type * enkf_obs, double scale_factor); - + void enkf_obs_local_scale_std( const enkf_obs_type * enkf_obs , const local_obsdata_type * local_obsdata, double scale_factor); + void enkf_obs_add_local_nodes_with_data(const enkf_obs_type * enkf_obs , local_obsdata_type * local_obs , enkf_fs_type *fs , const bool_vector_type * ens_mask); + double enkf_obs_scale_correlated_std(const enkf_obs_type * enkf_obs , enkf_fs_type * fs , const int_vector_type * ens_active_list , const local_obsdata_type * local_obsdata); + local_obsdata_type * enkf_obs_alloc_all_active_local_obs( const enkf_obs_type * enkf_obs , const char * key); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h index 822d9cdff9..8b4c3e8eed 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h @@ -106,6 +106,7 @@ typedef struct enkf_state_struct enkf_state_type; void enkf_state_update_eclbase( enkf_state_type * enkf_state ); void enkf_state_invalidate_cache( enkf_state_type * enkf_state ); void enkf_state_add_node(enkf_state_type * , const char * , const enkf_config_node_type * ); + enkf_node_type * enkf_state_get_or_create_node(enkf_state_type * enkf_state, const enkf_config_node_type * config_node); void enkf_state_load_ecl_restart(enkf_state_type * , bool , int ); void enkf_state_sample(enkf_state_type * , int); void enkf_state_fwrite(const enkf_state_type * , enkf_fs_type * fs , int , int , state_enum ); @@ -123,7 +124,8 @@ typedef struct enkf_state_struct enkf_state_type; rng_type * enkf_state_get_rng( const enkf_state_type * enkf_state ); unsigned int enkf_state_get_random( enkf_state_type * enkf_state ); - run_status_type enkf_state_get_simple_run_status(const enkf_state_type * state); + run_status_type enkf_state_get_simple_run_status(const enkf_state_type * state); + void enkf_state_add_subst_kw(enkf_state_type * enkf_state , const char * kw , const char * value , const char * doc_string); /******************************************************************/ /* Forward model callbacks: */ diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h index 05a3841c46..1a9fb27f9b 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_types.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_types.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ENKF_TYPES_H__ @@ -43,7 +43,7 @@ extern "C" { typedef enum { ACTIVE = 1, LOCAL_INACTIVE = 2, /* Not active in current local update scheme. */ - DEACTIVATED = 3, /* Deactivaed due to to small overlap, or... */ + DEACTIVATED = 3, /* Deactivaed due to to small overlap, or... */ MISSING = 4} active_type; /* Set as missing by the forward model. */ @@ -62,11 +62,11 @@ typedef enum {INVALID_VAR = 0 , /* */ PARAMETER = 1 , /* A parameter which is updated with enkf: PORO , MULTFLT , ..*/ DYNAMIC_STATE = 2 , /* Dynamic data which are needed for a restart - i.e. pressure and saturations. */ DYNAMIC_RESULT = 4 , /* Dynamic results which are NOT needed for a restart - i.e. well rates. */ - STATIC_STATE = 8 , /* Keywords like XCON++ from eclipse restart files - which are just dragged along */ - INDEX_STATE = 16 } /* Index data - enum value is used for storage classification */ -enkf_var_type; - - + STATIC_STATE = 8 , /* Keywords like XCON++ from eclipse restart files - which are just dragged along */ + INDEX_STATE = 16 } /* Index data - enum value is used for storage classification */ +enkf_var_type; + + typedef enum { DEFAULT_KEEP = 0, /* Remove for enkf assimilation - keep for ensemble experiments. */ EXPLICIT_DELETE = 1, /* Remove unconditionally */ @@ -77,7 +77,7 @@ keep_runpath_type; -/* +/* ert_impl_type are the actual node implementation types. Observe that one ert_impl_type can be used in several ways as enkf_var_type. For instance the pressure is implemented with a @@ -91,20 +91,21 @@ keep_runpath_type; */ - -typedef enum {INVALID = 0 , - IMPL_TYPE_OFFSET = 100, - STATIC = 100 , /* MULTZ has been removed & MULTFLT */ + +typedef enum {INVALID = 0 , + IMPL_TYPE_OFFSET = 100 , + STATIC = 100 , /* MULTZ has been removed & MULTFLT */ FIELD = 104 , /* WELL has been removed */ GEN_KW = 107 , /* RELPERM has been removed & HAVANA_FAULT */ + CUSTOM_KW = 108 , SUMMARY = 110 , /* TPGZONE has been removed */ GEN_DATA = 113 , /* PILOT_POINT has been removed */ SURFACE = 114 , CONTAINER = 115 } ert_impl_type; - - -/* + + +/* Should update the functions enkf_types_get_impl_name() and enkf_types_get_impl_type__() when this enum is updated. In addition to enkf_config_add_type(). @@ -125,18 +126,18 @@ typedef enum {UNDEFINED = 0 , {.value = 6 , .name = "BOTH"} #define ENKF_STATE_ENUM_SIZE 4 - - + + typedef enum { REPORT_STEP_INCOMPATIBLE = 1, LOAD_FAILURE = 2} enkf_fw_load_result_enum; - - /** + + /** These are 2^n bitmasks. */ @@ -150,13 +151,13 @@ typedef enum { TRUNCATE_NONE = 0, /** This enum is used to differentiate between different types of run. The point is that depending on this mode we can be more or - less restrictive on the amount of input we require from the user. + less restrictive on the amount of input we require from the user. In mode enkf_assimlation ( which is the default ), we require quite a lot of info, whereas in the case screening_experiment we require less. - screening_experiment: + screening_experiment: - SIZE - RUNPATH - ECLBASE @@ -173,14 +174,14 @@ typedef enum { TRUNCATE_NONE = 0, */ -typedef enum { ENKF_ASSIMILATION = 1, +typedef enum { ENKF_ASSIMILATION = 1, ENSEMBLE_EXPERIMENT = 2, SMOOTHER_UPDATE = 4 , INIT_ONLY = 8 } run_mode_type; - + #define ENKF_RUN_ENUM_DEFS {.value = 1 , .name = "ENKF_ASSIMILATION"}, \ - {.value = 2 , .name = "ENSEMBLE_EXPERIMENT"} + {.value = 2 , .name = "ENSEMBLE_EXPERIMENT"} #define ENKF_RUN_ENUM_SIZE 2 @@ -205,7 +206,7 @@ typedef enum { ENKF_ASSIMILATION = 1, JOB_RUN_FAILURE = 2, JOB_LOAD_FAILURE = 3, JOB_RUN_OK = 4 } run_status_type; - + /*****************************************************************/ @@ -223,16 +224,16 @@ typedef enum { ALL_ACTIVE = 1, /* The variable/observation is fully active, i.e. all cells/all faults/all .. */ INACTIVE = 2, /* Fully inactive */ PARTLY_ACTIVE = 3 /* Partly active - must supply additonal type spesific information on what is active.*/ -} active_mode_type; +} active_mode_type; + - typedef struct { int report_step; - int iens; + int iens; state_enum state; } node_id_type; - - + + /*****************************************************************/ /* Possible transitions: */ @@ -250,12 +251,12 @@ typedef enum { INIT_CONDITIONAL = 1, INIT_FORCE = 2 } init_mode_type; - + typedef struct enkf_obs_struct enkf_obs_type; - + const char * enkf_types_get_var_name(enkf_var_type var_type); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h index 3c71f6d541..6bcaed9216 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h @@ -1,26 +1,26 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ensemble_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ensemble_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ENSEMBLE_CONFIG_H__ #define __ENSEMBLE_CONFIG_H__ #ifdef __cplusplus extern "C" { -#endif +#endif #include <stdbool.h> #include <ert/util/stringlist.h> @@ -28,11 +28,14 @@ extern "C" { #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_sum.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/enkf/summary_config.h> #include <ert/enkf/enkf_config_node.h> #include <ert/enkf/enkf_types.h> +#include <ert/enkf/summary_key_matcher.h> +#include <ert/enkf/custom_kw_config_set.h> @@ -47,9 +50,12 @@ typedef struct ensemble_config_struct ensemble_config_type; void ensemble_config_add_node( ensemble_config_type * ensemble_config , enkf_config_node_type * node); enkf_config_node_type * ensemble_config_add_gen_data( ensemble_config_type * config , const char * key , bool dynamic , bool forward_init); enkf_config_node_type * ensemble_config_add_summary(ensemble_config_type * ensemble_config , const char * key, load_fail_type load_fail); + enkf_config_node_type * ensemble_config_add_summary_observation(ensemble_config_type * ensemble_config , const char * key, load_fail_type load_fail); enkf_config_node_type * ensemble_config_add_gen_kw( ensemble_config_type * config , const char * key , bool forward_init); + enkf_config_node_type * ensemble_config_add_custom_kw(ensemble_config_type * config, const char * key, const char * result_file, const char * output_file); + void ensemble_config_update_custom_kw_config(ensemble_config_type * config, custom_kw_config_set_type * config_set); enkf_config_node_type * ensemble_config_add_field( ensemble_config_type * config , const char * key , ecl_grid_type * ecl_grid , bool forward_init); - int ensemble_config_get_observations( const ensemble_config_type * config , enkf_obs_type * enkf_obs , const char * user_key , int obs_count , + int ensemble_config_get_observations( const ensemble_config_type * config , enkf_obs_type * enkf_obs , const char * user_key , int obs_count , time_t * obs_time , double * y , double * std); void ensemble_config_ensure_static_key(ensemble_config_type * ensemble_config , const char * kw ); void ensemble_config_clear_obs_keys(ensemble_config_type * ensemble_config); @@ -57,29 +63,31 @@ typedef struct ensemble_config_struct ensemble_config_type; const enkf_config_node_type * ensemble_config_user_get_node(const ensemble_config_type * , const char * , char **); ert_impl_type ensemble_config_impl_type(const ensemble_config_type *, const char * ); enkf_var_type ensemble_config_var_type(const ensemble_config_type *, const char * ); - void ensemble_config_init(ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid , const ecl_sum_type * refcase); + void ensemble_config_init(ensemble_config_type * ensemble_config , const config_content_type * config , ecl_grid_type * grid , const ecl_sum_type * refcase); void ensemble_config_free(ensemble_config_type * ); bool ensemble_config_has_key(const ensemble_config_type * , const char * ); - bool ensemble_config_has_impl_type(const ensemble_config_type * config, const ert_impl_type impl_type); + bool ensemble_config_has_impl_type(const ensemble_config_type * config, const ert_impl_type impl_type); bool ensemble_config_have_forward_init( const ensemble_config_type * ensemble_config ); - + void ensemble_config_del_node(ensemble_config_type * , const char * ); - void ensemble_config_add_config_items(config_type * ); + void ensemble_config_add_config_items(config_parser_type * ); + + void ensemble_config_init_GEN_PARAM( ensemble_config_type * ensemble_config , const config_content_type * config ); - void ensemble_config_init_GEN_PARAM( ensemble_config_type * ensemble_config , const config_type * config ); + enkf_config_node_type * ensemble_config_get_node(const ensemble_config_type * , const char * ); + enkf_config_node_type * ensemble_config_get_or_create_summary_node(ensemble_config_type * ensemble_config, const char * key); + stringlist_type * ensemble_config_alloc_keylist(const ensemble_config_type *); + stringlist_type * ensemble_config_alloc_keylist_from_var_type(const ensemble_config_type * , int var_mask); + stringlist_type * ensemble_config_alloc_keylist_from_impl_type(const ensemble_config_type *, ert_impl_type); + bool ensemble_config_iget_keep_runpath(const ensemble_config_type * , int ); + ensemble_config_type * ensemble_config_alloc( ); + void ensemble_config_fprintf_config( ensemble_config_type * ensemble_config , FILE * stream ); + const summary_key_matcher_type * ensemble_config_get_summary_key_matcher(const ensemble_config_type * ensemble_config); - enkf_config_node_type * ensemble_config_get_node(const ensemble_config_type * , const char * ); - stringlist_type * ensemble_config_alloc_keylist(const ensemble_config_type *); - stringlist_type * ensemble_config_alloc_keylist_from_var_type(const ensemble_config_type * , int var_mask); - stringlist_type * ensemble_config_alloc_keylist_from_impl_type(const ensemble_config_type * , ert_impl_type ); - bool ensemble_config_iget_keep_runpath(const ensemble_config_type * , int ); - ensemble_config_type * ensemble_config_alloc( ); - void ensemble_config_fprintf_config( ensemble_config_type * ensemble_config , FILE * stream ); + enkf_config_node_type * ensemble_config_add_STATIC_node(ensemble_config_type * , const char * ); + int ensemble_config_get_size(const ensemble_config_type * ensemble_config ); - enkf_config_node_type * ensemble_config_add_STATIC_node(ensemble_config_type * , - const char * ); - UTIL_IS_INSTANCE_HEADER( ensemble_config ); UTIL_SAFE_CAST_HEADER( ensemble_config ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h index 679f54263e..c96bd01251 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_report_list.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_report_list.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -25,10 +25,11 @@ extern "C" { #endif #include <stdbool.h> -#include <ert/ecl/ecl_sum.h> +#include <ert/ecl/ecl_sum.h> + +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> -#include <ert/config/config.h> - typedef struct ert_report_list_struct ert_report_list_type; ert_report_list_type * ert_report_list_alloc(const char * target_path, const char * plot_path ); @@ -41,14 +42,14 @@ extern "C" { void ert_report_list_add_groups( ert_report_list_type * report_list , const ecl_sum_type * ecl_sum , const char * group_pattern ); void ert_report_list_add_wells( ert_report_list_type * report_list , const ecl_sum_type * ecl_sum , const char * well_pattern ); void ert_report_list_add_global_context( ert_report_list_type * report_list , const char * key , const char * value); - void ert_report_list_site_init( ert_report_list_type * report_list , config_type * config ); - void ert_report_list_init( ert_report_list_type * report_list , config_type * config , const ecl_sum_type * refcase); + void ert_report_list_site_init( ert_report_list_type * report_list , config_content_type * config ); + void ert_report_list_init( ert_report_list_type * report_list , config_content_type * config , const ecl_sum_type * refcase); void ert_report_list_create( ert_report_list_type * report_list , const char * current_case , bool verbose ); - void ert_report_list_add_config_items( config_type * config ); + void ert_report_list_add_config_items( config_parser_type * config ); int ert_report_list_get_latex_timeout( const ert_report_list_type * report_list ); bool ert_report_list_get_init_large_report( const ert_report_list_type * report_list ); void ert_report_list_set_init_large_report( ert_report_list_type * report_list , bool init_large_report); - + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_run_context.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_run_context.h index f848b5186b..2d862b8329 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_run_context.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_run_context.h @@ -67,6 +67,9 @@ typedef struct ert_run_context_struct ert_run_context_type; subst_list_type * subst_list , init_mode_type init_mode , int iter); + void ert_run_context_set_init_fs(ert_run_context_type * context, enkf_fs_type * init_fs); + void ert_run_context_set_result_fs(ert_run_context_type * context, enkf_fs_type * result_fs); + void ert_run_context_set_update_target_fs(ert_run_context_type * context, enkf_fs_type * update_target_fs); void ert_run_context_free( ert_run_context_type * ); int ert_run_context_get_size( const ert_run_context_type * context ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h index d6c5c6be91..63d10a1a7c 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ert_template.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ert_template.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ERT_TEMPLATE_H__ @@ -26,7 +26,8 @@ extern "C" { #include <ert/util/subst_list.h> #include <ert/util/stringlist.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> typedef struct ert_template_struct ert_template_type; typedef struct ert_templates_struct ert_templates_type; @@ -35,7 +36,7 @@ typedef struct ert_templates_struct ert_templates_type; stringlist_type * ert_templates_alloc_list( ert_templates_type * ert_templates); ert_template_type * ert_template_alloc( const char * template_file , const char * target_file, subst_list_type * parent_subst) ; void ert_template_free( ert_template_type * ert_tamplete ); -void ert_template_instantiate( ert_template_type * ert_template , const char * path , const subst_list_type * arg_list ); +void ert_template_instantiate( ert_template_type * ert_template , const char * path , const subst_list_type * arg_list ); void ert_template_add_arg( ert_template_type * ert_template , const char * key , const char * value ); void ert_template_free__(void * arg); @@ -52,7 +53,7 @@ const char * ert_template_get_template_file( const ert_template_type * e const char * ert_template_get_target_file( const ert_template_type * ert_template); const char * ert_template_get_args_as_string( const ert_template_type * ert_template ); void ert_templates_fprintf_config( const ert_templates_type * ert_templates , FILE * stream ); -void ert_templates_init( ert_templates_type * templates , const config_type * config ); +void ert_templates_init( ert_templates_type * templates , const config_content_type * config ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_test_context.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_test_context.h index 01890edb92..4dfacef55d 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_test_context.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_test_context.h @@ -1,20 +1,20 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - + Copyright (C) 2014 Statoil ASA, Norway. + The file 'ert_test_context.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef ERT_TEST_CONTEXT_H @@ -26,15 +26,15 @@ #include <ert/enkf/enkf_main.h> -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif typedef struct ert_test_context_struct ert_test_context_type; void ert_test_context_set_store( ert_test_context_type * test_context , bool store); -ert_test_context_type * ert_test_context_alloc( const char * test_name , const char * model_config , const char * site_config); -ert_test_context_type * ert_test_context_alloc_python( const char * test_name , const char * model_config , const char * site_config); +ert_test_context_type * ert_test_context_alloc( const char * test_name , const char * model_config); +ert_test_context_type * ert_test_context_alloc_python( const char * test_name , const char * model_config); void ert_test_context_free( ert_test_context_type * test_context ); enkf_main_type * ert_test_context_get_main( ert_test_context_type * test_context ); bool ert_test_context_install_workflow_job( ert_test_context_type * test_context , const char * job_name , const char * job_file); @@ -46,7 +46,7 @@ const char * ert_test_context_get_cwd( const ert_test_context_type * UTIL_IS_INSTANCE_HEADER( ert_test_context ); -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h index e40b52c0ad..c93bab264b 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_workflow_list.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_workflow_list.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __ERT_WORKFLOW_LIST_H__ @@ -27,7 +27,8 @@ extern "C" { #include <ert/util/subst_list.h> #include <ert/util/type_macros.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/config/config_error.h> #include <ert/job_queue/workflow.h> @@ -35,7 +36,7 @@ extern "C" { typedef struct ert_workflow_list_struct ert_workflow_list_type; - + workflow_type * ert_workflow_list_get_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name ); workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflow_list , const char * workflow_file , const char * workflow_name); void ert_workflow_list_free( ert_workflow_list_type * workflow_list ); @@ -44,9 +45,10 @@ extern "C" { void ert_workflow_list_add_job( ert_workflow_list_type * workflow_list , const char * job_name , const char * config_file ); bool ert_workflow_list_has_job( const ert_workflow_list_type * workflow_list , const char * job_name); const workflow_job_type * ert_workflow_list_get_job( const ert_workflow_list_type * workflow_list , const char * job_name); + stringlist_type * ert_workflow_list_get_job_names(const ert_workflow_list_type * workflow_list); void ert_workflow_list_add_alias( ert_workflow_list_type * workflow_list , const char * real_name , const char * alias); - void ert_workflow_list_add_config_items( config_type * config ); - void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_type * config ); + void ert_workflow_list_add_config_items( config_parser_type * config ); + void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_content_type * config ); bool ert_workflow_list_run_workflow(ert_workflow_list_type * workflow_list, const char * workflow_name , void * self); bool ert_workflow_list_run_workflow__(ert_workflow_list_type * workflow_list, workflow_type * workflow, bool verbose , void * self); bool ert_workflow_list_has_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name ); @@ -57,6 +59,7 @@ extern "C" { const subst_list_type * ert_workflow_list_get_context(const ert_workflow_list_type * workflow_list); int ert_workflow_list_get_size( const ert_workflow_list_type * workflow_list); + UTIL_IS_INSTANCE_HEADER( ert_workflow_list ); #ifdef __cplusplus diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data.h index c5f23173f3..3181d098e0 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'gen_data.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'gen_data.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __GEN_DATA_H__ diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data_config.h index 118053ec78..56d48bdfc1 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_data_config.h @@ -1,24 +1,24 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'gen_data_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'gen_data_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __GEN_DATA_CONFIG_H__ #define __GEN_DATA_CONFIG_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif #include <stdbool.h> @@ -32,11 +32,11 @@ extern "C" { #include <ert/enkf/enkf_macros.h> #include <ert/enkf/gen_data_common.h> -typedef enum { GEN_DATA_UNDEFINED = 0, +typedef enum { GEN_DATA_UNDEFINED = 0, ASCII = 1, /* The file is ASCII file with a vector of numbers formatted with "%g". */ ASCII_TEMPLATE = 2, /* The data is inserted into a user defined template file. */ BINARY_DOUBLE = 3, /* The data is in a binary file with doubles. */ - BINARY_FLOAT = 4} /* The data is in a binary file with floats. */ + BINARY_FLOAT = 4} /* The data is in a binary file with floats. */ gen_data_file_format_type; bool gen_data_config_is_dynamic( const gen_data_config_type * config ); @@ -45,8 +45,8 @@ typedef enum { GEN_DATA_UNDEFINED = 0, bool gen_data_config_set_template( gen_data_config_type * config , const char * template_ecl_file , const char * template_data_key ); bool gen_data_config_has_active_mask( const gen_data_config_type * config , enkf_fs_type * fs , int report_step); - - /* + + /* Observe that the format ASCII_template can *NOT* be used for loading files. */ @@ -81,14 +81,14 @@ typedef enum { GEN_DATA_UNDEFINED = 0, int gen_data_config_num_report_step( const gen_data_config_type * config ); const char * gen_data_config_get_template_file( const gen_data_config_type * config ); const char * gen_data_config_get_template_key( const gen_data_config_type * config ); - void gen_data_config_fprintf_config( const gen_data_config_type * config , enkf_var_type var_type , const char * outfile , const char * infile , + void gen_data_config_fprintf_config( const gen_data_config_type * config , enkf_var_type var_type , const char * outfile , const char * infile , const char * min_std_file , FILE * stream); UTIL_IS_INSTANCE_HEADER(gen_data_config); UTIL_SAFE_CAST_HEADER(gen_data_config); UTIL_SAFE_CAST_HEADER_CONST(gen_data_config); VOID_FREE_HEADER(gen_data_config) - + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_obs.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_obs.h index dc65df4a06..a8a7fa32ef 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_obs.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/gen_obs.h @@ -23,18 +23,26 @@ #include <ert/enkf/enkf_macros.h> #include <ert/enkf/gen_data_config.h> #include <ert/enkf/obs_data.h> +#include <ert/enkf/active_list.h> typedef struct gen_obs_struct gen_obs_type; gen_obs_type * gen_obs_alloc(gen_data_config_type * config , const char * obs_key , const char * , double , double , const char * , const char * , const char * ); void gen_obs_user_get_with_data_index(const gen_obs_type * gen_obs , const char * index_key , double * value , double * std , bool * valid); -void gen_obs_scale_std(gen_obs_type * gen_obs, double std_multiplier ); -void gen_obs_scale_std__(void * gen_obs, double std_multiplier ); +void gen_obs_update_std_scale(gen_obs_type * gen_obs, double std_multiplier , const active_list_type * active_list); int gen_obs_get_size(const gen_obs_type * gen_obs); double gen_obs_iget_std(const gen_obs_type * gen_obs, int index); -double gen_obs_iget_data(const gen_obs_type * gen_obs, int index); +double gen_obs_iget_value(const gen_obs_type * gen_obs, int index); +double gen_obs_iget_std_scaling(const gen_obs_type * gen_obs, int index); int gen_obs_get_obs_index(const gen_obs_type * gen_obs, int index); +void gen_obs_load_observation(gen_obs_type * gen_obs, const char * obs_file); +void gen_obs_set_scalar( gen_obs_type * gen_obs , double scalar_value , double scalar_std); +void gen_obs_attach_data_index( gen_obs_type * gen_obs , const int_vector_type * data_index ); +void gen_obs_load_data_index( gen_obs_type * obs , const char * data_index_file); +void gen_obs_parse_data_index( gen_obs_type * obs , const char * data_index_string); + + VOID_CHI2_HEADER(gen_obs); @@ -43,5 +51,6 @@ VOID_FREE_HEADER(gen_obs); VOID_GET_OBS_HEADER(gen_obs); VOID_MEASURE_HEADER(gen_obs); VOID_USER_GET_OBS_HEADER(gen_obs); +VOID_UPDATE_STD_SCALE_HEADER(gen_obs); #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h index 0dc49fb512..76cbb69fb0 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'local_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'local_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __LOCAL_CONFIG_H__ @@ -40,13 +40,13 @@ typedef enum { ATTACH_MINISTEP = 3, /* UPDATESTEP_NAME , MINISTEP_NAME -> local_updatestep_add_ministep(); */ CREATE_DATASET = 4, /* NAME */ ATTACH_DATASET = 5, /* DATASET_NAME MINISETP_NAME */ - CREATE_OBSSET = 6, /* NAME */ + CREATE_OBSSET = 6, /* NAME */ ADD_DATA = 7, /* DATA_KEY -> local_ministep_add_node(); */ ADD_OBS = 8, /* OBS_KEY -> local_ministep_add_obs(); */ ACTIVE_LIST_ADD_OBS_INDEX = 9, /* OBS_KEY , ACTIVE_INDEX */ ACTIVE_LIST_ADD_DATA_INDEX = 10, /* DATA_KEY , ACTIVE_INDEX */ ACTIVE_LIST_ADD_MANY_OBS_INDEX = 11, /* OBS_KEY , NUM_INDEX , INDEX1, INDEX2, INDEX3,... */ - ACTIVE_LIST_ADD_MANY_DATA_INDEX = 12, /* DATA_KEY , NUM_INDEX , INDEX1 , INDEX2 , INDEX3 ,... */ + ACTIVE_LIST_ADD_MANY_DATA_INDEX = 12, /* DATA_KEY , NUM_INDEX , INDEX1 , INDEX2 , INDEX3 ,... */ INSTALL_UPDATESTEP = 13, /* UPDATESTEP_NAME , STEP1 , STEP2 local_config_set_updatestep() */ INSTALL_DEFAULT_UPDATESTEP = 14, /* UPDATETSTEP_NAME local_config_set_default_updatestep() */ DEL_DATA = 16, /* DATASET KEY*/ @@ -58,15 +58,15 @@ typedef enum { COPY_OBSSET = 22, /* SRC_NAME TARGET_NAME */ /*****************************************************************/ CREATE_ECLREGION = 100, /* Name of region TRUE|FALSE*/ - LOAD_FILE = 101, /* Key, filename */ + LOAD_FILE = 101, /* Key, filename */ ECLREGION_SELECT_ALL = 102, /* Region TRUE|FALSE */ ECLREGION_SELECT_VALUE_EQUAL = 103, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */ - ECLREGION_SELECT_VALUE_LESS = 104, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */ - ECLREGION_SELECT_VALUE_MORE = 105, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */ + ECLREGION_SELECT_VALUE_LESS = 104, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */ + ECLREGION_SELECT_VALUE_MORE = 105, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */ ECLREGION_SELECT_BOX = 106, /* Region i1 i2 j1 j2 k1 k2 TRUE|FALSE */ ECLREGION_SELECT_SLICE = 107, /* Region dir n1 n2 TRUE|FALSE */ ECLREGION_SELECT_PLANE = 108, /* Region nx ny nz px py pz sign TRUE|FALSE */ - ECLREGION_SELECT_IN_POLYGON = 109, /* Region num_points p1x p12 p2x p2y p3x p3y ... pnx pny TRUE|FALSE */ + ECLREGION_SELECT_IN_POLYGON = 109, /* Region num_points p1x p12 p2x p2y p3x p3y ... pnx pny TRUE|FALSE */ /*****************************************************************/ CREATE_POLYGON = 200,/* NAME NUM_POINTS x1 y1 x2 y2 x3 y3 ... xn yn */ LOAD_POLYGON = 201,/* NAME FILENAME */ @@ -75,8 +75,8 @@ typedef enum { CREATE_SURFACE_REGION = 301, SURFACE_REGION_SELECT_IN_POLYGON = 302, SURFACE_REGION_SELECT_LINE = 303, - ADD_DATA_SURFACE = 304 -} local_config_instruction_type; + ADD_DATA_SURFACE = 304 +} local_config_instruction_type; @@ -88,7 +88,7 @@ typedef enum { #define ATTACH_DATASET_STRING "ATTACH_DATASET" #define CREATE_OBSSET_STRING "CREATE_OBSSET" #define ADD_DATA_STRING "ADD_DATA" -#define ADD_OBS_STRING "ADD_OBS" +#define ADD_OBS_STRING "ADD_OBS" #define ACTIVE_LIST_ADD_OBS_INDEX_STRING "ACTIVE_LIST_ADD_OBS_INDEX" #define ACTIVE_LIST_ADD_DATA_INDEX_STRING "ACTIVE_LIST_ADD_DATA_INDEX" #define ACTIVE_LIST_ADD_MANY_OBS_INDEX_STRING "ACTIVE_LIST_ADD_MANY_OBS_INDEX" @@ -104,18 +104,18 @@ typedef enum { #define COPY_OBSSET_STRING "COPY_OBSSET" #define CREATE_ECLREGION_STRING "CREATE_ECLREGION" #define LOAD_FILE_STRING "LOAD_FILE" -#define ECLREGION_SELECT_ALL_STRING "ECLREGION_SELECT_ALL" +#define ECLREGION_SELECT_ALL_STRING "ECLREGION_SELECT_ALL" #define ECLREGION_SELECT_VALUE_EQUAL_STRING "ECLREGION_SELECT_VALUE_EQUAL" #define ECLREGION_SELECT_VALUE_LESS_STRING "ECLREGION_SELECT_VALUE_LESS" #define ECLREGION_SELECT_VALUE_MORE_STRING "ECLREGION_SELECT_VALUE_MORE" -#define ECLREGION_SELECT_BOX_STRING "ECLREGION_SELECT_BOX" -#define ECLREGION_SELECT_SLICE_STRING "ECLREGION_SELECT_SLICE" +#define ECLREGION_SELECT_BOX_STRING "ECLREGION_SELECT_BOX" +#define ECLREGION_SELECT_SLICE_STRING "ECLREGION_SELECT_SLICE" #define ECLREGION_SELECT_PLANE_STRING "ECLREGION_SELECT_PLANE" #define ECLREGION_SELECT_IN_POLYGON_STRING "ECLREGION_SELECT_IN_POLYGON" #define CREATE_POLYGON_STRING "CREATE_POLYGON" #define LOAD_POLYGON_STRING "LOAD_POLYGON" -#define LOAD_SURFACE_STRING "LOAD_SURFACE" -#define CREATE_SURFACE_REGION_STRING "CREATE_SURFACE_REGION" +#define LOAD_SURFACE_STRING "LOAD_SURFACE" +#define CREATE_SURFACE_REGION_STRING "CREATE_SURFACE_REGION" #define SURFACE_REGION_SELECT_IN_POLYGON_STRING "SURFACE_REGION_SELECT_IN_POLYGON" #define SURFACE_REGION_SELECT_LINE_STRING "SURFACE_REGION_SELECT_LINE" #define ADD_DATA_SURFACE_STRING "ADD_DATA_SURFACE" @@ -133,7 +133,7 @@ const local_updatestep_type * local_config_iget_updatestep( const local_config_t local_updatestep_type * local_config_get_updatestep( const local_config_type * local_config , const char * key); local_ministep_type * local_config_get_ministep( const local_config_type * local_config , const char * key); void local_config_set_updatestep(local_config_type * local_config, int step1 , int step2 , const char * key); -void local_config_reload( local_config_type * local_config , const ecl_grid_type * ecl_grid , const ensemble_config_type * ensemble_config , const enkf_obs_type * enkf_obs , +void local_config_reload( local_config_type * local_config , const ecl_grid_type * ecl_grid , const ensemble_config_type * ensemble_config , const enkf_obs_type * enkf_obs , const char * all_active_config_file); const char * local_config_get_cmd_string( local_config_instruction_type cmd ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_dataset.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_dataset.h index 21955ce618..2a8d2d59fa 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_dataset.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_dataset.h @@ -38,7 +38,10 @@ void local_dataset_fprintf( const local_dataset_type * dataset , active_list_type * local_dataset_get_node_active_list(const local_dataset_type * dataset , const char * node_key ); stringlist_type * local_dataset_alloc_keys( const local_dataset_type * dataset ); int local_dataset_get_size( const local_dataset_type * dataset ); +void local_dataset_del_node( local_dataset_type * dataset , const char * node_key); +void local_dataset_clear( local_dataset_type * dataset); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_ministep.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_ministep.h index eafe78f494..d09177fc17 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_ministep.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_ministep.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'local_ministep.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'local_ministep.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __LOCAL_MINISTEP_H__ @@ -28,12 +28,11 @@ extern "C" { #include <ert/enkf/active_list.h> #include <ert/enkf/local_dataset.h> -#include <ert/enkf/local_obsset.h> - +#include <ert/enkf/local_obsdata.h> typedef struct local_ministep_struct local_ministep_type; -local_ministep_type * local_ministep_alloc(const char * name , local_obsset_type * observations); +local_ministep_type * local_ministep_alloc(const char * name , local_obsdata_type * observations); void local_ministep_free(local_ministep_type * ministep); void local_ministep_free__(void * arg); void local_ministep_add_obs(local_ministep_type * ministep, const char * obs_key); @@ -47,7 +46,7 @@ void local_ministep_clear_nodes( local_ministep_type * ministep void local_ministep_clear_observations( local_ministep_type * ministep); void local_ministep_fprintf( const local_ministep_type * ministep , FILE * stream ); void local_ministep_add_dataset( local_ministep_type * ministep , const local_dataset_type * dataset); -local_obsset_type * local_ministep_get_obsset(const local_ministep_type * ministep); +local_obsdata_type * local_ministep_get_obsdata(const local_ministep_type * ministep); local_dataset_type * local_ministep_get_dataset( const local_ministep_type * ministep, const char * dataset_name); UTIL_SAFE_CAST_HEADER(local_ministep); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata.h index 88f1303c5e..dcb2ae5d14 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - + Copyright (C) 2013 Statoil ASA, Norway. + The file 'local_obsdata.h' - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __LOCAL_OBSDATA_H__ #define __LOCAL_OBSDATA_H__ @@ -29,14 +29,20 @@ extern "C" { typedef struct local_obsdata_struct local_obsdata_type; + void local_obsdata_free__( void * arg); bool local_obsdata_has_node( const local_obsdata_type * data , const char * key); + local_obsdata_type * local_obsdata_alloc_copy( const local_obsdata_type * src, const char * target_key); local_obsdata_type * local_obsdata_alloc( const char * name ); void local_obsdata_free( local_obsdata_type * data ); int local_obsdata_get_size( const local_obsdata_type * data ); bool local_obsdata_add_node( local_obsdata_type * data , local_obsdata_node_type * node ); - const local_obsdata_node_type * local_obsdata_iget( const local_obsdata_type * data , int index); + local_obsdata_node_type * local_obsdata_iget( const local_obsdata_type * data , int index); local_obsdata_type * local_obsdata_alloc_wrapper( local_obsdata_node_type * node ); const char * local_obsdata_get_name( const local_obsdata_type * data); + local_obsdata_node_type * local_obsdata_get( const local_obsdata_type * data , const char * key); + void local_obsdata_clear( local_obsdata_type * data ); + void local_obsdata_del_node( local_obsdata_type * data , const char * key); + void local_obsdata_reset_tstep_list( local_obsdata_type * data , const int_vector_type * step_list); UTIL_IS_INSTANCE_HEADER( local_obsdata ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata_node.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata_node.h index 387b2ee6f6..d8f4d450fe 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata_node.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata_node.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - + Copyright (C) 2013 Statoil ASA, Norway. + The file 'local_obsdata_node.h' - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __LOCAL_OBSDATA_NODE_H__ #define __LOCAL_OBSDATA_NODE_H__ @@ -23,24 +23,29 @@ extern "C" { #endif #include <ert/util/type_macros.h> +#include <ert/util/int_vector.h> -#include <ert/enkf/obs_tstep_list.h> #include <ert/enkf/active_list.h> typedef struct local_obsdata_node_struct local_obsdata_node_type; - + local_obsdata_node_type * local_obsdata_node_alloc( const char * obs_key ); + local_obsdata_node_type * local_obsdata_node_alloc_copy( const local_obsdata_node_type * src); const char * local_obsdata_node_get_key( const local_obsdata_node_type * node ); void local_obsdata_node_free( local_obsdata_node_type * node ); void local_obsdata_node_free__( void * arg ); active_list_type * local_obsdata_node_get_active_list( const local_obsdata_node_type * node ); - const obs_tstep_list_type * local_obsdata_node_get_tstep_list( const local_obsdata_node_type * node); void local_obsdata_node_copy_active_list( local_obsdata_node_type * node , const active_list_type * active_list); void local_obsdata_node_add_tstep( local_obsdata_node_type * node, int tstep); void local_obsdata_node_add_range( local_obsdata_node_type * node, int step1, int step2); - -UTIL_IS_INSTANCE_HEADER( local_obsdata_node ); + const int_vector_type * local_obsdata_node_get_tstep_list( const local_obsdata_node_type * node); + bool local_obsdata_node_all_timestep_active( const local_obsdata_node_type * node); + bool local_obsdata_node_has_tstep( const local_obsdata_node_type * node , int tstep); + void local_obsdata_node_reset_tstep_list( local_obsdata_node_type * node , const int_vector_type * step_list); + + UTIL_IS_INSTANCE_HEADER( local_obsdata_node ); + UTIL_SAFE_CAST_HEADER( local_obsdata_node ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsset.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsset.h deleted file mode 100644 index 5c5ddf0524..0000000000 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsset.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'local_obsset.h' - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. -*/ -#ifndef __LOCAL_OBSSET_H__ -#define __LOCAL_OBSSET_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> - -#include <ert/enkf/active_list.h> - -typedef struct local_obsset_struct local_obsset_type; - -local_obsset_type * local_obsset_alloc( const char * name ); -local_obsset_type * local_obsset_alloc_copy( local_obsset_type * src_dataset , const char * copy_name ); -void local_obsset_free( local_obsset_type * obsset ); -void local_obsset_free__( void * arg ); -void local_obsset_add_obs(local_obsset_type * obsset, const char * obs_key); -void local_obsset_del_obs( local_obsset_type * obsset , const char * obs_key); -const char * local_obsset_get_name( const local_obsset_type * obsset ); -void local_obsset_fprintf(local_obsset_type * obsset , FILE * stream); -active_list_type * local_obsset_get_obs_active_list( const local_obsset_type * obsset , const char * obs_key ); -hash_iter_type * local_obsset_alloc_obs_iter( const local_obsset_type * obsset ); -void local_obsset_clear( local_obsset_type * obsset ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_updatestep.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_updatestep.h index 47c9253e5b..324a69f5c3 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_updatestep.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_updatestep.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'local_updatestep.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'local_updatestep.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __LOCAL_UPDATESTEP_H__ @@ -24,6 +24,7 @@ extern "C" { #endif #include <ert/enkf/local_ministep.h> +#include <ert/enkf/local_obsdata.h> typedef struct local_updatestep_struct local_updatestep_type; @@ -31,7 +32,7 @@ local_updatestep_type * local_updatestep_alloc( const char * name ); void local_updatestep_free__(void * arg); void local_updatestep_add_ministep( local_updatestep_type * updatestep , local_ministep_type * ministep); local_ministep_type * local_updatestep_iget_ministep( const local_updatestep_type * updatestep , int index); -local_obsset_type * local_updatestep_iget_obsset( const local_updatestep_type * updatestep , int index); +local_obsdata_type * local_updatestep_iget_obsdata( const local_updatestep_type * updatestep , int index); int local_updatestep_get_num_ministep( const local_updatestep_type * updatestep ); local_updatestep_type * local_updatestep_alloc_copy( const local_updatestep_type * src , const char * name ); void local_updatestep_fprintf( const local_updatestep_type * updatestep , FILE * stream); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/meas_data.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/meas_data.h index d201f7f8c5..562ffd8c48 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/meas_data.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/meas_data.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'meas_data.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'meas_data.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __MEAS_DATA_H__ @@ -27,36 +27,39 @@ extern "C" { #include <ert/util/matrix.h> #include <ert/util/hash.h> -#include <ert/util/int_vector.h> +#include <ert/util/bool_vector.h> #include <ert/util/type_macros.h> typedef struct meas_data_struct meas_data_type; -typedef struct meas_block_struct meas_block_type; +typedef struct meas_block_struct meas_block_type; - UTIL_IS_INSTANCE_HEADER( meas_data ); +UTIL_IS_INSTANCE_HEADER( meas_data ); +UTIL_SAFE_CAST_HEADER( meas_block ); +bool meas_block_iens_active( const meas_block_type * meas_block , int iens); void meas_block_iset( meas_block_type * meas_block , int iens , int iobs , double value); -double meas_block_iget_ens_mean( const meas_block_type * meas_block , int iobs ); -double meas_block_iget_ens_std( const meas_block_type * meas_block , int iobs); -void meas_block_deactivate( meas_block_type * meas_block , int iobs ); - +double meas_block_iget( const meas_block_type * meas_block , int iens , int iobs); +double meas_block_iget_ens_mean( meas_block_type * meas_block , int iobs ); +double meas_block_iget_ens_std( meas_block_type * meas_block , int iobs); +void meas_block_deactivate( meas_block_type * meas_block , int iobs ); +bool meas_block_iget_active( const meas_block_type * meas_block , int iobs); void meas_data_fprintf( const meas_data_type * matrix , FILE * stream); - void meas_data_reset(meas_data_type * ); - meas_data_type * meas_data_alloc( const int_vector_type * ens_active_list ); +void meas_data_reset(meas_data_type * ); + meas_data_type * meas_data_alloc( const bool_vector_type * ens_mask); void meas_data_free(meas_data_type * ); void meas_data_add(meas_data_type * , int , double ); -matrix_type * meas_data_allocS(const meas_data_type * matrix , int active_size); +matrix_type * meas_data_allocS(const meas_data_type * matrix); +int meas_data_get_active_obs_size( const meas_data_type * matrix ); void meas_data_deactivate(meas_data_type * meas_data, int index); -int meas_data_get_ens_size( const meas_data_type * meas_data ); +int meas_data_get_active_ens_size( const meas_data_type * meas_data ); int meas_data_get_nrobs( const meas_data_type * meas_data ); meas_block_type * meas_data_add_block( meas_data_type * matrix , const char * obs_key , int report_step , int obs_size); -meas_block_type * meas_data_iget_block( meas_data_type * matrix , int block_mnr); +int meas_data_get_num_blocks( const meas_data_type * meas_block ); +meas_block_type * meas_data_iget_block( const meas_data_type * matrix , int block_mnr); const meas_block_type * meas_data_iget_block_const( const meas_data_type * matrix , int block_nr ); -void meas_block_calculate_ens_stats( meas_block_type * meas_block ); -int meas_block_get_total_size( const meas_block_type * meas_block ); -bool meas_block_iget_active( const meas_block_type * meas_block , int iobs); -void meas_data_assign_vector(meas_data_type * target_matrix, const meas_data_type * src_matrix , int target_index , int src_index); +int meas_block_get_total_obs_size( const meas_block_type * meas_block ); + #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/model_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/model_config.h index 3308090ca6..8d193253e0 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/model_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/model_config.h @@ -1,24 +1,24 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'model_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'model_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __MODEL_CONFIG_H__ #define __MODEL_CONFIG_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -28,7 +28,8 @@ extern "C" { #include <ert/util/path_fmt.h> #include <ert/util/type_macros.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/job_queue/ext_joblist.h> #include <ert/job_queue/forward_model.h> @@ -57,7 +58,7 @@ extern "C" { const char * model_config_get_enspath( const model_config_type * model_config); const char * model_config_get_rftpath( const model_config_type * model_config); fs_driver_impl model_config_get_dbase_type(const model_config_type * model_config ); - const ecl_sum_type * model_config_get_refcase( const model_config_type * model_config ); + const ecl_sum_type * model_config_get_refcase( const model_config_type * model_config ); void model_config_init_internalization( model_config_type * ); void model_config_set_internalize_state( model_config_type * , int ); void model_config_set_load_state( model_config_type * , int ); @@ -66,7 +67,7 @@ extern "C" { bool model_config_has_history(const model_config_type * config); int model_config_get_last_history_restart(const model_config_type * ); time_map_type * model_config_get_external_time_map( const model_config_type * config); - void model_config_init(model_config_type * model_config , const config_type * , int ens_size , const ext_joblist_type * , int , const sched_file_type * , const ecl_sum_type * refcase); + void model_config_init(model_config_type * model_config , const config_content_type * , int ens_size , const ext_joblist_type * , int , const sched_file_type * , const ecl_sum_type * refcase); void model_config_free(model_config_type *); bool model_config_runpath_requires_iter( const model_config_type * model_config ); path_fmt_type * model_config_get_runpath_fmt(const model_config_type * ); @@ -95,7 +96,7 @@ extern "C" { UTIL_IS_INSTANCE_HEADER( model_config); -#ifdef __cplusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_data.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_data.h index 34e618f45d..db56079675 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_data.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_data.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'obs_data.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'obs_data.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __OBS_DATA_H__ @@ -54,20 +54,20 @@ const obs_block_type * obs_data_iget_block_const( const obs_data_type * obs_ obs_block_type * obs_data_get_block( obs_data_type * obs_data , const char * obs_key ); obs_block_type * obs_data_add_block( obs_data_type * obs_data , const char * obs_key , int obs_size , matrix_type * error_covar , bool error_covar_owner); -obs_data_type * obs_data_alloc(); +obs_data_type * obs_data_alloc(double global_std_scaling); void obs_data_free(obs_data_type *); void obs_data_reset(obs_data_type * obs_data); matrix_type * obs_data_allocD(const obs_data_type * obs_data , const matrix_type * E , const matrix_type * S); -matrix_type * obs_data_allocR(const obs_data_type * obs_data , int active_size ); -matrix_type * obs_data_allocdObs(const obs_data_type * obs_data , int active_size ); +matrix_type * obs_data_allocR(const obs_data_type * obs_data ); +matrix_type * obs_data_allocdObs(const obs_data_type * obs_data ); //matrix_type * obs_data_alloc_innov(const obs_data_type * obs_data , const meas_data_type * meas_data , int active_size); -matrix_type * obs_data_allocE(const obs_data_type * obs_data , rng_type * rng , int ens_size, int active_size); -matrix_type * obs_data_allocE_non_centred(const obs_data_type * obs_data , rng_type * rng , int ens_size, int active_size); +matrix_type * obs_data_allocE(const obs_data_type * obs_data , rng_type * rng , int active_ens_size); +matrix_type * obs_data_allocE_non_centred(const obs_data_type * obs_data , rng_type * rng , int ens_size); void obs_data_scale(const obs_data_type * obs_data , matrix_type *S , matrix_type *E , matrix_type *D , matrix_type *R , matrix_type * O); void obs_data_scale_kernel(const obs_data_type * obs_data , matrix_type *S , matrix_type *E , matrix_type *D , double *dObs); void obs_data_fprintf(const obs_data_type * , const meas_data_type * meas_data , FILE *); void obs_data_iget_value_std(const obs_data_type * obs_data , int index , double * value , double * std); -int obs_data_get_active_size( obs_data_type * obs_data ); +int obs_data_get_active_size(const obs_data_type * obs_data ); int obs_data_get_num_blocks( const obs_data_type * obs_data ); const char * obs_block_get_key( const obs_block_type * obs_block) ; diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_tstep_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_tstep_list.h deleted file mode 100644 index 414ec8c8e2..0000000000 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_tstep_list.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'obs_tstep_list.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. -*/ - -#ifndef __OBS_TSTEP_LIST_H__ -#define __OBS_TSTEP_LIST_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdbool.h> - -#include <ert/util/type_macros.h> - - typedef struct obs_tstep_list_struct obs_tstep_list_type; - - obs_tstep_list_type * obs_tstep_list_alloc(); - void obs_tstep_list_free( obs_tstep_list_type * list ); - bool obs_tstep_list_all_active( const obs_tstep_list_type * list ); - int obs_tstep_list_get_size( const obs_tstep_list_type * list ); - void obs_tstep_list_add_tstep( obs_tstep_list_type * list , int tstep); - void obs_tstep_list_add_range( obs_tstep_list_type * list , int step1 , int step2); - bool obs_tstep_list_contains( const obs_tstep_list_type * list , int tstep); - int obs_tstep_list_iget( const obs_tstep_list_type * list , int index); - int obs_tstep_list_get_last( const obs_tstep_list_type * list ); - - UTIL_IS_INSTANCE_HEADER( obs_tstep_list ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_vector.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_vector.h index 6ac5c22e85..281579e0cf 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_vector.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_vector.h @@ -1,31 +1,32 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'obs_vector.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'obs_vector.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __OBS_VECTOR_H__ #define __OBS_VECTOR_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif #include <time.h> #include <ert/util/bool_vector.h> +#include <ert/util/int_vector.h> #include <ert/sched/history.h> @@ -42,21 +43,23 @@ extern "C" { #include <ert/enkf/enkf_macros.h> #include <ert/enkf/active_list.h> #include <ert/enkf/time_map.h> +#include <ert/enkf/local_obsdata_node.h> + typedef void (obs_free_ftype) (void *); typedef void (obs_get_ftype) (const void * , obs_data_type * , enkf_fs_type *, int , const active_list_type * ); typedef void (obs_meas_ftype) (const void * , const void *, node_id_type , meas_data_type * , const active_list_type * ); - typedef void (obs_user_get_ftype) (void * , const char * , double * , double * , bool *); - typedef void (obs_scale_std_ftype) (void * , double ); + typedef void (obs_user_get_ftype) (void * , const char * , double * , double * , bool *); + typedef void (obs_update_std_scale_ftype) (void * , double , const active_list_type * ); typedef double (obs_chi2_ftype) (const void * , const void *, node_id_type ); typedef enum { GEN_OBS = 1, SUMMARY_OBS = 2, BLOCK_OBS = 3} obs_impl_type; - + typedef struct obs_vector_struct obs_vector_type; - - + + void obs_vector_clear_nodes( obs_vector_type * obs_vector ); void obs_vector_del_node(obs_vector_type * obs_vector , int index); void obs_vector_free(obs_vector_type * ); @@ -69,6 +72,7 @@ extern "C" { const char * obs_vector_get_key(const obs_vector_type * ); obs_impl_type obs_vector_get_impl_type(const obs_vector_type * ); int obs_vector_get_active_report_step(const obs_vector_type * ); + const int_vector_type * obs_vector_get_step_list(const obs_vector_type * vector); void obs_vector_user_get(const obs_vector_type * obs_vector , const char * index_key , int report_step , double * value , double * std , bool * valid); int obs_vector_get_next_active_step(const obs_vector_type * , int ); void * obs_vector_iget_node(const obs_vector_type * , int ); @@ -78,29 +82,33 @@ extern "C" { obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_type * , const ecl_grid_type * grid , time_map_type * obs_time , const ecl_sum_type * refcase , ensemble_config_type * ); void obs_vector_set_config_node(obs_vector_type * , const enkf_config_node_type * ); obs_vector_type * obs_vector_alloc(obs_impl_type obs_type , const char * obs_key , enkf_config_node_type * config_node, int num_reports); - void obs_vector_scale_std(obs_vector_type * obs_vector, double std_multiplier); + void obs_vector_scale_std(obs_vector_type * obs_vector, const local_obsdata_node_type * local_node , double std_multiplier); void obs_vector_install_node(obs_vector_type * obs_vector , int obs_index , void * node ); double obs_vector_chi2(const obs_vector_type * , enkf_fs_type * , node_id_type node_id); - - void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector , - enkf_fs_type * fs, - bool_vector_type * valid , - int step1 , int step2 , - int iens1 , int iens2 , - state_enum load_state , + + void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector , + enkf_fs_type * fs, + bool_vector_type * valid , + int step1 , int step2 , + int iens1 , int iens2 , + state_enum load_state , double ** chi2); double obs_vector_total_chi2(const obs_vector_type * , enkf_fs_type * , int , state_enum ); void obs_vector_ensemble_total_chi2(const obs_vector_type * , enkf_fs_type * , int , state_enum , double * ); enkf_config_node_type * obs_vector_get_config_node(const obs_vector_type * ); const char * obs_vector_get_obs_key( const obs_vector_type * obs_vector); + local_obsdata_node_type * obs_vector_alloc_local_node(const obs_vector_type * obs_vector); - UTIL_SAFE_CAST_HEADER(obs_vector); - VOID_FREE_HEADER(obs_vector); -#ifdef __cplusplus + UTIL_IS_INSTANCE_HEADER(obs_vector); + UTIL_SAFE_CAST_HEADER(obs_vector); + VOID_FREE_HEADER(obs_vector); + + +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h index 9e275d9e94..e257ea1bfd 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h @@ -1,24 +1,27 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'plot_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'plot_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __PLOT_CONFIG_H__ #define __PLOT_CONFIG_H__ -#include <ert/config/config.h> + +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> + #include <ert/ecl/ecl_sum.h> typedef struct plot_config_struct plot_config_type; @@ -44,9 +47,9 @@ const char * plot_config_get_viewer(const plot_config_type * plot_config ) const char * plot_config_get_driver(const plot_config_type * plot_config ); void plot_config_free( plot_config_type * plot_config); plot_config_type * plot_config_alloc_default(); -void plot_config_init(plot_config_type * plot_config , const config_type * config ); +void plot_config_init(plot_config_type * plot_config , const config_content_type * config ); -void plot_config_add_config_items( config_type * config ); +void plot_config_add_config_items( config_parser_type * config ); void plot_config_show_viewer_warning( plot_config_type * plot_config ); void plot_config_toggle_logy( plot_config_type * plot_config ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h index 3fc40f20fe..7033a7e069 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h @@ -1,28 +1,28 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'qc_module.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'qc_module.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __QC_MODULE_H__ #define __QC_MODULE_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/enkf/ert_workflow_list.h> #include <ert/enkf/runpath_list.h> @@ -37,15 +37,15 @@ extern "C" { runpath_list_type * qc_module_get_runpath_list( qc_module_type * qc_module ); void qc_module_set_path( qc_module_type * qc_module , const char * qc_path); const char * qc_module_get_path( const qc_module_type * qc_module ); - void qc_module_init( qc_module_type * qc_module , const config_type * config); + void qc_module_init( qc_module_type * qc_module , const config_content_type * config); void qc_module_export_runpath_list( const qc_module_type * qc_module ); - void qc_module_add_config_items( config_type * config ); + void qc_module_add_config_items( config_parser_type * config ); void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * path, const char * filename); const char * qc_module_get_runpath_list_file(const qc_module_type * qc_module); -#ifdef __cplusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h index 2cadae1901..6392ca6b6e 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h @@ -1,36 +1,37 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'rng_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'rng_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __RNG_CONFIG_H__ #define __RNG_CONFIG_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif #include <ert/util/rng.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> -typedef struct rng_config_struct rng_config_type; +typedef struct rng_config_struct rng_config_type; void rng_config_fprintf_config( rng_config_type * rng_config , FILE * stream ); - void rng_config_init( rng_config_type * rng_config , config_type * config ); + void rng_config_init( rng_config_type * rng_config , config_content_type * config ); void rng_config_set_type( rng_config_type * rng_config , rng_alg_type type); rng_alg_type rng_config_get_type(const rng_config_type * rng_config ); const char * rng_config_get_seed_load_file( const rng_config_type * rng_config ); @@ -39,11 +40,11 @@ typedef struct rng_config_struct rng_config_type; void rng_config_set_seed_store_file( rng_config_type * rng_config , const char * seed_store_file); rng_config_type * rng_config_alloc( ); void rng_config_free( rng_config_type * rng); - void rng_config_add_config_items( config_type * config ); + void rng_config_add_config_items( config_parser_type * config ); rng_type * rng_config_alloc_init_rng( const rng_config_type * rng_config); void rng_config_init_rng(const rng_config_type * rng_config, rng_type * rng ); -#ifdef __cplusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/run_arg.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/run_arg.h index 5b65c7c1b1..6eb5a8f88a 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/run_arg.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/run_arg.h @@ -53,7 +53,6 @@ UTIL_IS_INSTANCE_HEADER( run_arg ); state_enum run_arg_get_dynamic_init_state( const run_arg_type * run_arg ); state_enum run_arg_get_parameter_init_state( const run_arg_type * run_arg ); int run_arg_get_parameter_init_step( const run_arg_type * run_arg ); - bool run_arg_is_ready( const run_arg_type * run_arg); int run_arg_get_step1( const run_arg_type * run_arg ); int run_arg_get_step2( const run_arg_type * run_arg ); run_mode_type run_arg_get_run_mode( const run_arg_type * run_arg ); @@ -63,8 +62,6 @@ UTIL_IS_INSTANCE_HEADER( run_arg ); void run_arg_increase_submit_count( run_arg_type * run_arg ); void run_arg_set_queue_index( run_arg_type * run_arg , int queue_index); - void run_arg_set_ready( run_arg_type * run_arg , bool ready); - void run_arg_free(run_arg_type * run_arg); void run_arg_free__(void * arg); const char * run_arg_get_runpath( const run_arg_type * run_arg); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h index 2caf29209b..e8c28a8de9 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h @@ -35,6 +35,8 @@ extern "C" { void runpath_list_sort( runpath_list_type * list ); int runpath_list_iget_iens( runpath_list_type * list , int index); int runpath_list_iget_iter( runpath_list_type * list , int index); + char * runpath_list_iget_runpath( runpath_list_type * list , int index); + char * runpath_list_iget_basename( runpath_list_type * list , int index); void runpath_list_set_line_fmt( runpath_list_type * list , const char * line_fmt ); const char * runpath_list_get_line_fmt( const runpath_list_type * list ); void runpath_list_fprintf( runpath_list_type * list); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h index 87ff1a2e27..83f2b06346 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'site_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'site_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __SITE_CONFIG_H__ @@ -26,7 +26,8 @@ extern "C" { #include <ert/util/stringlist.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/job_queue/job_queue.h> #include <ert/job_queue/ext_joblist.h> @@ -35,24 +36,26 @@ extern "C" { typedef struct site_config_struct site_config_type; + const char * site_config_get_location(); + bool site_config_has_job_script( const site_config_type * site_config ); const char * site_config_get_manual_url( const site_config_type * site_config ); void site_config_set_manual_url( site_config_type * site_config , const char * manual_url ); const char * site_config_get_default_browser( const site_config_type * site_config ); void site_config_set_default_browser( site_config_type * site_config , const char * default_browser ); - + const char * site_config_get_license_root_path( const site_config_type * site_config ); void site_config_set_license_root_path( site_config_type * site_config , const char * license_root_path); void site_config_init_user_mode( site_config_type * site_config ); - + void site_config_set_num_cpu( site_config_type * site_config , int num_cpu ); void site_config_update_lsf_request(site_config_type * , const forward_model_type *); - bool site_config_init(site_config_type * site_config , const config_type * config); - void site_config_free(site_config_type *); + bool site_config_init(site_config_type * site_config , const config_content_type * config); + void site_config_free(site_config_type *); ext_joblist_type * site_config_get_installed_jobs( const site_config_type * ); job_queue_type * site_config_get_job_queue( const site_config_type * ); void site_config_set_ens_size( site_config_type * site_config , int ens_size ); - + void site_config_set_max_running_lsf( site_config_type * site_config , int max_running_lsf); int site_config_get_max_running_lsf( const site_config_type * site_config ); void site_config_set_max_running_rsh( site_config_type * site_config , int max_running_rsh); @@ -65,40 +68,41 @@ typedef struct site_config_struct site_config_type; void site_config_clear_pathvar( site_config_type * site_config ); stringlist_type * site_config_get_path_variables( const site_config_type * site_config ); stringlist_type * site_config_get_path_values( const site_config_type * site_config ); - + void site_config_clear_rsh_host_list( site_config_type * site_config ); hash_type * site_config_get_rsh_host_list( const site_config_type * site_config ); void site_config_add_rsh_host( site_config_type * site_config , const char * rsh_host , int max_running); - + void site_config_set_lsf_queue( site_config_type * site_config , const char * lsf_queue); const char * site_config_get_lsf_queue( const site_config_type * site_config ); void site_config_set_lsf_request( site_config_type * site_config , const char * lsf_request); const char * site_config_get_lsf_request( const site_config_type * site_config ); - + const char * site_config_get_job_queue_name( const site_config_type * site_config ); void site_config_set_job_queue( site_config_type * site_config , const char * queue_name ); - + void site_config_set_rsh_command( site_config_type * site_config , const char * rsh_command); const char * site_config_get_rsh_command( const site_config_type * site_config ); - - + void site_config_set_ext_job_search_path(site_config_type * site_config, bool search_path); + + bool site_config_set_job_script( site_config_type * site_config , const char * job_script ); const char * site_config_get_job_script( const site_config_type * site_config ); - + void site_config_set_max_submit( site_config_type * site_config , int max_submit ); int site_config_get_max_submit(const site_config_type * site_config ); - + bool site_config_queue_is_running( const site_config_type * site_config ); int site_config_install_job(site_config_type * site_config , const char * job_name , const char * install_file); bool site_config_del_job( site_config_type * site_config , const char * job_name ); - + void site_config_set_umask( site_config_type * site_config , mode_t umask); mode_t site_config_get_umask( const site_config_type * site_config ); void site_config_fprintf_config( const site_config_type * site_config , FILE * stream ); - + site_config_type * site_config_alloc_empty(); - void site_config_add_config_items( config_type * config , bool site_mode); + void site_config_add_config_items( config_parser_type * config , bool site_mode); #ifdef __cplusplus } #endif -#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_config.h index ccea682f1c..63cae2fcf6 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_config.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'summary_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'summary_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __SUMMARY_CONFIG_H__ @@ -50,7 +50,7 @@ typedef enum { LOAD_FAIL_SILENT = 0, // We just try to load - and if it is typedef struct summary_config_struct summary_config_type; typedef struct summary_struct summary_type; - + void summary_config_update_load_fail_mode( summary_config_type * config , load_fail_type load_fail); void summary_config_set_load_fail_mode( summary_config_type * config , load_fail_type load_fail); load_fail_type summary_config_get_load_fail_mode( const summary_config_type * config); @@ -70,15 +70,15 @@ typedef enum { LOAD_FAIL_SILENT = 0, // We just try to load - and if it is void summary_config_summarize(const summary_config_type * ); void summary_config_add_obs_key(summary_config_type * , const char * ); int summary_config_get_byte_size(const summary_config_type * ); - + UTIL_IS_INSTANCE_HEADER(summary_config); UTIL_SAFE_CAST_HEADER(summary_config); UTIL_SAFE_CAST_HEADER_CONST(summary_config); GET_DATA_SIZE_HEADER(summary); VOID_GET_DATA_SIZE_HEADER(summary); VOID_CONFIG_FREE_HEADER(summary); - - + + #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_key_matcher.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_key_matcher.h new file mode 100644 index 0000000000..db707b342f --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_key_matcher.h @@ -0,0 +1,28 @@ +#ifndef __SUMMARY_KEY_MATCHER_H__ +#define __SUMMARY_KEY_MATCHER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <ert/util/type_macros.h> +#include <ert/util/stringlist.h> + +#include <ert/enkf/enkf_types.h> + + typedef struct summary_key_matcher_struct summary_key_matcher_type; + + summary_key_matcher_type * summary_key_matcher_alloc(); + void summary_key_matcher_free(summary_key_matcher_type * matcher); + int summary_key_matcher_get_size(const summary_key_matcher_type * matcher); + void summary_key_matcher_add_summary_key(summary_key_matcher_type * matcher, const char * summary_key); + bool summary_key_matcher_match_summary_key(const summary_key_matcher_type * matcher, const char * summary_key); + bool summary_key_matcher_summary_key_is_required(const summary_key_matcher_type * matcher, const char * summary_key); + stringlist_type * summary_key_matcher_get_keys(const summary_key_matcher_type * matcher); + + UTIL_IS_INSTANCE_HEADER( summary_key_matcher ); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_key_set.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_key_set.h new file mode 100644 index 0000000000..c9f1f3080b --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_key_set.h @@ -0,0 +1,34 @@ +#ifndef __SUMMARY_KEY_SET_H__ +#define __SUMMARY_KEY_SET_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <ert/util/type_macros.h> + +#include <ert/enkf/enkf_types.h> + + typedef struct summary_key_set_struct summary_key_set_type; + + summary_key_set_type * summary_key_set_alloc(); + summary_key_set_type * summary_key_set_alloc_from_file(const char * filename, bool read_only); + void summary_key_set_free(summary_key_set_type * set); + int summary_key_set_get_size(summary_key_set_type * set); + bool summary_key_set_add_summary_key(summary_key_set_type * set, const char * summary_key); + bool summary_key_set_has_summary_key(summary_key_set_type * set, const char * summary_key); + stringlist_type * summary_key_set_get_keys(summary_key_set_type * set); + bool summary_key_set_is_read_only(const summary_key_set_type * set); + + void summary_key_set_fwrite(summary_key_set_type * set, const char * filename); + bool summary_key_set_fread(summary_key_set_type * set, const char * filename); + + + + UTIL_IS_INSTANCE_HEADER( summary_key_set ); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_obs.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_obs.h index b446800aab..fcf1254c58 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_obs.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/summary_obs.h @@ -57,9 +57,10 @@ summary_obs_type * summary_obs_alloc( double auto_corrf_param); -double summary_obs_get_value( const summary_obs_type * summary_obs ); -double summary_obs_get_std( const summary_obs_type * summary_obs ); - + double summary_obs_get_value( const summary_obs_type * summary_obs ); + double summary_obs_get_std( const summary_obs_type * summary_obs ); + double summary_obs_get_std_scaling( const summary_obs_type * summary_obs ); + auto_corrf_ftype * summary_obs_get_auto_corrf( const summary_obs_type * summary_obs ); double summary_obs_get_auto_corrf_param( const summary_obs_type * summary_obs ); @@ -80,8 +81,7 @@ summary_obs_type * summary_obs_alloc_from_SUMMARY_OBSERVATION( void summary_obs_set(summary_obs_type * , double , double ); -void summary_obs_scale_std(summary_obs_type * summary_obs, double std_multiplier ); -void summary_obs_scale_std__(void * summary_obs, double std_multiplier ); +void summary_obs_update_std_scale(summary_obs_type * summary_obs, double std_multiplier , const active_list_type * active_list); VOID_FREE_HEADER(summary_obs); VOID_GET_OBS_HEADER(summary_obs); @@ -89,6 +89,7 @@ VOID_MEASURE_HEADER(summary_obs); UTIL_IS_INSTANCE_HEADER(summary_obs); VOID_USER_GET_OBS_HEADER(summary_obs); VOID_CHI2_HEADER(summary_obs); +VOID_UPDATE_STD_SCALE_HEADER(summary_obs); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h index e10b2bf7d5..e5491b6a13 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h @@ -1,25 +1,25 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - The file 'time_map.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + The file 'time_map.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __TIME_MAP_H__ #define __TIME_MAP_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { -#endif +#endif #include <time.h> @@ -60,8 +60,8 @@ typedef struct time_map_struct time_map_type; int_vector_type * time_map_alloc_index_map( time_map_type * map , const ecl_sum_type * ecl_sum ); int time_map_lookup_time( time_map_type * map , time_t time); int time_map_lookup_days( time_map_type * map , double sim_days); - -#ifdef __cplusplus + int time_map_lookup_time_with_tolerance( time_map_type * map , time_t time , int seconds_before_tolerance, int seconds_after_tolerance); +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/trans_func.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/trans_func.h index 23543b7485..0b40a90590 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/trans_func.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/trans_func.h @@ -33,7 +33,7 @@ typedef struct trans_func_struct trans_func_type; typedef double (transform_ftype) (double , const arg_pack_type *); typedef bool (validate_ftype) (const trans_func_type * ); -trans_func_type * trans_func_fscanf_alloc( FILE * stream ); +trans_func_type * trans_func_fscanf_alloc( FILE * stream, const char * filename ); double trans_func_eval( const trans_func_type * trans_func , double x); void trans_func_free( trans_func_type * trans_func ); diff --git a/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt b/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt index 99e7a8178d..f261889a39 100644 --- a/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt @@ -58,7 +58,6 @@ set( source_files enkf_analysis.c enkf_main.c local_dataset.c - local_obsset.c surface.c surface_config.c enkf_plot_data.c @@ -76,16 +75,21 @@ set( source_files ecl_refcase_list.c local_obsdata_node.c local_obsdata.c - obs_tstep_list.c pca_plot_data.c pca_plot_vector.c state_map.c cases_config.c - state_map.c + state_map.c + summary_key_set.c + summary_key_matcher.c ert_test_context.c ert_log.c run_arg.c - ert_run_context.c) + ert_run_context.c + custom_kw.c + custom_kw_config.c + custom_kw_config_set.c + ) set( header_files ert_report.h @@ -155,7 +159,6 @@ set( header_files enkf_defaults.h container_config.h local_dataset.h - local_obsset.h surface.h surface_config.h local_context.h @@ -173,22 +176,28 @@ set( header_files ecl_refcase_list.h local_obsdata_node.h local_obsdata.h - obs_tstep_list.h pca_plot_data.h pca_plot_vector.h - state_map.h - cases_config.h + state_map.h + summary_key_set.h + summary_key_matcher.h + cases_config.h state_map.h ert_test_context.h ert_log.h run_arg.h - ert_run_context.h) + ert_run_context.h + custom_kw.h + custom_kw_config.h + custom_kw_config_set.h + ) add_library( enkf ${LIBRARY_TYPE} ${source_files} ) set_target_properties( enkf PROPERTIES VERSION 1.0 SOVERSION 1.0 ) - +set( SITE_CONFIG_FILE /project/res/etc/ERT/site-config CACHE FILEPATH "Path to global ERT Configuration file") +set_source_files_properties( site_config.c PROPERTIES COMPILE_DEFINITIONS "SITE_CONFIG_FILE=\"${SITE_CONFIG_FILE}\"") #configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CMake/config/ert_build_info.h.in # ${CMAKE_CURRENT_BINARY_DIR}/ert_build_info.h ) diff --git a/ThirdParty/Ert/devel/libenkf/src/active_list.c b/ThirdParty/Ert/devel/libenkf/src/active_list.c index f0581bf3b2..77e20efda9 100644 --- a/ThirdParty/Ert/devel/libenkf/src/active_list.c +++ b/ThirdParty/Ert/devel/libenkf/src/active_list.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'active_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'active_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -31,8 +31,8 @@ elements of a node/observation which is active. At the lowest level the active elements in a node is just a list of integers. This list of integers, with som extra twists is what is implemented - here. - + here. + All the xxx_config objects have a pointer to an active_list instance. This pointer is passed to the enkf_serialize / enkf_deserialize routines. @@ -57,7 +57,7 @@ a fault object. Then the code will be like: .... When this fault object is serialized/deserialized only the elements - 0,4,5 are updated. + 0,4,5 are updated. */ @@ -191,7 +191,7 @@ const int * active_list_get_active(const active_list_type * active_list) { if (active_list->mode == PARTLY_ACTIVE) return int_vector_get_const_ptr( active_list->index_list ); else - return NULL; + return NULL; } @@ -200,7 +200,7 @@ bool active_list_iget( const active_list_type * active_list , int index ) { return true; else if (active_list->mode == INACTIVE) return false; - else + else return int_vector_iget( active_list->index_list , index ); } @@ -214,7 +214,7 @@ void active_list_fprintf( const active_list_type * active_list , bool obs , cons fprintf(stream , "%s %s %d\n" , local_config_get_cmd_string( ACTIVE_LIST_ADD_MANY_OBS_INDEX ) , key , int_vector_size( active_list->index_list )); else fprintf(stream , "%s %s %d\n" , local_config_get_cmd_string( ACTIVE_LIST_ADD_MANY_OBS_INDEX ) , key , int_vector_size( active_list->index_list )); - + for (i = 0; i < int_vector_size( active_list->index_list ); i++) { fprintf(stream , "%6d " , int_vector_iget( active_list->index_list , i)); if ((i % 10) == 9) diff --git a/ThirdParty/Ert/devel/libenkf/src/analysis_config.c b/ThirdParty/Ert/devel/libenkf/src/analysis_config.c index 23c23d09c9..953a08daf7 100644 --- a/ThirdParty/Ert/devel/libenkf/src/analysis_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/analysis_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'analysis_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'analysis_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -26,7 +26,8 @@ #include <ert/util/rng.h> #include <ert/util/type_macros.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/analysis/analysis_module.h> @@ -55,14 +56,15 @@ struct analysis_config_struct { char * PC_path; bool store_PC; bool update_results; /* Should result values like e.g. WWCT be updated? */ - bool single_node_update; /* When creating the default ALL_ACTIVE local configuration. */ - rng_type * rng; + bool single_node_update; /* When creating the default ALL_ACTIVE local configuration. */ + rng_type * rng; analysis_iter_config_type * iter_config; - int min_realisations; + int min_realisations; bool stop_long_running; - int max_runtime; - -}; + bool std_scale_correlated_obs; + int max_runtime; + double global_std_scaling; +}; @@ -70,7 +72,7 @@ struct analysis_config_struct { UTIL_IS_INSTANCE_FUNCTION( analysis_config , ANALYSIS_CONFIG_TYPE_ID ) /*****************************************************************/ -/* +/* Interacting with modules ------------------------ @@ -83,7 +85,7 @@ are loaded with the config statement: Where 'ModuleName is the name you want to use to refer to the module, and libfile is the name of the library file which implements the analysis -module[1]. +module[1]. It is possible to create a copy of an analysis module under a different name, this can be convenient when trying out the same algorithm with @@ -113,7 +115,7 @@ ANALYSIS_SELECT ModuleName optionally contain a path component. The libfile will be passed directly to the dlopen() library call, this implies that normal runtime linking conventions apply - i.e. you have three options: - + 1. The library name is given with a full path. 2. The library is in a standard location for shared libraries. 3. The library is in one of the directories mentioned in the @@ -121,7 +123,7 @@ ANALYSIS_SELECT ModuleName */ - + /*****************************************************************/ bool analysis_config_have_enough_realisations( const analysis_config_type * config , int realisations) { @@ -142,18 +144,34 @@ bool analysis_config_have_enough_realisations( const analysis_config_type * conf void analysis_config_set_stop_long_running( analysis_config_type * config, bool stop_long_running ) { config->stop_long_running = stop_long_running; -} +} bool analysis_config_get_stop_long_running( const analysis_config_type * config) { return config->stop_long_running; } +bool analysis_config_get_std_scale_correlated_obs( const analysis_config_type * config) { + return config->std_scale_correlated_obs; +} + +void analysis_config_set_std_scale_correlated_obs( analysis_config_type * config, bool std_scale_correlated_obs) { + config->std_scale_correlated_obs = std_scale_correlated_obs; +} + +double analysis_config_get_global_std_scaling(const analysis_config_type * config) { + return config->global_std_scaling; +} + +void analysis_config_set_global_std_scaling(analysis_config_type * config, double global_std_scaling) { + config->global_std_scaling = global_std_scaling; +} + int analysis_config_get_max_runtime( const analysis_config_type * config ) { - return config->max_runtime; -} + return config->max_runtime; +} void analysis_config_set_max_runtime( analysis_config_type * config, int max_runtime ) { - config->max_runtime = max_runtime; + config->max_runtime = max_runtime; } void analysis_config_set_min_realisations( analysis_config_type * config , int min_realisations) { @@ -178,7 +196,7 @@ double analysis_config_get_alpha(const analysis_config_type * config) { } void analysis_config_set_store_PC( analysis_config_type * config , bool store_PC) { - config->store_PC = store_PC; + config->store_PC = store_PC; } bool analysis_config_get_store_PC( const analysis_config_type * config ) { @@ -221,7 +239,7 @@ void analysis_config_set_log_path(analysis_config_type * config , const char * l */ const char * analysis_config_get_log_path( const analysis_config_type * config ) { util_make_path( config->log_path ); - return config->log_path; + return config->log_path; } @@ -268,7 +286,7 @@ void analysis_config_set_merge_observations( analysis_config_type * config , boo /*****************************************************************/ -void analysis_config_load_internal_module( analysis_config_type * config , +void analysis_config_load_internal_module( analysis_config_type * config , const char * user_name , const char * symbol_table ) { analysis_module_type * module = analysis_module_alloc_internal( config->rng , user_name , symbol_table ); if (module != NULL) @@ -277,17 +295,17 @@ void analysis_config_load_internal_module( analysis_config_type * config , fprintf(stderr,"** Warning: failed to load module %s from %s.\n",user_name , symbol_table); } -void analysis_config_load_all_external_modules_from_config ( analysis_config_type * analysis, const config_type * config) { - if (config_item_set( config, ANALYSIS_LOAD_KEY)) { - const config_content_item_type * load_item = config_get_content_item( config , ANALYSIS_LOAD_KEY ); - if (load_item != NULL) { - for (int i=0; i < config_content_item_get_size( load_item ); i++) { - const config_content_node_type * load_node = config_content_item_iget_node( load_item , i ); - const char * user_name = config_content_node_iget( load_node , 0 ); - const char * lib_name = config_content_node_iget( load_node , 1 ); - analysis_config_load_external_module( analysis , user_name , lib_name); - } +void analysis_config_load_all_external_modules_from_config ( analysis_config_type * analysis, const config_content_type * config) { + + if (config_content_has_item( config, ANALYSIS_LOAD_KEY)) { + const config_content_item_type * load_item = config_content_get_item( config , ANALYSIS_LOAD_KEY ); + for (int i=0; i < config_content_item_get_size( load_item ); i++) { + const config_content_node_type * load_node = config_content_item_iget_node( load_item , i ); + const char * user_name = config_content_node_iget( load_node , 0 ); + const char * lib_name = config_content_node_iget( load_node , 1 ); + + analysis_config_load_external_module( analysis , user_name , lib_name); } } } @@ -306,8 +324,8 @@ bool analysis_config_load_external_module( analysis_config_type * config , } -void analysis_config_add_module_copy( analysis_config_type * config , - const char * src_name , +void analysis_config_add_module_copy( analysis_config_type * config , + const char * src_name , const char * target_name) { analysis_module_type * module = analysis_config_get_module( config , src_name ); if (analysis_module_internal( module )) @@ -339,7 +357,7 @@ void analysis_config_reload_module( analysis_config_type * config , const char * module = analysis_config_get_module( config , module_name ); else module = config->analysis_module; - + if (!analysis_module_internal( module )) { char * user_name = util_alloc_string_copy(analysis_module_get_name( module )); char * lib_name = util_alloc_string_copy(analysis_module_get_lib_name( module )); @@ -379,25 +397,25 @@ bool analysis_config_get_module_option( const analysis_config_type * config , lo bool analysis_config_select_module( analysis_config_type * config , const char * module_name ) { - if (analysis_config_has_module( config , module_name )) { + if (analysis_config_has_module( config , module_name )) { analysis_module_type * module = analysis_config_get_module( config , module_name ); - + if (analysis_module_check_option( module , ANALYSIS_ITERABLE)) { if (analysis_config_get_single_node_update( config )) { fprintf(stderr," ** Warning: the module:%s requires the setting \"SINGLE_NODE_UPDATE FALSE\" in the config file.\n" , module_name); fprintf(stderr," ** the module has NOT been selected. \n"); return false; - } + } } - + config->analysis_module = module; return true; } else { if (config->analysis_module == NULL) util_abort("%s: sorry module:%s does not exist - and no module currently selected\n",__func__ , module_name); else - fprintf(stderr , "** Warning: analysis module:%s does not exist - current selection unchanged:%s\n", - module_name , + fprintf(stderr , "** Warning: analysis module:%s does not exist - current selection unchanged:%s\n", + module_name , analysis_module_get_name( config->analysis_module )); return false; } @@ -436,38 +454,41 @@ void analysis_config_load_internal_modules( analysis_config_type * config ) { for enkf_defaults.h */ -void analysis_config_init( analysis_config_type * analysis , const config_type * config ) { - if (config_item_set( config , UPDATE_LOG_PATH_KEY )) - analysis_config_set_log_path( analysis , config_get_value( config , UPDATE_LOG_PATH_KEY )); - - if (config_item_set( config , STD_CUTOFF_KEY )) - analysis_config_set_std_cutoff( analysis , config_get_value_as_double( config , STD_CUTOFF_KEY )); +void analysis_config_init( analysis_config_type * analysis , const config_content_type * config ) { + if (config_content_has_item( config , UPDATE_LOG_PATH_KEY )) + analysis_config_set_log_path( analysis , config_content_get_value( config , UPDATE_LOG_PATH_KEY )); + + if (config_content_has_item( config , STD_CUTOFF_KEY )) + analysis_config_set_std_cutoff( analysis , config_content_get_value_as_double( config , STD_CUTOFF_KEY )); + + if (config_content_has_item( config , ENKF_ALPHA_KEY )) + analysis_config_set_alpha( analysis , config_content_get_value_as_double( config , ENKF_ALPHA_KEY )); - if (config_item_set( config , ENKF_ALPHA_KEY )) - analysis_config_set_alpha( analysis , config_get_value_as_double( config , ENKF_ALPHA_KEY )); + if (config_content_has_item( config , ENKF_MERGE_OBSERVATIONS_KEY )) + analysis_config_set_merge_observations( analysis , config_content_get_value_as_bool( config , ENKF_MERGE_OBSERVATIONS_KEY )); - if (config_item_set( config , ENKF_MERGE_OBSERVATIONS_KEY )) - analysis_config_set_merge_observations( analysis , config_get_value_as_bool( config , ENKF_MERGE_OBSERVATIONS_KEY )); + if (config_content_has_item( config , ENKF_RERUN_KEY )) + analysis_config_set_rerun( analysis , config_content_get_value_as_bool( config , ENKF_RERUN_KEY )); - if (config_item_set( config , ENKF_RERUN_KEY )) - analysis_config_set_rerun( analysis , config_get_value_as_bool( config , ENKF_RERUN_KEY )); + if (config_content_has_item( config , UPDATE_RESULTS_KEY )) + analysis_config_set_update_results( analysis , config_content_get_value_as_bool( config , UPDATE_RESULTS_KEY )); - if (config_item_set( config , UPDATE_RESULTS_KEY )) - analysis_config_set_update_results( analysis , config_get_value_as_bool( config , UPDATE_RESULTS_KEY )); + if (config_content_has_item( config , SINGLE_NODE_UPDATE_KEY )) + analysis_config_set_single_node_update( analysis , config_content_get_value_as_bool( config , SINGLE_NODE_UPDATE_KEY )); - if (config_item_set( config , SINGLE_NODE_UPDATE_KEY )) - analysis_config_set_single_node_update( analysis , config_get_value_as_bool( config , SINGLE_NODE_UPDATE_KEY )); - - if (config_item_set( config , RERUN_START_KEY )) - analysis_config_set_rerun_start( analysis , config_get_value_as_int( config , RERUN_START_KEY )); + if (config_content_has_item( config , STD_SCALE_CORRELATED_OBS_KEY )) + analysis_config_set_std_scale_correlated_obs( analysis , config_content_get_value_as_bool( config , STD_SCALE_CORRELATED_OBS_KEY )); - if (config_item_set( config , MIN_REALIZATIONS_KEY )) { + if (config_content_has_item( config , RERUN_START_KEY )) + analysis_config_set_rerun_start( analysis , config_content_get_value_as_int( config , RERUN_START_KEY )); + + if (config_content_has_item( config , MIN_REALIZATIONS_KEY )) { double percent = 0.0; - config_content_node_type * config_content = config_get_value_node(config , MIN_REALIZATIONS_KEY); + config_content_node_type * config_content = config_content_get_value_node(config , MIN_REALIZATIONS_KEY); char * min_realizations_string = config_content_node_alloc_joined_string(config_content, " "); if (util_sscanf_percent(min_realizations_string, &percent)) { - int num_realizations = config_get_value_as_int(config, NUM_REALIZATIONS_KEY); + int num_realizations = config_content_get_value_as_int(config, NUM_REALIZATIONS_KEY); int min_realizations = num_realizations * percent/100; analysis_config_set_min_realisations(analysis, min_realizations); } else { @@ -479,28 +500,28 @@ void analysis_config_init( analysis_config_type * analysis , const config_type * } free(min_realizations_string); } - - if (config_item_set( config , STOP_LONG_RUNNING_KEY )) - analysis_config_set_stop_long_running( analysis , config_get_value_as_bool( config , STOP_LONG_RUNNING_KEY )); - - if (config_item_set( config, MAX_RUNTIME_KEY)) { - analysis_config_set_max_runtime( analysis, config_get_value_as_int( config, MAX_RUNTIME_KEY )); + + if (config_content_has_item( config , STOP_LONG_RUNNING_KEY )) + analysis_config_set_stop_long_running( analysis , config_content_get_value_as_bool( config , STOP_LONG_RUNNING_KEY )); + + if (config_content_has_item( config, MAX_RUNTIME_KEY)) { + analysis_config_set_max_runtime( analysis, config_content_get_value_as_int( config, MAX_RUNTIME_KEY )); } - - /* Loading external modules */ + + /* Loading external modules */ analysis_config_load_all_external_modules_from_config(analysis, config); - + /* Reload/copy modules. */ { - const config_content_item_type * copy_item = config_get_content_item( config , ANALYSIS_COPY_KEY ); - if (copy_item != NULL) { + if (config_content_has_item( config , ANALYSIS_COPY_KEY )) { + const config_content_item_type * copy_item = config_content_get_item( config , ANALYSIS_COPY_KEY ); for (int i=0; i < config_content_item_get_size( copy_item ); i++) { const config_content_node_type * copy_node = config_content_item_iget_node( copy_item , i ); const char * src_name = config_content_node_iget( copy_node , 0 ); const char * target_name = config_content_node_iget( copy_node , 1 ); - + analysis_config_add_module_copy( analysis , src_name , target_name); } } @@ -509,11 +530,11 @@ void analysis_config_init( analysis_config_type * analysis , const config_type * /* Setting variables for analysis modules */ { - const config_content_item_type * assign_item = config_get_content_item( config , ANALYSIS_SET_VAR_KEY ); - if (assign_item != NULL) { + if (config_content_has_item( config , ANALYSIS_SET_VAR_KEY )) { + const config_content_item_type * assign_item = config_content_get_item( config , ANALYSIS_SET_VAR_KEY ); for (int i=0; i < config_content_item_get_size( assign_item ); i++) { const config_content_node_type * assign_node = config_content_item_iget_node( assign_item , i ); - + const char * module_name = config_content_node_iget( assign_node , 0 ); const char * var_name = config_content_node_iget( assign_node , 1 ); analysis_module_type * module = analysis_config_get_module( analysis , module_name ); @@ -537,8 +558,8 @@ void analysis_config_init( analysis_config_type * analysis , const config_type * } } - if (config_item_set( config, ANALYSIS_SELECT_KEY )) - analysis_config_select_module( analysis , config_get_value( config , ANALYSIS_SELECT_KEY )); + if (config_content_has_item( config, ANALYSIS_SELECT_KEY )) + analysis_config_select_module( analysis , config_content_get_value( config , ANALYSIS_SELECT_KEY )); analysis_iter_config_init( analysis->iter_config , config ); } @@ -569,7 +590,7 @@ void analysis_config_free(analysis_config_type * config) { analysis_config_type * analysis_config_alloc( rng_type * rng ) { analysis_config_type * config = util_malloc( sizeof * config ); UTIL_TYPE_ID_INIT( config , ANALYSIS_CONFIG_TYPE_ID ); - + config->log_path = NULL; config->PC_filename = NULL; config->PC_path = NULL; @@ -590,10 +611,12 @@ analysis_config_type * analysis_config_alloc( rng_type * rng ) { analysis_config_set_stop_long_running( config , DEFAULT_ANALYSIS_STOP_LONG_RUNNING ); analysis_config_set_max_runtime( config , DEFAULT_MAX_RUNTIME ); - config->analysis_module = NULL; - config->analysis_modules = hash_alloc(); - config->rng = rng; - config->iter_config = analysis_iter_config_alloc(); + config->analysis_module = NULL; + config->analysis_modules = hash_alloc(); + config->rng = rng; + config->iter_config = analysis_iter_config_alloc(); + config->std_scale_correlated_obs = false; + config->global_std_scaling = 1.0; return config; } @@ -605,9 +628,9 @@ analysis_config_type * analysis_config_alloc( rng_type * rng ) { is instantiated with defaults from enkf_defaults.h */ -void analysis_config_add_config_items( config_type * config ) { +void analysis_config_add_config_items( config_parser_type * config ) { config_schema_item_type * item; - + config_add_key_value( config , ENKF_ALPHA_KEY , false , CONFIG_FLOAT); config_add_key_value( config , STD_CUTOFF_KEY , false , CONFIG_FLOAT); config_add_key_value( config , ENKF_MERGE_OBSERVATIONS_KEY , false , CONFIG_BOOL); @@ -628,13 +651,14 @@ void analysis_config_add_config_items( config_type * config ) { config_add_key_value( config , UPDATE_LOG_PATH_KEY , false , CONFIG_STRING); config_add_key_value( config , MIN_REALIZATIONS_KEY , false , CONFIG_STRING ); config_add_key_value( config , MAX_RUNTIME_KEY , false , CONFIG_INT ); - - item = config_add_key_value( config , STOP_LONG_RUNNING_KEY, false, CONFIG_BOOL ); - stringlist_type * child_list = stringlist_alloc_new(); - stringlist_append_ref(child_list, MIN_REALIZATIONS_KEY); - config_schema_item_set_required_children_on_value(item , "TRUE" , child_list); - stringlist_free(child_list); - + config_add_key_value( config , STD_SCALE_CORRELATED_OBS_KEY, false , CONFIG_BOOL ); + + item = config_add_key_value( config , STOP_LONG_RUNNING_KEY, false, CONFIG_BOOL ); + stringlist_type * child_list = stringlist_alloc_new(); + stringlist_append_ref(child_list, MIN_REALIZATIONS_KEY); + config_schema_item_set_required_children_on_value(item , "TRUE" , child_list); + stringlist_free(child_list); + config_add_key_value( config , ANALYSIS_SELECT_KEY , false , CONFIG_STRING); item = config_add_schema_item( config , ANALYSIS_LOAD_KEY , false ); @@ -642,20 +666,20 @@ void analysis_config_add_config_items( config_type * config ) { item = config_add_schema_item( config , ANALYSIS_COPY_KEY , false ); config_schema_item_set_argc_minmax( item , 2 , 2); - + item = config_add_schema_item( config , ANALYSIS_SET_VAR_KEY , false ); config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX); analysis_iter_config_add_config_items( config ); } - - + + void analysis_config_fprintf_config( analysis_config_type * config , FILE * stream) { fprintf( stream , CONFIG_COMMENTLINE_FORMAT ); fprintf( stream , CONFIG_COMMENT_FORMAT , "Here comes configuration information related to the EnKF analysis."); - - + + if (config->merge_observations != DEFAULT_MERGE_OBSERVATIONS) { fprintf( stream , CONFIG_KEY_FORMAT , ENKF_MERGE_OBSERVATIONS_KEY); fprintf( stream , CONFIG_ENDVALUE_FORMAT , CONFIG_BOOL_STRING( config->merge_observations )); @@ -677,17 +701,17 @@ void analysis_config_fprintf_config( analysis_config_type * config , FILE * stre fprintf( stream , CONFIG_FLOAT_FORMAT , config->overlap_alpha ); fprintf( stream , "\n"); } - + if (config->update_results != DEFAULT_SINGLE_NODE_UPDATE) { fprintf( stream , CONFIG_KEY_FORMAT , SINGLE_NODE_UPDATE_KEY); fprintf( stream , CONFIG_ENDVALUE_FORMAT , CONFIG_BOOL_STRING( config->single_node_update )); } - + if (config->rerun) { fprintf( stream , CONFIG_KEY_FORMAT , ENKF_RERUN_KEY); fprintf( stream , CONFIG_ENDVALUE_FORMAT , CONFIG_BOOL_STRING( config->rerun )); } - + if (config->rerun_start != DEFAULT_RERUN_START) { fprintf( stream , CONFIG_KEY_FORMAT , RERUN_START_KEY); fprintf( stream , CONFIG_INT_FORMAT , config->rerun_start ); @@ -698,7 +722,7 @@ void analysis_config_fprintf_config( analysis_config_type * config , FILE * stre fprintf( stream , CONFIG_KEY_FORMAT , UPDATE_LOG_PATH_KEY); fprintf( stream , CONFIG_ENDVALUE_FORMAT , config->log_path ); } - + fprintf(stream , "\n\n"); } diff --git a/ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c b/ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c index fd8c11b464..b269ca447d 100644 --- a/ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'analysis_iter_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'analysis_iter_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -24,7 +24,7 @@ #include <ert/util/util.h> #include <ert/util/stringlist.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/enkf/enkf_defaults.h> #include <ert/enkf/config_keys.h> @@ -36,13 +36,13 @@ struct analysis_iter_config_struct { stringlist_type * storage; int num_iterations; int num_iter_tries; - bool case_set; - bool num_iterations_set; + bool case_set; + bool num_iterations_set; }; void analysis_iter_config_set_num_iterations( analysis_iter_config_type * config , int num_iterations) { - config->num_iterations = num_iterations; + config->num_iterations = num_iterations; config->num_iterations_set = true; } @@ -81,7 +81,7 @@ char * analysis_iter_config_get_case_fmt( analysis_iter_config_type * config) { analysis_iter_config_type * analysis_iter_config_alloc() { - analysis_iter_config_type * config = util_malloc( sizeof * config ); + analysis_iter_config_type * config = util_malloc( sizeof * config ); config->case_fmt = NULL; analysis_iter_config_set_case_fmt( config, DEFAULT_ANALYSIS_ITER_CASE); config->storage = stringlist_alloc_new(); @@ -110,22 +110,22 @@ const char * analysis_iter_config_iget_case( analysis_iter_config_type * config } -void analysis_iter_config_add_config_items( config_type * config ) { +void analysis_iter_config_add_config_items( config_parser_type * config ) { config_add_key_value( config , ITER_CASE_KEY , false , CONFIG_STRING); config_add_key_value( config , ITER_COUNT_KEY , false , CONFIG_INT); config_add_key_value( config , ITER_RETRY_COUNT_KEY , false , CONFIG_INT); } -void analysis_iter_config_init(analysis_iter_config_type * iter_config , const config_type * config) { - if (config_item_set( config , ITER_CASE_KEY )) - analysis_iter_config_set_case_fmt( iter_config , config_get_value( config , ITER_CASE_KEY )); - - if (config_item_set( config , ITER_COUNT_KEY )) - analysis_iter_config_set_num_iterations( iter_config , config_get_value_as_int( config , ITER_COUNT_KEY )); +void analysis_iter_config_init(analysis_iter_config_type * iter_config , const config_content_type * config) { + if (config_content_has_item( config , ITER_CASE_KEY )) + analysis_iter_config_set_case_fmt( iter_config , config_content_get_value( config , ITER_CASE_KEY )); + + if (config_content_has_item( config , ITER_COUNT_KEY )) + analysis_iter_config_set_num_iterations( iter_config , config_content_get_value_as_int( config , ITER_COUNT_KEY )); - if (config_item_set( config , ITER_RETRY_COUNT_KEY )) - analysis_iter_config_set_num_retries_per_iteration( iter_config , config_get_value_as_int( config , ITER_RETRY_COUNT_KEY )); + if (config_content_has_item( config , ITER_RETRY_COUNT_KEY )) + analysis_iter_config_set_num_retries_per_iteration( iter_config , config_content_get_value_as_int( config , ITER_RETRY_COUNT_KEY )); } diff --git a/ThirdParty/Ert/devel/libenkf/src/block_obs.c b/ThirdParty/Ert/devel/libenkf/src/block_obs.c index 89101d2166..6abc75137c 100644 --- a/ThirdParty/Ert/devel/libenkf/src/block_obs.c +++ b/ThirdParty/Ert/devel/libenkf/src/block_obs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'block_obs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'block_obs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -41,7 +41,7 @@ #include <ert/enkf/meas_data.h> #include <ert/enkf/field_config.h> #include <ert/enkf/active_list.h> -#include <ert/enkf/block_obs.h> +#include <ert/enkf/block_obs.h> #include <ert/enkf/enkf_defaults.h> #define BLOCK_OBS_TYPE_ID 661098 @@ -57,8 +57,9 @@ typedef struct { int active_index; double value; double std; - char * sum_key; -} point_obs_type; + double std_scaling; + char * sum_key; +} point_obs_type; static UTIL_SAFE_CAST_FUNCTION(point_obs , POINT_OBS_TYPE_ID); @@ -69,7 +70,7 @@ struct block_obs_struct { vector_type * point_list; const ecl_grid_type * grid; const void * data_config; - block_obs_source_type source_type; + block_obs_source_type source_type; }; @@ -91,13 +92,13 @@ static point_obs_type * point_obs_alloc( block_obs_source_type source_type , i point_obs->source_type = source_type; point_obs->i = i; point_obs->j = j; - point_obs->k = k; + point_obs->k = k; point_obs->active_index = active_index; point_obs->value = value; point_obs->std = std; point_obs->sum_key = util_alloc_string_copy( sum_key ); - - + point_obs->std_scaling = 1.0; + return point_obs; } @@ -125,7 +126,7 @@ static double point_obs_iget_data( const point_obs_type * point_obs , const void } else if (point_obs->source_type == SOURCE_SUMMARY) { const container_type * container = container_safe_cast_const( state ); const summary_type * summary = summary_safe_cast_const( container_iget_node( container , iobs )); - return summary_get( summary , node_id.report_step , node_id.state ); + return summary_get( summary , node_id.report_step , node_id.state ); } else { util_abort("%s: unknown source type: %d \n",__func__, point_obs->source_type ); return -1; @@ -151,9 +152,9 @@ static void block_obs_validate_ijk( const ecl_grid_type * grid , int size, const for (l = 0; l < size; l++) { if (ecl_grid_ijk_valid(grid , i[l] , j[l] , k[l])) { int active_index = ecl_grid_get_active_index3( grid , i[l] , j[l] , k[l]); - if (active_index < 0) + if (active_index < 0) util_abort("%s: sorry: cell:(%d,%d,%d) is not active - can not observe it. \n",__func__ , i[l]+1 , j[l]+1 , k[l]+1); - + } else util_abort("%s: sorry: cell (%d,%d,%d) is outside valid range: \n",__func__ , i[l]+1 , j[l]+1 , k[l]+1); } @@ -183,15 +184,16 @@ void block_obs_append_summary_obs( block_obs_type * block_obs , int i , int j , block_obs_type * block_obs_alloc(const char * obs_key, - const void * data_config , + const void * data_config , const ecl_grid_type * grid) { - if (!(field_config_is_instance( data_config ) || container_config_is_instance( data_config ))) + + if (!(field_config_is_instance( data_config ) || container_config_is_instance( data_config ))) return NULL; { block_obs_type * block_obs = util_malloc(sizeof * block_obs); UTIL_TYPE_ID_INIT( block_obs , BLOCK_OBS_TYPE_ID ); - + block_obs->obs_key = util_alloc_string_copy(obs_key); block_obs->data_config = data_config; block_obs->point_list = vector_alloc_new(); @@ -201,7 +203,7 @@ block_obs_type * block_obs_alloc(const char * obs_key, block_obs->source_type = SOURCE_FIELD; else block_obs->source_type = SOURCE_SUMMARY; - + return block_obs; } } @@ -212,9 +214,9 @@ block_obs_type * block_obs_alloc(const char * obs_key, The input vectors i,j,k should contain offset zero values. */ block_obs_type * block_obs_alloc_complete(const char * obs_key, - block_obs_source_type source_type , - const stringlist_type * summary_keys , - const void * data_config , + block_obs_source_type source_type , + const stringlist_type * summary_keys , + const void * data_config , const ecl_grid_type * grid , int size, const int * i, @@ -264,18 +266,18 @@ void block_obs_get_observations(const block_obs_type * block_obs, obs_data_type int active_size = active_list_get_active_size( __active_list , obs_size); active_mode_type active_mode = active_list_get_mode( __active_list ); obs_block_type * obs_block = obs_data_add_block( obs_data , block_obs->obs_key , obs_size , NULL , false ); - + if (active_mode == ALL_ACTIVE) { for (i=0; i < obs_size; i++) { const point_obs_type * point_obs = block_obs_iget_point_const( block_obs , i ); - obs_block_iset(obs_block , i , point_obs->value , point_obs->std ); + obs_block_iset(obs_block , i , point_obs->value , point_obs->std * point_obs->std_scaling ); } } else if (active_mode == PARTLY_ACTIVE) { - const int * active_list = active_list_get_active( __active_list ); + const int * active_list = active_list_get_active( __active_list ); for (i =0 ; i < active_size; i++) { int iobs = active_list[i]; const point_obs_type * point_obs = block_obs_iget_point_const( block_obs , i ); - obs_block_iset(obs_block , iobs , point_obs->value , point_obs->std ); + obs_block_iset(obs_block , iobs , point_obs->value , point_obs->std * point_obs->std_scaling ); } } } @@ -306,7 +308,7 @@ void block_obs_measure(const block_obs_type * block_obs, const void * state , no int active_size = active_list_get_active_size( __active_list , obs_size ); meas_block_type * meas_block = meas_data_add_block( meas_data , block_obs->obs_key , node_id.report_step , obs_size ); int iobs; - + active_mode_type active_mode = active_list_get_mode( __active_list ); if (active_mode == ALL_ACTIVE) { for (iobs=0; iobs < obs_size; iobs++) { @@ -314,7 +316,7 @@ void block_obs_measure(const block_obs_type * block_obs, const void * state , no meas_block_iset( meas_block , node_id.iens , iobs , value ); } } else if (active_mode == PARTLY_ACTIVE) { - const int * active_list = active_list_get_active( __active_list ); + const int * active_list = active_list_get_active( __active_list ); for (int i =0 ; i < active_size; i++) { iobs = active_list[i]; { @@ -328,12 +330,14 @@ void block_obs_measure(const block_obs_type * block_obs, const void * state , no -double block_obs_chi2(const block_obs_type * block_obs, const field_type * field_state, node_id_type node_id) { +double block_obs_chi2(const block_obs_type * block_obs, const void * state, node_id_type node_id) { double sum_chi2 = 0; int obs_size = block_obs_get_size( block_obs ); + block_obs_assert_data(block_obs, state); + for (int i=0; i < obs_size; i++) { const point_obs_type * point_obs = block_obs_iget_point_const( block_obs , i ); - double sim_value = point_obs_iget_data( point_obs , field_state , i, node_id ); + double sim_value = point_obs_iget_data( point_obs , state , i, node_id ); double x = (sim_value - point_obs->value) / point_obs->std; sum_chi2 += x*x; } @@ -362,6 +366,12 @@ double block_obs_iget_std(const block_obs_type * block_obs, int index ){ return point_obs->std; } +double block_obs_iget_std_scaling(const block_obs_type * block_obs, int index ){ + const point_obs_type * point_obs = block_obs_iget_point_const( block_obs , index ); + return point_obs->std_scaling; +} + + void block_obs_user_get(const block_obs_type * block_obs , const char * index_key , double *value , double * std, bool * valid) { int i,j,k; @@ -423,18 +433,24 @@ int block_obs_get_size(const block_obs_type * block_obs) { return vector_get_size( block_obs->point_list ); } -void block_obs_scale_std(block_obs_type * block_obs, double scale_factor) { +void block_obs_update_std_scale(block_obs_type * block_obs, double scale_factor, const active_list_type * active_list) { int obs_size = block_obs_get_size( block_obs ); - for (int i = 0; i < obs_size; i++) { - point_obs_type * point_observation = block_obs_iget_point( block_obs , i ); - point_observation->std = point_observation->std * scale_factor; + if (active_list_get_mode( active_list ) == ALL_ACTIVE) { + for (int i = 0; i < obs_size; i++) { + point_obs_type * point_observation = block_obs_iget_point( block_obs , i ); + point_observation->std_scaling = scale_factor; + } + } else { + const int * active_index = active_list_get_active( active_list ); + int size = active_list_get_active_size( active_list , obs_size ); + for (int i=0; i < size; i++) { + int obs_index = active_index[i]; + point_obs_type * point_observation = block_obs_iget_point( block_obs , obs_index ); + point_observation->std_scaling = scale_factor; + } } } -void block_obs_scale_std__(void * block_obs, double scale_factor) { - block_obs_type * observation = block_obs_safe_cast(block_obs); - block_obs_scale_std(observation, scale_factor); -} @@ -447,3 +463,4 @@ VOID_GET_OBS(block_obs) VOID_MEASURE_UNSAFE(block_obs , data) // The cast of data field is not checked - that is done in block_obs_measure(). VOID_USER_GET_OBS(block_obs) VOID_CHI2(block_obs , field) +VOID_UPDATE_STD_SCALE(block_obs) diff --git a/ThirdParty/Ert/devel/libenkf/src/cases_config.c b/ThirdParty/Ert/devel/libenkf/src/cases_config.c index bfe7537ba3..7a3c594d37 100644 --- a/ThirdParty/Ert/devel/libenkf/src/cases_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/cases_config.c @@ -24,7 +24,7 @@ #include <ert/util/util.h> #include <ert/util/stringlist.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/enkf/enkf_defaults.h> #include <ert/enkf/config_keys.h> diff --git a/ThirdParty/Ert/devel/libenkf/src/custom_kw.c b/ThirdParty/Ert/devel/libenkf/src/custom_kw.c new file mode 100644 index 0000000000..5862c4a8b9 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/custom_kw.c @@ -0,0 +1,124 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <stdbool.h> +#include <math.h> + +#include <ert/util/util.h> +#include <ert/util/matrix.h> +#include <ert/util/bool_vector.h> +#include <ert/util/rng.h> +#include <ert/util/stringlist.h> + +#include <ert/ecl/fortio.h> +#include <ert/ecl/ecl_sum.h> +#include <ert/ecl/ecl_file.h> +#include <ert/ecl/ecl_util.h> + +#include <ert/enkf/enkf_serialize.h> +#include <ert/enkf/enkf_types.h> +#include <ert/enkf/enkf_macros.h> +#include <ert/enkf/enkf_util.h> +#include <ert/enkf/custom_kw_config.h> +#include <ert/enkf/custom_kw.h> +#include <ert/enkf/enkf_fs.h> + + +struct custom_kw_struct { + int __type_id; + custom_kw_config_type * config; + /* Thin config object - mainly contains filename for remote load */ + stringlist_type * data; /* Actual storage - will be casted to double or float on use. */ +}; + + +custom_kw_type * custom_kw_alloc(const custom_kw_config_type * config) { + custom_kw_type * custom_kw = util_malloc(sizeof * custom_kw); + custom_kw->config = (custom_kw_config_type *) config; + custom_kw->data = stringlist_alloc_new(); + custom_kw->__type_id = CUSTOM_KW; + return custom_kw; +} + +void custom_kw_free(custom_kw_type * custom_kw) { + stringlist_free(custom_kw->data); + free(custom_kw); +} + +const stringlist_type * custom_kw_get_data(const custom_kw_type * custom_kw) { + return custom_kw->data; +} + +bool custom_kw_key_is_null(const custom_kw_type * custom_kw, char * key) { + int index = custom_kw_config_index_of_key(custom_kw->config, key); + return stringlist_iget(custom_kw->data, index) == NULL; +} + +double custom_kw_iget_as_double(const custom_kw_type * custom_kw, int index) { + double value; + + util_sscanf_double(stringlist_iget(custom_kw->data, index), & value); + return value; +} + +const char * custom_kw_iget_as_string(const custom_kw_type * custom_kw, int index) { + return stringlist_iget(custom_kw->data, index); +} + +custom_kw_config_type * custom_kw_get_config(const custom_kw_type * custom_kw) { + return custom_kw->config; +} + +bool custom_kw_fload(custom_kw_type * custom_kw, const char * filename) { + return custom_kw_config_parse_result_file(custom_kw->config, filename, custom_kw->data); +} + +bool custom_kw_forward_load(custom_kw_type * custom_kw, const char * ecl_file, const ecl_sum_type * ecl_sum, const ecl_file_type * restart_file, int report_step) { + return custom_kw_fload(custom_kw, ecl_file); +} + +bool custom_kw_write_to_buffer(const custom_kw_type * custom_kw, buffer_type * buffer, int report_step, state_enum state) { + stringlist_buffer_fwrite(custom_kw->data, buffer); + return true; +} + +void custom_kw_read_from_buffer(const custom_kw_type * custom_kw, buffer_type * buffer, enkf_fs_type * fs, int report_step, state_enum state) { + stringlist_buffer_fread(custom_kw->data, buffer); +} + +void custom_kw_ecl_write(const custom_kw_type * custom_kw, const char * run_path, const char * base_file, void * filestream) { + //printf("CustomKW ecl_write\n"); +} + +void custom_kw_serialize(const custom_kw_type * custom_kw, node_id_type node_id, const active_list_type * active_list, matrix_type * A, int row_offset, int column) { + printf("CustomKW serialize\n"); +} + +void custom_kw_deserialize(custom_kw_type * custom_kw, node_id_type node_id, const active_list_type * active_list, const matrix_type * A, int row_offset, int column) { + printf("CustomKW deserialize\n"); +} + +/******************************************************************/ +/* Anonumously generated functions used by the enkf_node object */ +/******************************************************************/ +UTIL_SAFE_CAST_FUNCTION_CONST(custom_kw, CUSTOM_KW) + +UTIL_SAFE_CAST_FUNCTION(custom_kw, CUSTOM_KW) + +VOID_ALLOC(custom_kw) + +VOID_FREE(custom_kw) + +VOID_FORWARD_LOAD(custom_kw) + +VOID_FLOAD(custom_kw) + +VOID_ECL_WRITE(custom_kw) + +VOID_READ_FROM_BUFFER(custom_kw); + +VOID_WRITE_TO_BUFFER(custom_kw); + +VOID_SERIALIZE(custom_kw) + +VOID_DESERIALIZE(custom_kw) diff --git a/ThirdParty/Ert/devel/libenkf/src/custom_kw_config.c b/ThirdParty/Ert/devel/libenkf/src/custom_kw_config.c new file mode 100644 index 0000000000..847d497c65 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/custom_kw_config.c @@ -0,0 +1,272 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <pthread.h> + +#include <ert/util/util.h> +#include <ert/util/int_vector.h> +#include <ert/util/bool_vector.h> +#include <ert/util/string_util.h> +#include <ert/util/type_macros.h> +#include <ert/util/hash.h> +#include <ert/util/stringlist.h> + +#include <ert/config/config_parser.h> +#include <ert/ecl/ecl_util.h> + +#include <ert/enkf/enkf_macros.h> +#include <ert/enkf/enkf_types.h> +#include <ert/enkf/enkf_fs.h> +#include <ert/enkf/config_keys.h> +#include <ert/enkf/enkf_defaults.h> + +#include <ert/enkf/custom_kw_config.h> + + +#define CUSTOM_KW_CONFIG_ID 90051933 + +struct custom_kw_config_struct { + CONFIG_STD_FIELDS; + char * name; + char * result_file; + char * output_file; + + hash_type * custom_keys; + hash_type * custom_key_types; /* True if float */ + bool undefined; + char * key_definition_file; + + pthread_rwlock_t rw_lock; +}; + + +custom_kw_config_type * custom_kw_config_alloc_empty(const char * key, const char * result_file, const char * output_file) { + custom_kw_config_type * custom_kw_config = util_malloc(sizeof * custom_kw_config); + UTIL_TYPE_ID_INIT(custom_kw_config, CUSTOM_KW_CONFIG_ID); + + custom_kw_config->name = NULL; + custom_kw_config->result_file = util_alloc_string_copy(result_file); + custom_kw_config->output_file = util_alloc_string_copy(output_file); + custom_kw_config->name = util_alloc_string_copy(key); + custom_kw_config->undefined = true; + custom_kw_config->key_definition_file = NULL; + + custom_kw_config->custom_keys = hash_alloc(); + custom_kw_config->custom_key_types = hash_alloc(); //types: 0 if string 1 if double + pthread_rwlock_init(& custom_kw_config->rw_lock, NULL); + + return custom_kw_config; +} + +void custom_kw_config_free(custom_kw_config_type * config) { + util_safe_free(config->name); + util_safe_free(config->result_file); + util_safe_free(config->output_file); + util_safe_free(config->key_definition_file); + + hash_free(config->custom_keys); + hash_free(config->custom_key_types); + + pthread_rwlock_destroy(& config->rw_lock); + + free(config); +} + +static void custom_kw_config_reset__(custom_kw_config_type * config) { + config->undefined = true; + hash_clear(config->custom_keys); + hash_clear(config->custom_key_types); + util_safe_free(config->key_definition_file); + config->key_definition_file = NULL; +} + +void custom_kw_config_serialize(custom_kw_config_type * config, stringlist_type * config_set) { + pthread_rwlock_rdlock(& config->rw_lock); + { + stringlist_clear(config_set); + + stringlist_type * configured_keys = custom_kw_config_get_keys(config); + + for (int i = 0; i < stringlist_get_size(configured_keys); i++) { + const char * key = stringlist_iget(configured_keys, i); + bool double_type = custom_kw_config_key_is_double(config, key); + int index = custom_kw_config_index_of_key(config, key); + char buffer[256]; + + sprintf(buffer, "%s %d %d", key, index, double_type); + stringlist_append_copy(config_set, buffer); + } + + stringlist_free(configured_keys); + + } + pthread_rwlock_unlock(& config->rw_lock); +} + +void custom_kw_config_deserialize(custom_kw_config_type * config, stringlist_type * config_set) { + pthread_rwlock_wrlock(& config->rw_lock); + { + custom_kw_config_reset__(config); + + for (int i = 0; i < stringlist_get_size(config_set); i++) { + const char * items = stringlist_iget(config_set, i); + + char key[128]; + int index; + int is_double; + + int count = sscanf(items, "%s %d %d", key, &index, &is_double); + + if (count == 3) { + hash_insert_int(config->custom_keys, key, index); + hash_insert_int(config->custom_key_types, key, is_double); + } else + util_abort("%s: internal error - deserialize failed\n",__func__); + } + config->undefined = false; + config->key_definition_file = util_alloc_string_copy("from storage"); //Todo: Handle this differently? + } + pthread_rwlock_unlock(& config->rw_lock); +} + +int custom_kw_config_size(const custom_kw_config_type * config) { + return hash_get_size(config->custom_keys); +} + +const char * custom_kw_config_get_name(const custom_kw_config_type * config) { + return config->name; +} + +char * custom_kw_config_get_result_file(const custom_kw_config_type * config) { + return config->result_file; +} + +char * custom_kw_config_get_output_file(const custom_kw_config_type * config) { + return config->output_file; +} + +bool custom_kw_config_has_key(const custom_kw_config_type * config, const char * key) { + return hash_has_key(config->custom_keys, key); +} + +bool custom_kw_config_key_is_double(const custom_kw_config_type * config, const char * key) { + return hash_get_int(config->custom_key_types, key) == 1; +} + +int custom_kw_config_index_of_key(const custom_kw_config_type * config, const char * key) { + return hash_get_int(config->custom_keys, key); +} + +stringlist_type * custom_kw_config_get_keys(const custom_kw_config_type * config) { + return hash_alloc_stringlist(config->custom_keys); +} + +static bool custom_kw_config_setup__(custom_kw_config_type * config, const char * result_file) { + FILE * stream = util_fopen__(result_file, "r"); + if (stream != NULL) { + bool read_ok = true; + config->key_definition_file = util_alloc_string_copy(result_file); + + int counter = 0; + char key[128]; + char value[128]; + int read_count; + while ((read_count = fscanf(stream, "%s %s", key, value)) != EOF) { + if (read_count == 1) { + printf("[%s] Warning: Key: '%s:%s' is missing value in file: '%s'\n", __func__, config->name, key, result_file); + read_ok = false; + break; + } + + if (custom_kw_config_has_key(config, key)) { + printf("[%s] Warning: Key: '%s:%s' already defined!\n", __func__, config->name, key); + } else { + hash_insert_int(config->custom_keys, key, counter++); + hash_insert_int(config->custom_key_types, key, util_sscanf_double(value, NULL)); + } + } + + fclose(stream); + return read_ok; + } + return false; +} + +static bool custom_kw_config_read_data__(const custom_kw_config_type * config, const char * result_file, stringlist_type * result) { + FILE * stream = util_fopen__(result_file, "r"); + if (stream != NULL) { + bool read_ok = true; + + stringlist_clear(result); + stringlist_iset_ref(result, hash_get_size(config->custom_keys) - 1, NULL); + hash_type * read_keys = hash_alloc(); + + char key[128]; + char value[128]; + int read_count; + while ((read_count = fscanf(stream, "%s %s", key, value)) != EOF) { + if (read_count == 1) { + printf("[%s] Warning: Key: '%s:%s' missing value in file: %s!\n", __func__, config->name, key, result_file); + read_ok = false; + break; + } + + if (custom_kw_config_has_key(config, key)) { + if (hash_has_key(read_keys, key)) { + printf("[%s] Warning: Key: '%s:%s' has appeared multiple times. Only the last occurrence will be used!\n", __func__, config->name, key); + } + + hash_insert_int(read_keys, key, 1); + int index = custom_kw_config_index_of_key(config, key); + stringlist_iset_copy(result, index, value); + + } else { + printf("[%s] Warning: Key: '%s:%s' not in the available set. Ignored!\n", __func__, config->name, key); + } + } + + fclose(stream); + + if (read_ok) { + read_ok = hash_key_list_compare(read_keys, config->custom_keys); + } + + return read_ok; + } + return false; +} + +bool custom_kw_config_parse_result_file(custom_kw_config_type * config, const char * result_file, stringlist_type * result) { + bool read_ok = true; + + pthread_rwlock_wrlock(& config->rw_lock); + if (config->undefined) { + read_ok = custom_kw_config_setup__(config, result_file); + if (read_ok) { + config->undefined = false; + } + } + pthread_rwlock_unlock(& config->rw_lock); + + if (read_ok) { + read_ok = custom_kw_config_read_data__(config, result_file, result); + } + + return read_ok; +} + + + +/*****************************************************************/ + +UTIL_IS_INSTANCE_FUNCTION(custom_kw_config, CUSTOM_KW_CONFIG_ID) + +UTIL_SAFE_CAST_FUNCTION(custom_kw_config, CUSTOM_KW_CONFIG_ID) + +UTIL_SAFE_CAST_FUNCTION_CONST(custom_kw_config, CUSTOM_KW_CONFIG_ID) + + + +/*****************************************************************/ + +VOID_FREE(custom_kw_config) diff --git a/ThirdParty/Ert/devel/libenkf/src/custom_kw_config_set.c b/ThirdParty/Ert/devel/libenkf/src/custom_kw_config_set.c new file mode 100644 index 0000000000..ef40bca984 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/custom_kw_config_set.c @@ -0,0 +1,143 @@ +#define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ + +#include <stdlib.h> +#include <pthread.h> +#include <stdbool.h> + +#include <ert/util/util.h> +#include <ert/util/hash.h> +#include <ert/util/stringlist.h> +#include <ert/util/type_macros.h> + +#include <ert/enkf/enkf_types.h> +#include <ert/enkf/custom_kw_config_set.h> + + +#define CUSTOM_KW_CONFIG_SET_TYPE_ID 701622133 + +struct custom_kw_config_set_struct { + UTIL_TYPE_ID_DECLARATION; + hash_type * config_set; + pthread_rwlock_t rw_lock; +}; + + +UTIL_IS_INSTANCE_FUNCTION(custom_kw_config_set, CUSTOM_KW_CONFIG_SET_TYPE_ID) + + +custom_kw_config_set_type * custom_kw_config_set_alloc() { + custom_kw_config_set_type * set = util_malloc(sizeof * set); + UTIL_TYPE_ID_INIT(set, CUSTOM_KW_CONFIG_SET_TYPE_ID); + set->config_set = hash_alloc(); + pthread_rwlock_init(& set->rw_lock, NULL); + return set; +} + +custom_kw_config_set_type * custom_kw_config_set_alloc_from_file(const char * filename) { + custom_kw_config_set_type * set = custom_kw_config_set_alloc(); + custom_kw_config_set_fread(set, filename); + return set; +} + +void custom_kw_config_set_free(custom_kw_config_set_type * set) { + hash_free(set->config_set); + free(set); +} + +void custom_kw_config_set_add_config(custom_kw_config_set_type * set, const custom_kw_config_type * config) { + pthread_rwlock_wrlock(& set->rw_lock); + { + const char * name = custom_kw_config_get_name(config); + + if (!hash_has_key(set->config_set, name)) { + stringlist_type * stringlist = stringlist_alloc_new(); + hash_insert_hash_owned_ref(set->config_set, name, stringlist, stringlist_free__); + } + + stringlist_type * formatted_keys = (stringlist_type *) hash_get(set->config_set, name); + custom_kw_config_serialize(config, formatted_keys); + + } + pthread_rwlock_unlock(& set->rw_lock); +} + +void custom_kw_config_set_update_config(custom_kw_config_set_type * set, custom_kw_config_type * config) { + pthread_rwlock_rdlock(& set->rw_lock); + { + const char * name = custom_kw_config_get_name(config); + + if(!hash_has_key(set->config_set, name)) { + printf("[%s] Warning: The key:'%s' is not part of this set. Ignored!\n", __func__, name); + } else { + stringlist_type * formatted_keys = (stringlist_type *) hash_get(set->config_set, name); + custom_kw_config_deserialize(config, formatted_keys); + } + } + pthread_rwlock_unlock(& set->rw_lock); +} + + +void custom_kw_config_set_reset(custom_kw_config_set_type * set) { + pthread_rwlock_wrlock(& set->rw_lock); + { + hash_clear(set->config_set); + } + pthread_rwlock_unlock(& set->rw_lock); +} + +stringlist_type * custom_kw_config_set_get_keys_alloc(custom_kw_config_set_type * set) { + return hash_alloc_stringlist(set->config_set); +} + +void custom_kw_config_set_fwrite(custom_kw_config_set_type * set, const char * filename) { + pthread_rwlock_rdlock(& set->rw_lock); + { + FILE * stream = util_mkdir_fopen(filename, "w"); + if (stream) { + stringlist_type * keys = hash_alloc_stringlist(set->config_set); + stringlist_fwrite(keys, stream); + + for (int i = 0; i < stringlist_get_size(keys); i++) { + const char * key = stringlist_iget(keys, i); + stringlist_type * formatted_keys = (stringlist_type *) hash_get(set->config_set, key); + stringlist_fwrite(formatted_keys, stream); + } + + free(keys); + fclose(stream); + } else { + util_abort("%s: failed to open: %s for writing \n", __func__, filename); + } + } + pthread_rwlock_unlock(& set->rw_lock); +} + + +bool custom_kw_config_set_fread(custom_kw_config_set_type * set, const char * filename) { + bool file_exists = false; + + pthread_rwlock_wrlock(& set->rw_lock); + { + hash_clear(set->config_set); + + if (util_file_exists(filename)) { + FILE * stream = util_fopen(filename, "r"); + if (stream) { + stringlist_type * key_set = stringlist_fread_alloc(stream); + + for (int i = 0; i < stringlist_get_size(key_set); i++) { + const char * key = stringlist_iget(key_set, i); + stringlist_type * config_keys = stringlist_fread_alloc(stream); + hash_insert_hash_owned_ref(set->config_set, key, config_keys, stringlist_free__); + } + stringlist_free(key_set); + fclose(stream); + } else { + util_abort("%s: failed to open: %s for reading \n", __func__, filename); + } + file_exists = true; + } + } + pthread_rwlock_unlock(& set->rw_lock); + return file_exists; +} diff --git a/ThirdParty/Ert/devel/libenkf/src/ecl_config.c b/ThirdParty/Ert/devel/libenkf/src/ecl_config.c index 1fc1d36980..4504b851ed 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ecl_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/ecl_config.c @@ -29,7 +29,8 @@ #include <ert/sched/sched_file.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/config/config_schema_item.h> #include <ert/ecl/ecl_grid.h> @@ -77,7 +78,7 @@ struct ecl_config_struct int last_history_restart; bool can_restart; /* Have we found the <INIT> tag in the data file? */ int num_cpu; /* We should parse the ECLIPSE data file and determine how many cpus this eclipse file needs. */ - ecl_unit_enum unit_system; /* Either metric, field or lab */ + ert_ecl_unit_enum unit_system; /* Either metric, field or lab */ }; /*****************************************************************/ @@ -141,13 +142,13 @@ void ecl_config_set_data_file(ecl_config_type * ecl_config, const char * data_fi ecl_config->data_file = util_realloc_string_copy(ecl_config->data_file, data_file); { FILE * stream = util_fopen(ecl_config->data_file, "r"); - parser_type * parser = parser_alloc(NULL, NULL, NULL, NULL, "--", "\n"); + basic_parser_type * parser = basic_parser_alloc(NULL, NULL, NULL, NULL, "--", "\n"); char * init_tag = enkf_util_alloc_tagged_string("INIT"); - ecl_config->can_restart = parser_fseek_string(parser, stream, init_tag, false, true); + ecl_config->can_restart = basic_parser_fseek_string(parser, stream, init_tag, false, true); free(init_tag); - parser_free(parser); + basic_parser_free(parser); fclose(stream); } ecl_config->start_date = ecl_util_get_start_date(ecl_config->data_file); @@ -520,7 +521,7 @@ ecl_config_type * ecl_config_alloc() ecl_config->static_kw_set = set_alloc_empty(); ecl_config->user_static_kw = stringlist_alloc_new(); ecl_config->num_cpu = 1; /* This must get a valid default in case no ECLIPSE datafile is provided. */ - ecl_config->unit_system = ECL_METRIC_UNITS; + ecl_config->unit_system = ERT_ECL_METRIC_UNITS; ecl_config->data_file = NULL; ecl_config->input_init_section = NULL; ecl_config->init_section = NULL; @@ -538,30 +539,30 @@ ecl_config_type * ecl_config_alloc() return ecl_config; } -void ecl_config_init(ecl_config_type * ecl_config, const config_type * config) +void ecl_config_init(ecl_config_type * ecl_config, const config_content_type * config) { - if (config_item_set(config, ECLBASE_KEY)) { - ui_return_type * ui_return = ecl_config_validate_eclbase(ecl_config, config_iget(config, ECLBASE_KEY, 0, 0)); + if (config_content_has_item(config, ECLBASE_KEY)) { + ui_return_type * ui_return = ecl_config_validate_eclbase(ecl_config, config_content_iget(config, ECLBASE_KEY, 0, 0)); if (ui_return_get_status(ui_return) == UI_RETURN_OK) - ecl_config_set_eclbase(ecl_config, config_iget(config, ECLBASE_KEY, 0, 0)); + ecl_config_set_eclbase(ecl_config, config_content_iget(config, ECLBASE_KEY, 0, 0)); else util_abort("%s: failed to set eclbase format. Error:%s\n", __func__ , ui_return_get_last_error(ui_return)); ui_return_free(ui_return); } - if (config_item_set(config, DATA_FILE_KEY)) + if (config_content_has_item(config, DATA_FILE_KEY)) { - ui_return_type * ui_return = ecl_config_validate_data_file(ecl_config, config_iget(config, DATA_FILE_KEY, 0, 0)); + ui_return_type * ui_return = ecl_config_validate_data_file(ecl_config, config_content_iget(config, DATA_FILE_KEY, 0, 0)); if (ui_return_get_status( ui_return ) == UI_RETURN_OK) - ecl_config_set_data_file( ecl_config, config_iget(config, DATA_FILE_KEY, 0, 0) ); + ecl_config_set_data_file( ecl_config, config_content_iget(config, DATA_FILE_KEY, 0, 0) ); else util_abort("%s: problem setting ECLIPSE data file\n",__func__ , ui_return_get_last_error(ui_return)); - + ui_return_free(ui_return); } - - if (config_item_set(config, SCHEDULE_FILE_KEY)) { - const char * schedule_target_file = config_safe_iget(config, SCHEDULE_FILE_KEY, 0, 1); + + if (config_content_has_item(config, SCHEDULE_FILE_KEY)) { + const char * schedule_target_file = config_content_safe_iget(config, SCHEDULE_FILE_KEY, 0, 1); if (schedule_target_file) { ui_return_type * ui_return_sched_target_file = ecl_config_validate_schedule_file(ecl_config, schedule_target_file); if (!ui_return_get_status(ui_return_sched_target_file) == UI_RETURN_OK) { @@ -570,46 +571,46 @@ void ecl_config_init(ecl_config_type * ecl_config, const config_type * config) ui_return_free(ui_return_sched_target_file); } - ui_return_type * ui_return = ecl_config_validate_schedule_file(ecl_config, config_iget(config, SCHEDULE_FILE_KEY, 0, 0)); + ui_return_type * ui_return = ecl_config_validate_schedule_file(ecl_config, config_content_iget(config, SCHEDULE_FILE_KEY, 0, 0)); if (ui_return_get_status(ui_return) == UI_RETURN_OK) - ecl_config_set_schedule_file(ecl_config, config_iget(config, SCHEDULE_FILE_KEY, 0, 0), schedule_target_file); + ecl_config_set_schedule_file(ecl_config, config_content_iget(config, SCHEDULE_FILE_KEY, 0, 0), schedule_target_file); else util_abort("%s: failed to set schedule file. Error:%s\n",__func__ , ui_return_get_last_error(ui_return)); ui_return_free(ui_return); } - if (config_item_set(config, GRID_KEY)) { - const char * grid_file = config_iget(config, GRID_KEY, 0, 0); + if (config_content_has_item(config, GRID_KEY)) { + const char * grid_file = config_content_iget(config, GRID_KEY, 0, 0); ui_return_type * ui_return = ecl_config_validate_grid( ecl_config , grid_file); if (ui_return_get_status(ui_return) == UI_RETURN_OK) ecl_config_set_grid(ecl_config, grid_file ); else util_abort("%s: failed to set grid file:%s Error:%s \n",__func__ , grid_file , ui_return_get_last_error(ui_return)); - + ui_return_free( ui_return ); } - - if (config_item_set(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY)) + + if (config_content_has_item(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY)) { int iocc; - for (iocc = 0; iocc < config_get_occurences(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY); iocc++) + for (iocc = 0; iocc < config_content_get_occurences(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY); iocc++) ecl_config_add_fixed_length_schedule_kw(ecl_config, - config_iget(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 0), - config_iget_as_int(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 1)); + config_content_iget(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 0), + config_content_iget_as_int(config, ADD_FIXED_LENGTH_SCHEDULE_KW_KEY, iocc, 1)); } - if (config_item_set(config, REFCASE_KEY)) + if (config_content_has_item(config, REFCASE_KEY)) { - const char * refcase_path = config_get_value_as_path(config, REFCASE_KEY); + const char * refcase_path = config_content_get_value_as_path(config, REFCASE_KEY); if (!ecl_config_load_refcase(ecl_config, refcase_path)) fprintf(stderr, "** Warning: loading refcase:%s failed \n", refcase_path); } - if (config_item_set(config, REFCASE_LIST_KEY)) + if (config_content_has_item(config, REFCASE_LIST_KEY)) { - config_content_item_type * item = config_get_content_item(config, REFCASE_LIST_KEY); + config_content_item_type * item = config_content_get_item(config, REFCASE_LIST_KEY); int i; for (i = 0; i < config_content_item_get_size(item); i++) { @@ -624,9 +625,9 @@ void ecl_config_init(ecl_config_type * ecl_config, const config_type * config) } /* Deprecated */ - if (config_item_set(config, PLOT_REFCASE_LIST_KEY)) + if (config_content_has_item(config, PLOT_REFCASE_LIST_KEY)) { - const char * case_list_file = config_get_value(config, PLOT_REFCASE_LIST_KEY); + const char * case_list_file = config_content_get_value(config, PLOT_REFCASE_LIST_KEY); FILE * stream = util_fopen(case_list_file, "r"); bool at_eof; do @@ -642,8 +643,8 @@ void ecl_config_init(ecl_config_type * ecl_config, const config_type * config) fclose(stream); } - if (config_item_set(config, INIT_SECTION_KEY)) - ecl_config_set_init_section(ecl_config, config_get_value(config, INIT_SECTION_KEY)); + if (config_content_has_item(config, INIT_SECTION_KEY)) + ecl_config_set_init_section(ecl_config, config_content_get_value(config, INIT_SECTION_KEY)); else if (ecl_config->can_restart) /** This is a hard error - the datafile contains <INIT>, however @@ -670,9 +671,9 @@ void ecl_config_init(ecl_config_type * ecl_config, const config_type * config) IFF the user has no intentitions of any form of restart, this is perfectly legitemate. */ - if (config_item_set(config, END_DATE_KEY)) + if (config_content_has_item(config, END_DATE_KEY)) { - const char * date_string = config_get_value(config, END_DATE_KEY); + const char * date_string = config_content_get_value(config, END_DATE_KEY); time_t end_date; if (util_sscanf_date(date_string, &end_date)) ecl_config_set_end_date(ecl_config, end_date); @@ -856,14 +857,12 @@ bool ecl_config_get_unified_summary(const ecl_config_type * ecl_config) return ecl_io_config_get_unified_summary(ecl_config->io_config); } -void ecl_config_static_kw_init(ecl_config_type * ecl_config, const config_type * config) +void ecl_config_static_kw_init(ecl_config_type * ecl_config, const config_content_type * config) { - const config_content_item_type * content_item = config_get_content_item(config, STATIC_KW_KEY); - if (content_item != NULL ) - { + if (config_content_has_item( config , STATIC_KW_KEY)) { + const config_content_item_type * content_item = config_content_get_item(config, STATIC_KW_KEY); int j; - for (j = 0; j < config_content_item_get_size(content_item); j++) - { + for (j = 0; j < config_content_item_get_size(content_item); j++) { const config_content_node_type * content_node = config_content_item_iget_node(content_item, j); int k; for (k = 0; k < config_content_node_get_size(content_node); k++) @@ -872,7 +871,7 @@ void ecl_config_static_kw_init(ecl_config_type * ecl_config, const config_type * } } -void ecl_config_add_config_items(config_type * config) +void ecl_config_add_config_items(config_parser_type * config) { config_schema_item_type * item; @@ -1011,11 +1010,11 @@ void ecl_config_fprintf_config(const ecl_config_type * ecl_config, FILE * stream const char * ecl_config_get_depth_unit(const ecl_config_type * ecl_config) { switch(ecl_config->unit_system) { - case ECL_METRIC_UNITS: + case ERT_ECL_METRIC_UNITS: return "M"; - case ECL_FIELD_UNITS: + case ERT_ECL_FIELD_UNITS: return "FT"; - case ECL_LAB_UNITS: + case ERT_ECL_LAB_UNITS: return "CM"; default: util_abort("%s: unit system enum value:%d not recognized \n",__func__ , ecl_config->unit_system); @@ -1027,11 +1026,11 @@ const char * ecl_config_get_depth_unit(const ecl_config_type * ecl_config) const char * ecl_config_get_pressure_unit(const ecl_config_type * ecl_config) { switch(ecl_config->unit_system) { - case ECL_METRIC_UNITS: + case ERT_ECL_METRIC_UNITS: return "BARSA"; - case ECL_FIELD_UNITS: + case ERT_ECL_FIELD_UNITS: return "PSIA"; - case ECL_LAB_UNITS: + case ERT_ECL_LAB_UNITS: return "ATMA"; default: util_abort("%s: unit system enum value:%d not recognized \n",__func__ , ecl_config->unit_system); diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_analysis.c b/ThirdParty/Ert/devel/libenkf/src/enkf_analysis.c index 5abc965d25..fcb7d3a5c3 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_analysis.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_analysis.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_analysis.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_analysis.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <math.h> @@ -49,32 +49,32 @@ void enkf_analysis_fprintf_obs_summary(const obs_data_type * obs_data , const me fprintf(stream , "\n"); else fprintf(stream , " - %04d \n",int_vector_get_last( step_list )); - - - fprintf(stream , "Ministep......: %s \n",ministep_name); + + + fprintf(stream , "Ministep......: %s \n",ministep_name); fprintf(stream , "-------------------------------------------------------------------------------------------------------------------------------\n"); { char * obs_fmt = util_alloc_sprintf(" %%-3d : %%-32s %s +/- %s" , float_fmt , float_fmt); char * sim_fmt = util_alloc_sprintf(" %s +/- %s \n" , float_fmt , float_fmt); - fprintf(stream , " Observed history | Simulated data \n"); + fprintf(stream , " Observed history | Simulated data \n"); fprintf(stream , "-------------------------------------------------------------------------------------------------------------------------------\n"); - + { int block_nr; int obs_count = 1; /* Only for printing */ for (block_nr =0; block_nr < obs_data_get_num_blocks( obs_data ); block_nr++) { const obs_block_type * obs_block = obs_data_iget_block_const( obs_data , block_nr); - const meas_block_type * meas_block = meas_data_iget_block_const( meas_data , block_nr ); + meas_block_type * meas_block = meas_data_iget_block( meas_data , block_nr ); const char * obs_key = obs_block_get_key( obs_block ); - + for (int iobs = 0; iobs < obs_block_get_size( obs_block ); iobs++) { const char * print_key; if (iobs == 0) print_key = obs_key; else print_key = " ..."; - + fprintf(stream , obs_fmt , obs_count , print_key , obs_block_iget_value( obs_block , iobs ) , obs_block_iget_std( obs_block , iobs )); { active_type active_mode = obs_block_iget_active_mode( obs_block , iobs ); @@ -95,10 +95,10 @@ void enkf_analysis_fprintf_obs_summary(const obs_data_type * obs_data , const me } } } - + free( obs_fmt ); free( sim_fmt ); - } + } fprintf(stream , "===============================================================================================================================\n"); fprintf(stream , "\n\n\n"); } @@ -110,11 +110,10 @@ void enkf_analysis_deactivate_outliers(obs_data_type * obs_data , meas_data_type for (int block_nr =0; block_nr < obs_data_get_num_blocks( obs_data ); block_nr++) { obs_block_type * obs_block = obs_data_iget_block( obs_data , block_nr); meas_block_type * meas_block = meas_data_iget_block( meas_data , block_nr ); - - meas_block_calculate_ens_stats( meas_block ); + { int iobs; - for (iobs =0; iobs < meas_block_get_total_size( meas_block ); iobs++) { + for (iobs =0; iobs < meas_block_get_total_obs_size( meas_block ); iobs++) { if (meas_block_iget_active( meas_block , iobs )) { double ens_std = meas_block_iget_ens_std( meas_block , iobs ); if (ens_std <= std_cutoff) { @@ -129,8 +128,8 @@ void enkf_analysis_deactivate_outliers(obs_data_type * obs_data , meas_data_type double obs_std = obs_block_iget_std( obs_block , iobs ); double obs_value = obs_block_iget_value( obs_block , iobs ); double innov = obs_value - ens_mean; - - /* + + /* Deactivated because the distance between the observed data and the ensemble prediction is to large. Keeping these outliers will lead to numerical problems. @@ -153,10 +152,9 @@ void enkf_analysis_deactivate_std_zero(obs_data_type * obs_data , meas_data_type obs_block_type * obs_block = obs_data_iget_block( obs_data , block_nr); meas_block_type * meas_block = meas_data_iget_block( meas_data , block_nr ); - meas_block_calculate_ens_stats( meas_block ); { int iobs; - for (iobs =0; iobs < meas_block_get_total_size( meas_block ); iobs++) { + for (iobs =0; iobs < meas_block_get_total_obs_size( meas_block ); iobs++) { if (meas_block_iget_active( meas_block , iobs )) { double ens_std = meas_block_iget_ens_std( meas_block , iobs ); if (ens_std <= 0.0) { diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_config_node.c b/ThirdParty/Ert/devel/libenkf/src/enkf_config_node.c index e83868547f..c13ddf4b79 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_config_node.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_config_node.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_config_node.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_config_node.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -35,6 +35,7 @@ #include <ert/enkf/field_config.h> #include <ert/enkf/gen_data_config.h> #include <ert/enkf/gen_kw_config.h> +#include <ert/enkf/custom_kw_config.h> #include <ert/enkf/summary_config.h> #include <ert/enkf/surface_config.h> #include <ert/enkf/container_config.h> @@ -51,11 +52,11 @@ struct enkf_config_node_struct { UTIL_TYPE_ID_DECLARATION; ert_impl_type impl_type; - enkf_var_type var_type; - bool vector_storage; + enkf_var_type var_type; + bool vector_storage; bool forward_init; /* Should the (parameter) node be initialized by loading results from the Forward model? */ - bool_vector_type * internalize; /* Should this node be internalized - observe that question of what to internalize is MOSTLY handled at a higher level - without consulting this variable. Can be NULL. */ + bool_vector_type * internalize; /* Should this node be internalized - observe that question of what to internalize is MOSTLY handled at a higher level - without consulting this variable. Can be NULL. */ stringlist_type * obs_keys; /* Keys of observations which observe this node. */ char * key; path_fmt_type * init_file_fmt; /* Format used to create files for initialization. */ @@ -63,8 +64,8 @@ struct enkf_config_node_struct { path_fmt_type * enkf_outfile_fmt; /* Name of file which is written by EnKF, and read by the forward model. */ void * data; /* This points to the config object of the actual implementation. */ enkf_node_type * min_std; - char * min_std_file; - + char * min_std_file; + vector_type * container_nodes; /*****************************************************************/ /* Function pointers to methods working on the underlying config object. */ @@ -97,9 +98,9 @@ static bool enkf_config_node_has_container(const enkf_config_node_type * node , bool enkf_config_node_has_node( const enkf_config_node_type * node , enkf_fs_type * fs , node_id_type node_id) { - if (node->impl_type == CONTAINER) + if (node->impl_type == CONTAINER) return enkf_config_node_has_container( node , fs , node_id ); - else + else return enkf_fs_has_node( fs , node->key , node->var_type , node_id.report_step , node_id.iens , node_id.state ); } @@ -111,65 +112,64 @@ bool enkf_config_node_has_vector( const enkf_config_node_type * node , enkf_fs_t -static enkf_config_node_type * enkf_config_node_alloc__( enkf_var_type var_type, - ert_impl_type impl_type, - const char * key, - bool forward_init) { - - enkf_config_node_type * node = util_malloc( sizeof *node ); - UTIL_TYPE_ID_INIT( node , ENKF_CONFIG_NODE_TYPE_ID ); - node->forward_init = forward_init; - node->var_type = var_type; - node->impl_type = impl_type; - node->key = util_alloc_string_copy( key ); - node->container_nodes = vector_alloc_new(); - node->vector_storage = false; - - node->init_file_fmt = NULL; - node->enkf_infile_fmt = NULL; - node->enkf_outfile_fmt = NULL; - node->internalize = NULL; - node->data = NULL; - node->obs_keys = stringlist_alloc_new(); - node->min_std = NULL; - node->min_std_file = NULL; - - node->get_data_size = NULL; - node->freef = NULL; - { +static enkf_config_node_type * enkf_config_node_alloc__(enkf_var_type var_type, ert_impl_type impl_type, const char * key, bool forward_init) { + enkf_config_node_type * node = util_malloc( sizeof *node ); + UTIL_TYPE_ID_INIT( node , ENKF_CONFIG_NODE_TYPE_ID ); + node->forward_init = forward_init; + node->var_type = var_type; + node->impl_type = impl_type; + node->key = util_alloc_string_copy( key ); + node->container_nodes = vector_alloc_new(); + node->vector_storage = false; + + node->init_file_fmt = NULL; + node->enkf_infile_fmt = NULL; + node->enkf_outfile_fmt = NULL; + node->internalize = NULL; + node->data = NULL; + node->obs_keys = stringlist_alloc_new(); + node->min_std = NULL; + node->min_std_file = NULL; + + node->get_data_size = NULL; + node->freef = NULL; + switch(impl_type) { - case(FIELD): - node->freef = field_config_free__; - node->get_data_size = field_config_get_data_size__; - break; - case(STATIC): - break; - case(GEN_KW): - node->freef = gen_kw_config_free__; - node->get_data_size = gen_kw_config_get_data_size__; - break; - case(SUMMARY): - node->vector_storage = true; - node->freef = summary_config_free__; - node->get_data_size = summary_config_get_data_size__; - break; - case(GEN_DATA): - node->freef = gen_data_config_free__; - node->get_data_size = NULL; - break; - case(SURFACE): - node->freef = surface_config_free__; - node->get_data_size = surface_config_get_data_size__; - break; - case(CONTAINER): - node->freef = container_config_free__; - node->get_data_size = container_config_get_data_size__; - break; - default: - util_abort("%s : invalid implementation type: %d - aborting \n",__func__ , impl_type); + case(FIELD): + node->freef = field_config_free__; + node->get_data_size = field_config_get_data_size__; + break; + case(STATIC): + break; + case(GEN_KW): + node->freef = gen_kw_config_free__; + node->get_data_size = gen_kw_config_get_data_size__; + break; + case(CUSTOM_KW): + node->freef = custom_kw_config_free__; + node->get_data_size = NULL; + break; + case(SUMMARY): + node->vector_storage = true; + node->freef = summary_config_free__; + node->get_data_size = summary_config_get_data_size__; + break; + case(GEN_DATA): + node->freef = gen_data_config_free__; + node->get_data_size = NULL; + break; + case(SURFACE): + node->freef = surface_config_free__; + node->get_data_size = surface_config_get_data_size__; + break; + case(CONTAINER): + node->freef = container_config_free__; + node->get_data_size = container_config_get_data_size__; + break; + default: + util_abort("%s : invalid implementation type: %d - aborting \n",__func__ , impl_type); } - } - return node; + return node; } @@ -186,17 +186,17 @@ bool enkf_config_node_vector_storage( const enkf_config_node_type * config_node) static bool enkf_config_node_is_valid_GEN_KW( const enkf_config_node_type * config_node ) { bool valid = gen_kw_config_is_valid( config_node->data ); valid = (valid && (config_node->enkf_outfile_fmt != NULL)); - + return valid; } static bool enkf_config_node_is_valid_FIELD( const enkf_config_node_type * config_node ) { bool valid = false; - if ( config_node->var_type != INVALID_VAR ) + if ( config_node->var_type != INVALID_VAR ) valid = field_config_is_valid( config_node->data ); - - + + return valid; } @@ -204,7 +204,7 @@ static bool enkf_config_node_is_valid_FIELD( const enkf_config_node_type * confi static bool enkf_config_node_is_valid_GEN_DATA( const enkf_config_node_type * config_node ) { bool valid = gen_kw_config_is_valid( config_node->data ); valid = (valid && (config_node->enkf_outfile_fmt != NULL)); - + return valid; } @@ -231,7 +231,7 @@ bool enkf_config_node_is_valid( const enkf_config_node_type * config_node ) { default: util_abort("%s: - what the fuXX - internal bug. \n",__func__); } - + return valid; } @@ -253,15 +253,15 @@ void enkf_config_node_update_min_std( enkf_config_node_type * config_node , cons } -static void enkf_config_node_update( enkf_config_node_type * config_node , - const char * initfile_fmt , - const char * enkf_outfile_fmt , +static void enkf_config_node_update( enkf_config_node_type * config_node , + const char * initfile_fmt , + const char * enkf_outfile_fmt , const char * enkf_infile_fmt , const char * min_std_file ) { - config_node->init_file_fmt = path_fmt_realloc_path_fmt( config_node->init_file_fmt , initfile_fmt ); - config_node->enkf_infile_fmt = path_fmt_realloc_path_fmt( config_node->enkf_infile_fmt , enkf_infile_fmt ); - config_node->enkf_outfile_fmt = path_fmt_realloc_path_fmt( config_node->enkf_outfile_fmt , enkf_outfile_fmt ); + config_node->init_file_fmt = path_fmt_realloc_path_fmt( config_node->init_file_fmt , initfile_fmt ); + config_node->enkf_infile_fmt = path_fmt_realloc_path_fmt( config_node->enkf_infile_fmt , enkf_infile_fmt ); + config_node->enkf_outfile_fmt = path_fmt_realloc_path_fmt( config_node->enkf_outfile_fmt , enkf_outfile_fmt ); enkf_config_node_update_min_std( config_node , min_std_file ); } @@ -270,11 +270,11 @@ static void enkf_config_node_update( enkf_config_node_type * config_node , enkf_config_node_type * enkf_config_node_alloc(enkf_var_type var_type, ert_impl_type impl_type, - bool forward_init , - const char * key , - const char * init_file_fmt , - const char * enkf_outfile_fmt , - const char * enkf_infile_fmt , + bool forward_init , + const char * key , + const char * init_file_fmt , + const char * enkf_outfile_fmt , + const char * enkf_infile_fmt , void * data) { enkf_config_node_type * node = enkf_config_node_alloc__( var_type , impl_type , key , forward_init); @@ -289,22 +289,26 @@ enkf_config_node_type * enkf_config_node_alloc(enkf_var_type var_ty void enkf_config_node_update_gen_kw( enkf_config_node_type * config_node , const char * enkf_outfile_fmt , /* The include file created by ERT for the forward model. */ - const char * template_file , + const char * template_file , const char * parameter_file , const char * min_std_file , const char * init_file_fmt ) { /* 1: Update the low level gen_kw_config stuff. */ - gen_kw_config_update( config_node->data , template_file , parameter_file ); + gen_kw_config_update( config_node->data , template_file , parameter_file ); /* 2: Update the stuff which is owned by the upper-level enkf_config_node instance. */ enkf_config_node_update( config_node , init_file_fmt , enkf_outfile_fmt , NULL , min_std_file); } +void enkf_config_node_update_custom_kw(enkf_config_node_type * config_node, const char * result_file, const char * output_file) { + enkf_config_node_update(config_node, NULL, output_file, result_file, NULL); +} + /** This will create a new gen_kw_config instance which is NOT yet - valid. + valid. */ enkf_config_node_type * enkf_config_node_new_gen_kw( const char * key , const char * tag_fmt , bool forward_init) { enkf_config_node_type * config_node = enkf_config_node_alloc__( PARAMETER , GEN_KW , key , forward_init); @@ -312,6 +316,11 @@ enkf_config_node_type * enkf_config_node_new_gen_kw( const char * key , const ch return config_node; } +enkf_config_node_type * enkf_config_node_new_custom_kw(const char * key, const char * result_file, const char * output_file) { + enkf_config_node_type * config_node = enkf_config_node_alloc__(DYNAMIC_RESULT, CUSTOM_KW, key, false); + config_node->data = custom_kw_config_alloc_empty(key, result_file, output_file); + return config_node; +} enkf_config_node_type * enkf_config_node_new_surface( const char * key , bool forward_init) { enkf_config_node_type * config_node = enkf_config_node_alloc__( PARAMETER , SURFACE , key , forward_init); @@ -324,7 +333,7 @@ void enkf_config_node_update_surface( enkf_config_node_type * config_node , cons /* 1: Update the data owned by the surface node. */ surface_config_set_base_surface( config_node->data , base_surface ); - + /* 2: Update the stuff which is owned by the upper-level enkf_config_node instance. */ enkf_config_node_update( config_node , init_file_fmt , output_file , NULL , min_std_file); } @@ -341,66 +350,66 @@ enkf_config_node_type * enkf_config_node_alloc_summary( const char * key , load_ -enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM( const char * node_key , - bool forward_init , - gen_data_file_format_type input_format , - gen_data_file_format_type output_format , - const char * init_file_fmt , +enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM( const char * node_key , + bool forward_init , + gen_data_file_format_type input_format , + gen_data_file_format_type output_format , + const char * init_file_fmt , const char * ert_outfile_fmt) { enkf_config_node_type * config_node = enkf_config_node_alloc__( PARAMETER , GEN_DATA , node_key , forward_init ); config_node->data = gen_data_config_alloc_GEN_PARAM( node_key , output_format , input_format); - + enkf_config_node_update( config_node , /* Generic update - needs the format settings from the special.*/ init_file_fmt , - ert_outfile_fmt , - NULL , + ert_outfile_fmt , + NULL , NULL ); - + return config_node; } -enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_result( const char * key , +enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_result( const char * key , gen_data_file_format_type input_format, const char * enkf_infile_fmt ) { - + enkf_config_node_type * config_node = enkf_config_node_alloc__( DYNAMIC_RESULT , GEN_DATA , key , false); config_node->data = gen_data_config_alloc_GEN_DATA_result( key , input_format ); - + enkf_config_node_update( config_node , /* Generic update - needs the format settings from the special.*/ - NULL , - NULL , + NULL , + NULL , enkf_infile_fmt , - NULL ); - + NULL ); + return config_node; } -enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_state( const char * key, - bool forward_init , +enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_state( const char * key, + bool forward_init , gen_data_file_format_type input_format, gen_data_file_format_type output_format, - const char * init_file_fmt , - const char * template_ecl_file , + const char * init_file_fmt , + const char * template_ecl_file , const char * template_data_key , - const char * enkf_outfile_fmt , - const char * enkf_infile_fmt , + const char * enkf_outfile_fmt , + const char * enkf_infile_fmt , const char * min_std_file) { - + if (gen_data_config_valid_result_format( enkf_infile_fmt )) { enkf_config_node_type * config_node = enkf_config_node_alloc__( DYNAMIC_STATE , GEN_DATA , key , forward_init); config_node->data = gen_data_config_alloc_GEN_DATA_state( key , output_format , input_format ); enkf_config_node_update(config_node , /* Generic update - needs the format settings from the special.*/ init_file_fmt , - enkf_outfile_fmt , - enkf_infile_fmt, - min_std_file); + enkf_outfile_fmt , + enkf_infile_fmt, + min_std_file); return config_node; } else { @@ -422,13 +431,13 @@ enkf_config_node_type * enkf_config_node_new_container( const char * key ) { void enkf_config_node_update_container( enkf_config_node_type * config_node , const enkf_config_node_type * child_node) { vector_append_ref( config_node->container_nodes , child_node ); container_config_add_node( config_node->data , child_node ); -} - +} + const char * enkf_config_node_iget_container_key( const enkf_config_node_type * config_node , int index) { const enkf_config_node_type * child_node = vector_iget_const( config_node->container_nodes , index ); return child_node->key; } - + /*****************************************************************/ @@ -456,18 +465,18 @@ void enkf_config_node_update_state_field( enkf_config_node_type * config_node , -void enkf_config_node_update_parameter_field( enkf_config_node_type * config_node , - const char * enkf_outfile_fmt , - const char * init_file_fmt , - const char * min_std_file , +void enkf_config_node_update_parameter_field( enkf_config_node_type * config_node , + const char * enkf_outfile_fmt , + const char * init_file_fmt , + const char * min_std_file , int truncation , double value_min , double value_max , - const char * init_transform , + const char * init_transform , const char * output_transform ) { field_file_format_type export_format = field_config_default_export_format( enkf_outfile_fmt ); /* Purely based on extension, recognizes ROFF and GRDECL, the rest will be ecl_kw format. */ field_config_update_parameter_field( config_node->data , truncation , value_min , value_max , - export_format , - init_transform , + export_format , + init_transform , output_transform ); config_node->var_type = PARAMETER; enkf_config_node_update( config_node , init_file_fmt , enkf_outfile_fmt , NULL , min_std_file); @@ -480,19 +489,19 @@ void enkf_config_node_update_parameter_field( enkf_config_node_type * config_nod /*****************************************************************/ -void enkf_config_node_update_general_field( enkf_config_node_type * config_node , - const char * enkf_outfile_fmt , - const char * enkf_infile_fmt , - const char * init_file_fmt , - const char * min_std_file , +void enkf_config_node_update_general_field( enkf_config_node_type * config_node , + const char * enkf_outfile_fmt , + const char * enkf_infile_fmt , + const char * init_file_fmt , + const char * min_std_file , int truncation , - double value_min , - double value_max , + double value_min , + double value_max , const char * init_transform , const char * input_transform , - const char * output_transform ) { + const char * output_transform ) { + - field_file_format_type export_format = field_config_default_export_format( enkf_outfile_fmt ); /* Purely based on extension, recognizes ROFF and GRDECL, the rest will be ecl_kw format. */ { enkf_var_type var_type; @@ -506,17 +515,17 @@ void enkf_config_node_update_general_field( enkf_config_node_type * config_node } config_node->var_type = var_type; } - field_config_update_general_field( config_node->data , + field_config_update_general_field( config_node->data , truncation , value_min , value_max , - export_format , - init_transform , - input_transform , + export_format , + init_transform , + input_transform , output_transform ); enkf_config_node_update( config_node , init_file_fmt , enkf_outfile_fmt , enkf_infile_fmt, min_std_file); } - + @@ -552,18 +561,18 @@ void enkf_config_node_free(enkf_config_node_type * node) { free(node->key); stringlist_free(node->obs_keys); - if (node->enkf_infile_fmt != NULL) + if (node->enkf_infile_fmt != NULL) path_fmt_free( node->enkf_infile_fmt ); - if (node->enkf_outfile_fmt != NULL) + if (node->enkf_outfile_fmt != NULL) path_fmt_free( node->enkf_outfile_fmt ); - + if (node->init_file_fmt != NULL) path_fmt_free( node->init_file_fmt ); if (node->internalize != NULL) bool_vector_free( node->internalize ); - + if (node->min_std != NULL) enkf_node_free( node->min_std ); @@ -598,7 +607,7 @@ const char * enkf_config_node_get_init_file_fmt( const enkf_config_node_type * c void enkf_config_node_set_min_std( enkf_config_node_type * config_node , enkf_node_type * min_std ) { if (config_node->min_std != NULL) enkf_node_free( config_node->min_std ); - + config_node->min_std = min_std; } @@ -658,7 +667,7 @@ char * enkf_config_node_alloc_outfile(const enkf_config_node_type * node , int r /* The path argument is used when the function is during forward_model - based initialisation. + based initialisation. */ char * enkf_config_node_alloc_initfile( const enkf_config_node_type * node , const char * path , int iens) { @@ -679,14 +688,14 @@ char * enkf_config_node_alloc_initfile( const enkf_config_node_type * node , con -void * enkf_config_node_get_ref(const enkf_config_node_type * node) { - return node->data; +void * enkf_config_node_get_ref(const enkf_config_node_type * node) { + return node->data; } bool enkf_config_node_include_type(const enkf_config_node_type * config_node , int mask) { - + enkf_var_type var_type = config_node->var_type; if (var_type & mask) return true; @@ -701,13 +710,13 @@ bool enkf_config_node_use_forward_init(const enkf_config_node_type * config_node } -ert_impl_type enkf_config_node_get_impl_type(const enkf_config_node_type *config_node) { - return config_node->impl_type; +ert_impl_type enkf_config_node_get_impl_type(const enkf_config_node_type *config_node) { + return config_node->impl_type; } -enkf_var_type enkf_config_node_get_var_type(const enkf_config_node_type *config_node) { - return config_node->var_type; +enkf_var_type enkf_config_node_get_var_type(const enkf_config_node_type *config_node) { + return config_node->var_type; } @@ -735,7 +744,7 @@ int enkf_config_node_load_obs( const enkf_config_node_type * config_node , enkf_ for (iobs = 0; iobs < stringlist_get_size( config_node->obs_keys ); iobs++) { obs_vector_type * obs_vector = enkf_obs_get_vector( enkf_obs , stringlist_iget( config_node->obs_keys , iobs)); - + int report_step = -1; while (true) { report_step = obs_vector_get_next_active_step( obs_vector , report_step); @@ -749,14 +758,14 @@ int enkf_config_node_load_obs( const enkf_config_node_type * config_node , enkf_ gen_obs data type is different depending on whether is called with a data context user_key (as here) or with a observation context user_key (as when plotting an observation plot). See more - documentation of the function gen_obs_user_get_data_index(). + documentation of the function gen_obs_user_get_data_index(). */ if (impl_type == GEN_DATA) gen_obs_user_get_with_data_index( obs_vector_iget_node( obs_vector , report_step ) , key_index , &value , &std1 , &valid); else obs_vector_user_get( obs_vector , key_index , report_step , &value , &std1 , &valid); - + if (valid) { if (obs_count > 0) { _sim_time[num_obs] = enkf_obs_iget_obs_time( enkf_obs , report_step ); @@ -775,11 +784,11 @@ int enkf_config_node_load_obs( const enkf_config_node_type * config_node , enkf_ double_vector_type * std = double_vector_alloc_shared_wrapper( 0 , 0 , _std , obs_count ); time_t_vector_type * sim_time = time_t_vector_alloc_shared_wrapper( 0 , 0 , _sim_time , obs_count ); int * sort_perm = time_t_vector_alloc_sort_perm( sim_time ); - + time_t_vector_permute( sim_time , sort_perm ); double_vector_permute( y , sort_perm ); double_vector_permute( std , sort_perm ); - + free( sort_perm ); double_vector_free( y ); double_vector_free( std ); @@ -814,11 +823,11 @@ void enkf_config_node_fprintf_config( const enkf_config_node_type * config_node case(FIELD): fprintf( stream , CONFIG_KEY_FORMAT , FIELD_KEY ); fprintf( stream , CONFIG_VALUE_FORMAT , config_node->key ); - field_config_fprintf_config( config_node->data , - config_node->var_type , - path_fmt_get_fmt( config_node->enkf_outfile_fmt ) , - path_fmt_get_fmt( config_node->enkf_infile_fmt ) , - config_node->min_std_file , + field_config_fprintf_config( config_node->data , + config_node->var_type , + path_fmt_get_fmt( config_node->enkf_outfile_fmt ) , + path_fmt_get_fmt( config_node->enkf_infile_fmt ) , + config_node->min_std_file , stream ); break; case(GEN_DATA): @@ -827,12 +836,12 @@ void enkf_config_node_fprintf_config( const enkf_config_node_type * config_node fprintf( stream , CONFIG_KEY_FORMAT , GEN_PARAM_KEY ); else fprintf( stream , CONFIG_KEY_FORMAT , GEN_DATA_KEY ); - - gen_data_config_fprintf_config( config_node->data , + + gen_data_config_fprintf_config( config_node->data , config_node->var_type , - path_fmt_get_fmt( config_node->enkf_outfile_fmt ) , - path_fmt_get_fmt( config_node->enkf_infile_fmt ) , - config_node->min_std_file , + path_fmt_get_fmt( config_node->enkf_outfile_fmt ) , + path_fmt_get_fmt( config_node->enkf_infile_fmt ) , + config_node->min_std_file , stream ); break; default: @@ -842,33 +851,39 @@ void enkf_config_node_fprintf_config( const enkf_config_node_type * config_node } /*****************************************************************/ -void enkf_config_node_add_GEN_PARAM_config_schema( config_type * config ) { +void enkf_config_node_add_GEN_PARAM_config_schema( config_parser_type * config ) { config_schema_item_type * item; item = config_add_schema_item(config , GEN_PARAM_KEY , false ); config_schema_item_set_argc_minmax(item , 2 , CONFIG_DEFAULT_ARG_MAX); } -void enkf_config_node_add_GEN_DATA_config_schema( config_type * config ) { +void enkf_config_node_add_GEN_DATA_config_schema( config_parser_type * config ) { config_schema_item_type * item; item = config_add_schema_item(config , GEN_DATA_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); } - +void enkf_config_node_add_CUSTOM_KW_config_schema(config_parser_type * config){ + config_schema_item_type * item = config_add_schema_item(config, CUSTOM_KW_KEY, false); + config_schema_item_set_argc_minmax(item, 2, 3); + config_schema_item_iset_type(item, 0, CONFIG_STRING); + config_schema_item_iset_type(item, 1, CONFIG_PATH); + config_schema_item_iset_type(item, 2, CONFIG_PATH); +} enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_from_config( const config_content_node_type * node ) { enkf_config_node_type * config_node = NULL; const char * node_key = config_content_node_iget( node , 0 ); { hash_type * options = hash_alloc(); - + config_content_node_init_opt_hash( node , options , 1 ); { gen_data_file_format_type input_format = gen_data_config_check_format( hash_safe_get( options , INPUT_FORMAT_KEY)); gen_data_file_format_type output_format = gen_data_config_check_format( hash_safe_get( options , OUTPUT_FORMAT_KEY)); const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY); - const char * ecl_file = hash_safe_get( options , ECL_FILE_KEY); + const char * ecl_file = hash_safe_get( options , ECL_FILE_KEY); const char * template = hash_safe_get( options , TEMPLATE_KEY); const char * data_key = hash_safe_get( options , KEY_KEY); const char * result_file = hash_safe_get( options , RESULT_FILE_KEY); @@ -878,7 +893,7 @@ enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_from_config( const confi int_vector_type * report_steps = int_vector_alloc(0,0); bool forward_init = false; bool valid_input = true; - + if (input_format == GEN_DATA_UNDEFINED) valid_input = false; @@ -886,11 +901,11 @@ enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_from_config( const confi fprintf(stderr, "** ERROR: The RESULT_FILE:%s setting for %s is invalid - must have an embedded %%d - and be a relative path.\n" , result_file , node_key ); valid_input = false; } - + if (report_steps_string) { if (!string_util_update_active_list( report_steps_string , report_steps )) { valid_input = false; - fprintf(stderr,"** ERROR: The REPORT_STEPS:%s attribute was not valid.\n",report_steps_string); + fprintf(stderr,"** ERROR: The REPORT_STEPS:%s attribute was not valid.\n",report_steps_string); } } else { fprintf(stderr,"** ERROR: As of July 2014 the GEN_DATA keywords must have a REPORT_STEPS:xxxx \n"); @@ -908,7 +923,7 @@ enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_from_config( const confi fprintf(stderr," The GEN_DATA keyword: %s will be ignored\n",node_key); valid_input = false; } - + if (valid_input) { if (forward_string) { @@ -916,43 +931,43 @@ enkf_config_node_type * enkf_config_node_alloc_GEN_DATA_from_config( const confi fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string); } - if ((init_file_fmt == NULL) && - (ecl_file == NULL) && - (result_file != NULL)) + if ((init_file_fmt == NULL) && + (ecl_file == NULL) && + (result_file != NULL)) config_node = enkf_config_node_alloc_GEN_DATA_result( node_key , input_format , result_file); - else if ((init_file_fmt != NULL) && - (ecl_file != NULL) && - (result_file != NULL)) - config_node = enkf_config_node_alloc_GEN_DATA_state( node_key , - forward_init , - input_format , - output_format , - init_file_fmt , - template , - data_key , - ecl_file , - result_file , + else if ((init_file_fmt != NULL) && + (ecl_file != NULL) && + (result_file != NULL)) + config_node = enkf_config_node_alloc_GEN_DATA_state( node_key , + forward_init , + input_format , + output_format , + init_file_fmt , + template , + data_key , + ecl_file , + result_file , min_std_file); - + { gen_data_config_type * gen_data_config = enkf_config_node_get_ref( config_node ); - if (template) + if (template) gen_data_config_set_template( gen_data_config , template , data_key); - - for (int i=0; i < int_vector_size( report_steps ); i++) { + + for (int i=0; i < int_vector_size( report_steps ); i++) { int report_step = int_vector_iget( report_steps , i ); gen_data_config_add_report_step( gen_data_config , report_step); enkf_config_node_set_internalize( config_node , report_step ); } } } - + int_vector_free( report_steps ); } hash_free( options ); } - + return config_node; } @@ -963,7 +978,7 @@ enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM_from_config( const conf const char * ecl_file = config_content_node_iget( node , 1 ); { hash_type * options = hash_alloc(); - + config_content_node_init_opt_hash( node , options , 2 ); { gen_data_file_format_type input_format = gen_data_config_check_format( hash_safe_get( options , INPUT_FORMAT_KEY)); @@ -976,7 +991,7 @@ enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM_from_config( const conf bool forward_init = false; bool valid_input = true; - + if (input_format == GEN_DATA_UNDEFINED) valid_input = false; @@ -1003,7 +1018,7 @@ enkf_config_node_type * enkf_config_node_alloc_GEN_PARAM_from_config( const conf if (!template_set_ok) fprintf(stderr,"** Warning: the template settings were not applied correctly - ignored\n"); } - + if (min_std_file) enkf_config_node_update_min_std( config_node , min_std_file ); diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c b/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c index c3bfc0a96d..0899bc19ad 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_fs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_fs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <sys/types.h> @@ -44,8 +44,10 @@ #include <ert/enkf/gen_data.h> #include <ert/enkf/time_map.h> #include <ert/enkf/state_map.h> +#include <ert/enkf/summary_key_set.h> #include <ert/enkf/misfit_ensemble.h> #include <ert/enkf/cases_config.h> +#include <ert/enkf/custom_kw_config_set.h> /** @@ -69,7 +71,7 @@ The interface - ------------- + ------------- The unit of storage in the enkf_fs system is one enkf_node instance. The interface between the storage system and the rest of the EnKF system is @@ -86,7 +88,7 @@ - iens : ensemble member number - report_step : the report_step number we are interested in - - state : whether we are considering an analyzed node or a forecast. + - state : whether we are considering an analyzed node or a forecast. In addition to the functions enkf_fs_fread_node() and enkf_fs_fwrite_node() there are higher level functions enkf_fs_fread_alloc_ensemble() to load an ensemble of @@ -124,7 +126,7 @@ This driver utilizes that parameters do not change during the forward model, i.e. (analyzed , t) = (forecast , t - 1). So, only one version of the data is actually stored; if you ask for the forecast you just get the data from the - previous report_step. + previous report_step. To support spin-ups and such the driver will actually go backwards in report_time all the way until a node is found on disk. @@ -173,7 +175,7 @@ The enkf_mount_info file (BINARY) consists of four records (one for each driver, including the index). The format of each record is: - DRIVER_CATEGORY DRIVER_ID INFO + DRIVER_CATEGORY DRIVER_ID INFO int int void * The driver category should be one of the four integer values in @@ -187,7 +189,7 @@ enkf_mount_info file, but when four records are read it checks that all drivers have been initialized, and aborts if that is not the case. - + If the enkf_mount_info file is deleted you (might) be fucked. It is currently 'protected' with chomd a-w - but that is of course not foolprof. @@ -203,12 +205,14 @@ */ -#define ENKF_FS_TYPE_ID 1089763 -#define ENKF_MOUNT_MAP "enkf_mount_info" -#define TIME_MAP_FILE "time-map" -#define STATE_MAP_FILE "state-map" -#define MISFIT_ENSEMBLE_FILE "misfit-ensemble" -#define CASE_CONFIG_FILE "case_config" +#define ENKF_FS_TYPE_ID 1089763 +#define ENKF_MOUNT_MAP "enkf_mount_info" +#define SUMMARY_KEY_SET_FILE "summary-key-set" +#define TIME_MAP_FILE "time-map" +#define STATE_MAP_FILE "state-map" +#define MISFIT_ENSEMBLE_FILE "misfit-ensemble" +#define CASE_CONFIG_FILE "case_config" +#define CUSTOM_KW_CONFIG_SET_FILE "custom_kw_config_set" struct enkf_fs_struct { UTIL_TYPE_ID_DECLARATION; @@ -218,20 +222,22 @@ struct enkf_fs_struct { char * lock_file; int lock_fd; - + fs_driver_type * dynamic_forecast; fs_driver_type * dynamic_analyzed; fs_driver_type * parameter; fs_driver_type * eclipse_static; fs_driver_type * index ; - bool read_only; /* Whether this filesystem has been mounted read-only. */ - time_map_type * time_map; - cases_config_type * cases_config; - state_map_type * state_map; - misfit_ensemble_type * misfit_ensemble; - /* - The variables below here are for storing arbitrary files within + bool read_only; /* Whether this filesystem has been mounted read-only. */ + time_map_type * time_map; + cases_config_type * cases_config; + state_map_type * state_map; + summary_key_set_type * summary_key_set; + misfit_ensemble_type * misfit_ensemble; + custom_kw_config_set_type * custom_kw_config_set; + /* + The variables below here are for storing arbitrary files within the enkf_fs storage directory, but not as serialized enkf_nodes. */ path_fmt_type * case_fmt; @@ -239,7 +245,8 @@ struct enkf_fs_struct { path_fmt_type * case_tstep_fmt; path_fmt_type * case_tstep_member_fmt; - int refcount; + int refcount; + int writecount; }; @@ -264,7 +271,7 @@ int enkf_fs_decref( enkf_fs_type * fs ) { if (fs->refcount < 0) util_abort("%s: internal fuckup. The filesystem refcount:%d is < 0 \n",__func__ , fs->refcount); - + if (refcount == 0) enkf_fs_umount( fs ); @@ -289,6 +296,8 @@ static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point ) { fs->time_map = time_map_alloc( ); fs->cases_config = cases_config_alloc(); fs->state_map = state_map_alloc(); + fs->summary_key_set = summary_key_set_alloc(); + fs->custom_kw_config_set = custom_kw_config_set_alloc(); fs->misfit_ensemble = misfit_ensemble_alloc(); fs->index = NULL; fs->eclipse_static = NULL; @@ -298,8 +307,9 @@ static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point ) { fs->read_only = true; fs->mount_point = util_alloc_string_copy( mount_point ); fs->refcount = 0; + fs->writecount = 0; fs->lock_fd = 0; - + if (mount_point == NULL) util_abort("%s: fatal internal error: mount_point == NULL \n",__func__); { @@ -329,7 +339,7 @@ static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point ) { static int enkf_fs_fread_fs_version__(FILE * stream) { int version; long fs_tag = util_fread_long( stream ); - if (fs_tag == FS_MAGIC_ID) + if (fs_tag == FS_MAGIC_ID) version = util_fread_int(stream); else version = 0; @@ -338,9 +348,9 @@ static int enkf_fs_fread_fs_version__(FILE * stream) { /** - -1 : No mount map found. + -1 : No mount map found. 0 : Old mount map without version info. - x : Actual version info. + x : Actual version info. */ static int enkf_fs_get_fs_version__(const char * config_file) { @@ -349,16 +359,16 @@ static int enkf_fs_get_fs_version__(const char * config_file) { FILE * stream = util_fopen(config_file , "r"); version = enkf_fs_fread_fs_version__(stream); fclose(stream); - } + } return version; } /** - Function written to look for old (version <= 104) mount info maps. + Function written to look for old (version <= 104) mount info maps. */ int enkf_fs_get_version104( const char * path ) { - char * config_file = util_alloc_filename( path , ENKF_MOUNT_MAP, NULL); + char * config_file = util_alloc_filename( path , ENKF_MOUNT_MAP, NULL); int version = enkf_fs_get_fs_version__( config_file ); free( config_file ); return version; @@ -386,25 +396,25 @@ static void enkf_fs_init_path_fmt( enkf_fs_type * fs) { static void enkf_fs_create_plain_fs( FILE * stream , void * arg) { - + plain_driver_create_fs( stream , DRIVER_PARAMETER , DEFAULT_PLAIN_NODE_PARAMETER_PATH , DEFAULT_PLAIN_VECTOR_PARAMETER_PATH); plain_driver_create_fs( stream , DRIVER_STATIC , DEFAULT_PLAIN_NODE_STATIC_PATH , DEFAULT_PLAIN_VECTOR_STATIC_PATH); plain_driver_create_fs( stream , DRIVER_DYNAMIC_FORECAST , DEFAULT_PLAIN_NODE_DYNAMIC_FORECAST_PATH , DEFAULT_PLAIN_VECTOR_DYNAMIC_FORECAST_PATH); plain_driver_create_fs( stream , DRIVER_DYNAMIC_ANALYZED , DEFAULT_PLAIN_NODE_DYNAMIC_ANALYZED_PATH , DEFAULT_PLAIN_VECTOR_DYNAMIC_ANALYZED_PATH); plain_driver_create_fs( stream , DRIVER_INDEX , DEFAULT_PLAIN_NODE_INDEX_PATH , DEFAULT_PLAIN_VECTOR_INDEX_PATH ); - + } static void enkf_fs_create_block_fs( FILE * stream , int num_drivers , const char * mount_point , void * arg) { - + block_fs_driver_create_fs( stream , mount_point , DRIVER_PARAMETER , num_drivers , "Ensemble/mod_%d" , "PARAMETER"); block_fs_driver_create_fs( stream , mount_point , DRIVER_STATIC , num_drivers , "Ensemble/mod_%d" , "STATIC"); block_fs_driver_create_fs( stream , mount_point , DRIVER_DYNAMIC_FORECAST , num_drivers , "Ensemble/mod_%d" , "FORECAST"); block_fs_driver_create_fs( stream , mount_point , DRIVER_DYNAMIC_ANALYZED , num_drivers , "Ensemble/mod_%d" , "ANALYZED"); block_fs_driver_create_fs( stream , mount_point , DRIVER_INDEX , 1 , "Index" , "INDEX"); - + } @@ -431,14 +441,14 @@ static void enkf_fs_assign_driver( enkf_fs_type * fs , fs_driver_type * driver , static enkf_fs_type * enkf_fs_mount_block_fs( FILE * fstab_stream , const char * mount_point ) { enkf_fs_type * fs = enkf_fs_alloc_empty( mount_point ); - + { int driver_nr; for (driver_nr = 0; driver_nr < 5; driver_nr++) { fs_driver_enum driver_type = util_fread_int( fstab_stream ); fs_driver_type * driver = block_fs_driver_open( fstab_stream , mount_point , driver_type , fs->read_only); - + enkf_fs_assign_driver( fs , driver , driver_type ); } } @@ -453,7 +463,7 @@ static enkf_fs_type * enkf_fs_mount_plain( FILE * fstab_stream , const char * m for (driver_nr = 0; driver_nr < 5; driver_nr++) { fs_driver_enum driver_type = util_fread_int( fstab_stream ); fs_driver_type * driver = plain_driver_open( fstab_stream , mount_point ); - + enkf_fs_assign_driver( fs , driver , driver_type ); } } @@ -482,7 +492,7 @@ enkf_fs_type * enkf_fs_create_fs( const char * mount_point, fs_driver_impl drive fclose( stream ); } - if (mount) + if (mount) return enkf_fs_mount( mount_point ); else return NULL; @@ -515,7 +525,17 @@ static void enkf_fs_fsync_state_map( enkf_fs_type * fs ) { free( filename ); } +static void enkf_fs_fsync_summary_key_set( enkf_fs_type * fs ) { + char * filename = enkf_fs_alloc_case_filename( fs , SUMMARY_KEY_SET_FILE ); + summary_key_set_fwrite( fs->summary_key_set , filename ); + free( filename ); +} +static void enkf_fs_fsync_custom_kw_config_set( enkf_fs_type * fs ) { + char * filename = enkf_fs_alloc_case_filename(fs, CUSTOM_KW_CONFIG_SET_FILE); + custom_kw_config_set_fwrite(fs->custom_kw_config_set, filename ); + free( filename ); +} static void enkf_fs_fread_cases_config( enkf_fs_type * fs ) { char * filename = enkf_fs_alloc_case_filename( fs , CASE_CONFIG_FILE ); @@ -530,6 +550,17 @@ static void enkf_fs_fread_state_map( enkf_fs_type * fs ) { free( filename ); } +static void enkf_fs_fread_summary_key_set( enkf_fs_type * fs ) { + char * filename = enkf_fs_alloc_case_filename( fs , SUMMARY_KEY_SET_FILE ); + summary_key_set_fread( fs->summary_key_set , filename ); + free( filename ); +} + +static void enkf_fs_fread_custom_kw_config_set(enkf_fs_type * fs) { + char * filename = enkf_fs_alloc_case_filename(fs, CUSTOM_KW_CONFIG_SET_FILE); + custom_kw_config_set_fread(fs->custom_kw_config_set, filename); + free( filename ); +} state_map_type * enkf_fs_alloc_readonly_state_map( const char * mount_point ) { path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt( DEFAULT_CASE_PATH ); @@ -542,6 +573,16 @@ state_map_type * enkf_fs_alloc_readonly_state_map( const char * mount_point ) { return state_map; } +summary_key_set_type * enkf_fs_alloc_readonly_summary_key_set( const char * mount_point ) { + path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt( DEFAULT_CASE_PATH ); + char * filename = path_fmt_alloc_file( path_fmt , false , mount_point , SUMMARY_KEY_SET_FILE); + + summary_key_set_type * summary_key_set = summary_key_set_alloc_from_file( filename, true ); + + path_fmt_free( path_fmt ); + free( filename ); + return summary_key_set; +} time_map_type * enkf_fs_alloc_readonly_time_map( const char * mount_point ) { path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt( DEFAULT_CASE_PATH ); @@ -581,14 +622,14 @@ static void enkf_fs_fwrite_misfit( enkf_fs_type * fs ) { enkf_fs_type * enkf_fs_mount( const char * mount_point ) { FILE * stream = fs_driver_open_fstab( mount_point , false ); - + if (stream != NULL) { enkf_fs_type * fs = NULL; fs_driver_assert_magic( stream ); fs_driver_assert_version( stream , mount_point ); { fs_driver_impl driver_id = util_fread_int( stream ); - + switch( driver_id ) { case( BLOCK_FS_DRIVER_ID ): fs = enkf_fs_mount_block_fs( stream , mount_point); @@ -605,8 +646,10 @@ enkf_fs_type * enkf_fs_mount( const char * mount_point ) { enkf_fs_fread_time_map( fs ); enkf_fs_fread_cases_config( fs ); enkf_fs_fread_state_map( fs ); + enkf_fs_fread_summary_key_set( fs ); + enkf_fs_fread_custom_kw_config_set( fs ); enkf_fs_fread_misfit( fs ); - + enkf_fs_get_ref( fs ); return fs; } @@ -616,7 +659,7 @@ enkf_fs_type * enkf_fs_mount( const char * mount_point ) { bool enkf_fs_exists( const char * mount_point ) { bool exists = false; - + FILE * stream = fs_driver_open_fstab( mount_point , false ); if (stream != NULL) { exists = true; @@ -652,7 +695,7 @@ static void enkf_fs_umount( enkf_fs_type * fs ) { enkf_fs_free_driver( fs->parameter ); enkf_fs_free_driver( fs->eclipse_static ); enkf_fs_free_driver( fs->index ); - + if (fs->lock_fd > 0) { close( fs->lock_fd ); // Closing the lock_file file descriptor - and releasing the lock. util_unlink_existing( fs->lock_file ); @@ -666,8 +709,9 @@ static void enkf_fs_umount( enkf_fs_type * fs ) { path_fmt_free( fs->case_member_fmt ); path_fmt_free( fs->case_tstep_fmt ); path_fmt_free( fs->case_tstep_member_fmt ); - + state_map_free( fs->state_map ); + summary_key_set_free(fs->summary_key_set); time_map_free( fs->time_map ); cases_config_free( fs->cases_config ); misfit_ensemble_free( fs->misfit_ensemble ); @@ -682,13 +726,13 @@ static void enkf_fs_umount( enkf_fs_type * fs ) { static void * select_dynamic_driver(enkf_fs_type * fs , state_enum state ) { void * driver = NULL; - if (state == ANALYZED) + if (state == ANALYZED) driver = fs->dynamic_analyzed; - else if (state == FORECAST) + else if (state == FORECAST) driver = fs->dynamic_forecast; - else + else util_abort("%s: tried to select dynamic driver according to ID:%d - invalid \n",__func__ , state); - + return driver; } @@ -737,6 +781,8 @@ void enkf_fs_fsync( enkf_fs_type * fs ) { enkf_fs_fsync_time_map( fs ); enkf_fs_fsync_cases_config( fs) ; enkf_fs_fsync_state_map( fs ); + enkf_fs_fsync_summary_key_set( fs ); + enkf_fs_fsync_custom_kw_config_set(fs); } @@ -758,9 +804,9 @@ static int __get_parameter_report_step( fs_driver_type * driver , const char * n seek backwards through the report numbers, all the way back to report_nr 0. The direct motivation for this functionality is the following situation: - + 1. We do a spin-up from report 0 to report R1. - + 2. We start the assimulation from R1, then we have to go all the way back to report 0 to get hold of the parameter. @@ -775,28 +821,28 @@ static int __get_parameter_report_step( fs_driver_type * driver , const char * n } -void enkf_fs_fread_node(enkf_fs_type * enkf_fs , buffer_type * buffer , - const char * node_key , - enkf_var_type var_type , - int report_step, - int iens , +void enkf_fs_fread_node(enkf_fs_type * enkf_fs , buffer_type * buffer , + const char * node_key , + enkf_var_type var_type , + int report_step, + int iens , state_enum state) { - + fs_driver_type * driver = enkf_fs_select_driver(enkf_fs , var_type , state , node_key ); if (var_type == PARAMETER) report_step = __get_parameter_report_step(driver , node_key , report_step , iens , state); - + buffer_rewind( buffer ); driver->load_node(driver , node_key , report_step , iens , buffer); } -void enkf_fs_fread_vector(enkf_fs_type * enkf_fs , buffer_type * buffer , - const char * node_key , - enkf_var_type var_type , - int iens , +void enkf_fs_fread_vector(enkf_fs_type * enkf_fs , buffer_type * buffer , + const char * node_key , + enkf_var_type var_type , + int iens , state_enum state) { - + fs_driver_type * driver = enkf_fs_select_driver(enkf_fs , var_type , state , node_key ); buffer_rewind( buffer ); @@ -807,16 +853,16 @@ void enkf_fs_fread_vector(enkf_fs_type * enkf_fs , buffer_type * buffer , bool enkf_fs_has_node(enkf_fs_type * enkf_fs , const char * node_key , enkf_var_type var_type , int report_step , int iens , state_enum state) { fs_driver_type * driver = fs_driver_safe_cast(enkf_fs_select_driver(enkf_fs , var_type , state , node_key)); - return driver->has_node(driver , node_key , report_step , iens ); + return driver->has_node(driver , node_key , report_step , iens ); } bool enkf_fs_has_vector(enkf_fs_type * enkf_fs , const char * node_key , enkf_var_type var_type , int iens , state_enum state) { fs_driver_type * driver = fs_driver_safe_cast(enkf_fs_select_driver(enkf_fs , var_type , state , node_key)); - return driver->has_vector(driver , node_key , iens ); + return driver->has_vector(driver , node_key , iens ); } -void enkf_fs_fwrite_node(enkf_fs_type * enkf_fs , buffer_type * buffer , const char * node_key, enkf_var_type var_type, +void enkf_fs_fwrite_node(enkf_fs_type * enkf_fs , buffer_type * buffer , const char * node_key, enkf_var_type var_type, int report_step , int iens , state_enum state) { if (enkf_fs->read_only) util_abort("%s: attempt to write to read_only filesystem mounted at:%s - aborting. \n",__func__ , enkf_fs->mount_point); @@ -830,7 +876,7 @@ void enkf_fs_fwrite_node(enkf_fs_type * enkf_fs , buffer_type * buffer , const c } -void enkf_fs_fwrite_vector(enkf_fs_type * enkf_fs , buffer_type * buffer , const char * node_key, enkf_var_type var_type, +void enkf_fs_fwrite_vector(enkf_fs_type * enkf_fs , buffer_type * buffer , const char * node_key, enkf_var_type var_type, int iens , state_enum state) { if (enkf_fs->read_only) util_abort("%s: attempt to write to read_only filesystem mounted at:%s - aborting. \n",__func__ , enkf_fs->mount_point); @@ -955,7 +1001,7 @@ FILE * enkf_fs_open_case_member_file( const enkf_fs_type * fs , const char * inp free( filename ); return stream; } - + FILE * enkf_fs_open_case_tstep_file( const enkf_fs_type * fs , const char * input_name , int tstep , const char * mode) { char * filename = enkf_fs_alloc_case_tstep_filename( fs , tstep , input_name ); @@ -973,7 +1019,7 @@ FILE * enkf_fs_open_case_tstep_member_file( const enkf_fs_type * fs , const char } /*****************************************************************/ -/* +/* The open_exXXX functions will return NULL if the file does not already exist. These functions can only be used to open with 'r' mode. @@ -1002,7 +1048,7 @@ FILE * enkf_fs_open_excase_member_file( const enkf_fs_type * fs , const char * i free( filename ); return stream; } - + FILE * enkf_fs_open_excase_tstep_file( const enkf_fs_type * fs , const char * input_name , int tstep ) { char * filename = enkf_fs_alloc_case_tstep_filename( fs , tstep , input_name ); @@ -1018,7 +1064,7 @@ FILE * enkf_fs_open_excase_tstep_member_file( const enkf_fs_type * fs , const ch free( filename ); return stream; } - + /*****************************************************************/ time_map_type * enkf_fs_get_time_map( const enkf_fs_type * fs ) { @@ -1033,8 +1079,27 @@ state_map_type * enkf_fs_get_state_map( const enkf_fs_type * fs ) { return fs->state_map; } +summary_key_set_type * enkf_fs_get_summary_key_set( const enkf_fs_type * fs ) { + return fs->summary_key_set; +} + +custom_kw_config_set_type * enkf_fs_get_custom_kw_config_set(const enkf_fs_type * fs) { + return fs->custom_kw_config_set; +} misfit_ensemble_type * enkf_fs_get_misfit_ensemble( const enkf_fs_type * fs ) { return fs->misfit_ensemble; } +void enkf_fs_increase_write_count(enkf_fs_type * fs) { + fs->writecount = fs->writecount + 1; +} + +void enkf_fs_decrease_write_count(enkf_fs_type * fs) { + fs->writecount = fs->writecount - 1; +} + +int enkf_fs_get_write_count(const enkf_fs_type * fs) { + return fs->writecount; +} + diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_main.c b/ThirdParty/Ert/devel/libenkf/src/enkf_main.c index 0745668a88..e870978d9b 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_main.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_main.c @@ -1,18 +1,18 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - The file 'enkf_main.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + The file 'enkf_main.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -48,7 +48,7 @@ #include <ert/util/string_util.h> #include <ert/util/type_vector_functions.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_schema_item.h> #include <ert/ecl/ecl_util.h> @@ -163,16 +163,16 @@ struct enkf_main_struct { subst_func_pool_type * subst_func_pool; subst_list_type * subst_list; /* A parent subst_list instance - common to all ensemble members. */ /*-------------------------*/ - + int_vector_type * keep_runpath; /* HACK: This is only used in the initialization period - afterwards the data is held by the enkf_state object. */ bool pre_clear_runpath; /* HACK: This is only used in the initialization period - afterwards the data is held by the enkf_state object. */ char * site_config_file; - char * user_config_file; - char * rft_config_file; /* File giving the configuration to the RFTwells*/ + char * user_config_file; + char * rft_config_file; /* File giving the configuration to the RFTwells*/ enkf_obs_type * obs; enkf_state_type ** ensemble; /* The ensemble ... */ - int ens_size; /* The size of the ensemble */ + int ens_size; /* The size of the ensemble */ bool verbose; }; @@ -182,7 +182,7 @@ struct enkf_main_struct { /*****************************************************************/ void enkf_main_init_internalization( enkf_main_type * , run_mode_type ); - +void enkf_main_update_local_updates( enkf_main_type * enkf_main); @@ -233,7 +233,7 @@ ui_return_type * enkf_main_set_eclbase( enkf_main_type * enkf_main , const char } void enkf_main_init_jobname( enkf_main_type * enkf_main) { - for (int iens = 0; iens < enkf_main->ens_size; iens++) + for (int iens = 0; iens < enkf_main->ens_size; iens++) enkf_state_update_jobname( enkf_main->ensemble[iens] ); } @@ -249,7 +249,7 @@ void enkf_main_set_user_config_file( enkf_main_type * enkf_main , const char * u void enkf_main_set_rft_config_file( enkf_main_type * enkf_main , const char * rft_config_file ) { enkf_main->rft_config_file = util_realloc_string_copy( enkf_main->rft_config_file , rft_config_file ); -} +} void enkf_main_set_site_config_file( enkf_main_type * enkf_main , const char * site_config_file ) { enkf_main->site_config_file = util_realloc_string_copy( enkf_main->site_config_file , site_config_file ); @@ -330,41 +330,50 @@ qc_module_type * enkf_main_get_qc_module( const enkf_main_type * enkf_main ) { } -/** - Will do a forced reload of the observtaions; if the user has edited - the content of the observation file while the ERT instance is - running. +/* + Adding inverse observation keys to the enkf_nodes; can be called + several times. */ -void enkf_main_reload_obs( enkf_main_type * enkf_main) { - enkf_obs_reload(enkf_main->obs , - model_config_get_history(enkf_main->model_config), - model_config_get_external_time_map(enkf_main->model_config), - ecl_config_get_grid( enkf_main->ecl_config ), - ecl_config_get_refcase( enkf_main->ecl_config ) , - analysis_config_get_std_cutoff(enkf_main->analysis_config), - enkf_main->ensemble_config ); + +void enkf_main_update_obs_keys( enkf_main_type * enkf_main ) { + /* First clear all existing observation keys. */ + ensemble_config_clear_obs_keys( enkf_main->ensemble_config ); + + /* Add new observation keys. */ + { + hash_type * map = enkf_obs_alloc_data_map(enkf_main->obs); + hash_iter_type * iter = hash_iter_alloc(map); + const char * obs_key = hash_iter_get_next_key(iter); + while (obs_key != NULL) { + const char * state_kw = hash_get(map , obs_key); + ensemble_config_add_obs_key(enkf_main->ensemble_config , state_kw , obs_key); + obs_key = hash_iter_get_next_key(iter); + } + hash_iter_free(iter); + hash_free(map); + } } +void enkf_main_alloc_obs( enkf_main_type * enkf_main ) { + enkf_main->obs = enkf_obs_alloc( model_config_get_history(enkf_main->model_config), + model_config_get_external_time_map(enkf_main->model_config), + ecl_config_get_grid( enkf_main->ecl_config ), + ecl_config_get_refcase( enkf_main->ecl_config ) , + enkf_main->ensemble_config ); +} -/** - Will not reload the observations if the input config file - @obs_config_file is equal to the currently set config_file. If you - want to force a reload of the observations use the function - enkf_main_reload_obs(). -*/ +void enkf_main_load_obs( enkf_main_type * enkf_main , const char * obs_config_file , bool clear_existing) { + if (clear_existing) + enkf_obs_clear( enkf_main->obs ); -void enkf_main_load_obs( enkf_main_type * enkf_main , const char * obs_config_file ) { - if (!util_string_equal( obs_config_file , enkf_obs_get_config_file( enkf_main->obs ))) { - enkf_obs_load(enkf_main->obs , - model_config_get_history(enkf_main->model_config), - model_config_get_external_time_map(enkf_main->model_config), - obs_config_file , - ecl_config_get_grid( enkf_main->ecl_config ), - ecl_config_get_refcase( enkf_main->ecl_config ) , - analysis_config_get_std_cutoff(enkf_main->analysis_config), - enkf_main->ensemble_config ); - } + if (enkf_obs_load(enkf_main->obs , + obs_config_file , + analysis_config_get_std_cutoff(enkf_main->analysis_config))) { + enkf_main_update_obs_keys(enkf_main); + enkf_main_update_local_updates(enkf_main ); + } else + fprintf(stderr,"** Warning: failed to load observation data from: %s \n",obs_config_file); } @@ -379,7 +388,7 @@ static void enkf_main_update_num_cpu( enkf_main_type * enkf_main ) { { char * num_cpu_key = enkf_util_alloc_tagged_string( "NUM_CPU" ); char * num_cpu_string = util_alloc_sprintf( "%d" , ecl_config_get_num_cpu( enkf_main->ecl_config )); - + subst_list_append_owned_ref( enkf_main->subst_list , num_cpu_key , num_cpu_string , NULL ); free( num_cpu_key ); } @@ -409,15 +418,17 @@ static void enkf_main_free_ensemble( enkf_main_type * enkf_main ) { } -void enkf_main_free(enkf_main_type * enkf_main){ +void enkf_main_free(enkf_main_type * enkf_main){ if (enkf_main->rng != NULL) rng_free( enkf_main->rng ); rng_config_free( enkf_main->rng_config ); - - enkf_obs_free(enkf_main->obs); + + if (enkf_main->obs) + enkf_obs_free(enkf_main->obs); + ranking_table_free( enkf_main->ranking_table ); enkf_main_free_ensemble( enkf_main ); - if (enkf_main->dbase != NULL) + if (enkf_main->dbase != NULL) enkf_fs_decref( enkf_main->dbase ); ert_log_close(); @@ -425,14 +436,13 @@ void enkf_main_free(enkf_main_type * enkf_main){ analysis_config_free(enkf_main->analysis_config); ecl_config_free(enkf_main->ecl_config); model_config_free( enkf_main->model_config); - - + + qc_module_free( enkf_main->qc_module ); site_config_free( enkf_main->site_config); ensemble_config_free( enkf_main->ensemble_config ); - - if (enkf_main->local_config != NULL) - local_config_free( enkf_main->local_config ); + + local_config_free( enkf_main->local_config ); ert_report_list_free( enkf_main->report_list ); ert_workflow_list_free( enkf_main->workflow_list ); @@ -441,7 +451,7 @@ void enkf_main_free(enkf_main_type * enkf_main){ int_vector_free( enkf_main->keep_runpath ); plot_config_free( enkf_main->plot_config ); ert_templates_free( enkf_main->templates ); - + subst_func_pool_free( enkf_main->subst_func_pool ); subst_list_free( enkf_main->subst_list ); util_safe_free( enkf_main->user_config_file ); @@ -552,11 +562,11 @@ enkf_node_type ** enkf_main_get_node_ensemble(const enkf_main_type * enkf_main , enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); const int ens_size = enkf_main_get_ensemble_size( enkf_main ); enkf_node_type ** node_ensemble = util_calloc(ens_size , sizeof * node_ensemble ); - node_id_type node_id = {.report_step = report_step , - .state = load_state , + node_id_type node_id = {.report_step = report_step , + .state = load_state , .iens = -1 }; int iens; - + for (iens = 0; iens < ens_size; iens++) { node_ensemble[iens] = enkf_state_get_node(enkf_main->ensemble[iens] , key); @@ -622,7 +632,7 @@ void enkf_main_inflate_node(enkf_main_type * enkf_main , enkf_fs_type * target_f enkf_node_type * mean = enkf_node_copyc( ensemble[0] ); enkf_node_type * std = enkf_node_copyc( ensemble[0] ); int iens; - + /* Shifting away the mean */ enkf_main_node_mean( (const enkf_node_type **) ensemble , ens_size , mean ); enkf_node_scale( mean , -1 ); @@ -660,7 +670,7 @@ void enkf_main_inflate_node(enkf_main_type * enkf_main , enkf_fs_type * target_f -/** +/** Denne burde istedet loope gjennom noklene fra use_count direkte. */ @@ -675,7 +685,7 @@ void enkf_main_inflate(enkf_main_type * enkf_main , enkf_fs_type * target_fs , i if (hash_get_counter(use_count , key) > 0) { const enkf_config_node_type * config_node = ensemble_config_get_node( enkf_main->ensemble_config , key ); const enkf_node_type * min_std = enkf_config_node_get_min_std( config_node ); - + if (min_std != NULL) { msg_update( msg , key ); enkf_main_inflate_node(enkf_main , target_fs , report_step , key , min_std ); @@ -703,7 +713,7 @@ static int __get_active_size(enkf_main_type * enkf_main , const char * key, int { if (enkf_config_node_get_impl_type( config_node ) == GEN_DATA) { enkf_node_type * node = enkf_state_get_node( enkf_main->ensemble[0] , key); - node_id_type node_id = {.report_step = report_step , + node_id_type node_id = {.report_step = report_step , .iens = 0, .state = FORECAST }; @@ -731,12 +741,12 @@ static int __get_active_size(enkf_main_type * enkf_main , const char * key, int /*****************************************************************/ /** - Helper struct used to pass information to the multithreaded + Helper struct used to pass information to the multithreaded serialize / deserialize functions. */ typedef struct { - enkf_fs_type * src_fs; + enkf_fs_type * src_fs; enkf_fs_type * target_fs; enkf_state_type ** ensemble; int iens1; /* Inclusive lower limit. */ @@ -745,7 +755,7 @@ typedef struct { int report_step; int target_step; state_enum load_state; - run_mode_type run_mode; + run_mode_type run_mode; int row_offset; const active_list_type * active_list; matrix_type * A; @@ -754,13 +764,13 @@ typedef struct { -static void serialize_node( enkf_fs_type * fs , - enkf_state_type ** ensemble , - const char * key , - int iens , - int report_step , - state_enum load_state , - int row_offset , +static void serialize_node( enkf_fs_type * fs , + enkf_state_type ** ensemble , + const char * key , + int iens , + int report_step , + state_enum load_state , + int row_offset , int column, const active_list_type * active_list, matrix_type * A) { @@ -777,32 +787,32 @@ static void * serialize_nodes_mt( void * arg ) { for (iens = info->iens1; iens < info->iens2; iens++) { int column = int_vector_iget( info->iens_active_index , iens); if (column >= 0) - serialize_node( info->src_fs , - info->ensemble , - info->key , - iens , - info->report_step , - info->load_state , - info->row_offset , + serialize_node( info->src_fs , + info->ensemble , + info->key , + iens , + info->report_step , + info->load_state , + info->row_offset , column, - info->active_list , + info->active_list , info->A ); } return NULL; } -static void enkf_main_serialize_node( const char * node_key , - state_enum load_state , - const active_list_type * active_list , - int row_offset , - thread_pool_type * work_pool , +static void enkf_main_serialize_node( const char * node_key , + state_enum load_state , + const active_list_type * active_list , + int row_offset , + thread_pool_type * work_pool , serialize_info_type * serialize_info) { /* Multithreaded serializing*/ const int num_cpu_threads = thread_pool_get_max_running( work_pool ); int icpu; - + thread_pool_restart( work_pool ); for (icpu = 0; icpu < num_cpu_threads; icpu++) { serialize_info[icpu].key = node_key; @@ -819,14 +829,14 @@ static void enkf_main_serialize_node( const char * node_key , /** The return value is the number of rows in the serialized - A matrix. + A matrix. */ -static int enkf_main_serialize_dataset( enkf_main_type * enkf_main, +static int enkf_main_serialize_dataset( enkf_main_type * enkf_main, const local_dataset_type * dataset , int report_step, - hash_type * use_count , - int * active_size , + hash_type * use_count , + int * active_size , int * row_offset, thread_pool_type * work_pool, serialize_info_type * serialize_info ) { @@ -836,7 +846,7 @@ static int enkf_main_serialize_dataset( enkf_main_type * enkf_main, const int num_kw = stringlist_get_size( update_keys ); int ens_size = matrix_get_columns( A ); int current_row = 0; - + for (int ikw=0; ikw < num_kw; ikw++) { const char * key = stringlist_iget(update_keys , ikw); enkf_config_node_type * config_node = ensemble_config_get_node( enkf_main->ensemble_config , key ); @@ -848,46 +858,46 @@ static int enkf_main_serialize_dataset( enkf_main_type * enkf_main, continue; } else { const active_list_type * active_list = local_dataset_get_node_active_list( dataset , key ); - + active_size[ikw] = __get_active_size( enkf_main , key , report_step , active_list ); row_offset[ikw] = current_row; { int matrix_rows = matrix_get_rows( A ); - if ((active_size[ikw] + current_row) > matrix_rows) + if ((active_size[ikw] + current_row) > matrix_rows) matrix_resize( A , matrix_rows + 2 * active_size[ikw] , ens_size , true ); } - + if (active_size[ikw] > 0) { state_enum load_state; - + if (hash_inc_counter( use_count , key) == 0) load_state = FORECAST; /* This is the first time this keyword is updated for this reportstep */ else load_state = ANALYZED; - + enkf_main_serialize_node( key , load_state , active_list , row_offset[ikw] , work_pool , serialize_info ); current_row += active_size[ikw]; } } - } + } matrix_shrink_header( A , current_row , ens_size ); - stringlist_free( update_keys ); + stringlist_free( update_keys ); return matrix_get_rows( A ); } -static void deserialize_node( enkf_fs_type * fs, - enkf_state_type ** ensemble , - const char * key , - int iens, - int target_step , - int row_offset , +static void deserialize_node( enkf_fs_type * fs, + enkf_state_type ** ensemble , + const char * key , + int iens, + int target_step , + int row_offset , int column, const active_list_type * active_list, matrix_type * A) { - + enkf_node_type * node = enkf_state_get_node( ensemble[iens] , key); node_id_type node_id = { .report_step = target_step , .iens = iens , .state = ANALYZED }; enkf_node_deserialize(node , fs , node_id , active_list , A , row_offset , column); @@ -908,29 +918,29 @@ static void * deserialize_nodes_mt( void * arg ) { } -static void enkf_main_deserialize_dataset( ensemble_config_type * ensemble_config , - const local_dataset_type * dataset , - const int * active_size , - const int * row_offset , - serialize_info_type * serialize_info , +static void enkf_main_deserialize_dataset( ensemble_config_type * ensemble_config , + const local_dataset_type * dataset , + const int * active_size , + const int * row_offset , + serialize_info_type * serialize_info , thread_pool_type * work_pool ) { - + int num_cpu_threads = thread_pool_get_max_running( work_pool ); stringlist_type * update_keys = local_dataset_alloc_keys( dataset ); for (int i = 0; i < stringlist_get_size( update_keys ); i++) { const char * key = stringlist_iget(update_keys , i); enkf_config_node_type * config_node = ensemble_config_get_node( ensemble_config , key ); if ((serialize_info[0].run_mode == SMOOTHER_UPDATE) && (enkf_config_node_get_var_type( config_node ) != PARAMETER)) - /* + /* We have tried to serialize a dynamic node when we are in smoother update mode; that does not make sense and we just - continue. + continue. */ continue; else { if (active_size[i] > 0) { const active_list_type * active_list = local_dataset_get_node_active_list( dataset , key ); - + { /* Multithreaded */ int icpu; @@ -939,7 +949,7 @@ static void enkf_main_deserialize_dataset( ensemble_config_type * ensemble_confi serialize_info[icpu].key = key; serialize_info[icpu].active_list = active_list; serialize_info[icpu].row_offset = row_offset[i]; - + thread_pool_add_job( work_pool , deserialize_nodes_mt , &serialize_info[icpu]); } thread_pool_join( work_pool ); @@ -955,14 +965,14 @@ static void serialize_info_free( serialize_info_type * serialize_info ) { free( serialize_info ); } -static serialize_info_type * serialize_info_alloc( enkf_fs_type * src_fs, - enkf_fs_type * target_fs , +static serialize_info_type * serialize_info_alloc( enkf_fs_type * src_fs, + enkf_fs_type * target_fs , const int_vector_type * iens_active_index , - int target_step , - enkf_state_type ** ensemble , - run_mode_type run_mode , - int report_step , - matrix_type * A , + int target_step , + enkf_state_type ** ensemble , + run_mode_type run_mode , + int report_step , + matrix_type * A , int num_cpu_threads ) { serialize_info_type * serialize_info = util_calloc( num_cpu_threads , sizeof * serialize_info ); @@ -986,21 +996,21 @@ static serialize_info_type * serialize_info_alloc( enkf_fs_type * src_fs, return serialize_info; } -void enkf_main_fprintf_PC(const char * filename , - matrix_type * PC , +void enkf_main_fprintf_PC(const char * filename , + matrix_type * PC , matrix_type * PC_obs) { FILE * stream = util_mkdir_fopen(filename , "w"); const int num_PC = matrix_get_rows( PC ); const int ens_size = matrix_get_columns( PC ); int ipc,iens; - - for (ipc = 0; ipc < num_PC; ipc++) + + for (ipc = 0; ipc < num_PC; ipc++) fprintf(stream , "%10.6f " , matrix_iget( PC_obs , ipc , 0)); fprintf(stream , "\n"); - + for (iens = 0; iens < ens_size; iens++) { - for (ipc = 0; ipc < num_PC; ipc++) + for (ipc = 0; ipc < num_PC; ipc++) fprintf(stream ,"%10.6f " , matrix_iget( PC , ipc, iens )); fprintf(stream , "\n"); } @@ -1008,47 +1018,47 @@ void enkf_main_fprintf_PC(const char * filename , } -void enkf_main_get_PC( const matrix_type * S, +void enkf_main_get_PC( const matrix_type * S, const matrix_type * dObs, - double truncation , - int ncomp , - matrix_type * PC , - matrix_type * PC_obs , + double truncation , + int ncomp , + matrix_type * PC , + matrix_type * PC_obs , double_vector_type * singular_values) { - + enkf_linalg_get_PC( S , dObs , truncation , ncomp , PC , PC_obs , singular_values); } -void enkf_main_init_PC( const enkf_main_type * enkf_main , - const local_obsdata_type * obsdata , - double truncation_or_ncomp , - matrix_type * PC , +void enkf_main_init_PC( const enkf_main_type * enkf_main , + const local_obsdata_type * obsdata , + double truncation_or_ncomp , + matrix_type * PC , matrix_type * PC_obs , double_vector_type * singular_values) { - + state_enum state = FORECAST; enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); state_map_type * state_map = enkf_fs_get_state_map( fs ); const int total_ens_size = enkf_main_get_ensemble_size(enkf_main); bool_vector_type * ens_mask = bool_vector_alloc(total_ens_size , false ); - obs_data_type * obs_data = obs_data_alloc(); - int_vector_type * ens_active_list; + obs_data_type * obs_data = obs_data_alloc(1.0); + int_vector_type * ens_active_list; meas_data_type * meas_data; state_map_select_matching( state_map , ens_mask , STATE_HAS_DATA ); ens_active_list = bool_vector_alloc_active_list( ens_mask ); if (int_vector_size( ens_active_list )) { - meas_data = meas_data_alloc( ens_active_list ); - - enkf_obs_get_obs_and_measure_data( enkf_main_get_obs( enkf_main ), + meas_data = meas_data_alloc( ens_mask ); + + enkf_obs_get_obs_and_measure_data( enkf_main_get_obs( enkf_main ), enkf_main_get_fs( enkf_main ), - obsdata , - state , - ens_active_list , - meas_data , + obsdata , + state , + ens_active_list , + meas_data , obs_data ); if (0) @@ -1061,9 +1071,8 @@ void enkf_main_init_PC( const enkf_main_type * enkf_main , } { - int active_size = obs_data_get_active_size( obs_data ); - matrix_type * S = meas_data_allocS( meas_data , active_size ); - matrix_type * dObs = obs_data_allocdObs( obs_data , active_size ); + matrix_type * S = meas_data_allocS( meas_data ); + matrix_type * dObs = obs_data_allocdObs( obs_data ); double truncation = -1; int ncomp = -1; @@ -1074,11 +1083,11 @@ void enkf_main_init_PC( const enkf_main_type * enkf_main , obs_data_scale( obs_data , S , NULL , NULL , NULL , dObs ); enkf_linalg_get_PC( S , dObs , truncation , ncomp , PC , PC_obs , singular_values); - + matrix_free( S ); matrix_free( dObs ); } - + bool_vector_free( ens_mask ); int_vector_free( ens_active_list ); obs_data_free( obs_data ); @@ -1088,8 +1097,8 @@ void enkf_main_init_PC( const enkf_main_type * enkf_main , } -pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_main , - local_obsdata_type * obs_data, +pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_main , + local_obsdata_type * obs_data, double truncation_or_ncomp) { pca_plot_data_type * pca_plot_data; { @@ -1099,7 +1108,7 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_ enkf_main_init_PC( enkf_main , obs_data , truncation_or_ncomp , PC , PC_obs , singular_values ); pca_plot_data = pca_plot_data_alloc( local_obsdata_get_name( obs_data ) , PC , PC_obs , singular_values); - + double_vector_free( singular_values ); matrix_free( PC ); matrix_free( PC_obs ); @@ -1116,49 +1125,49 @@ static void assert_matrix_size(const matrix_type * m , const char * name , int r static void assert_size_equal(int ens_size , const bool_vector_type * ens_mask) { if (bool_vector_size( ens_mask ) != ens_size) util_abort("%s: fundamental inconsisentcy detected. Total ens_size:%d mask_size:%d \n",__func__ , ens_size , bool_vector_size( ens_mask )); -} +} -static void enkf_main_analysis_update( enkf_main_type * enkf_main , +static void enkf_main_analysis_update( enkf_main_type * enkf_main , enkf_fs_type * target_fs , - const bool_vector_type * ens_mask , - int target_step , + const bool_vector_type * ens_mask , + int target_step , hash_type * use_count, - run_mode_type run_mode , + run_mode_type run_mode , int step1 , - int step2 , - const local_ministep_type * ministep , - const meas_data_type * forecast , + int step2 , + const local_ministep_type * ministep , + const meas_data_type * forecast , obs_data_type * obs_data) { const int cpu_threads = 4; const int matrix_start_size = 250000; thread_pool_type * tp = thread_pool_alloc( cpu_threads , false ); analysis_module_type * module = analysis_config_get_active_module( enkf_main->analysis_config ); - int ens_size = meas_data_get_ens_size( forecast ); + int active_ens_size = meas_data_get_active_ens_size( forecast ); int active_size = obs_data_get_active_size( obs_data ); - matrix_type * X = matrix_alloc( ens_size , ens_size ); - matrix_type * S = meas_data_allocS( forecast , active_size ); - matrix_type * R = obs_data_allocR( obs_data , active_size ); - matrix_type * dObs = obs_data_allocdObs( obs_data , active_size ); - matrix_type * A = matrix_alloc( matrix_start_size , ens_size ); + matrix_type * X = matrix_alloc( active_ens_size , active_ens_size ); + matrix_type * S = meas_data_allocS( forecast ); + matrix_type * R = obs_data_allocR( obs_data ); + matrix_type * dObs = obs_data_allocdObs( obs_data ); + matrix_type * A = matrix_alloc( matrix_start_size , active_ens_size ); matrix_type * E = NULL; matrix_type * D = NULL; matrix_type * localA = NULL; int_vector_type * iens_active_index = bool_vector_alloc_active_index_list(ens_mask , -1); - assert_matrix_size(X , "X" , ens_size , ens_size); - assert_matrix_size(S , "S" , active_size , ens_size); + assert_matrix_size(X , "X" , active_ens_size , active_ens_size); + assert_matrix_size(S , "S" , active_size , active_ens_size); assert_matrix_size(R , "R" , active_size , active_size); assert_size_equal( enkf_main_get_ensemble_size( enkf_main ) , ens_mask ); if (analysis_module_check_option( module , ANALYSIS_NEED_ED)) { - E = obs_data_allocE( obs_data , enkf_main->rng , ens_size , active_size ); + E = obs_data_allocE( obs_data , enkf_main->rng , active_ens_size ); D = obs_data_allocD( obs_data , E , S ); - assert_matrix_size( E , "E" , active_size , ens_size); - assert_matrix_size( D , "D" , active_size , ens_size); + assert_matrix_size( E , "E" , active_size , active_ens_size); + assert_matrix_size( D , "D" , active_size , active_ens_size); } if (analysis_module_check_option( module , ANALYSIS_SCALE_DATA)) @@ -1168,38 +1177,38 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main , localA = A; /*****************************************************************/ - + analysis_module_init_update( module , ens_mask , S , R , dObs , E , D ); { hash_iter_type * dataset_iter = local_ministep_alloc_dataset_iter( ministep ); enkf_fs_type * src_fs = enkf_main_get_fs( enkf_main ); - serialize_info_type * serialize_info = serialize_info_alloc( src_fs , - target_fs , + serialize_info_type * serialize_info = serialize_info_alloc( src_fs , + target_fs , iens_active_index, - target_step , - enkf_main_get_ensemble( enkf_main ) , - run_mode , - step2 , - A , + target_step , + enkf_main_get_ensemble( enkf_main ) , + run_mode , + step2 , + A , cpu_threads); - + // Store PC: if (analysis_config_get_store_PC( enkf_main->analysis_config )) { double truncation = -1; - int ncomp = ens_size - 1; + int ncomp = active_ens_size - 1; matrix_type * PC = matrix_alloc(1,1); matrix_type * PC_obs = matrix_alloc(1,1); - double_vector_type * singular_values = double_vector_alloc(0,0); - local_obsset_type * obsset = local_ministep_get_obsset( ministep ); - const char * obsset_name = local_obsset_get_name( obsset ); - + double_vector_type * singular_values = double_vector_alloc(0,0); + local_obsdata_type * obsdata = local_ministep_get_obsdata( ministep ); + const char * obsdata_name = local_obsdata_get_name( obsdata ); + enkf_main_get_PC( S , dObs , truncation , ncomp , PC , PC_obs , singular_values); { - char * filename = util_alloc_sprintf(analysis_config_get_PC_filename( enkf_main->analysis_config ) , step1 , step2 , obsset_name); + char * filename = util_alloc_sprintf(analysis_config_get_PC_filename( enkf_main->analysis_config ) , step1 , step2 , obsdata_name); char * full_path = util_alloc_filename( analysis_config_get_PC_path( enkf_main->analysis_config) , filename , NULL ); enkf_main_fprintf_PC( full_path , PC , PC_obs); - + free( full_path ); free( filename ); } @@ -1207,7 +1216,7 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main , matrix_free( PC_obs ); double_vector_free( singular_values ); } - + if (localA == NULL) analysis_module_initX( module , X , NULL , S , R , dObs , E , D ); @@ -1218,7 +1227,7 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main , if (local_dataset_get_size( dataset )) { int * active_size = util_calloc( local_dataset_get_size( dataset ) , sizeof * active_size ); int * row_offset = util_calloc( local_dataset_get_size( dataset ) , sizeof * row_offset ); - + enkf_main_serialize_dataset( enkf_main , dataset , step2 , use_count , active_size , row_offset , tp , serialize_info); if (analysis_module_check_option( module , ANALYSIS_UPDATE_A)){ @@ -1235,10 +1244,10 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main , matrix_inplace_matmul_mt2( A , X , tp ); } - + // The deserialize also calls enkf_node_store() functions. enkf_main_deserialize_dataset( enkf_main_get_ensemble_config( enkf_main ) , dataset , active_size , row_offset , serialize_info , tp); - + free( active_size ); free( row_offset ); } @@ -1248,7 +1257,7 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main , serialize_info_free( serialize_info ); } analysis_module_complete_update( module ); - + /*****************************************************************/ @@ -1297,79 +1306,92 @@ bool enkf_main_UPDATE(enkf_main_type * enkf_main , const int_vector_type * step_ Observations and measurements are collected in these temporary structures. obs_data is a precursor for the 'd' vector, and meas_forecast is a precursor for the 'S' matrix'. - + The reason for going via these temporary structures is to support deactivating observations which should not be used in the update process. */ - obs_data_type * obs_data = obs_data_alloc(); - meas_data_type * meas_forecast = meas_data_alloc( ens_active_list ); - meas_data_type * meas_analyzed = meas_data_alloc( ens_active_list ); + double global_std_scaling = analysis_config_get_global_std_scaling(analysis_config); + obs_data_type * obs_data = obs_data_alloc(global_std_scaling); + meas_data_type * meas_forecast = meas_data_alloc( ens_mask ); + meas_data_type * meas_analyzed = meas_data_alloc( ens_mask ); local_config_type * local_config = enkf_main->local_config; const local_updatestep_type * updatestep = local_config_iget_updatestep( local_config , current_step ); /* Only last step considered when forming local update */ hash_type * use_count = hash_alloc(); const char * log_path = analysis_config_get_log_path( enkf_main->analysis_config ); FILE * log_stream; - - if ((local_updatestep_get_num_ministep( updatestep ) > 1) && + + if ((local_updatestep_get_num_ministep( updatestep ) > 1) && (analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE))) { util_exit("** ERROR: Can not combine iterable modules with multi step updates - sorry\n"); } - + { char * log_file; - if (int_vector_size( step_list ) == 1) + if (int_vector_size( step_list ) == 1) log_file = util_alloc_sprintf("%s%c%04d" , log_path , UTIL_PATH_SEP_CHAR , int_vector_iget( step_list , 0)); - else + else log_file = util_alloc_sprintf("%s%c%04d-%04d" , log_path , UTIL_PATH_SEP_CHAR , int_vector_iget( step_list , 0) , int_vector_get_last( step_list )); log_stream = util_fopen( log_file , "w" ); - + free( log_file ); } - + for (int ministep_nr = 0; ministep_nr < local_updatestep_get_num_ministep( updatestep ); ministep_nr++) { /* Looping over local analysis ministep */ local_ministep_type * ministep = local_updatestep_iget_ministep( updatestep , ministep_nr ); - local_obsset_type * obsset = local_ministep_get_obsset( ministep ); + local_obsdata_type * obsdata = local_ministep_get_obsdata( ministep ); obs_data_reset( obs_data ); meas_data_reset( meas_forecast ); - - enkf_obs_get_obs_and_measure( enkf_main->obs, - source_fs , - step_list , - FORECAST, - ens_active_list , - meas_forecast, - obs_data , - obsset ); - + + /* + Temporarily we will just force the timestep from the input + argument onto the obsdata instance; in the future the + obsdata should hold it's own here. + */ + local_obsdata_reset_tstep_list(obsdata, step_list); + + if (analysis_config_get_std_scale_correlated_obs(enkf_main->analysis_config)) { + double scale_factor = enkf_obs_scale_correlated_std(enkf_main->obs, source_fs, ens_active_list, obsdata); + ert_log_add_fmt_message(1, NULL, "Scaling standard deviation in obdsata set:%s with %g", local_obsdata_get_name(obsdata) , scale_factor); + } + + enkf_obs_get_obs_and_measure_data( enkf_main->obs, + source_fs , + obsdata, + FORECAST, + ens_active_list , + meas_forecast, + obs_data); + + enkf_analysis_deactivate_outliers( obs_data , meas_forecast , std_cutoff , alpha); - + if (enkf_main->verbose) enkf_analysis_fprintf_obs_summary( obs_data , meas_forecast , step_list , local_ministep_get_name( ministep ) , stdout ); enkf_analysis_fprintf_obs_summary( obs_data , meas_forecast , step_list , local_ministep_get_name( ministep ) , log_stream ); if (obs_data_get_active_size(obs_data) > 0) - enkf_main_analysis_update( enkf_main , - target_fs , - ens_mask , - target_step , - use_count , - run_mode , - int_vector_get_first( step_list ), - current_step , - ministep , - meas_forecast , + enkf_main_analysis_update( enkf_main , + target_fs , + ens_mask , + target_step , + use_count , + run_mode , + int_vector_get_first( step_list ), + current_step , + ministep , + meas_forecast , obs_data ); else if (target_fs != source_fs) { ert_log_add_fmt_message( 1 , stderr , "No active observations. Parameters copied directly: %s -> %s" , enkf_fs_get_case_name( enkf_main_get_fs( enkf_main )) , enkf_fs_get_case_name( target_fs)); - enkf_main_init_case_from_existing( enkf_main , - enkf_main_get_fs( enkf_main ) , - 0 , - ANALYZED , + enkf_main_init_case_from_existing( enkf_main , + enkf_main_get_fs( enkf_main ) , + 0 , + ANALYZED , target_fs ); } } @@ -1378,7 +1400,7 @@ bool enkf_main_UPDATE(enkf_main_type * enkf_main , const int_vector_type * step_ obs_data_free( obs_data ); meas_data_free( meas_forecast ); meas_data_free( meas_analyzed ); - + enkf_main_inflate( enkf_main , target_fs , current_step , use_count); hash_free( use_count ); @@ -1392,12 +1414,12 @@ bool enkf_main_UPDATE(enkf_main_type * enkf_main , const int_vector_type * step_ int_vector_free( ens_active_list ); return true; } else { - fprintf(stderr,"** ERROR ** There are %d active realisations left, which is less than the minimum specified (%d) - stopping assimilation.\n" , - active_ens_size , + fprintf(stderr,"** ERROR ** There are %d active realisations left, which is less than the minimum specified (%d) - stopping assimilation.\n" , + active_ens_size , analysis_config_get_min_realisations(analysis_config)); return false; } - + } @@ -1425,7 +1447,7 @@ bool enkf_main_smoother_update(enkf_main_type * enkf_main , enkf_fs_type * targe step_list = enkf_main_update_alloc_step_list( enkf_main , 0 , step2 , stride); update_done = enkf_main_smoother_update__( enkf_main , step_list , target_fs ); int_vector_free( step_list ); - + return update_done; } @@ -1437,14 +1459,14 @@ static void enkf_main_report_run_failure( const enkf_main_type * enkf_main , con int queue_index = run_arg_get_queue_index( run_arg ); const char * stderr_file = job_queue_iget_stderr_file( job_queue , queue_index ); - if (stderr_file == NULL) + if (stderr_file == NULL) ert_log_add_fmt_message( 1 , stderr , "** ERROR ** path:%s job:%s reason:%s" , - job_queue_iget_run_path( job_queue , queue_index), + job_queue_iget_run_path( job_queue , queue_index), job_queue_iget_failed_job( job_queue , queue_index), job_queue_iget_error_reason( job_queue , queue_index )); else ert_log_add_fmt_message( 1 , stderr , "** ERROR ** path:%s job:%s reason:%s Check file:%s" , - job_queue_iget_run_path( job_queue , queue_index), + job_queue_iget_run_path( job_queue , queue_index), job_queue_iget_failed_job( job_queue , queue_index), job_queue_iget_error_reason( job_queue , queue_index ), job_queue_iget_stderr_file( job_queue , queue_index )); @@ -1455,7 +1477,7 @@ static void enkf_main_report_run_failure( const enkf_main_type * enkf_main , con static void enkf_main_report_load_failure( const enkf_main_type * enkf_main , run_arg_type * run_arg ) { job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config); int queue_index = run_arg_get_queue_index( run_arg ); - + ert_log_add_fmt_message( 1 , stderr , "** ERROR ** path:%s - Could not load all required data", job_queue_iget_run_path( job_queue , queue_index)); } @@ -1466,28 +1488,28 @@ static void enkf_main_monitor_job_queue ( const enkf_main_type * enkf_main) { job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config); int min_realisations = analysis_config_get_min_realisations(enkf_main->analysis_config); - + bool cont = true; if (0 >= min_realisations) cont = false; - + while (cont) { //Check if minimum number of realizations have run, and if so, kill the rest after a certain time if ((job_queue_get_num_complete(job_queue) >= min_realisations)) { job_queue_set_auto_job_stop_time(job_queue); cont = false; } - + //Check if minimum number of realizations is not possible. If so, it is time to give up - int possible_sucesses = job_queue_get_num_running(job_queue) + - job_queue_get_num_waiting(job_queue) + - job_queue_get_num_pending(job_queue) + - job_queue_get_num_complete(job_queue); - + int possible_sucesses = job_queue_get_num_running(job_queue) + + job_queue_get_num_waiting(job_queue) + + job_queue_get_num_pending(job_queue) + + job_queue_get_num_complete(job_queue); + if (possible_sucesses < min_realisations) { - cont = false; + cont = false; } - + if (cont) { util_usleep(10000); } @@ -1512,19 +1534,19 @@ void enkf_main_isubmit_job( enkf_main_type * enkf_main , run_arg_type * run_arg { runpath_list_type * runpath_list = qc_module_get_runpath_list( enkf_main->qc_module ); - runpath_list_add( runpath_list , + runpath_list_add( runpath_list , run_arg_get_iens( run_arg ), run_arg_get_iter( run_arg ), run_arg_get_runpath( run_arg ), enkf_state_get_eclbase( enkf_state )); } - + enkf_state_init_eclipse( enkf_state , run_arg ); if (run_arg_get_run_mode(run_arg) != INIT_ONLY) { // The job_queue_node will take ownership of this arg_pack; and destroy it when // the job_queue_node is discarded. arg_pack_type * load_arg = arg_pack_alloc(); - + /* Prepare the job and submit it to the queue */ @@ -1532,16 +1554,16 @@ void enkf_main_isubmit_job( enkf_main_type * enkf_main , run_arg_type * run_arg arg_pack_append_ptr( load_arg , run_arg ); { - int queue_index = job_queue_add_job_mt( job_queue , - job_script , - enkf_state_complete_forward_modelOK__ , - enkf_state_complete_forward_modelRETRY__ , + int queue_index = job_queue_add_job_mt( job_queue , + job_script , + enkf_state_complete_forward_modelOK__ , + enkf_state_complete_forward_modelRETRY__ , enkf_state_complete_forward_modelEXIT__, - load_arg , + load_arg , ecl_config_get_num_cpu( ecl_config ), - run_path , - member_config_get_jobname( member_config ) , - 1, + run_path , + member_config_get_jobname( member_config ) , + 1, (const char *[1]) { run_path } ); run_arg_set_queue_index( run_arg , queue_index ); @@ -1565,28 +1587,28 @@ static void * enkf_main_isubmit_job__( void * arg ) { - -void enkf_main_submit_jobs( enkf_main_type * enkf_main , + +void enkf_main_submit_jobs( enkf_main_type * enkf_main , const ert_run_context_type * run_context ) { runpath_list_type * runpath_list = qc_module_get_runpath_list( enkf_main->qc_module ); - + runpath_list_clear( runpath_list ); { int iens; const bool_vector_type * iactive = ert_run_context_get_iactive( run_context ); const int active_ens_size = util_int_min( bool_vector_size( iactive ) , enkf_main_get_ensemble_size( enkf_main )); thread_pool_type * submit_threads = thread_pool_alloc( 4 , true ); - + for (iens = 0; iens < active_ens_size; iens++) { if (bool_vector_iget(iactive , iens)) { run_arg_type * run_arg = ert_run_context_iens_get_arg( run_context , iens); arg_pack_type * arg_pack = arg_pack_alloc( ); // This is discarded by the enkf_main_isubmit_job__() - + arg_pack_append_ptr( arg_pack , enkf_main ); arg_pack_append_ptr( arg_pack , run_arg); - + thread_pool_add_job(submit_threads , enkf_main_isubmit_job__ , arg_pack); - } + } } /* @@ -1595,8 +1617,8 @@ void enkf_main_submit_jobs( enkf_main_type * enkf_main , to the job_queue manager. */ - thread_pool_join(submit_threads); - thread_pool_free(submit_threads); + thread_pool_join(submit_threads); + thread_pool_free(submit_threads); } runpath_list_fprintf( runpath_list ); } @@ -1605,7 +1627,7 @@ void enkf_main_submit_jobs( enkf_main_type * enkf_main , /** If all simulations have completed successfully the function will - return true, otherwise it will return false. + return true, otherwise it will return false. */ @@ -1620,20 +1642,20 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , // int iter , // int step1 , // int step2) { - + if (ert_run_context_get_step1(run_context)) ecl_config_assert_restart( enkf_main_get_ecl_config( enkf_main ) ); - + { int job_size , iens; bool verbose_queue = enkf_main->verbose; const int active_ens_size = util_int_min( bool_vector_size( ert_run_context_get_iactive( run_context )) , enkf_main_get_ensemble_size( enkf_main )); - - //enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); + + //enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); //enkf_fs_type * target_fs = fs; // ERRORE //path_fmt_type * runpath_fmt = model_config_get_runpath_fmt( enkf_main->model_config ); - + // //ert_run_context_type * run_context; //int job_size; @@ -1647,7 +1669,7 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , // run_context = ert_run_context_alloc_ENSEMBLE_EXPERIMENT( fs , iactive , runpath_fmt , enkf_main->subst_list , iter ); // break; //case(SMOOTHER_UPDATE): - // run_context = ert_run_context_alloc_SMOOTHER_RUN( fs , fs , iactive , runpath_fmt , enkf_main->subst_list , iter); + // run_context = ert_run_context_alloc_SMOOTHER_RUN( fs , fs , iactive , runpath_fmt , enkf_main->subst_list , iter); // break; //case(ENKF_ASSIMILATION): // run_context = ert_run_context_alloc_ENKF_ASSIMILATION( fs , iactive , runpath_fmt , enkf_main->subst_list , init_state_parameter , init_state_dynamic , step1 , step2 , iter); @@ -1656,38 +1678,38 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , // util_abort("%s: what the fuck? \n",__func__); //} - state_map_deselect_matching( enkf_fs_get_state_map( ert_run_context_get_init_fs( run_context )) , + state_map_deselect_matching( enkf_fs_get_state_map( ert_run_context_get_init_fs( run_context )) , ert_run_context_get_iactive( run_context ), STATE_LOAD_FAILURE | STATE_PARENT_FAILURE); - + ert_log_add_fmt_message( 1 , NULL , "===================================================================", false); if (ert_run_context_get_mode( run_context ) == ENKF_ASSIMILATION) { int step1 = ert_run_context_get_step1(run_context); int step2 = ert_run_context_get_step2(run_context); printf("Starting forward step: %d -> %d\n", step1 , step2 ); ert_log_add_fmt_message( 1 , NULL , "Forward model: %d -> %d ",step1,step2); - } - + } + job_size = bool_vector_count_equal( ert_run_context_get_iactive(run_context) , true ); { job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config); job_queue_manager_type * queue_manager = job_queue_manager_alloc( job_queue ); - + /* Start the queue */ if (ert_run_context_get_mode( run_context ) != INIT_ONLY) { - if (site_config_has_job_script( enkf_main->site_config )) + if (site_config_has_job_script( enkf_main->site_config )) job_queue_manager_start_queue( queue_manager , job_size , verbose_queue ); else util_exit("No job script specified, can not start any jobs. Use the key JOB_SCRIPT in the config file\n"); } - - enkf_main_submit_jobs( enkf_main , run_context ); - + + enkf_main_submit_jobs( enkf_main , run_context ); + if (ert_run_context_get_mode(run_context) != INIT_ONLY) { job_queue_submit_complete( job_queue ); ert_log_add_message( 1 , NULL , "All jobs submitted to internal queue - waiting for completion" , false); - - int max_runtime = analysis_config_get_max_runtime(enkf_main_get_analysis_config( enkf_main )); - job_queue_set_max_job_duration(job_queue, max_runtime); + + int max_runtime = analysis_config_get_max_runtime(enkf_main_get_analysis_config( enkf_main )); + job_queue_set_max_job_duration(job_queue, max_runtime); enkf_main_monitor_job_queue( enkf_main ); job_queue_manager_wait( queue_manager ); @@ -1695,17 +1717,17 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , job_queue_manager_free( queue_manager ); } - + /* This should be carefully checked for the situation where only a subset (with offset > 0) of realisations are simulated. */ bool totalOK = true; if (ert_run_context_get_mode( run_context ) != INIT_ONLY) { - for (iens = 0; iens < active_ens_size; iens++) { + for (iens = 0; iens < active_ens_size; iens++) { if (bool_vector_iget(ert_run_context_get_iactive(run_context) , iens)) { run_arg_type * run_arg = ert_run_context_iens_get_arg( run_context , iens ); run_status_type run_status = run_arg_get_run_status( run_arg ); - + switch (run_status) { case JOB_RUN_FAILURE: enkf_main_report_run_failure( enkf_main , run_arg ); @@ -1725,11 +1747,11 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , } enkf_fs_fsync( ert_run_context_get_result_fs( run_context ) ); - if (totalOK) + if (totalOK) ert_log_add_fmt_message( 1 , NULL , "All jobs complete and data loaded."); } else totalOK = false; - + return totalOK; } } @@ -1742,14 +1764,14 @@ int_vector_type * enkf_main_update_alloc_step_list( const enkf_main_type * enkf_ if (step2 < load_start) util_abort("%s: fatal internal error: Tried to make step list %d ... %d \n",__func__ , load_start , step2); - - if (stride == 0) + + if (stride == 0) int_vector_append( step_list , step2 ); else { int step = util_int_max( 1 , load_start ); while (true) { int_vector_append( step_list , step ); - + if (step == step2) break; else { @@ -1759,9 +1781,9 @@ int_vector_type * enkf_main_update_alloc_step_list( const enkf_main_type * enkf_ break; } } - + } - } + } return step_list; } @@ -1791,7 +1813,7 @@ void enkf_main_init_run( enkf_main_type * enkf_main, const ert_run_context_type const ext_joblist_type * joblist = site_config_get_installed_jobs( enkf_main->site_config); model_config_set_enkf_sched( enkf_main->model_config , joblist , ert_run_context_get_mode( run_context )); } - + enkf_main_init_internalization(enkf_main , ert_run_context_get_mode( run_context )); { stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER ); @@ -1804,37 +1826,37 @@ void enkf_main_init_run( enkf_main_type * enkf_main, const ert_run_context_type void enkf_main_run_exp(enkf_main_type * enkf_main , - bool_vector_type * iactive , + bool_vector_type * iactive , bool simulate ) { - + ert_run_context_type * run_context; init_mode_type init_mode = INIT_CONDITIONAL; int iter = 0; if (simulate) - run_context = enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT(enkf_main , - enkf_main_get_fs( enkf_main ) , - iactive , - init_mode , + run_context = enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT(enkf_main , + enkf_main_get_fs( enkf_main ) , + iactive , + init_mode , iter ); else - run_context = enkf_main_alloc_ert_run_context_INIT_ONLY( enkf_main , - enkf_main_get_fs( enkf_main ) , - iactive , - init_mode , + run_context = enkf_main_alloc_ert_run_context_INIT_ONLY( enkf_main , + enkf_main_get_fs( enkf_main ) , + iactive , + init_mode , iter ); - + enkf_main_init_run( enkf_main , run_context ); if (enkf_main_run_step(enkf_main , run_context)) enkf_main_run_post_workflow(enkf_main); - + ert_run_context_free( run_context ); } void enkf_main_run_assimilation(enkf_main_type * enkf_main , - bool_vector_type * iactive , + bool_vector_type * iactive , int init_step_parameters , int start_report , state_enum start_state) { @@ -1853,14 +1875,14 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main , int inode; ert_run_context_type * run_context; - + if (start_state == ANALYZED) analyzed_start = true; else if (start_state == FORECAST) analyzed_start = false; else util_abort("%s: internal error - start_state must be analyzed | forecast \n",__func__); - + prev_enkf_on = analyzed_start; for (inode = start_inode; inode < num_nodes; inode++) { const enkf_sched_node_type * node = enkf_sched_iget_node(enkf_sched , inode); @@ -1877,7 +1899,7 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main , enkf_sched_node_get_data(node , &report_step1 , &report_step2 , &enkf_on ); if (inode == start_inode) report_step1 = start_report; /* If we are restarting from somewhere. */ - + if (rerun) { /* rerun ... */ load_start = report_step1; /* +1 below. Observe that report_step is set to rerun_start below. */ @@ -1898,17 +1920,17 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main , init_state_parameter = init_state_dynamic; load_start = report_step1; } - - run_context = enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( enkf_main, - enkf_main_get_fs( enkf_main ) , - iactive , - init_mode , - init_state_parameter, - init_state_dynamic , + + run_context = enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( enkf_main, + enkf_main_get_fs( enkf_main ) , + iactive , + init_mode , + init_state_parameter, + init_state_dynamic , report_step1 , // init_step parameter - report_step2 , + report_step2 , iter ); - + enkf_main_init_run( enkf_main , run_context ); enkf_main_run_step(enkf_main , run_context); { @@ -1916,27 +1938,27 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main , state_map_type * state_map = enkf_fs_get_state_map(result_fs); const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main); int active_ens_size = state_map_count_matching(state_map , STATE_HAS_DATA); - + if (analysis_config_have_enough_realisations(analysis_config , active_ens_size)) { if (enkf_on) { bool merge_observations = analysis_config_get_merge_observations( enkf_main->analysis_config ); int_vector_type * step_list; int stride; - + if (merge_observations) stride = 1; else stride = 0; - + step_list = enkf_main_update_alloc_step_list( enkf_main , ert_run_context_get_load_start(run_context) , report_step2 , stride ); - + enkf_main_assimilation_update(enkf_main , step_list); int_vector_free( step_list ); enkf_fs_fsync( enkf_main->dbase ); } } else { - fprintf(stderr,"** ERROR ** There are %d active realisations left, which is less than the minimum specified (%d) - stopping assimilation.\n" , - active_ens_size , + fprintf(stderr,"** ERROR ** There are %d active realisations left, which is less than the minimum specified (%d) - stopping assimilation.\n" , + active_ens_size , analysis_config_get_min_realisations(analysis_config)); break; } @@ -1951,10 +1973,10 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main , bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_type init_mode, int iter) { bool run_ok; - ert_run_context_type * run_context = enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT( enkf_main , - enkf_main_get_fs( enkf_main ) , - iactive , - init_mode , + ert_run_context_type * run_context = enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT( enkf_main , + enkf_main_get_fs( enkf_main ) , + iactive , + init_mode , iter ); enkf_main_init_run( enkf_main , run_context ); run_ok = enkf_main_run_step( enkf_main , run_context ); @@ -1974,12 +1996,12 @@ void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_ enkf_fs_type * target_fs = enkf_main_mount_alt_fs( enkf_main , target_fs_name , true ); bool update_done = enkf_main_smoother_update( enkf_main , target_fs ); - if (rerun) { + if (rerun) { if (update_done) { enkf_main_set_fs( enkf_main , target_fs , target_fs_name); if (enkf_main_run_simple_step(enkf_main , iactive , INIT_NONE, iter + 1)) enkf_main_run_post_workflow(enkf_main); - } else + } else fprintf(stderr,"** Warning: the analysis update failed - no rerun started.\n"); } enkf_fs_decref( target_fs ); @@ -1989,21 +2011,21 @@ void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_ fprintf(stderr,"** ERROR: The normal smoother should not be combined with an iterable analysis module\n"); } - + static bool enkf_main_run_simulation_and_postworkflow(enkf_main_type * enkf_main, const ert_run_context_type * run_context) { bool ret = true; analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main); const int min_realizations = analysis_config_get_min_realisations(analysis_config); - + bool total_ok = enkf_main_run_step(enkf_main , run_context); - + if (total_ok || (bool_vector_count_equal(ert_run_context_get_iactive( run_context ), true) >= min_realizations)) enkf_main_run_post_workflow(enkf_main); else { fprintf(stderr,"Simulation in iteration %d failed, stopping Iterated Ensemble Smoother\n", ert_run_context_get_iter( run_context )); ret = false; } - + return ret; } @@ -2092,7 +2114,7 @@ void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int num_iterations_to //if (!enkf_main_run_simulation_and_postworkflow(enkf_main, current_iteration-1, iactive)) break; } - + ert_run_context_free( run_context ); } } @@ -2112,25 +2134,25 @@ ert_run_context_type * enkf_main_alloc_ert_run_context_INIT_ONLY(const enkf_main return ert_run_context_alloc_INIT_ONLY( fs , iactive , model_config_get_runpath_fmt( enkf_main->model_config ) , enkf_main->subst_list , init_mode , iter ); } -ert_run_context_type * enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( const enkf_main_type * enkf_main , - enkf_fs_type * fs , +ert_run_context_type * enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( const enkf_main_type * enkf_main , + enkf_fs_type * fs , const bool_vector_type * iactive , - init_mode_type init_mode , + init_mode_type init_mode , state_enum init_state_parameter , state_enum init_state_dynamic , - int step1 , + int step1 , int step2 , int iter) { - return ert_run_context_alloc_ENKF_ASSIMILATION( enkf_main_get_fs( enkf_main ) , - iactive , - model_config_get_runpath_fmt( enkf_main->model_config ) , - enkf_main->subst_list , - init_mode , - init_state_parameter, - init_state_dynamic , + return ert_run_context_alloc_ENKF_ASSIMILATION( enkf_main_get_fs( enkf_main ) , + iactive , + model_config_get_runpath_fmt( enkf_main->model_config ) , + enkf_main->subst_list , + init_mode , + init_state_parameter, + init_state_dynamic , step1 , // init_step parameter - step2 , + step2 , iter ); } @@ -2143,7 +2165,7 @@ ert_run_context_type * enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( const here... */ -void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , +void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , const char * local_config_file ) { @@ -2153,9 +2175,9 @@ void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , const char * update_step_name = "ALL_ACTIVE"; const char * ministep_name = "ALL_ACTIVE"; const char * obsset_name = "ALL_OBS"; - const char * dataset_name = "ALL_DATA"; // <- This is is created for possible further use, even if - // single_node_update is true. - + const char * dataset_name = "ALL_DATA"; // <- This is is created for possible further use, even if + // single_node_update is true. + FILE * stream = util_fopen( local_config_file , "w"); fprintf(stream , "%-32s %s\n", local_config_get_cmd_string( CREATE_UPDATESTEP ) , update_step_name); @@ -2164,9 +2186,9 @@ void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , fprintf(stream , "%-32s %s %s \n" , local_config_get_cmd_string( ATTACH_MINISTEP ), update_step_name , ministep_name); fprintf(stream , "%-32s %s \n", local_config_get_cmd_string( CREATE_DATASET ) , dataset_name); - if (!single_node_update) + if (!single_node_update) fprintf(stream , "%-32s %s %s \n", local_config_get_cmd_string( ATTACH_DATASET ) , ministep_name , dataset_name); - + /* Adding all observation keys */ { hash_iter_type * obs_iter = enkf_obs_alloc_iter( enkf_main->obs ); @@ -2176,7 +2198,7 @@ void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , } hash_iter_free( obs_iter ); } - + /* Adding all node which can be updated. */ { stringlist_type * keylist = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER + DYNAMIC_STATE + DYNAMIC_RESULT); @@ -2197,13 +2219,13 @@ void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , if (util_string_equal(key , "PRED")) add_node = false; - + if (add_node) { if (single_node_update) { fprintf(stream , "%-32s %s \n" , local_config_get_cmd_string( CREATE_DATASET ) , key); fprintf(stream , "%-32s %s %s \n" , local_config_get_cmd_string( ATTACH_DATASET ) , ministep_name , key); fprintf(stream , "%-32s %s %s\n" , local_config_get_cmd_string( ADD_DATA ) , key , key); - } + } fprintf(stream , "%-32s %s %s\n",local_config_get_cmd_string( ADD_DATA ) , dataset_name , key); } } @@ -2218,7 +2240,7 @@ void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , -static void enkf_main_init_user_config( const enkf_main_type * enkf_main , config_type * config ) { +static void enkf_main_init_user_config( const enkf_main_type * enkf_main , config_parser_type * config ) { config_schema_item_type * item; /*****************************************************************/ @@ -2226,7 +2248,7 @@ static void enkf_main_init_user_config( const enkf_main_type * enkf_main , confi /* */ /* 1. boolean - required? */ /*****************************************************************/ - + ert_workflow_list_add_config_items( config ); plot_config_add_config_items( config ); analysis_config_add_config_items( config ); @@ -2242,11 +2264,11 @@ static void enkf_main_init_user_config( const enkf_main_type * enkf_main , confi config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); config_add_key_value( config , LOG_LEVEL_KEY , false , CONFIG_INT); - config_add_key_value( config , LOG_FILE_KEY , false , CONFIG_STRING); + config_add_key_value( config , LOG_FILE_KEY , false , CONFIG_STRING); config_add_key_value(config , MAX_RESAMPLE_KEY , false , CONFIG_INT); - - + + item = config_add_schema_item(config , NUM_REALIZATIONS_KEY , true ); config_schema_item_set_argc_minmax(item , 1 , 1); config_schema_item_iset_type( item , 0 , CONFIG_INT ); @@ -2269,7 +2291,7 @@ static void enkf_main_init_user_config( const enkf_main_type * enkf_main , confi item = config_add_schema_item( config , JOBNAME_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); - + item = config_add_schema_item(config , SELECT_CASE_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); @@ -2317,7 +2339,7 @@ static void enkf_main_init_user_config( const enkf_main_type * enkf_main , confi { stringlist_type * refcase_dep = stringlist_alloc_argv_ref( (const char *[1]) { REFCASE_KEY } , 1); - + item = config_add_schema_item(config , HISTORY_SOURCE_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1); config_schema_item_set_common_selection_set(item , 3 , (const char *[3]) {"SCHEDULE" , "REFCASE_SIMULATED" , "REFCASE_HISTORY"}); @@ -2326,7 +2348,7 @@ static void enkf_main_init_user_config( const enkf_main_type * enkf_main , confi stringlist_free(refcase_dep); } - + ert_report_list_add_config_items( config); qc_module_add_config_items( config ); } @@ -2363,24 +2385,24 @@ void enkf_main_parse_keep_runpath(enkf_main_type * enkf_main , const char * keep int i; for (i = 0; i < ens_size; i++) int_vector_iset( enkf_main->keep_runpath , i , DEFAULT_KEEP); - + { int_vector_type * active_list = string_util_alloc_active_list(keep_runpath_string); for (i = 0; i < int_vector_size( active_list ); i++) int_vector_iset( enkf_main->keep_runpath , int_vector_iget( active_list , i ) , EXPLICIT_KEEP); - + int_vector_free( active_list ); } - - + + { int_vector_type * active_list = string_util_alloc_active_list(delete_runpath_string); for (i = 0; i < int_vector_size( active_list ); i++) int_vector_iset( enkf_main->keep_runpath , int_vector_iget( active_list , i ) , EXPLICIT_DELETE); - + int_vector_free( active_list ); } } @@ -2416,12 +2438,12 @@ static void enkf_main_add_subst_kw( enkf_main_type * enkf_main , const char * ke subst_list_append_owned_ref( enkf_main->subst_list , tagged_key , util_alloc_string_copy( value ), help_text); else subst_list_append_ref( enkf_main->subst_list , tagged_key , value , help_text); - + free(tagged_key); } -static void enkf_main_init_qc( enkf_main_type * enkf_main , config_type * config ) { +static void enkf_main_init_qc( enkf_main_type * enkf_main , config_content_type * config ) { qc_module_init( enkf_main->qc_module , config ); enkf_main_add_subst_kw( enkf_main , "QC_PATH" , qc_module_get_path( enkf_main->qc_module ) , "QC Root path" , true); } @@ -2436,7 +2458,7 @@ static void enkf_main_init_subst_list( enkf_main_type * enkf_main ) { subst_func_pool_add_func( enkf_main->subst_func_pool , "MUL" , "Multiplies arguments" , subst_func_mul , true , 1 , 0 , NULL); subst_func_pool_add_func( enkf_main->subst_func_pool , "RANDINT" , "Returns a random integer - 32 bit" , subst_func_randint , false , 0 , 0 , enkf_main->rng); subst_func_pool_add_func( enkf_main->subst_func_pool , "RANDFLOAT" , "Returns a random float 0-1." , subst_func_randfloat , false , 0 , 0 , enkf_main->rng); - + /** Allocating the parent subst_list instance. This will (should ...) be the top level subst instance for all substitions in the ert @@ -2476,17 +2498,18 @@ enkf_main_type * enkf_main_alloc_empty( ) { enkf_main->site_config_file = NULL; enkf_main->rft_config_file = NULL; enkf_main->local_config = NULL; - enkf_main->rng = NULL; + enkf_main->rng = NULL; enkf_main->ens_size = 0; enkf_main->keep_runpath = int_vector_alloc( 0 , DEFAULT_KEEP ); enkf_main->rng_config = rng_config_alloc( ); enkf_main->site_config = site_config_alloc_empty(); enkf_main->ensemble_config = ensemble_config_alloc(); enkf_main->ecl_config = ecl_config_alloc(); - enkf_main->plot_config = plot_config_alloc_default(); + enkf_main->plot_config = plot_config_alloc_default(); enkf_main->ranking_table = ranking_table_alloc( 0 ); - enkf_main->obs = enkf_obs_alloc( ); + enkf_main->obs = NULL; enkf_main->model_config = model_config_alloc( ); + enkf_main->local_config = local_config_alloc( ); enkf_main_rng_init( enkf_main ); enkf_main->subst_func_pool = subst_func_pool_alloc( ); @@ -2494,9 +2517,9 @@ enkf_main_type * enkf_main_alloc_empty( ) { enkf_main->templates = ert_templates_alloc( enkf_main->subst_list ); enkf_main->workflow_list = ert_workflow_list_alloc( enkf_main->subst_list ); enkf_main->qc_module = qc_module_alloc( enkf_main->workflow_list , DEFAULT_QC_PATH ); - enkf_main->analysis_config = analysis_config_alloc( enkf_main->rng ); + enkf_main->analysis_config = analysis_config_alloc( enkf_main->rng ); enkf_main->report_list = ert_report_list_alloc( DEFAULT_REPORT_PATH , plot_config_get_path( enkf_main->plot_config ) ); - + enkf_main_init_subst_list( enkf_main ); enkf_main_set_verbose( enkf_main , true ); return enkf_main; @@ -2520,27 +2543,27 @@ static void enkf_main_install_data_kw( enkf_main_type * enkf_main , hash_type * } hash_iter_free(iter); } +} +static void enkf_main_install_common_data_kw( enkf_main_type * enkf_main ) { /* Installing the based (key,value) pairs which are common to all ensemble members, and independent of time. */ - { - char * cwd = util_alloc_cwd(); - char * date_string = util_alloc_date_stamp(); - const char * num_cpu_string = "1"; - - enkf_main_add_subst_kw( enkf_main , "CWD" , cwd , "The current working directory we are running from - the location of the config file." , true); - enkf_main_add_subst_kw( enkf_main , "CONFIG_PATH" , cwd , "The current working directory we are running from - the location of the config file." , true); - enkf_main_add_subst_kw( enkf_main , "DATE" , date_string , "The current date." , true); - enkf_main_add_subst_kw( enkf_main , "NUM_CPU" , num_cpu_string , "The number of CPU used for one forward model." , true ); - enkf_main_add_subst_kw( enkf_main , "RUNPATH_FILE" , qc_module_get_runpath_list_file( enkf_main->qc_module ) , "The name of a file with a list of run directories." , true); + char * cwd = util_alloc_cwd(); + char * date_string = util_alloc_date_stamp(); + const char * num_cpu_string = "1"; - free( cwd ); - free( date_string ); - } + enkf_main_add_subst_kw( enkf_main , "CWD" , cwd , "The current working directory we are running from - the location of the config file." , true); + enkf_main_add_subst_kw( enkf_main , "CONFIG_PATH" , cwd , "The current working directory we are running from - the location of the config file." , true); + enkf_main_add_subst_kw( enkf_main , "DATE" , date_string , "The current date." , true); + enkf_main_add_subst_kw( enkf_main , "NUM_CPU" , num_cpu_string , "The number of CPU used for one forward model." , true ); + enkf_main_add_subst_kw( enkf_main , "RUNPATH_FILE" , qc_module_get_runpath_list_file( enkf_main->qc_module ) , "The name of a file with a list of run directories." , true); + + free( cwd ); + free( date_string ); } @@ -2561,36 +2584,36 @@ void enkf_main_resize_ensemble( enkf_main_type * enkf_main , int new_ens_size ) ranking_table_set_ens_size( enkf_main->ranking_table , new_ens_size ); /* Tell the site_config object (i.e. the queue drivers) about the new ensemble size: */ site_config_set_ens_size( enkf_main->site_config , new_ens_size ); - + /* The ensemble is shrinking. */ if (new_ens_size < enkf_main->ens_size) { /*1: Free all ensemble members which go out of scope. */ for (iens = new_ens_size; iens < enkf_main->ens_size; iens++) enkf_state_free( enkf_main->ensemble[iens] ); - + /*2: Shrink the ensemble pointer. */ enkf_main->ensemble = util_realloc(enkf_main->ensemble , new_ens_size * sizeof * enkf_main->ensemble ); enkf_main->ens_size = new_ens_size; return; } - - + + /* The ensemble is expanding */ if (new_ens_size > enkf_main->ens_size) { /*1: Grow the ensemble pointer. */ enkf_main->ensemble = util_realloc(enkf_main->ensemble , new_ens_size * sizeof * enkf_main->ensemble ); /*2: Allocate the new ensemble members. */ - for (iens = enkf_main->ens_size; iens < new_ens_size; iens++) + for (iens = enkf_main->ens_size; iens < new_ens_size; iens++) /* Observe that due to the initialization of the rng - this function is currently NOT thread safe. */ enkf_main->ensemble[iens] = enkf_state_alloc(iens, - enkf_main->rng , + enkf_main->rng , enkf_main->dbase , model_config_iget_casename( enkf_main->model_config , iens ) , enkf_main->pre_clear_runpath , - int_vector_safe_iget( enkf_main->keep_runpath , iens) , + int_vector_safe_iget( enkf_main->keep_runpath , iens) , enkf_main->model_config , enkf_main->ensemble_config , enkf_main->site_config , @@ -2600,7 +2623,7 @@ void enkf_main_resize_ensemble( enkf_main_type * enkf_main , int new_ens_size ) enkf_main->ens_size = new_ens_size; return; } - + util_abort("%s: something is seriously broken - should NOT be here .. \n",__func__); } @@ -2610,7 +2633,7 @@ void enkf_main_resize_ensemble( enkf_main_type * enkf_main , int new_ens_size ) void enkf_main_update_node( enkf_main_type * enkf_main , const char * key ) { int iens; - for (iens = 0; iens < enkf_main->ens_size; iens++) + for (iens = 0; iens < enkf_main->ens_size; iens++) enkf_state_update_node( enkf_main->ensemble[iens] , key ); } @@ -2656,13 +2679,13 @@ void enkf_main_gen_data_special( enkf_main_type * enkf_main ) { /** SCHEDULE_PREDICTION_FILE. - + The SCHEDULE_PREDICTION_FILE is implemented as a GEN_KW instance, with some twists. Observe the following: - + 1. The SCHEDULE_PREDICTION_FILE is added to the ensemble_config as a GEN_KW node with key 'PRED'. - + 2. The target file is set equal to the initial prediction file (i.e. the template in this case), NOT including any path components. @@ -2681,7 +2704,7 @@ void enkf_main_set_schedule_prediction_file__( enkf_main_type * enkf_main , cons if (template_file != NULL) { char * target_file; bool forward_init = false; - enkf_config_node_type * config_node = ensemble_config_add_gen_kw( enkf_main->ensemble_config , key , forward_init); + enkf_config_node_type * config_node = ensemble_config_add_gen_kw( enkf_main->ensemble_config , key , forward_init); { char * base; char * ext; @@ -2707,57 +2730,30 @@ const char * enkf_main_get_schedule_prediction_file( const enkf_main_type * enkf } -/* - Adding inverse observation keys to the enkf_nodes; can be called - several times. -*/ - - -void enkf_main_update_obs_keys( enkf_main_type * enkf_main ) { - /* First clear all existing observation keys. */ - ensemble_config_clear_obs_keys( enkf_main->ensemble_config ); - - /* Add new observation keys. */ - { - hash_type * map = enkf_obs_alloc_data_map(enkf_main->obs); - hash_iter_type * iter = hash_iter_alloc(map); - const char * obs_key = hash_iter_get_next_key(iter); - while (obs_key != NULL) { - const char * state_kw = hash_get(map , obs_key); - ensemble_config_add_obs_key(enkf_main->ensemble_config , state_kw , obs_key); - obs_key = hash_iter_get_next_key(iter); - } - hash_iter_free(iter); - hash_free(map); - } -} /*****************************************************************/ -static void enkf_main_init_data_kw( enkf_main_type * enkf_main , config_type * config ) { +static void enkf_main_init_data_kw( enkf_main_type * enkf_main , config_content_type * config ) { { - const subst_list_type * define_list = config_get_define_list( config ); + const subst_list_type * define_list = config_content_get_define_list( config ); for (int i=0; i < subst_list_get_size( define_list ); i++) { const char * key = subst_list_iget_key( define_list , i ); const char * value = subst_list_iget_value( define_list , i ); enkf_main_add_data_kw( enkf_main , key , value ); } } - - { - config_content_item_type * data_item = config_get_content_item( config , DATA_KW_KEY ); - hash_type * data_kw = NULL; - if (data_item) - data_kw = config_content_item_alloc_hash(data_item , true); - + + if (config_content_has_item( config , DATA_KW_KEY)) { + config_content_item_type * data_item = config_content_get_item( config , DATA_KW_KEY ); + hash_type * data_kw = config_content_item_alloc_hash(data_item , true); enkf_main_install_data_kw( enkf_main , data_kw ); - - if (data_kw) - hash_free( data_kw ); + hash_free( data_kw ); } + + enkf_main_install_common_data_kw( enkf_main ); } - + @@ -2777,42 +2773,28 @@ void enkf_main_rng_init( enkf_main_type * enkf_main) { } -void enkf_main_init_local_updates( enkf_main_type * enkf_main , const config_type * config ) { +void enkf_main_update_local_updates( enkf_main_type * enkf_main) { const enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main ); if (enkf_obs_have_obs( enkf_obs )) { - enkf_main->local_config = local_config_alloc( ); - /* First create the default ALL_ACTIVE configuration. */ { char * all_active_config_file = util_alloc_tmp_file("/tmp" , "enkf_local_config" , true); - enkf_main_create_all_active_config( enkf_main , + enkf_main_create_all_active_config( enkf_main , all_active_config_file ); - - /* Install custom local_config - if present.*/ - { - int i; - for (i = 0; i < config_get_occurences( config , LOCAL_CONFIG_KEY); i++) { - const stringlist_type * files = config_iget_stringlist_ref(config , LOCAL_CONFIG_KEY , i); - for (int j=0; j < stringlist_get_size( files ); j++) - local_config_add_config_file( enkf_main->local_config , stringlist_iget( files , j) ); - } - } - + /** - This is where the local configuration files are actually parsed. + This is where the local configuration files are actually parsed. */ - local_config_reload( enkf_main->local_config , - ecl_config_get_grid( enkf_main->ecl_config ), - enkf_main->ensemble_config , - enkf_main->obs , + local_config_reload( enkf_main->local_config , + ecl_config_get_grid( enkf_main->ecl_config ), + enkf_main->ensemble_config , + enkf_main->obs , all_active_config_file ); - + unlink( all_active_config_file ); free(all_active_config_file); } - } else - if (config_get_occurences( config , LOCAL_CONFIG_KEY) > 0) - fprintf(stderr,"** Warning: Not possible to configure local analysis without SCHEDULE or REFCASE - %s keyword(s) ignored\n", LOCAL_CONFIG_KEY); + } } @@ -2828,19 +2810,22 @@ void enkf_main_init_local_updates( enkf_main_type * enkf_main , const config_typ static void enkf_main_bootstrap_site(enkf_main_type * enkf_main , const char * site_config_file) { if (site_config_file != NULL) { if (!util_file_exists(site_config_file)) util_exit("%s: can not locate site configuration file:%s \n",__func__ , site_config_file); - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); + site_config_add_config_items( config , true ); { - site_config_add_config_items( config , true ); - if (config_parse(config , site_config_file , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , false)) { - site_config_init( enkf_main->site_config , config ); - analysis_config_load_all_external_modules_from_config(enkf_main->analysis_config, config); - ert_report_list_site_init( enkf_main->report_list , config ); - ert_workflow_list_init( enkf_main->workflow_list , config ); + config_content_type * content = config_parse(config , site_config_file , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , false); + if (config_content_is_valid( content )) { + site_config_init( enkf_main->site_config , content ); + analysis_config_load_all_external_modules_from_config(enkf_main->analysis_config, content); + ert_report_list_site_init( enkf_main->report_list , content ); + ert_workflow_list_init( enkf_main->workflow_list , content ); } else { + config_error_type * errors = config_content_get_errors( content ); fprintf(stderr , "** ERROR: Parsing site configuration file:%s failed \n\n" , site_config_file); - config_fprintf_errors( config , true , stderr ); + config_error_fprintf( errors , true , stderr ); exit(1); } + config_content_free( content ); } config_free( config ); } @@ -2878,250 +2863,269 @@ static void enkf_main_bootstrap_site(enkf_main_type * enkf_main , const char * s FORWARD_MODEL DATA_FILE SCHEDULE_FILE - ECLBASE + ECLBASE */ +/** + It is possible to pass NULL as the model_config argument, in that + case only the site config file will be parsed. The purpose of this + is mainly to be able to test that the site config file is valid. +*/ -enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _model_config, bool strict , bool verbose) { - const char * site_config = getenv("ERT_SITE_CONFIG"); - char * model_config; - enkf_main_type * enkf_main; /* The enkf_main object is allocated when the config parsing is completed. */ - if (site_config == NULL) - site_config = _site_config; +enkf_main_type * enkf_main_bootstrap(const char * _model_config, bool strict , bool verbose) { + const char * site_config = site_config_get_location(); + char * model_config = NULL; + enkf_main_type * enkf_main; /* The enkf_main object is allocated when the config parsing is completed. */ - if (site_config == NULL) - fprintf(stderr,"**WARNING** main enkf_config file is not set. Use environment variable \"ERT_SITE_CONFIG\" - or recompile.\n"); - - { - char * path; - char * base; - char * ext; - if (util_is_link( _model_config )) { /* The command line argument given is a symlink - we start by changing to */ - /* the real location of the configuration file. */ - char * realpath = util_alloc_link_target( _model_config ); - util_alloc_file_components(realpath , &path , &base , &ext); - free( realpath ); - } else - util_alloc_file_components(_model_config , &path , &base , &ext); - - if (path != NULL) { - if (util_chdir(path) != 0) - util_abort("%s: failed to change directory to: %s : %s \n",__func__ , path , strerror(errno)); - - if (verbose) - printf("Changing to directory ...................: %s \n",path); - - if (ext != NULL) - model_config = util_alloc_filename( NULL , base , ext ); - else - model_config = util_alloc_string_copy( base ); + if (_model_config) { + { + char * path; + char * base; + char * ext; + if (util_is_link( _model_config )) { /* The command line argument given is a symlink - we start by changing to */ + /* the real location of the configuration file. */ + char * realpath = util_alloc_link_target( _model_config ); + util_alloc_file_components(realpath , &path , &base , &ext); + free( realpath ); + } else + util_alloc_file_components(_model_config , &path , &base , &ext); + + if (path != NULL) { + if (util_chdir(path) != 0) + util_abort("%s: failed to change directory to: %s : %s \n",__func__ , path , strerror(errno)); + + if (verbose) + printf("Changing to directory ...................: %s \n",path); + + if (ext != NULL) + model_config = util_alloc_filename( NULL , base , ext ); + else + model_config = util_alloc_string_copy( base ); + } else + model_config = util_alloc_string_copy(_model_config); + + util_safe_free( path ); + util_safe_free( base ); + util_safe_free( ext ); + } - } else - model_config = util_alloc_string_copy(_model_config); - - util_safe_free( path ); - util_safe_free( base ); - util_safe_free( ext ); + if (!util_file_exists(model_config)) + util_exit("%s: can not locate user configuration file:%s \n",__func__ , model_config); } - if (!util_file_exists(model_config)) - util_exit("%s: can not locate user configuration file:%s \n",__func__ , model_config); { - config_type * config; + config_parser_type * config; + config_content_type * content; enkf_main = enkf_main_alloc_empty( ); enkf_main_set_verbose( enkf_main , verbose ); enkf_main_bootstrap_site( enkf_main , site_config); - - config = config_alloc(); - enkf_main_init_user_config( enkf_main , config ); - site_config_add_config_items( config , false ); - site_config_init_user_mode( enkf_main->site_config ); - - if (!config_parse(config , model_config , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , true)) { - config_fprintf_errors( config , true , stderr ); - exit(1); - } - site_config_init( enkf_main->site_config , config ); /* <---- model_config : second pass. */ + if (model_config) { + config = config_alloc(); + enkf_main_init_user_config( enkf_main , config ); + site_config_add_config_items( config , false ); + site_config_init_user_mode( enkf_main->site_config ); + + content = config_parse(config , model_config , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , true); + if (!config_content_is_valid( content )) { + config_error_type * errors = config_content_get_errors( content ); + config_error_fprintf( errors , true , stderr ); + exit(1); + } - /*****************************************************************/ - /* - OK - now we have parsed everything - and we are ready to start - populating the enkf_main object. - */ + site_config_init( enkf_main->site_config , content ); /* <---- model_config : second pass. */ + /*****************************************************************/ + /* + OK - now we have parsed everything - and we are ready to start + populating the enkf_main object. + */ - enkf_main_set_site_config_file( enkf_main , site_config ); - enkf_main_set_user_config_file( enkf_main , model_config ); - { - char * log_file; - int log_level = DEFAULT_LOG_LEVEL; - if(config_item_set( config , LOG_LEVEL_KEY)) - log_level = config_get_value_as_int(config , LOG_LEVEL_KEY); + enkf_main_set_site_config_file( enkf_main , site_config ); + enkf_main_set_user_config_file( enkf_main , model_config ); - if (config_item_set( config , LOG_FILE_KEY)) - log_file = util_alloc_string_copy( config_get_value(config , LOG_FILE_KEY)); - else - log_file = util_alloc_filename( NULL , enkf_main->user_config_file , "log"); + { + char * log_file; + int log_level = DEFAULT_LOG_LEVEL; + if(config_content_has_item( content , LOG_LEVEL_KEY)) + log_level = config_content_get_value_as_int(content , LOG_LEVEL_KEY); - ert_log_init_log(log_level, log_file , enkf_main->verbose); - - free( log_file ); - } + if (config_content_has_item( content , LOG_FILE_KEY)) + log_file = util_alloc_string_copy( config_content_get_value(content , LOG_FILE_KEY)); + else + log_file = util_alloc_filename( NULL , enkf_main->user_config_file , "log"); - /* - Initializing the various 'large' sub config objects. - */ - rng_config_init( enkf_main->rng_config , config ); - enkf_main_rng_init( enkf_main ); /* Must be called before the ensmeble is created. */ - - enkf_main_init_subst_list( enkf_main ); - ert_workflow_list_init( enkf_main->workflow_list , config ); - - analysis_config_load_internal_modules( enkf_main->analysis_config ); - analysis_config_init( enkf_main->analysis_config , config ); - ecl_config_init( enkf_main->ecl_config , config ); - plot_config_init( enkf_main->plot_config , config ); - ensemble_config_init( enkf_main->ensemble_config , config , ecl_config_get_grid( enkf_main->ecl_config ) , ecl_config_get_refcase( enkf_main->ecl_config) ); - - model_config_init( enkf_main->model_config , - config , - enkf_main_get_ensemble_size( enkf_main ), - site_config_get_installed_jobs(enkf_main->site_config) , - ecl_config_get_last_history_restart( enkf_main->ecl_config ), - ecl_config_get_sched_file(enkf_main->ecl_config) , - ecl_config_get_refcase( enkf_main->ecl_config )); - - enkf_main_init_qc( enkf_main , config ); - enkf_main_init_data_kw( enkf_main , config ); - enkf_main_update_num_cpu( enkf_main ); - { - const config_content_item_type * pred_item = config_get_content_item( config , SCHEDULE_PREDICTION_FILE_KEY ); - if (pred_item != NULL) { - config_content_node_type * pred_node = config_content_item_get_last_node( pred_item ); - const char * template_file = config_content_node_iget_as_path( pred_node , 0 ); - { - hash_type * opt_hash = hash_alloc(); - config_content_node_init_opt_hash( pred_node , opt_hash , 1 ); - - const char * parameters = hash_safe_get( opt_hash , "PARAMETERS" ); - const char * min_std = hash_safe_get( opt_hash , "MIN_STD" ); - const char * init_files = hash_safe_get( opt_hash , "INIT_FILES" ); - - enkf_main_set_schedule_prediction_file__( enkf_main , template_file , parameters , min_std , init_files ); - hash_free( opt_hash ); - } + ert_log_init_log(log_level, log_file , enkf_main->verbose); + + free( log_file ); } - } - - - /*****************************************************************/ - /** - To keep or not to keep the runpath directories? The problem is - that the default behavior is different depending on the run_mode: - enkf_mode: In this case the default behaviour is to delete the - runpath directories. You can explicitly say that you want to - keep runpath directories with the KEEP_RUNPATH - directive. + /* + Initializing the various 'large' sub config objects. + */ + rng_config_init( enkf_main->rng_config , content ); + enkf_main_rng_init( enkf_main ); /* Must be called before the ensmeble is created. */ + + enkf_main_init_subst_list( enkf_main ); + ert_workflow_list_init( enkf_main->workflow_list , content ); + + analysis_config_load_internal_modules( enkf_main->analysis_config ); + analysis_config_init( enkf_main->analysis_config , content ); + ecl_config_init( enkf_main->ecl_config , content ); + plot_config_init( enkf_main->plot_config , content ); + + ensemble_config_init( enkf_main->ensemble_config , content , ecl_config_get_grid( enkf_main->ecl_config ) , ecl_config_get_refcase( enkf_main->ecl_config) ); + + model_config_init( enkf_main->model_config , + content , + enkf_main_get_ensemble_size( enkf_main ), + site_config_get_installed_jobs(enkf_main->site_config) , + ecl_config_get_last_history_restart( enkf_main->ecl_config ), + ecl_config_get_sched_file(enkf_main->ecl_config) , + ecl_config_get_refcase( enkf_main->ecl_config )); + + enkf_main_init_qc( enkf_main , content ); + enkf_main_init_data_kw( enkf_main , content ); + enkf_main_update_num_cpu( enkf_main ); + { + if (config_content_has_item( content , SCHEDULE_PREDICTION_FILE_KEY )) { + const config_content_item_type * pred_item = config_content_get_item( content , SCHEDULE_PREDICTION_FILE_KEY ); + config_content_node_type * pred_node = config_content_item_get_last_node( pred_item ); + const char * template_file = config_content_node_iget_as_path( pred_node , 0 ); + { + hash_type * opt_hash = hash_alloc(); + config_content_node_init_opt_hash( pred_node , opt_hash , 1 ); + + const char * parameters = hash_safe_get( opt_hash , "PARAMETERS" ); + const char * min_std = hash_safe_get( opt_hash , "MIN_STD" ); + const char * init_files = hash_safe_get( opt_hash , "INIT_FILES" ); + + enkf_main_set_schedule_prediction_file__( enkf_main , template_file , parameters , min_std , init_files ); + hash_free( opt_hash ); + } + } + } + + + /*****************************************************************/ + /** + To keep or not to keep the runpath directories? The problem is + that the default behavior is different depending on the run_mode: + + enkf_mode: In this case the default behaviour is to delete the + runpath directories. You can explicitly say that you want to + keep runpath directories with the KEEP_RUNPATH + directive. - experiments: In this case the default is to keep the runpath - directories around, but you can explicitly say that you - want to remove the directories by using the DELETE_RUNPATH - option. + experiments: In this case the default is to keep the runpath + directories around, but you can explicitly say that you + want to remove the directories by using the DELETE_RUNPATH + option. - The final decision is performed in enkf_state(). - */ - { + The final decision is performed in enkf_state(). + */ { - char * keep_runpath_string = NULL; - char * delete_runpath_string = NULL; - int ens_size = config_get_value_as_int(config , NUM_REALIZATIONS_KEY); - - if (config_item_set(config , KEEP_RUNPATH_KEY)) - keep_runpath_string = config_alloc_joined_string(config , KEEP_RUNPATH_KEY , ""); + { + char * keep_runpath_string = NULL; + char * delete_runpath_string = NULL; + int ens_size = config_content_get_value_as_int(content , NUM_REALIZATIONS_KEY); - if (config_item_set(config , DELETE_RUNPATH_KEY)) - delete_runpath_string = config_alloc_joined_string(config , DELETE_RUNPATH_KEY , ""); + if (config_content_has_item(content , KEEP_RUNPATH_KEY)) + keep_runpath_string = config_content_alloc_joined_string(content , KEEP_RUNPATH_KEY , ""); - enkf_main_parse_keep_runpath( enkf_main , keep_runpath_string , delete_runpath_string , ens_size ); + if (config_content_has_item(content , DELETE_RUNPATH_KEY)) + delete_runpath_string = config_content_alloc_joined_string(content , DELETE_RUNPATH_KEY , ""); - util_safe_free( keep_runpath_string ); - util_safe_free( delete_runpath_string ); - } + enkf_main_parse_keep_runpath( enkf_main , keep_runpath_string , delete_runpath_string , ens_size ); - /* This is really in the wrong place ... */ - { - enkf_main->pre_clear_runpath = DEFAULT_PRE_CLEAR_RUNPATH; - if (config_item_set(config , PRE_CLEAR_RUNPATH_KEY)) - enkf_main->pre_clear_runpath = config_get_value_as_bool( config , PRE_CLEAR_RUNPATH_KEY); - } + util_safe_free( keep_runpath_string ); + util_safe_free( delete_runpath_string ); + } + /* This is really in the wrong place ... */ + { + enkf_main->pre_clear_runpath = DEFAULT_PRE_CLEAR_RUNPATH; + if (config_content_has_item(content , PRE_CLEAR_RUNPATH_KEY)) + enkf_main->pre_clear_runpath = config_content_get_value_as_bool( content , PRE_CLEAR_RUNPATH_KEY); + } - ecl_config_static_kw_init( enkf_main->ecl_config , config ); - - /* Installing templates */ - { - ert_templates_init( enkf_main->templates , config ); - } + ecl_config_static_kw_init( enkf_main->ecl_config , content ); - /*****************************************************************/ - ert_report_list_init( enkf_main->report_list , config , ecl_config_get_refcase( enkf_main->ecl_config )); - - { - const char * obs_config_file; - if (config_item_set(config , OBS_CONFIG_KEY)) - obs_config_file = config_iget(config , OBS_CONFIG_KEY , 0,0); - else - obs_config_file = NULL; + /* Installing templates */ + ert_templates_init( enkf_main->templates , content ); - enkf_main_load_obs( enkf_main , obs_config_file ); - } + /*****************************************************************/ + ert_report_list_init( enkf_main->report_list , content , ecl_config_get_refcase( enkf_main->ecl_config )); - enkf_main_update_obs_keys(enkf_main); - { - const char * rft_config_file = NULL; - if (config_item_set(config , RFT_CONFIG_KEY)) - rft_config_file = config_iget(config , RFT_CONFIG_KEY , 0,0); + /*****************************************************************/ + { + const char * select_case = NULL; + if (config_content_has_item( content , SELECT_CASE_KEY)) + select_case = config_content_get_value( content , SELECT_CASE_KEY ); - enkf_main_set_rft_config_file( enkf_main , rft_config_file ); - } - + enkf_main_user_select_fs( enkf_main , select_case ); + } - /*****************************************************************/ - { - const char * select_case = NULL; - if (config_item_set( config , SELECT_CASE_KEY)) - select_case = config_get_value( config , SELECT_CASE_KEY ); - - enkf_main_user_select_fs( enkf_main , select_case ); - } - /* Adding ensemble members */ - enkf_main_resize_ensemble( enkf_main , config_iget_as_int(config , NUM_REALIZATIONS_KEY , 0 , 0) ); + { + const char * rft_config_file = NULL; + if (config_content_has_item(content , RFT_CONFIG_KEY)) + rft_config_file = config_content_iget(content , RFT_CONFIG_KEY , 0,0); - /*****************************************************************/ - /* - Installing the local_config object. Observe that the - ALL_ACTIVE local_config configuration is ALWAYS loaded. But - if you have created a personal local config that will be - loaded on top. - */ - enkf_main_init_local_updates(enkf_main , config ); - + enkf_main_set_rft_config_file( enkf_main , rft_config_file ); + } + + + /*****************************************************************/ + { + const char * select_case = NULL; + if (config_content_has_item( content , SELECT_CASE_KEY)) + select_case = config_content_get_value( content , SELECT_CASE_KEY ); + + enkf_main_user_select_fs( enkf_main , select_case ); + } + + /* Adding ensemble members */ + enkf_main_resize_ensemble( enkf_main , config_content_iget_as_int(content , NUM_REALIZATIONS_KEY , 0 , 0) ); + + /*****************************************************************/ + /* + Installing the local_config object. Observe that the + ALL_ACTIVE local_config configuration is ALWAYS loaded. But + if you have created a personal local config that will be + loaded on top. + */ + /* Install custom local_config - if present.*/ + { + int i; + for (i = 0; i < config_content_get_occurences( content , LOCAL_CONFIG_KEY); i++) { + const stringlist_type * files = config_content_iget_stringlist_ref(content , LOCAL_CONFIG_KEY , i); + for (int j=0; j < stringlist_get_size( files ); j++) + local_config_add_config_file( enkf_main->local_config , stringlist_iget( files , j) ); + } + } + + /* Loading observations */ + enkf_main_alloc_obs(enkf_main); + if (config_content_has_item(content , OBS_CONFIG_KEY)) { + const char * obs_config_file = config_content_iget(content , OBS_CONFIG_KEY , 0,0); + enkf_main_load_obs( enkf_main , obs_config_file , true ); + } + + } + config_content_free( content ); + config_free(config); } - config_free(config); + enkf_main_init_jobname( enkf_main ); + enkf_main_gen_data_special( enkf_main ); + free( model_config ); } - enkf_main_init_jobname( enkf_main ); - enkf_main_gen_data_special( enkf_main ); - free( model_config ); - return enkf_main; } @@ -3138,9 +3142,9 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo */ void enkf_main_create_new_config( const char * config_file , const char * storage_path , const char * case_name , const char * dbase_type , int num_realizations) { - + FILE * stream = util_mkdir_fopen( config_file , "w" ); - + fprintf(stream , CONFIG_KEY_FORMAT , ENSPATH_KEY); fprintf(stream , CONFIG_ENDVALUE_FORMAT , storage_path ); @@ -3153,7 +3157,7 @@ void enkf_main_create_new_config( const char * config_file , const char * storag fprintf(stream , CONFIG_KEY_FORMAT , NUM_REALIZATIONS_KEY); fprintf(stream , CONFIG_INT_FORMAT , num_realizations); fprintf(stream , "\n"); - + fclose( stream ); printf("Have created configuration file: %s \n",config_file ); @@ -3298,7 +3302,7 @@ void enkf_main_init_internalization( enkf_main_type * enkf_main , run_mode_type } hash_iter_free(iter); hash_free(map); - } + } } @@ -3341,7 +3345,7 @@ void enkf_main_log_fprintf_config( const enkf_main_type * enkf_main , FILE * str fprintf(stream , CONFIG_INT_FORMAT , ert_log_get_log_level()); fprintf(stream , "\n"); } - + fprintf(stream , "\n"); fprintf(stream , "\n"); } @@ -3371,12 +3375,12 @@ ert_report_list_type * enkf_main_get_report_list( const enkf_main_type * enkf_ma void enkf_main_fprintf_runpath_config( const enkf_main_type * enkf_main , FILE * stream ) { fprintf(stream , CONFIG_KEY_FORMAT , PRE_CLEAR_RUNPATH_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , CONFIG_BOOL_STRING( enkf_state_get_pre_clear_runpath( enkf_main->ensemble[0] ))); - + { bool keep_comma = false; bool del_comma = false; - - + + for (int iens = 0; iens < enkf_main->ens_size; iens++) { keep_runpath_type keep_runpath = enkf_main_iget_keep_runpath( enkf_main , iens ); if (keep_runpath == EXPLICIT_KEEP) { @@ -3384,7 +3388,7 @@ void enkf_main_fprintf_runpath_config( const enkf_main_type * enkf_main , FILE * fprintf(stream , CONFIG_KEY_FORMAT , KEEP_RUNPATH_KEY ); fprintf(stream , "%d" , iens); keep_comma = true; - } else + } else fprintf(stream , ",%d" , iens); } } @@ -3413,9 +3417,9 @@ void enkf_main_fprintf_runpath_config( const enkf_main_type * enkf_main , FILE * void enkf_main_fprintf_config( const enkf_main_type * enkf_main ) { if (util_file_exists( enkf_main->user_config_file)) { - /** + /** A version of the config file already exist, and we will take - backup. + backup. */ char * backup_file = NULL; char * prev_backup = NULL; @@ -3427,7 +3431,7 @@ void enkf_main_fprintf_config( const enkf_main_type * enkf_main ) { backup_nr++; } } while (util_file_exists( backup_file )); - + /** When leaving the do { } while loop backup_file will point to the first non-existing backup filename; and prev_backup will @@ -3447,28 +3451,27 @@ void enkf_main_fprintf_config( const enkf_main_type * enkf_main ) { if (prev_backup == NULL) util_copy_file( enkf_main->user_config_file , backup_file ); else { - if (!util_files_equal( enkf_main->user_config_file , prev_backup )) + if (!util_files_equal( enkf_main->user_config_file , prev_backup )) util_copy_file( enkf_main->user_config_file , backup_file ); } util_safe_free( prev_backup ); util_safe_free( backup_file ); } - + /* Start the proper saving */ { FILE * stream = util_fopen( enkf_main->user_config_file , "w"); - + ecl_config_fprintf_config( enkf_main->ecl_config , stream ); model_config_fprintf_config( enkf_main->model_config , enkf_main->ens_size , stream ); - enkf_obs_fprintf_config( enkf_main->obs , stream ); analysis_config_fprintf_config( enkf_main->analysis_config , stream ); ensemble_config_fprintf_config( enkf_main->ensemble_config , stream ); local_config_fprintf_config( enkf_main->local_config , stream ); enkf_main_fprintf_runpath_config( enkf_main , stream ); ert_templates_fprintf_config( enkf_main->templates , stream ); enkf_main_log_fprintf_config( enkf_main , stream ); - site_config_fprintf_config( enkf_main->site_config , stream ); + site_config_fprintf_config( enkf_main->site_config , stream ); rng_config_fprintf_config( enkf_main->rng_config , stream ); fclose( stream ); } @@ -3494,7 +3497,7 @@ bool enkf_main_run_workflow( enkf_main_type * enkf_main , const char * workflow void enkf_main_run_workflows( enkf_main_type * enkf_main , const stringlist_type * workflows) { int iw; - for (iw = 0; iw < stringlist_get_size( workflows ); iw++) + for (iw = 0; iw < stringlist_get_size( workflows ); iw++) enkf_main_run_workflow( enkf_main , stringlist_iget( workflows , iw )); } @@ -3582,15 +3585,15 @@ char * enkf_main_alloc_abs_path_to_init_file(const enkf_main_type * enkf_main, c abs_path_to_init_file = util_alloc_abs_path(path_to_init_file); if (abs_path_to_init_file && !util_file_exists(abs_path_to_init_file)) { - free(abs_path_to_init_file); + free(abs_path_to_init_file); abs_path_to_init_file = NULL; } - + if (runpath) - free(runpath); + free(runpath); if (path_to_init_file) - free(path_to_init_file); - + free(path_to_init_file); + return abs_path_to_init_file; } @@ -3612,15 +3615,15 @@ bool enkf_main_export_field(const enkf_main_type * enkf_main, bool enkf_main_export_field_with_fs(const enkf_main_type * enkf_main, - const char * kw, - const char * path, + const char * kw, + const char * path, bool_vector_type * iactive, field_file_format_type file_type, - int report_step, + int report_step, state_enum state, enkf_fs_type * fs) { - - bool ret = false; + + bool ret = false; if (util_int_format_count(path) < 1) { printf("EXPORT FIELD: There must be a %%d in the file name\n"); return ret; @@ -3628,15 +3631,15 @@ bool enkf_main_export_field_with_fs(const enkf_main_type * enkf_main, const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); const enkf_config_node_type * config_node = NULL; - bool node_found = false; - + bool node_found = false; + if (ensemble_config_has_key(ensemble_config, kw)) { - config_node = ensemble_config_get_node(ensemble_config, kw); + config_node = ensemble_config_get_node(ensemble_config, kw); if (config_node && enkf_config_node_get_impl_type(config_node) == FIELD) { - node_found = true; - } else + node_found = true; + } else printf("Did not find a FIELD %s node\n", kw); - } else + } else printf("Ensemble config does not have key %s\n", kw); if (node_found) { @@ -3680,18 +3683,18 @@ bool enkf_main_export_field_with_fs(const enkf_main_type * enkf_main, } else printf("%s : enkf_state_get_node returned NULL for parameters %d, %s \n", __func__, iens, kw); } - } + } if (init_file) free(init_file); } - + if (ret) printf("Successful export of FIELD %s\n", kw); - else + else printf("Errors during export of FIELD %s\n", kw); - return ret; + return ret; } diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c b/ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c index 323f45a478..ffe2471244 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c @@ -1,28 +1,32 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'enkf_main_jobs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'enkf_main_jobs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ +#include <unistd.h> + #include <ert/util/stringlist.h> #include <ert/util/string_util.h> #include <ert/util/int_vector.h> #include <ert/enkf/enkf_main.h> #include <ert/enkf/field_config.h> -#include <unistd.h> +#include <ert/enkf/local_obsdata.h> +#include <ert/enkf/local_obsdata_node.h> + static bool_vector_type * alloc_iactive_vector_from_range(const stringlist_type * range, int startindex, int endindex, int ens_size) { @@ -80,9 +84,9 @@ void * enkf_main_analysis_enkf_update_JOB( void * self , const stringlist_type * int target_step; int_vector_type * step_list; - + // Argument 0: The number of the step to write to - if (stringlist_get_size(args) > 1) + if (stringlist_get_size(args) > 1) util_sscanf_int(stringlist_iget( args , 1) , &target_step); else target_step = 0; @@ -92,11 +96,11 @@ void * enkf_main_analysis_enkf_update_JOB( void * self , const stringlist_type * char * step_args = stringlist_alloc_joined_substring(args , 2 , stringlist_get_size(args) , " "); step_list = string_util_alloc_active_list( step_args ); free( step_args ); - } else + } else step_list = int_vector_alloc(1,target_step); - + enkf_main_UPDATE( enkf_main , step_list , target_fs , target_step , SMOOTHER_UPDATE); - + int_vector_free( step_list ); return NULL; } @@ -126,11 +130,11 @@ void * enkf_main_analysis_update_JOB( void * self , const stringlist_type * args // Argument 1: The number of the step to write to - if (stringlist_get_size(args) > 1) + if (stringlist_get_size(args) > 1) util_sscanf_int(stringlist_iget( args , 1) , &target_step); else target_step = 0; - + // Argument 2 - ??: The timesteps to use in the update if (stringlist_get_size( args ) > 2) { char * step_args = stringlist_alloc_joined_substring(args , 2 , stringlist_get_size(args) , " "); @@ -141,9 +145,9 @@ void * enkf_main_analysis_update_JOB( void * self , const stringlist_type * args time_map_type * time_map = enkf_fs_get_time_map( enkf_main_get_fs( enkf_main )); step_list = enkf_main_update_alloc_step_list( enkf_main , 0 , time_map_get_last_step( time_map ) , stride); } - + enkf_main_UPDATE( enkf_main , step_list , target_fs , target_step , SMOOTHER_UPDATE); - + int_vector_free( step_list ); if (decrease_ref) @@ -223,7 +227,7 @@ void * enkf_main_iterated_smoother_JOB( void * self , const stringlist_type * ar const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main); analysis_iter_config_type * iter_config = analysis_config_get_iter_config(analysis_config); int num_iter = analysis_iter_config_get_num_iterations(iter_config); - + enkf_main_run_iterated_ES( enkf_main , num_iter); return NULL; } @@ -232,9 +236,9 @@ void * enkf_main_iterated_smoother_JOB( void * self , const stringlist_type * ar void * enkf_main_select_module_JOB( void * self , const stringlist_type * args ) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main ); - + analysis_config_select_module( analysis_config , stringlist_iget( args , 0 )); - + return NULL; } @@ -243,14 +247,14 @@ void * enkf_main_select_module_JOB( void * self , const stringlist_type * args ) void * enkf_main_create_reports_JOB(void * self , const stringlist_type * args ) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); ert_report_list_type * report_list = enkf_main_get_report_list( enkf_main ); - + ert_report_list_create( report_list , enkf_main_get_current_fs( enkf_main ) , true ); return NULL; } void * enkf_main_scale_obs_std_JOB(void * self, const stringlist_type * args ) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); - + double scale_factor; util_sscanf_double(stringlist_iget(args, 0), &scale_factor); @@ -263,8 +267,8 @@ void * enkf_main_scale_obs_std_JOB(void * self, const stringlist_type * args ) { /*****************************************************************/ -/* - Will create the new case if it does not exist. +/* + Will create the new case if it does not exist. */ void * enkf_main_select_case_JOB( void * self , const stringlist_type * args) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); @@ -301,12 +305,12 @@ void * enkf_main_init_case_from_existing_JOB( void * self , const stringlist_typ target_fs = enkf_fs_get_ref( enkf_main_get_fs(enkf_main) ); // Using get_ref so that we can unconditionally call decref() further down. } else target_fs = enkf_fs_get_ref( enkf_main_get_fs(enkf_main) ); // Using get_ref so that we can unconditionally call decref() further down. - + enkf_main_init_case_from_existing(enkf_main, source_fs, 0, ANALYZED, target_fs); enkf_fs_decref(target_fs); } enkf_fs_decref(source_fs); - + return NULL; } @@ -319,9 +323,9 @@ static void * enkf_main_load_results_JOB__( enkf_main_type * enkf_main , int ite stringlist_type ** realizations_msg_list = util_calloc(ens_size, sizeof * realizations_msg_list); for (int iens = 0; iens < ens_size; ++iens) realizations_msg_list[iens] = stringlist_alloc_new(); - + enkf_main_load_from_forward_model(enkf_main, iter , iactive, realizations_msg_list); - + for (int iens = 0; iens < ens_size; ++iens) { stringlist_type * msg = realizations_msg_list[iens]; if (stringlist_get_size(msg)) { @@ -331,11 +335,11 @@ static void * enkf_main_load_results_JOB__( enkf_main_type * enkf_main , int ite } stringlist_free(msg); } - + free(realizations_msg_list); bool_vector_free(iactive); return NULL; -} +} void * enkf_main_load_results_JOB( void * self , const stringlist_type * args) { @@ -354,7 +358,7 @@ void * enkf_main_load_results_iter_JOB( void * self , const stringlist_type * ar enkf_main_type * enkf_main = enkf_main_safe_cast( self ); stringlist_type * iens_args = stringlist_alloc_shallow_copy_with_limits( args , 1 , stringlist_get_size( args ) - 1); int iter; - + util_sscanf_int( stringlist_iget( args , 0 ) , &iter); enkf_main_load_results_JOB__(enkf_main , iter , iens_args ); stringlist_free( iens_args ); @@ -366,11 +370,11 @@ void * enkf_main_load_results_iter_JOB( void * self , const stringlist_type * ar /*****************************************************************/ static void enkf_main_jobs_export_field(const enkf_main_type * enkf_main, const stringlist_type * args, field_file_format_type file_type) { - const char * field = stringlist_iget(args, 0); - const char * file_name = stringlist_iget(args, 1); + const char * field = stringlist_iget(args, 0); + const char * file_name = stringlist_iget(args, 1); int report_step = 0; util_sscanf_int(stringlist_iget(args,2), &report_step); - state_enum state = enkf_types_get_state_enum(stringlist_iget(args, 3)); + state_enum state = enkf_types_get_state_enum(stringlist_iget(args, 3)); if (BOTH == state) { fprintf(stderr,"** Field export jobs only supports state_enum ANALYZED or FORECAST, not BOTH.\n"); @@ -385,28 +389,28 @@ static void enkf_main_jobs_export_field(const enkf_main_type * enkf_main, const void * enkf_main_export_field_JOB(void * self, const stringlist_type * args) { - const char * file_name = stringlist_iget(args, 1); - field_file_format_type file_type = field_config_default_export_format(file_name); - + const char * file_name = stringlist_iget(args, 1); + field_file_format_type file_type = field_config_default_export_format(file_name); + if ((RMS_ROFF_FILE == file_type) || (ECL_GRDECL_FILE == file_type)) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); enkf_main_jobs_export_field(enkf_main, args, file_type); } else - printf("EXPORT_FIELD filename argument: File extension must be either .roff or .grdecl\n"); - - return NULL; + printf("EXPORT_FIELD filename argument: File extension must be either .roff or .grdecl\n"); + + return NULL; } void * enkf_main_export_field_to_RMS_JOB(void * self, const stringlist_type * args) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); enkf_main_jobs_export_field(enkf_main, args, RMS_ROFF_FILE); - return NULL; + return NULL; } void * enkf_main_export_field_to_ECL_JOB(void * self, const stringlist_type * args) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); enkf_main_jobs_export_field(enkf_main, args, ECL_GRDECL_FILE); - return NULL; + return NULL; } @@ -552,11 +556,11 @@ static void enkf_main_export_runpath_file(enkf_main_type * enkf_main, else basename = util_alloc_sprintf("--%d", iens_value); - if (model_config_runpath_requires_iter(model_config)) + if (model_config_runpath_requires_iter(model_config)) runpath = util_alloc_sprintf(runpath_fmt, iens_value, iter_value); else runpath = util_alloc_sprintf(runpath_fmt, iens_value); - + runpath_list_add(runpath_list, iens_value, iter_value, runpath, basename); free(basename); @@ -578,7 +582,7 @@ void * enkf_main_export_runpath_file_JOB(void * self, const stringlist_type * ar int num_iterations = analysis_iter_config_get_num_iterations(iter_config); const model_config_type * model_config = enkf_main_get_model_config(enkf_main); int_vector_type * realizations = int_vector_alloc(1, 0); - int_vector_init_range(realizations, 0, ensemble_size-1, 1); + int_vector_init_range(realizations, 0, ensemble_size, 1); int_vector_type * iterations = int_vector_alloc(1, 0); @@ -600,7 +604,7 @@ void * enkf_main_export_runpath_file_JOB(void * self, const stringlist_type * ar if ((offset < stringlist_get_size(args)) && model_config_runpath_requires_iter(model_config)) { if (0 == strcmp("*", stringlist_iget(args, (offset+1)))) - int_vector_init_range(iterations, 0, num_iterations-1, 1); + int_vector_init_range(iterations, 0, num_iterations, 1); else { char * range_str = stringlist_alloc_joined_substring( args, offset+1, stringlist_get_size(args), ""); string_util_init_value_list(range_str, iterations); @@ -616,3 +620,41 @@ void * enkf_main_export_runpath_file_JOB(void * self, const stringlist_type * ar return NULL; } + + + +void * enkf_main_std_scale_correlated_obs_JOB(void * self, const stringlist_type * args) { + + if (stringlist_get_size(args) > 0) { + enkf_main_type * enkf_main = enkf_main_safe_cast( self ); + int ensemble_size = enkf_main_get_ensemble_size(enkf_main); + enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); + enkf_obs_type * obs = enkf_main_get_obs( enkf_main ); + int_vector_type * realizations = int_vector_alloc(1, 0); + local_obsdata_type * obsdata = local_obsdata_alloc( "OBS-JOB" ); + + int_vector_init_range(realizations, 0, ensemble_size, 1); + + for (int iarg = 0; iarg < stringlist_get_size(args); iarg++) { + const char * arg_key = stringlist_iget( args , iarg ); + stringlist_type * key_list = enkf_obs_alloc_matching_keylist(obs, arg_key); + for (int iobs=0; iobs < stringlist_get_size( key_list ); iobs++) { + const char * obs_key = stringlist_iget( key_list , iobs); + const obs_vector_type * obs_vector = enkf_obs_get_vector(obs, obs_key); + local_obsdata_add_node( obsdata , obs_vector_alloc_local_node(obs_vector) ); + } + stringlist_free( key_list ); + } + + if (local_obsdata_get_size(obsdata) > 0) + enkf_obs_scale_correlated_std(obs, fs, realizations, obsdata ); + + local_obsdata_free( obsdata ); + } + + return NULL; +} + + + + diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_main_manage_fs.c b/ThirdParty/Ert/devel/libenkf/src/enkf_main_manage_fs.c index 6bdda5dae7..2851b0cb33 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_main_manage_fs.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_main_manage_fs.c @@ -16,6 +16,8 @@ for more details. */ +#include <ert/enkf/summary_key_set.h> +#include <ert/enkf/custom_kw_config_set.h> bool enkf_main_case_is_current(const enkf_main_type * enkf_main , const char * case_path) { char * mount_point = enkf_main_alloc_mount_point( enkf_main , case_path ); @@ -397,7 +399,7 @@ static void enkf_main_write_current_case_file( const enkf_main_type * enkf_main, const char * base = CURRENT_CASE_FILE; char * current_case_file = util_alloc_filename(ens_path , base, NULL); FILE * stream = util_fopen( current_case_file , "w"); - fprintf(stream , case_path ); + fprintf(stream, "%s", case_path); util_fclose(stream); free(current_case_file); } @@ -516,6 +518,26 @@ enkf_fs_type * enkf_main_mount_alt_fs(const enkf_main_type * enkf_main , const c } +static void enkf_main_update_summary_config_from_fs__(enkf_main_type * enkf_main, enkf_fs_type * fs) { + ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); + summary_key_set_type * summary_key_set = enkf_fs_get_summary_key_set(fs); + stringlist_type * keys = summary_key_set_get_keys(summary_key_set); + + for(int i = 0; i < stringlist_get_size(keys); i++) { + const char * key = stringlist_iget(keys, i); + ensemble_config_add_summary(ensemble_config, key, LOAD_FAIL_SILENT); + } +} + + +static void enkf_main_update_custom_kw_config_from_fs__(enkf_main_type * enkf_main, enkf_fs_type * fs) { + ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); + custom_kw_config_set_type * custom_kw_config_set = enkf_fs_get_custom_kw_config_set(fs); + + ensemble_config_update_custom_kw_config(ensemble_config, custom_kw_config_set); +} + + /** The enkf_fs instances employ a simple reference counting scheme. The main point with this system is to avoid opening the @@ -547,18 +569,21 @@ enkf_fs_type * enkf_main_mount_alt_fs(const enkf_main_type * enkf_main , const c this is not adhered to. */ - void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const char * case_path /* Can be NULL */) { - if (enkf_main->dbase != fs) { - enkf_fs_incref( fs ); + if (enkf_main->dbase != fs) { + enkf_fs_incref( fs ); - if (enkf_main->dbase) - enkf_fs_decref( enkf_main->dbase ); + if (enkf_main->dbase) { + enkf_fs_decref(enkf_main->dbase); + } - enkf_main->dbase = fs; - enkf_main_invalidate_cache(enkf_main); - enkf_main_update_current_case(enkf_main, case_path); - } + enkf_main->dbase = fs; + enkf_main_invalidate_cache(enkf_main); + enkf_main_update_current_case(enkf_main, case_path); + + enkf_main_update_summary_config_from_fs__(enkf_main, fs); + enkf_main_update_custom_kw_config_from_fs__(enkf_main, fs); + } } diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_node.c b/ThirdParty/Ert/devel/libenkf/src/enkf_node.c index f1d0d60c79..adb5fbc416 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_node.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_node.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_node.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_node.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <string.h> @@ -36,6 +36,7 @@ #include <ert/enkf/surface.h> #include <ert/enkf/summary.h> #include <ert/enkf/ecl_static_kw.h> +#include <ert/enkf/custom_kw.h> #include <ert/enkf/gen_kw.h> #include <ert/enkf/gen_data.h> #include <ert/enkf/container.h> @@ -103,8 +104,8 @@ /*-----------------------------------------------------------------*/ /** - A note on memory - ================ + A note on memory + ================ The enkf_nodes can consume large amounts of memory, and for large models/ensembles we have a situation where not all the @@ -131,7 +132,7 @@ enkf_node_initialize() enkf_node_fread() - enkf_node_forward_load() + enkf_node_forward_load() These functions should all start with a call to enkf_node_ensure_memory(). The (re)allocation of data is done at @@ -147,7 +148,7 @@ punished? o The only memory operation which is exported to 'user-space' - (i.e. the enkf_state object) is enkf_node_free_data(). + (i.e. the enkf_state object) is enkf_node_free_data(). */ @@ -161,7 +162,7 @@ internal variables __state, __modified , __iens, and __report_step. These three variables are used/updated in the following manner: - + 1. The nodes are created with (modified, report_step, state, iens) == @@ -173,11 +174,11 @@ 3. After load (both from ensemble and ECLIPSE). We set modified -> false, and report_step, state and iens according to the load arguments. - + 4. After deserialize (i.e. update) we set modified -> true. - + 5. After write (to ensemble) we set in the same way as after load. - + 6. After free_data we invalidate according to the newly allocated status. @@ -216,20 +217,20 @@ struct enkf_node_struct { imul_ftype * imul; isqrt_ftype * isqrt; iaddsqr_ftype * iaddsqr; - + /******************************************************************/ bool vector_storage; char *node_key; /* The (hash)key this node is identified with. */ void *data; /* A pointer to the underlying enkf_object, i.e. gen_kw_type instance, or a field_type instance or ... */ const enkf_config_node_type *config; /* A pointer to a enkf_config_node instance (which again cointans a pointer to the config object of data). */ /*****************************************************************/ - + vector_type *container_nodes; - + /*****************************************************************/ /* The variables below this line are VERY INTERNAL. */ bool __modified; /* __modified, __report_step, __iens and __state are internal variables trying */ - node_id_type __node_id; /* to record the state of the in-memory reporesentation of the node->data. See */ + node_id_type __node_id; /* to record the state of the in-memory reporesentation of the node->data. See */ /* the documentation with heading "Keeping track of node state". */ /* Observe that this __iens variable "should not be used" - a node can change __iens value during run. */ state_enum __load_state; @@ -253,7 +254,7 @@ bool enkf_node_vector_storage( const enkf_node_type * node ) { */ -#define FUNC_ASSERT(func) if (func == NULL) util_abort("%s: function handler: %s not registered for node:%s - aborting\n",__func__ , #func , enkf_node->node_key); +#define FUNC_ASSERT(func) if (func == NULL) util_abort("%s: function handler: %s not registered for node:%s - aborting\n",__func__ , #func , enkf_node->node_key); @@ -268,7 +269,7 @@ void enkf_node_alloc_domain_object(enkf_node_type * node) { enkf_node_type * enkf_node_copyc(const enkf_node_type * enkf_node) { - FUNC_ASSERT(enkf_node->copy); + FUNC_ASSERT(enkf_node->copy); { const enkf_node_type * src = enkf_node; enkf_node_type * target; @@ -351,8 +352,8 @@ bool enkf_node_user_get_no_id(enkf_node_type * enkf_node , enkf_fs_type * fs , c FUNC_ASSERT( enkf_node->user_get ); { loadOK = enkf_node_try_load( enkf_node , fs , node_id); - - if (loadOK) + + if (loadOK) return enkf_node->user_get(enkf_node->data , key , report_step, state , value); else { *value = 0; @@ -406,21 +407,21 @@ bool enkf_node_forward_load(enkf_node_type *enkf_node , const char * run_path , loadOK = enkf_node->forward_load(enkf_node->data , NULL , ecl_sum , restart_block , report_step); else { char * input_file = enkf_config_node_alloc_infile(enkf_node->config , report_step); - + if (input_file != NULL) { char * file = util_alloc_filename( run_path , input_file , NULL); loadOK = enkf_node->forward_load(enkf_node->data , file , ecl_sum , restart_block , report_step); free(file); } else loadOK = enkf_node->forward_load(enkf_node->data , run_path , ecl_sum , restart_block , report_step); - + util_safe_free( input_file ); } } enkf_node->__node_id.report_step = report_step; enkf_node->__node_id.state = FORECAST; - enkf_node->__node_id.iens = iens; - + enkf_node->__node_id.iens = iens; + enkf_node->__modified = false; return loadOK; } @@ -444,8 +445,8 @@ bool enkf_node_forward_load_vector(enkf_node_type *enkf_node , const char * run_ // This is broken .... enkf_node->__node_id.report_step = 0;//report_step1; enkf_node->__node_id.state = FORECAST; - enkf_node->__node_id.iens = iens; - + enkf_node->__node_id.iens = iens; + enkf_node->__modified = false; return loadOK; } @@ -476,7 +477,7 @@ static bool enkf_node_store_buffer( enkf_node_type * enkf_node , enkf_fs_type * { bool data_written; buffer_type * buffer = buffer_alloc( 100 ); - const enkf_config_node_type * config_node = enkf_node_get_config( enkf_node ); + const enkf_config_node_type * config_node = enkf_node_get_config( enkf_node ); buffer_fwrite_time_t( buffer , time(NULL)); data_written = enkf_node->write_to_buffer(enkf_node->data , buffer , report_step , state ); if (data_written) { @@ -509,7 +510,7 @@ bool enkf_node_store(enkf_node_type * enkf_node , enkf_fs_type * fs , bool force } else { if (node_id.report_step == 0) { ert_impl_type impl_type = enkf_node_get_impl_type(enkf_node); - if (impl_type == SUMMARY) + if (impl_type == SUMMARY) return false; /* For report step == 0 the summary data is just garbage. */ } @@ -541,8 +542,8 @@ bool enkf_node_try_load(enkf_node_type *enkf_node , enkf_fs_type * fs , node_id_ if (enkf_node_has_data( enkf_node , fs , local_id)) { enkf_node_load( enkf_node , fs , local_id ); return true; - } - + } + local_id.state = FORECAST; if (enkf_node_has_data( enkf_node , fs , local_id)) { enkf_node_load( enkf_node , fs , local_id); @@ -566,12 +567,12 @@ static void enkf_node_buffer_load( enkf_node_type * enkf_node , enkf_fs_type * f const enkf_config_node_type * config_node = enkf_node_get_config( enkf_node ); const char * node_key = enkf_config_node_get_key( config_node ); enkf_var_type var_type = enkf_config_node_get_var_type( config_node ); - + if (enkf_node->vector_storage) enkf_fs_fread_vector( fs , buffer , node_key , var_type , iens , state); else enkf_fs_fread_node( fs , buffer , node_key , var_type , report_step , iens , state ); - + buffer_fskip_time_t( buffer ); enkf_node->read_from_buffer(enkf_node->data , buffer , fs , report_step , state ); buffer_free( buffer ); @@ -583,7 +584,7 @@ static void enkf_node_buffer_load( enkf_node_type * enkf_node , enkf_fs_type * f void enkf_node_load_vector( enkf_node_type * enkf_node , enkf_fs_type * fs , int iens , state_enum state) { if ((enkf_node->__load_state & state) && - (enkf_node->__node_id.iens == iens)) + (enkf_node->__node_id.iens == iens)) return; else { enkf_node_buffer_load( enkf_node , fs , -1 , iens , state); @@ -609,10 +610,10 @@ void enkf_node_load(enkf_node_type * enkf_node , enkf_fs_type * fs , node_id_typ if (enkf_node->vector_storage) enkf_node_load_vector( enkf_node , fs , node_id.iens , node_id.state ); else { - if ((node_id.iens == enkf_node->__node_id.iens) && - (node_id.state == enkf_node->__node_id.state) && - (node_id.report_step == enkf_node->__node_id.report_step) && - (!enkf_node->__modified)) + if ((node_id.iens == enkf_node->__node_id.iens) && + (node_id.state == enkf_node->__node_id.state) && + (node_id.report_step == enkf_node->__node_id.report_step) && + (!enkf_node->__modified)) return; /* The in memory representation agrees with the buffer values */ else { enkf_node_buffer_load( enkf_node , fs , node_id.report_step, node_id.iens , node_id.state ); @@ -628,7 +629,7 @@ bool enkf_node_try_load_vector(enkf_node_type *enkf_node , enkf_fs_type * fs , i if (enkf_config_node_has_vector( enkf_node->config , fs , iens, state)) { enkf_node_load_vector( enkf_node , fs , iens , state ); return true; - } else + } else return false; } @@ -659,8 +660,8 @@ enkf_node_type * enkf_node_load_alloc( const enkf_config_node_type * config_node return node; } else { util_abort("%s: Could not load node: key:%s iens:%d report:%d state:%d\n", - __func__ , - enkf_config_node_get_key( config_node ) , + __func__ , + enkf_config_node_get_key( config_node ) , node_id.iens , node_id.report_step , node_id.state ); return NULL; } @@ -669,15 +670,15 @@ enkf_node_type * enkf_node_load_alloc( const enkf_config_node_type * config_node -void enkf_node_copy(const enkf_config_node_type * config_node , - enkf_fs_type * src_case, +void enkf_node_copy(const enkf_config_node_type * config_node , + enkf_fs_type * src_case, enkf_fs_type * target_case, node_id_type src_id , node_id_type target_id) { - + enkf_node_type * enkf_node = enkf_node_load_alloc(config_node, src_case , src_id); - - + + /* Hack to ensure that size is set for the gen_data instances. This sneeks low level stuff into a high level scope. BAD. */ { @@ -686,7 +687,7 @@ void enkf_node_copy(const enkf_config_node_type * config_node , /* Read the size at report_step_from */ gen_data_type * gen_data = enkf_node_value_ptr( enkf_node ); int size = gen_data_get_size( gen_data ); - + /* Enforce the size at report_step_to */ gen_data_assert_size( gen_data , size , target_id.report_step); } @@ -709,14 +710,14 @@ bool enkf_node_has_data( enkf_node_type * enkf_node , enkf_fs_type * fs , node_i if (enkf_config_node_has_vector( enkf_node->config , fs , iens , state )) enkf_node_load_vector( enkf_node , fs , iens , state ); } - - if ((node_id.iens == enkf_node->__node_id.iens) && (enkf_node->__load_state & state)) + + if ((node_id.iens == enkf_node->__node_id.iens) && (enkf_node->__load_state & state)) // The vector is loaded. Check if we have the report_step/state asked for: return enkf_node->has_data( enkf_node->data , report_step , state ); else - return false; + return false; } - } else + } else return enkf_config_node_has_node( enkf_node->config , fs , node_id ); } @@ -725,34 +726,34 @@ bool enkf_node_has_data( enkf_node_type * enkf_node , enkf_fs_type * fs , node_i Copy an ensemble of nodes. Note that the limits are inclusive. */ -void enkf_node_copy_ensemble(const enkf_config_node_type * config_node , - enkf_fs_type * src_case , - enkf_fs_type * target_case , +void enkf_node_copy_ensemble(const enkf_config_node_type * config_node , + enkf_fs_type * src_case , + enkf_fs_type * target_case , int report_step_from, state_enum state_from, /* src state */ int report_step_to , state_enum state_to, /* target state */ - int ens_size, + int ens_size, const int * permutations) { - + node_id_type src_id = {.report_step = report_step_from , .iens = 0 , .state = state_from }; node_id_type target_id = {.report_step = report_step_to , .iens = 0 , .state = state_to }; - + for(int iens_from = 0; iens_from < ens_size; iens_from++) { int iens_to; if (permutations == NULL) iens_to = iens_from; else iens_to = permutations[iens_from]; - + src_id.iens = iens_from; target_id.iens = iens_to; enkf_node_copy(config_node , src_case , target_case , src_id , target_id ); } } - -enkf_node_type ** enkf_node_load_alloc_ensemble( const enkf_config_node_type * config_node , enkf_fs_type * fs , + +enkf_node_type ** enkf_node_load_alloc_ensemble( const enkf_config_node_type * config_node , enkf_fs_type * fs , int report_step , int iens1 , int iens2 , state_enum state) { enkf_node_type ** ensemble = util_calloc( (iens2 - iens1) , sizeof * ensemble ); for (int iens = iens1; iens < iens2; iens++) { @@ -760,7 +761,7 @@ enkf_node_type ** enkf_node_load_alloc_ensemble( const enkf_config_node_type * c state_enum load_state; ensemble[iens - iens1] = NULL; - + if (state == BOTH) { node_id.state = ANALYZED; if (enkf_config_node_has_node( config_node , fs , node_id)) @@ -772,27 +773,27 @@ enkf_node_type ** enkf_node_load_alloc_ensemble( const enkf_config_node_type * c else load_state = UNDEFINED; } - } else + } else load_state = state; node_id.state = load_state; if (load_state != UNDEFINED) ensemble[iens - iens1] = enkf_node_load_alloc(config_node , fs , node_id); } - + return ensemble; } -void enkf_node_serialize(enkf_node_type *enkf_node , enkf_fs_type * fs, node_id_type node_id , +void enkf_node_serialize(enkf_node_type *enkf_node , enkf_fs_type * fs, node_id_type node_id , const active_list_type * active_list , matrix_type * A , int row_offset , int column) { FUNC_ASSERT(enkf_node->serialize); enkf_node_load( enkf_node , fs , node_id); enkf_node->serialize(enkf_node->data , node_id , active_list , A , row_offset , column); - + } @@ -871,7 +872,7 @@ bool enkf_node_initialize(enkf_node_type *enkf_node, int iens , rng_type * rng) enkf_node->__node_id.state = ANALYZED; enkf_node->__node_id.iens = iens; enkf_node->__modified = true; - } + } util_safe_free( init_file ); return init; } else @@ -889,7 +890,7 @@ void enkf_node_free_data(enkf_node_type * enkf_node) { enkf_node->free_data(enkf_node->data); enkf_node->__modified = true; enkf_node->__node_id.state = UNDEFINED; - enkf_node->__node_id.report_step = -1; + enkf_node->__node_id.report_step = -1; enkf_node->__node_id.iens = -1; } @@ -929,7 +930,7 @@ const char * enkf_node_get_key(const enkf_node_type * enkf_node) { This function has been implemented to ensure/force a reload of nodes when the case has changed. */ - + void enkf_node_invalidate_cache( enkf_node_type * node ) { node->__modified = true; node->__node_id.report_step = -1; @@ -950,7 +951,7 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi node->data = NULL; node->container_nodes = vector_alloc_new( ); enkf_node_invalidate_cache( node ); - + /* Start by initializing all function pointers to NULL. */ @@ -964,10 +965,10 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi node->free_data = NULL; node->user_get = NULL; node->user_get_vector = NULL; - node->fload = NULL; + node->fload = NULL; node->read_from_buffer = NULL; node->write_to_buffer = NULL; - node->serialize = NULL; + node->serialize = NULL; node->deserialize = NULL; node->clear = NULL; node->set_inflation = NULL; @@ -991,7 +992,7 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi node->copy = gen_kw_copy__; node->initialize = gen_kw_initialize__; node->freef = gen_kw_free__; - node->user_get = gen_kw_user_get__; + node->user_get = gen_kw_user_get__; node->write_to_buffer = gen_kw_write_to_buffer__; node->read_from_buffer = gen_kw_read_from_buffer__; node->serialize = gen_kw_serialize__; @@ -1005,13 +1006,24 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi node->set_inflation = gen_kw_set_inflation__; node->fload = gen_kw_fload__; break; + case(CUSTOM_KW): + node->alloc = custom_kw_alloc__; + node->freef = custom_kw_free__; + node->forward_load = custom_kw_forward_load__; + node->fload = custom_kw_fload__; + node->ecl_write = custom_kw_ecl_write__; + node->write_to_buffer = custom_kw_write_to_buffer__; + node->read_from_buffer = custom_kw_read_from_buffer__; + node->serialize = custom_kw_serialize__; + node->deserialize = custom_kw_deserialize__; + break; case(SUMMARY): node->forward_load = summary_forward_load__; node->forward_load_vector = summary_forward_load_vector__; node->alloc = summary_alloc__; node->copy = summary_copy__; node->freef = summary_free__; - node->user_get = summary_user_get__; + node->user_get = summary_user_get__; node->user_get_vector = summary_user_get_vector__; node->read_from_buffer = summary_read_from_buffer__; node->write_to_buffer = summary_write_to_buffer__; @@ -1029,11 +1041,11 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi break; case(SURFACE): node->initialize = surface_initialize__; - node->ecl_write = surface_ecl_write__; + node->ecl_write = surface_ecl_write__; node->alloc = surface_alloc__; node->copy = surface_copy__; node->freef = surface_free__; - node->user_get = surface_user_get__; + node->user_get = surface_user_get__; node->read_from_buffer = surface_read_from_buffer__; node->write_to_buffer = surface_write_to_buffer__; node->serialize = surface_serialize__; @@ -1048,8 +1060,8 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi break; case(FIELD): node->alloc = field_alloc__; - node->ecl_write = field_ecl_write__; - node->forward_load = field_forward_load__; + node->ecl_write = field_ecl_write__; + node->forward_load = field_forward_load__; node->copy = field_copy__; node->initialize = field_initialize__; node->freef = field_free__; @@ -1059,17 +1071,17 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi node->serialize = field_serialize__; node->deserialize = field_deserialize__; - node->clear = field_clear__; + node->clear = field_clear__; node->set_inflation = field_set_inflation__; node->iadd = field_iadd__; node->scale = field_scale__; node->iaddsqr = field_iaddsqr__; - node->imul = field_imul__; + node->imul = field_imul__; node->isqrt = field_isqrt__; node->fload = field_fload__; break; case(STATIC): - node->ecl_write = ecl_static_kw_ecl_write__; + node->ecl_write = ecl_static_kw_ecl_write__; node->alloc = ecl_static_kw_alloc__; node->copy = ecl_static_kw_copy__; node->freef = ecl_static_kw_free__; @@ -1091,7 +1103,7 @@ static enkf_node_type * enkf_node_alloc_empty(const enkf_config_node_type *confi node->deserialize = gen_data_deserialize__; node->set_inflation = gen_data_set_inflation__; - node->clear = gen_data_clear__; + node->clear = gen_data_clear__; node->iadd = gen_data_iadd__; node->scale = gen_data_scale__; node->iaddsqr = gen_data_iaddsqr__; @@ -1150,11 +1162,11 @@ static enkf_node_type * enkf_node_alloc_container(const enkf_config_node_type * const enkf_config_node_type * child_config = enkf_config_node_container_iget( config , i ); enkf_node_type * child_node; - if (shared) + if (shared) child_node = hash_get( node_hash , enkf_config_node_get_key( child_config )); else child_node = enkf_node_alloc( child_config ); - + enkf_node_container_add_node( container_node , child_node , shared); container_add_node( enkf_node_value_ptr( container_node ) , enkf_node_value_ptr( child_node )); } diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c b/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c index 8030c884e3..81418a1d7b 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'enkf_obs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'enkf_obs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <string.h> @@ -24,12 +24,15 @@ #include <ert/util/util.h> #include <ert/util/msg.h> #include <ert/util/vector.h> +#include <ert/util/type_vector_functions.h> #include <ert/config/conf.h> #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_sum.h> +#include <ert/analysis/enkf_linalg.h> + #include <ert/enkf/summary_obs.h> #include <ert/enkf/block_obs.h> #include <ert/enkf/enkf_fs.h> @@ -151,7 +154,7 @@ In the following example we have two observations | field_obs object. -------- -------- -------- ---|---- -------- | |-----------------------------------------------------------|------------------| | - | + | \|/ |-- field_obs -----------------------------------| | i = 25 , j = 16, k = 10, value = 278, std = 10 | @@ -186,38 +189,88 @@ static conf_class_type * enkf_obs_get_obs_conf_class(); struct enkf_obs_struct { /** A hash of obs_vector_types indexed by user provided keys. */ - bool have_obs; - char * config_file; /* The name of the config file which has been loaded. */ vector_type * obs_vector; hash_type * obs_hash; time_map_type * obs_time; /* For fast lookup of report_step -> obs_time */ + + bool valid; + /* Several shared resources - can generally be NULL*/ const history_type * history; /* A shared (not owned by enkf_obs) reference to the history object - used when adding HISTORY observations. */ + const ecl_sum_type * refcase; + const ecl_grid_type * grid; + time_map_type * external_time_map; + ensemble_config_type * ensemble_config; }; + ////////////////////////////////////////////////////////////////////////////////////// +static void enkf_obs_iset_obs_time(enkf_obs_type * enkf_obs , int report_step, time_t obs_time) { + time_map_update( enkf_obs->obs_time , report_step , obs_time); +} + + +static int enkf_obs_get_last_restart( const enkf_obs_type * enkf_obs ) { + return time_map_get_size( enkf_obs->obs_time ) - 1; +} + -enkf_obs_type * enkf_obs_alloc( ) + +enkf_obs_type * enkf_obs_alloc( const history_type * history , + time_map_type * external_time_map , + const ecl_grid_type * grid , + const ecl_sum_type * refcase, + ensemble_config_type * ensemble_config ) { - enkf_obs_type * enkf_obs = util_malloc(sizeof * enkf_obs); - enkf_obs->have_obs = false; - enkf_obs->obs_hash = hash_alloc(); - enkf_obs->obs_vector = vector_alloc_new(); - enkf_obs->obs_time = time_map_alloc(); - - enkf_obs->history = NULL; - enkf_obs->config_file = NULL; + enkf_obs_type * enkf_obs = util_malloc(sizeof * enkf_obs); + enkf_obs->obs_hash = hash_alloc(); + enkf_obs->obs_vector = vector_alloc_new(); + enkf_obs->obs_time = time_map_alloc(); + + enkf_obs->history = history; + enkf_obs->refcase = refcase; + enkf_obs->grid = grid; + enkf_obs->ensemble_config = ensemble_config; + enkf_obs->external_time_map = external_time_map; + enkf_obs->valid = false; + + /* Initialize obs time: */ + { + if (enkf_obs->history) { + int last_report = history_get_last_restart( enkf_obs->history ); + int step; + for (step =0; step <= last_report; step++) { + time_t obs_time = history_get_time_t_from_restart_nr( enkf_obs->history , step ); + enkf_obs_iset_obs_time( enkf_obs , step , obs_time ); + } + enkf_obs->valid = true; + } else { + if (enkf_obs->external_time_map) { + int last_report = time_map_get_size( enkf_obs->external_time_map ) - 1; + int step; + for (step =0; step <= last_report; step++) { + time_t obs_time = time_map_iget( enkf_obs->external_time_map , step ); + enkf_obs_iset_obs_time( enkf_obs , step , obs_time ); + } + enkf_obs->valid = true; + } + } + } + return enkf_obs; } bool enkf_obs_have_obs( const enkf_obs_type * enkf_obs ) { - return enkf_obs->have_obs; + if (vector_get_size( enkf_obs->obs_vector ) > 0) + return true; + else + return false; } @@ -225,8 +278,7 @@ void enkf_obs_free(enkf_obs_type * enkf_obs) { hash_free(enkf_obs->obs_hash); vector_free( enkf_obs->obs_vector ); time_map_free( enkf_obs->obs_time ); - util_safe_free( enkf_obs->config_file ); - free(enkf_obs); + free(enkf_obs); } @@ -237,13 +289,6 @@ time_t enkf_obs_iget_obs_time(const enkf_obs_type * enkf_obs , int report_step) } -static void enkf_obs_iset_obs_time(enkf_obs_type * enkf_obs , int report_step, time_t obs_time) { - time_map_update( enkf_obs->obs_time , report_step , obs_time); -} - -static int enkf_obs_get_last_restart( const enkf_obs_type * enkf_obs ) { - return time_map_get_size( enkf_obs->obs_time ) - 1; -} @@ -251,14 +296,15 @@ static int enkf_obs_get_last_restart( const enkf_obs_type * enkf_obs ) { Observe that the obs_vector can be NULL - in which it is of course not added. */ void enkf_obs_add_obs_vector(enkf_obs_type * enkf_obs, - const char * key , const obs_vector_type * vector) { + if (vector != NULL) { - if (hash_has_key(enkf_obs->obs_hash , key)) - util_abort("%s: Observation with key:%s already added.\n",__func__ , key); + const char * obs_key = obs_vector_get_key( vector ); + if (hash_has_key(enkf_obs->obs_hash , obs_key)) + util_abort("%s: Observation with key:%s already added.\n",__func__ , obs_key); - hash_insert_ref(enkf_obs->obs_hash , key , vector ); + hash_insert_ref(enkf_obs->obs_hash , obs_key , vector ); vector_append_owned_ref( enkf_obs->obs_vector , vector , obs_vector_free__); } } @@ -283,17 +329,17 @@ int enkf_obs_get_size( const enkf_obs_type * obs ) { static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf_obs, - obs_vector_type * obs_vector , + obs_vector_type * obs_vector , enkf_fs_type * fs, - const local_obsdata_node_type * obs_node , + const local_obsdata_node_type * obs_node , state_enum state, - const int_vector_type * ens_active_list , + const int_vector_type * ens_active_list , meas_data_type * meas_data, obs_data_type * obs_data, - double_vector_type * obs_value , + double_vector_type * obs_value , double_vector_type * obs_std) { - const obs_tstep_list_type * tstep_list = local_obsdata_node_get_tstep_list( obs_node ); + const int_vector_type * tstep_list = local_obsdata_node_get_tstep_list( obs_node ); const active_list_type * active_list = local_obsdata_node_get_active_list( obs_node ); matrix_type * error_covar = NULL; @@ -304,9 +350,9 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf /*1: Determine which report_steps have active observations; and collect the observed values. */ double_vector_reset( obs_std ); double_vector_reset( obs_value ); - - for (int i = 0; i < obs_tstep_list_get_size( tstep_list ); i++) { - step = obs_tstep_list_iget( tstep_list , i ); + + for (int i = 0; i < int_vector_size( tstep_list ); i++) { + step = int_vector_iget( tstep_list , i ); if (obs_vector_iget_active( obs_vector , step ) && active_list_iget( active_list , 0 /* Index into the scalar summary observation */)) { { const summary_obs_type * summary_obs = obs_vector_iget_node( obs_vector , step ); @@ -317,8 +363,8 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf active_count++; } } - - + + if (active_count > 0) { /*2: Estimate a covariance matrix. */ auto_corrf_ftype * auto_corrf; @@ -328,16 +374,16 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf auto_corrf = summary_obs_get_auto_corrf( summary_obs ); auto_corrf_param = summary_obs_get_auto_corrf_param( summary_obs ); } - + if ((active_count > 1) && (auto_corrf != NULL)) { int i,j; error_covar = matrix_alloc( active_count , active_count ); /* Will be freed by the obs_block instance. */ for (i = 0; i < active_count; i++) { for (j=0; j <= i; j++) { double covar = sqrt( double_vector_iget( obs_std , i ) * double_vector_iget( obs_std , j )); - double delta_t = enkf_obs_iget_obs_time( enkf_obs , i ) - enkf_obs_iget_obs_time( enkf_obs , j ); + double delta_t = enkf_obs_iget_obs_time( enkf_obs , i ) - enkf_obs_iget_obs_time( enkf_obs , j ); double corr = auto_corrf(delta_t / (24.00 * 3600) , auto_corrf_param ); - + matrix_iset(error_covar , i , j , covar * corr ); if (i != j) matrix_iset(error_covar , j , i , covar * corr ); @@ -345,8 +391,8 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf } } - - + + /* 3: Fill up the obs_block and meas_block structures with this time-aggregated summary observation. Passing in the error_covar @@ -355,33 +401,33 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf { obs_block_type * obs_block = obs_data_add_block( obs_data , obs_vector_get_obs_key( obs_vector ) , active_count , error_covar , true); - meas_block_type * meas_block = meas_data_add_block( meas_data, obs_vector_get_obs_key( obs_vector ) , obs_tstep_list_get_last( tstep_list ) , active_count ); + meas_block_type * meas_block = meas_data_add_block( meas_data, obs_vector_get_obs_key( obs_vector ) , int_vector_get_last( tstep_list ) , active_count ); enkf_node_type * work_node = enkf_node_alloc( obs_vector_get_config_node( obs_vector )); - for (int i=0; i < active_count; i++) + for (int i=0; i < active_count; i++) obs_block_iset( obs_block , i , double_vector_iget( obs_value , i) , double_vector_iget( obs_std , i )); - + active_count = 0; - for (int i = 0; i < obs_tstep_list_get_size( tstep_list ); i++) { - int step = obs_tstep_list_iget( tstep_list , i ); + for (int i = 0; i < int_vector_size( tstep_list ); i++) { + int step = int_vector_iget( tstep_list , i ); if (obs_vector_iget_active( obs_vector , step ) && active_list_iget( active_list , 0 /* Index into the scalar summary observation */)) { - + for (int iens_index = 0; iens_index < int_vector_size( ens_active_list ); iens_index++) { - + const int iens = int_vector_iget( ens_active_list , iens_index ); - node_id_type node_id = {.report_step = step, - .iens = iens , + node_id_type node_id = {.report_step = step, + .iens = iens , .state = state }; - + enkf_node_load( work_node , fs , node_id ); - - meas_block_iset(meas_block , - iens_index , active_count , + + meas_block_iset(meas_block , + iens , active_count , summary_get( enkf_node_value_ptr( work_node ) , node_id.report_step , node_id.state )); - + } active_count++; - } + } } enkf_node_free( work_node ); } @@ -390,9 +436,9 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf void enkf_obs_get_obs_and_measure_node( const enkf_obs_type * enkf_obs, enkf_fs_type * fs, - const local_obsdata_node_type * obs_node , + const local_obsdata_node_type * obs_node , state_enum state, - const int_vector_type * ens_active_list , + const int_vector_type * ens_active_list , meas_data_type * meas_data, obs_data_type * obs_data) { @@ -402,26 +448,26 @@ void enkf_obs_get_obs_and_measure_node( const enkf_obs_type * enkf_obs, double_vector_type * work_value = double_vector_alloc( 0 , -1 ); double_vector_type * work_std = double_vector_alloc( 0 , -1 ); - if ((obs_type == SUMMARY_OBS)) //&& ((end_step - start_step) > 1)) - enkf_obs_get_obs_and_measure_summary( enkf_obs , - obs_vector , - fs , - obs_node , - state , - ens_active_list , - meas_data , - obs_data , - work_value, + if ((obs_type == SUMMARY_OBS)) //&& ((end_step - start_step) > 1)) + enkf_obs_get_obs_and_measure_summary( enkf_obs , + obs_vector , + fs , + obs_node , + state , + ens_active_list , + meas_data , + obs_data , + work_value, work_std); else { - const obs_tstep_list_type * tstep_list = local_obsdata_node_get_tstep_list( obs_node ); - for (int i=0; i < obs_tstep_list_get_size( tstep_list ); i++) { - int report_step = obs_tstep_list_iget( tstep_list , i ); + const int_vector_type * tstep_list = local_obsdata_node_get_tstep_list( obs_node ); + for (int i=0; i < int_vector_size( tstep_list ); i++) { + int report_step = int_vector_iget( tstep_list , i ); if (obs_vector_iget_active(obs_vector , report_step)) { /* The observation is active for this report step. */ const active_list_type * active_list = local_obsdata_node_get_active_list( obs_node ); obs_vector_iget_observations(obs_vector , report_step , obs_data , active_list, fs); /* Collect the observed data in the obs_data instance. */ obs_vector_measure(obs_vector , fs , state , report_step , ens_active_list , meas_data , active_list); - } + } } } double_vector_free( work_value ); @@ -433,90 +479,48 @@ void enkf_obs_get_obs_and_measure_node( const enkf_obs_type * enkf_obs, /* This will append observations and simulated responses from - report_step to obs_data and meas_data. + report_step to obs_data and meas_data. Call obs_data_reset and meas_data_reset on obs_data and meas_data if you want to use fresh instances. */ void enkf_obs_get_obs_and_measure_data(const enkf_obs_type * enkf_obs, enkf_fs_type * fs, - const local_obsdata_type * local_obsdata , + const local_obsdata_type * local_obsdata , state_enum state, - const int_vector_type * ens_active_list , + const int_vector_type * ens_active_list , meas_data_type * meas_data, obs_data_type * obs_data) { - - + + int iobs; for (iobs = 0; iobs < local_obsdata_get_size( local_obsdata ); iobs++) { const local_obsdata_node_type * obs_node = local_obsdata_iget( local_obsdata , iobs ); - enkf_obs_get_obs_and_measure_node( enkf_obs , - fs , - obs_node , - state , - ens_active_list , - meas_data , + enkf_obs_get_obs_and_measure_node( enkf_obs , + fs , + obs_node , + state , + ens_active_list , + meas_data , obs_data); } } -void enkf_obs_get_obs_and_measure(const enkf_obs_type * enkf_obs, - enkf_fs_type * fs, - const int_vector_type * step_list , - state_enum state, - const int_vector_type * ens_active_list , - meas_data_type * meas_data, - obs_data_type * obs_data, - const local_obsset_type * obsset) { - - local_obsdata_type * local_obsdata = local_obsdata_alloc( "OBS-SET" ); - { - hash_iter_type * iter = local_obsset_alloc_obs_iter( obsset ); - while ( !hash_iter_is_complete(iter) ) { - const char * obs_key = hash_iter_get_next_key( iter ); - const active_list_type * active_list = local_obsset_get_obs_active_list( obsset , obs_key); - local_obsdata_node_type * obs_node = local_obsdata_node_alloc( obs_key ); - - local_obsdata_node_copy_active_list( obs_node , active_list ); - for (int i=0; i < int_vector_size( step_list ); i++) - local_obsdata_node_add_tstep( obs_node , int_vector_iget( step_list , i )); - - local_obsdata_add_node( local_obsdata , obs_node ); - } - hash_iter_free( iter ); - } - enkf_obs_get_obs_and_measure_data(enkf_obs , fs , local_obsdata , state , ens_active_list , meas_data , obs_data ); - local_obsdata_free( local_obsdata ); -} - - - -void enkf_obs_reload( enkf_obs_type * enkf_obs , - const history_type * history , - time_map_type * external_time_map , - const ecl_grid_type * grid , - const ecl_sum_type * refcase , - double std_cutoff , - ensemble_config_type * ensemble_config ) { - - enkf_obs_load( enkf_obs , - history , - external_time_map , - enkf_obs->config_file , - grid , - refcase , - std_cutoff , - ensemble_config ); +void enkf_obs_clear( enkf_obs_type * enkf_obs ) { + hash_clear( enkf_obs->obs_hash ); + vector_clear( enkf_obs->obs_vector ); + ensemble_config_clear_obs_keys(enkf_obs->ensemble_config); } + /** This function will load an observation configuration from the - observation file @config_file. + observation file @config_file. If called several times during one invocation the function will start by clearing the current content. @@ -524,168 +528,124 @@ void enkf_obs_reload( enkf_obs_type * enkf_obs , -void enkf_obs_load(enkf_obs_type * enkf_obs , - const history_type * history , - time_map_type * external_time_map , - const char * config_file, - const ecl_grid_type * grid , - const ecl_sum_type * refcase , - double std_cutoff , ensemble_config_type * ensemble_config) { +bool enkf_obs_load(enkf_obs_type * enkf_obs , + const char * config_file, + double std_cutoff) { - if (config_file == NULL) { - hash_clear( enkf_obs->obs_hash ); - enkf_obs->have_obs = false; - } else { - enkf_obs->history = history; - - /* Initializing obs_time */ - { - if (enkf_obs->history) { - int last_report = history_get_last_restart( enkf_obs->history ); - int step; - for (step =0; step <= last_report; step++) { - time_t obs_time = history_get_time_t_from_restart_nr( enkf_obs->history , step ); - enkf_obs_iset_obs_time( enkf_obs , step , obs_time ); - } - } else { - if (external_time_map) { - int last_report = time_map_get_size( external_time_map ) - 1; - int step; - for (step =0; step <= last_report; step++) { - time_t obs_time = time_map_iget( external_time_map , step ); - enkf_obs_iset_obs_time( enkf_obs , step , obs_time ); - } - } else { - fprintf(stderr,"** To load observations you must have a REFCASE / SCHEDULE_FILE / TIME_MAP - observations in %s ignored\n", config_file); - return; - } - } - } - + if (enkf_obs->valid) { + int last_report = enkf_obs_get_last_restart( enkf_obs ); + conf_class_type * enkf_conf_class = enkf_obs_get_obs_conf_class(); + conf_instance_type * enkf_conf = conf_instance_alloc_from_file(enkf_conf_class, "enkf_conf", config_file); + if(conf_instance_validate(enkf_conf) == false) + util_abort("Can not proceed with this configuration.\n"); + /** Handle HISTORY_OBSERVATION instances. */ { - int last_report = enkf_obs_get_last_restart( enkf_obs ); - conf_class_type * enkf_conf_class = enkf_obs_get_obs_conf_class(); - conf_instance_type * enkf_conf = conf_instance_alloc_from_file(enkf_conf_class, "enkf_conf", config_file); - - if(conf_instance_validate(enkf_conf) == false) - util_abort("Can not proceed with this configuration.\n"); - - if (enkf_obs->config_file != NULL) /* Clear current instance, observe that this function */ - hash_clear( enkf_obs->obs_hash ); /* will reload even if it is called repeatedly with the */ - /* same config_file. */ - - - /** Handle HISTORY_OBSERVATION instances. */ - { - stringlist_type * hist_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "HISTORY_OBSERVATION"); - int num_hist_obs = stringlist_get_size(hist_obs_keys); - - for (int hist_obs_nr = 0; hist_obs_nr < num_hist_obs; hist_obs_nr++) { - const char * obs_key = stringlist_iget(hist_obs_keys, hist_obs_nr); - if (enkf_obs->history) { - const conf_instance_type * hist_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); - obs_vector_type * obs_vector; - enkf_config_node_type * config_node; - - config_node = ensemble_config_add_summary( ensemble_config , obs_key , LOAD_FAIL_WARN ); - if (config_node != NULL) { - obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( ensemble_config , obs_key ), last_report); - if (obs_vector != NULL) { - if (obs_vector_load_from_HISTORY_OBSERVATION(obs_vector , - hist_obs_conf , - enkf_obs->obs_time , - enkf_obs->history , - ensemble_config, - std_cutoff )) - enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector); - else { - fprintf(stderr,"** Could not load historical data for observation:%s - ignored\n",obs_key); - obs_vector_free( obs_vector ); - } - } - } else - fprintf(stderr,"** Warning: summary:%s does not exist - observation:%s not added. \n", obs_key , obs_key); - } else - fprintf(stderr,"** Warning: no history object registered - observation:%s is ignored\n",obs_key); - } - - stringlist_free(hist_obs_keys); - } - - - - /** Handle SUMMARY_OBSERVATION instances. */ - { - stringlist_type * sum_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "SUMMARY_OBSERVATION"); - int num_sum_obs = stringlist_get_size(sum_obs_keys); - - - for(int sum_obs_nr = 0; sum_obs_nr < num_sum_obs; sum_obs_nr++) { - const char * obs_key = stringlist_iget(sum_obs_keys, sum_obs_nr); - const conf_instance_type * sum_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); - const char * sum_key = conf_instance_get_item_value_ref( sum_obs_conf , "KEY" ); + stringlist_type * hist_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "HISTORY_OBSERVATION"); + int num_hist_obs = stringlist_get_size(hist_obs_keys); + + for (int hist_obs_nr = 0; hist_obs_nr < num_hist_obs; hist_obs_nr++) { + const char * obs_key = stringlist_iget(hist_obs_keys, hist_obs_nr); + if (enkf_obs->history) { + const conf_instance_type * hist_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); obs_vector_type * obs_vector; enkf_config_node_type * config_node; - - config_node = ensemble_config_add_summary( ensemble_config , sum_key , LOAD_FAIL_WARN ); + config_node = ensemble_config_add_summary_observation( enkf_obs->ensemble_config , obs_key , LOAD_FAIL_WARN ); if (config_node != NULL) { - obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( ensemble_config , sum_key ), last_report); + obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( enkf_obs->ensemble_config , obs_key ), last_report); if (obs_vector != NULL) { - obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector , sum_obs_conf , enkf_obs->obs_time , ensemble_config); - enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector); + if (obs_vector_load_from_HISTORY_OBSERVATION(obs_vector , + hist_obs_conf , + enkf_obs->obs_time , + enkf_obs->history , + enkf_obs->ensemble_config, + std_cutoff )) { + enkf_obs_add_obs_vector(enkf_obs, obs_vector); + } else { + fprintf(stderr,"** Could not load historical data for observation:%s - ignored\n",obs_key); + obs_vector_free( obs_vector ); + } } - } else - fprintf(stderr,"** Warning: summary key:%s does not exist - observation key:%s not added.\n", sum_key , obs_key); - } - stringlist_free(sum_obs_keys); - } - - - /** Handle BLOCK_OBSERVATION instances. */ - { - stringlist_type * block_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "BLOCK_OBSERVATION"); - int num_block_obs = stringlist_get_size(block_obs_keys); - - for(int block_obs_nr = 0; block_obs_nr < num_block_obs; block_obs_nr++) - { - const char * obs_key = stringlist_iget(block_obs_keys, block_obs_nr); - const conf_instance_type * block_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); - obs_vector_type * obs_vector = obs_vector_alloc_from_BLOCK_OBSERVATION(block_obs_conf , grid , enkf_obs->obs_time , refcase , ensemble_config); - if (obs_vector != NULL) - enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector); - } - stringlist_free(block_obs_keys); + } else + fprintf(stderr,"** Warning: summary:%s does not exist - observation:%s not added. \n", obs_key , obs_key); + } else + fprintf(stderr,"** Warning: no history object registered - observation:%s is ignored\n",obs_key); } - - - /** Handle GENERAL_OBSERVATION instances. */ - { - stringlist_type * block_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "GENERAL_OBSERVATION"); - int num_block_obs = stringlist_get_size(block_obs_keys); - - for(int block_obs_nr = 0; block_obs_nr < num_block_obs; block_obs_nr++) - { - const char * obs_key = stringlist_iget(block_obs_keys, block_obs_nr); - const conf_instance_type * gen_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); - - obs_vector_type * obs_vector = obs_vector_alloc_from_GENERAL_OBSERVATION(gen_obs_conf , enkf_obs->obs_time , ensemble_config); - if (obs_vector != NULL) - enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector); + + stringlist_free(hist_obs_keys); + } + + + + /** Handle SUMMARY_OBSERVATION instances. */ + { + stringlist_type * sum_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "SUMMARY_OBSERVATION"); + int num_sum_obs = stringlist_get_size(sum_obs_keys); + + + for(int sum_obs_nr = 0; sum_obs_nr < num_sum_obs; sum_obs_nr++) { + const char * obs_key = stringlist_iget(sum_obs_keys, sum_obs_nr); + const conf_instance_type * sum_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); + const char * sum_key = conf_instance_get_item_value_ref( sum_obs_conf , "KEY" ); + obs_vector_type * obs_vector; + enkf_config_node_type * config_node; + + config_node = ensemble_config_add_summary_observation( enkf_obs->ensemble_config , sum_key , LOAD_FAIL_WARN ); + if (config_node != NULL) { + obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( enkf_obs->ensemble_config , sum_key ), last_report); + if (obs_vector != NULL) { + obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector , sum_obs_conf , enkf_obs->obs_time , enkf_obs->ensemble_config); + enkf_obs_add_obs_vector(enkf_obs, obs_vector); } - stringlist_free(block_obs_keys); + } else + fprintf(stderr,"** Warning: summary key:%s does not exist - observation key:%s not added.\n", sum_key , obs_key); } - - - conf_instance_free(enkf_conf ); - conf_class_free( enkf_conf_class); - enkf_obs->config_file = util_realloc_string_copy( enkf_obs->config_file , config_file ); - - if (enkf_obs_get_size( enkf_obs) > 0) - enkf_obs->have_obs = true; + stringlist_free(sum_obs_keys); } - } + + + /** Handle BLOCK_OBSERVATION instances. */ + { + stringlist_type * block_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "BLOCK_OBSERVATION"); + int num_block_obs = stringlist_get_size(block_obs_keys); + + for(int block_obs_nr = 0; block_obs_nr < num_block_obs; block_obs_nr++) + { + const char * obs_key = stringlist_iget(block_obs_keys, block_obs_nr); + const conf_instance_type * block_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); + obs_vector_type * obs_vector = obs_vector_alloc_from_BLOCK_OBSERVATION(block_obs_conf , enkf_obs->grid , enkf_obs->obs_time , enkf_obs->refcase , enkf_obs->ensemble_config); + if (obs_vector != NULL) + enkf_obs_add_obs_vector(enkf_obs, obs_vector); + } + stringlist_free(block_obs_keys); + } + + + /** Handle GENERAL_OBSERVATION instances. */ + { + stringlist_type * block_obs_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(enkf_conf, "GENERAL_OBSERVATION"); + int num_block_obs = stringlist_get_size(block_obs_keys); + + for(int block_obs_nr = 0; block_obs_nr < num_block_obs; block_obs_nr++) + { + const char * obs_key = stringlist_iget(block_obs_keys, block_obs_nr); + const conf_instance_type * gen_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key); + + obs_vector_type * obs_vector = obs_vector_alloc_from_GENERAL_OBSERVATION(gen_obs_conf , enkf_obs->obs_time , enkf_obs->ensemble_config); + if (obs_vector != NULL) + enkf_obs_add_obs_vector(enkf_obs, obs_vector); + } + stringlist_free(block_obs_keys); + } + + + conf_instance_free(enkf_conf ); + conf_class_free( enkf_conf_class); + + return true; + } else + return false; } @@ -751,7 +711,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_item_spec_type * item_spec_error_min_segment = conf_item_spec_alloc("ERROR_MIN", true, DT_POSFLOAT , "The positive floating point number ERROR_MIN gives the minimum value for the standard deviation of the observation when RELMIN is used."); conf_item_spec_set_default_value(item_spec_error_min_segment, "0.10"); - + conf_class_insert_owned_item_spec(segment_class, item_spec_start_segment); conf_class_insert_owned_item_spec(segment_class, item_spec_stop_segment); conf_class_insert_owned_item_spec(segment_class, item_spec_error_mode_segment); @@ -760,7 +720,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_class_insert_owned_sub_class(history_observation_class, segment_class); } - + conf_class_insert_owned_sub_class(enkf_conf_class, history_observation_class); } @@ -783,16 +743,19 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , const char * help_item_spec_days = "The DAYS item gives the observation time as days after simulation start."; conf_item_spec_type * item_spec_days = conf_item_spec_alloc("DAYS", false, DT_POSFLOAT , help_item_spec_days); + const char * help_item_spec_hours = "The HOURS item gives the observation time as hours after simulation start."; + conf_item_spec_type * item_spec_hours = conf_item_spec_alloc("HOURS", false, DT_POSFLOAT , help_item_spec_hours); + const char * help_item_spec_restart = "The RESTART item gives the observation time as the ECLIPSE restart nr."; conf_item_spec_type * item_spec_restart = conf_item_spec_alloc("RESTART", false, DT_POSINT , help_item_spec_restart); const char * help_item_spec_sumkey = "The string SUMMARY_KEY is used to look up the simulated value in the summary file. It has the same format as the summary.x program, e.g. WOPR:P4"; conf_item_spec_type * item_spec_sumkey = conf_item_spec_alloc("KEY", true, DT_STR , help_item_spec_sumkey); - conf_item_spec_type * item_spec_error_min = conf_item_spec_alloc("ERROR_MIN", true, DT_POSFLOAT , + conf_item_spec_type * item_spec_error_min = conf_item_spec_alloc("ERROR_MIN", true, DT_POSFLOAT , "The positive floating point number ERROR_MIN gives the minimum value for the standard deviation of the observation when RELMIN is used."); conf_item_spec_type * item_spec_error_mode = conf_item_spec_alloc("ERROR_MODE", true, DT_STR , "The string ERROR_MODE gives the error mode for the observation."); - + conf_item_spec_add_restriction(item_spec_error_mode, "REL"); conf_item_spec_add_restriction(item_spec_error_mode, "ABS"); conf_item_spec_add_restriction(item_spec_error_mode, "RELMIN"); @@ -803,6 +766,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_class_insert_owned_item_spec(summary_observation_class, item_spec_error); conf_class_insert_owned_item_spec(summary_observation_class, item_spec_date); conf_class_insert_owned_item_spec(summary_observation_class, item_spec_days); + conf_class_insert_owned_item_spec(summary_observation_class, item_spec_hours); conf_class_insert_owned_item_spec(summary_observation_class, item_spec_restart); conf_class_insert_owned_item_spec(summary_observation_class, item_spec_sumkey); conf_class_insert_owned_item_spec(summary_observation_class, item_spec_error_mode); @@ -811,9 +775,11 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , /** Create a mutex on DATE, DAYS and RESTART. */ conf_item_mutex_type * time_mutex = conf_class_new_item_mutex(summary_observation_class , true , false); - conf_item_mutex_add_item_spec(time_mutex, item_spec_date); - conf_item_mutex_add_item_spec(time_mutex, item_spec_days); - conf_item_mutex_add_item_spec(time_mutex, item_spec_restart); + conf_item_mutex_add_item_spec(time_mutex , item_spec_date); + conf_item_mutex_add_item_spec(time_mutex , item_spec_days); + conf_item_mutex_add_item_spec(time_mutex , item_spec_hours); + conf_item_mutex_add_item_spec(time_mutex , item_spec_restart); + conf_item_mutex_add_item_spec(time_mutex , item_spec_days ); conf_class_insert_owned_sub_class(enkf_conf_class, summary_observation_class); } @@ -834,12 +800,15 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , const char * help_item_spec_days = "The DAYS item gives the observation time as days after simulation start."; conf_item_spec_type * item_spec_days = conf_item_spec_alloc("DAYS", false, DT_POSFLOAT , help_item_spec_days); + const char * help_item_spec_hours = "The HOURS item gives the observation time as hours after simulation start."; + conf_item_spec_type * item_spec_hours = conf_item_spec_alloc("HOURS", false, DT_POSFLOAT , help_item_spec_hours); + const char * help_item_spec_restart = "The RESTART item gives the observation time as the ECLIPSE restart nr."; conf_item_spec_type * item_spec_restart = conf_item_spec_alloc("RESTART", false, DT_POSINT , help_item_spec_restart); conf_item_spec_type * item_spec_source = conf_item_spec_alloc("SOURCE", false, DT_STR , "The simulated data can be taken from the field or summary keys."); - - + + conf_item_spec_add_restriction(item_spec_source, "FIELD"); conf_item_spec_add_restriction(item_spec_source, "SUMMARY"); conf_item_spec_set_default_value(item_spec_source, "FIELD"); @@ -849,13 +818,14 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_class_insert_owned_item_spec(block_observation_class, item_spec_date); conf_class_insert_owned_item_spec(block_observation_class, item_spec_days); conf_class_insert_owned_item_spec(block_observation_class, item_spec_restart); - + conf_class_insert_owned_item_spec(block_observation_class, item_spec_hours); /** Create a mutex on DATE, DAYS and RESTART. */ { conf_item_mutex_type * time_mutex = conf_class_new_item_mutex(block_observation_class , true , false); conf_item_mutex_add_item_spec(time_mutex, item_spec_date); conf_item_mutex_add_item_spec(time_mutex, item_spec_days); conf_item_mutex_add_item_spec(time_mutex, item_spec_restart); + conf_item_mutex_add_item_spec(time_mutex, item_spec_hours); } /** Create and insert the sub class OBS. */ @@ -880,9 +850,9 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_item_spec_type * item_spec_error_mode = conf_item_spec_alloc("ERROR_MODE", true, DT_STR , "The string ERROR_MODE gives the error mode for the observation."); - conf_item_spec_type * item_spec_error_min = conf_item_spec_alloc("ERROR_MIN", true, DT_POSFLOAT , + conf_item_spec_type * item_spec_error_min = conf_item_spec_alloc("ERROR_MIN", true, DT_POSFLOAT , "The positive floating point number ERROR_MIN gives the minimum value for the standard deviation of the observation when RELMIN is used."); - + conf_item_spec_add_restriction(item_spec_error_mode, "REL"); conf_item_spec_add_restriction(item_spec_error_mode, "ABS"); conf_item_spec_add_restriction(item_spec_error_mode, "RELMIN"); @@ -896,7 +866,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_class_insert_owned_item_spec(obs_class, item_spec_error); conf_class_insert_owned_item_spec(obs_class, item_spec_error_mode); conf_class_insert_owned_item_spec(obs_class, item_spec_error_min); - + conf_class_insert_owned_sub_class(block_observation_class, obs_class); } @@ -909,12 +879,14 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , const char * help_item_spec_field = "The item DATA gives the observed GEN_DATA instance."; const char * help_item_spec_date = "The DATE item gives the observation time as the date date it occured. Format is dd/mm/yyyy."; const char * help_item_spec_days = "The DAYS item gives the observation time as days after simulation start."; - + const char * help_item_spec_hours = "The HOURS item gives the observation time as hours after simulation start."; + conf_class_type * gen_obs_class = conf_class_alloc_empty("GENERAL_OBSERVATION" , false , false, "The class general_observation is used for general observations"); conf_item_spec_type * item_spec_field = conf_item_spec_alloc("DATA", true, DT_STR , help_item_spec_field); conf_item_spec_type * item_spec_date = conf_item_spec_alloc("DATE", false, DT_DATE , help_item_spec_date); conf_item_spec_type * item_spec_days = conf_item_spec_alloc("DAYS", false, DT_POSFLOAT , help_item_spec_days); + conf_item_spec_type * item_spec_hours = conf_item_spec_alloc("HOURS", false, DT_POSFLOAT , help_item_spec_hours); conf_item_spec_type * item_spec_restart = conf_item_spec_alloc("RESTART", false, DT_POSINT , help_item_spec_restart); conf_item_spec_type * item_spec_error_covar = conf_item_spec_alloc("ERROR_COVAR", false, DT_FILE , "Name of file containing error-covariance as formatted matrix - no header"); @@ -922,16 +894,18 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_class_insert_owned_item_spec(gen_obs_class, item_spec_field); conf_class_insert_owned_item_spec(gen_obs_class, item_spec_date); conf_class_insert_owned_item_spec(gen_obs_class, item_spec_days); + conf_class_insert_owned_item_spec(gen_obs_class, item_spec_hours); conf_class_insert_owned_item_spec(gen_obs_class, item_spec_restart); /** Create a mutex on DATE, DAYS and RESTART. */ { conf_item_mutex_type * time_mutex = conf_class_new_item_mutex(gen_obs_class , true , false); - + conf_item_mutex_add_item_spec(time_mutex, item_spec_date); conf_item_mutex_add_item_spec(time_mutex, item_spec_days); + conf_item_mutex_add_item_spec(time_mutex, item_spec_hours); conf_item_mutex_add_item_spec(time_mutex, item_spec_restart); } - + { conf_item_spec_type * item_spec_obs_file = conf_item_spec_alloc("OBS_FILE" , false , DT_FILE , "The name of an (ascii) file with observation values."); conf_item_spec_type * item_spec_value = conf_item_spec_alloc("VALUE" , false , DT_FLOAT , "One scalar observation value."); @@ -946,16 +920,16 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , /* If the observation is in terms of VALUE - we must also have ERROR. The conf system does not (currently ??) enforce this dependency. */ - + conf_item_mutex_add_item_spec( value_mutex , item_spec_value); conf_item_mutex_add_item_spec( value_mutex , item_spec_obs_file); conf_item_mutex_add_item_spec( value_error_mutex , item_spec_value); conf_item_mutex_add_item_spec( value_error_mutex , item_spec_error); } - - - /* + + + /* The default is that all the elements in DATA are observed, but we can restrict ourselves to a list of indices, with either the INDEX_LIST or INDEX_FILE keywords. @@ -964,13 +938,13 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , conf_item_spec_type * item_spec_index_list = conf_item_spec_alloc("INDEX_LIST" , false , DT_STR , "A list of indicies - possibly with ranges which should be observed in the target field."); conf_item_spec_type * item_spec_index_file = conf_item_spec_alloc("INDEX_FILE" , false , DT_FILE , "An ASCII file containing a list of indices which should be observed in the target field."); conf_item_mutex_type * index_mutex = conf_class_new_item_mutex( gen_obs_class , false , false); - + conf_class_insert_owned_item_spec(gen_obs_class, item_spec_index_list); conf_class_insert_owned_item_spec(gen_obs_class, item_spec_index_file); conf_item_mutex_add_item_spec(index_mutex , item_spec_index_list); conf_item_mutex_add_item_spec(index_mutex , item_spec_index_file); } - + conf_class_insert_owned_sub_class(enkf_conf_class, gen_obs_class); } @@ -987,7 +961,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , */ stringlist_type * enkf_obs_alloc_typed_keylist(enkf_obs_type * enkf_obs , obs_impl_type obs_type) { stringlist_type * vars = stringlist_alloc_new(); - hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); + hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); const char * key = hash_iter_get_next_key(iter); while ( key != NULL) { obs_vector_type * obs_vector = hash_get( enkf_obs->obs_hash , key); @@ -1000,6 +974,11 @@ stringlist_type * enkf_obs_alloc_typed_keylist(enkf_obs_type * enkf_obs , obs_im } +obs_impl_type enkf_obs_get_type(const enkf_obs_type * enkf_obs , const char * key) { + obs_vector_type * obs_vector = hash_get( enkf_obs->obs_hash , key); + return obs_vector_get_impl_type(obs_vector); +} + /** */ @@ -1011,7 +990,7 @@ stringlist_type * enkf_obs_alloc_matching_keylist(const enkf_obs_type * enkf_obs char ** input_keys; int num_keys; - + util_split_string( input_string , " " , &num_keys , &input_keys); for (int i=0; i < num_keys; i++) { bool key_found = false; @@ -1038,7 +1017,7 @@ stringlist_type * enkf_obs_alloc_matching_keylist(const enkf_obs_type * enkf_obs stringlist_type * enkf_obs_alloc_keylist(enkf_obs_type * enkf_obs ) { stringlist_type * vars = stringlist_alloc_new(); - hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); + hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); const char * key = hash_iter_get_next_key(iter); while ( key != NULL) { stringlist_append_copy(vars , key); @@ -1079,7 +1058,7 @@ stringlist_type * enkf_obs_alloc_keylist(enkf_obs_type * enkf_obs ) { hash_type * enkf_obs_alloc_data_map(enkf_obs_type * enkf_obs) { hash_type * map = hash_alloc(); - hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); + hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); const char * key = hash_iter_get_next_key(iter); while ( key != NULL) { obs_vector_type * obs_vector = hash_get( enkf_obs->obs_hash , key); @@ -1096,20 +1075,7 @@ hash_iter_type * enkf_obs_alloc_iter( const enkf_obs_type * enkf_obs ) { } -const char * enkf_obs_get_config_file( const enkf_obs_type * enkf_obs) { - return enkf_obs->config_file; -} -void enkf_obs_fprintf_config( const enkf_obs_type * enkf_obs , FILE * stream) { - if (enkf_obs->config_file != NULL) { - fprintf( stream , CONFIG_COMMENTLINE_FORMAT ); - fprintf( stream , CONFIG_COMMENT_FORMAT , "The observations are stored in a separate config file."); - fprintf( stream , CONFIG_COMMENT_FORMAT , "Unfortunately there is separate config language for the observations ... :-("); - fprintf(stream , CONFIG_KEY_FORMAT , OBS_CONFIG_KEY); - fprintf(stream , CONFIG_ENDVALUE_FORMAT , enkf_obs->config_file ); - fprintf(stream , "\n\n"); - } -} /** @@ -1157,15 +1123,86 @@ const obs_vector_type * enkf_obs_user_get_vector(const enkf_obs_type * obs , con /*****************************************************************/ + void enkf_obs_scale_std(enkf_obs_type * enkf_obs, double scale_factor) { + local_obsdata_type * local_obs = enkf_obs_alloc_all_active_local_obs( enkf_obs , "ALL-OBS"); + enkf_obs_local_scale_std( enkf_obs , local_obs , scale_factor ); + local_obsdata_free( local_obs ); +} - hash_iter_type * observation_vector_iterator = enkf_obs_alloc_iter(enkf_obs); - while (!hash_iter_is_complete(observation_vector_iterator)) { - obs_vector_type * current_obs_vector = hash_iter_get_next_value(observation_vector_iterator); - obs_vector_scale_std(current_obs_vector, scale_factor); +void enkf_obs_local_scale_std( const enkf_obs_type * enkf_obs , const local_obsdata_type * local_obsdata, double scale_factor) { + int num_nodes = local_obsdata_get_size( local_obsdata ); + int node_nr; + for (node_nr = 0; node_nr < num_nodes; node_nr++) { + const local_obsdata_node_type * node = local_obsdata_iget( local_obsdata , node_nr ); + obs_vector_type * obs_vector = enkf_obs_get_vector( enkf_obs , local_obsdata_node_get_key( node )); + obs_vector_scale_std( obs_vector , node , scale_factor ); } - - hash_iter_free(observation_vector_iterator); } + +double enkf_obs_scale_correlated_std(const enkf_obs_type * enkf_obs , enkf_fs_type * fs , const int_vector_type * ens_active_list , const local_obsdata_type * local_obsdata) { + state_enum state = FORECAST; + bool_vector_type * ens_mask = int_vector_alloc_mask( ens_active_list ); + meas_data_type * meas_data = meas_data_alloc( ens_mask ); + obs_data_type * obs_data = obs_data_alloc( 1.0 ); + double scale_factor; + + enkf_obs_get_obs_and_measure_data( enkf_obs , fs , local_obsdata , state , ens_active_list , meas_data , obs_data ); + { + matrix_type * S = meas_data_allocS( meas_data ); + double truncation = 0.95; + int num_PC; + + obs_data_scale( obs_data , S , NULL , NULL , NULL , NULL ); + num_PC = enkf_linalg_num_PC( S , truncation ); + scale_factor = sqrt( obs_data_get_active_size( obs_data ) / num_PC ); + + matrix_free( S ); + } + enkf_obs_local_scale_std( enkf_obs , local_obsdata , scale_factor ); + + meas_data_free( meas_data ); + obs_data_free( obs_data ); + bool_vector_free( ens_mask ); + return scale_factor; +} + + + +void enkf_obs_add_local_nodes_with_data(const enkf_obs_type * enkf_obs , local_obsdata_type * local_obs , enkf_fs_type *fs , const bool_vector_type * ens_mask) { + hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); + while ( !hash_iter_is_complete( iter ) ) { + const char * key = hash_iter_get_next_key(iter); + obs_vector_type * obs_vector = hash_get( enkf_obs->obs_hash , key); + + if (obs_vector_has_data( obs_vector , ens_mask , fs )) { + local_obsdata_node_type * node = obs_vector_alloc_local_node( obs_vector ); + local_obsdata_add_node( local_obs , node ); + } + + } + hash_iter_free(iter); +} + + + +local_obsdata_type * enkf_obs_alloc_all_active_local_obs( const enkf_obs_type * enkf_obs , const char * key) { + local_obsdata_type * local_obs = local_obsdata_alloc( key ); + { + hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash); + while ( !hash_iter_is_complete( iter ) ) { + const char * key = hash_iter_get_next_key(iter); + obs_vector_type * obs_vector = hash_get( enkf_obs->obs_hash , key); + local_obsdata_node_type * node = obs_vector_alloc_local_node( obs_vector ); + local_obsdata_add_node( local_obs , node ); + } + hash_iter_free(iter); + } + return local_obs; +} + + + + diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_state.c b/ThirdParty/Ert/devel/libenkf/src/enkf_state.c index cbd93279ac..40195cb5e3 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_state.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_state.c @@ -73,6 +73,7 @@ #include <ert/enkf/state_map.h> #include <ert/enkf/ert_log.h> #include <ert/enkf/run_arg.h> +#include <ert/enkf/summary_key_matcher.h> #define ENKF_STATE_TYPE_ID 78132 @@ -207,7 +208,7 @@ member_config_type * enkf_state_get_member_config(const enkf_state_type * enkf_s -static void enkf_state_add_subst_kw(enkf_state_type * enkf_state , const char * kw , const char * value , const char * doc_string) { +void enkf_state_add_subst_kw(enkf_state_type * enkf_state , const char * kw , const char * value , const char * doc_string) { char * tagged_key = util_alloc_sprintf( INTERNAL_DATA_KW_TAG_FORMAT , kw ); subst_list_append_owned_ref(enkf_state->subst_list , tagged_key , util_alloc_string_copy(value) , doc_string); free(tagged_key); @@ -438,6 +439,14 @@ void enkf_state_add_node(enkf_state_type * enkf_state , const char * node_key , } +enkf_node_type * enkf_state_get_or_create_node(enkf_state_type * enkf_state, const enkf_config_node_type * config_node) { + const char * key = enkf_config_node_get_key(config_node); + if(!enkf_state_has_node(enkf_state, key)) { + enkf_state_add_node(enkf_state, key, config_node); + } + return enkf_state_get_node(enkf_state, key); +} + void enkf_state_update_node( enkf_state_type * enkf_state , const char * node_key ) { @@ -547,6 +556,16 @@ static void enkf_state_log_GEN_DATA_load( const enkf_node_type * enkf_node , int free( load_file ); } +static void enkf_state_log_custom_kw_load(const enkf_node_type * enkf_node, int report_step, stringlist_type * msg_list) { + /* In interactive mode we explicitly report the loads of GEN_DATA instances. */ + char * load_file = enkf_config_node_alloc_infile(enkf_node_get_config(enkf_node), report_step); + stringlist_append_owned_ref(msg_list, + util_alloc_sprintf("Loaded CUSTOM_KW: %s instance for step: %d from file: %s", + enkf_node_get_key(enkf_node), + report_step, + load_file)); + free(load_file); +} static bool enkf_state_report_step_compatible(const enkf_state_type * enkf_state, const ecl_sum_type * ecl_sum_simulated) { bool ret = true; @@ -561,14 +580,21 @@ static bool enkf_state_report_step_compatible(const enkf_state_type * enkf_state } +static int_vector_type * __enkf_state_get_time_index(enkf_fs_type * result_fs, ecl_sum_type * summary) { + time_map_type * time_map = enkf_fs_get_time_map( result_fs ); + time_map_summary_update( time_map , summary ); + return time_map_alloc_index_map( time_map , summary ); +} + static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enkf_state , run_arg_type * run_arg , const model_config_type * model_config , int * result, bool interactive , stringlist_type * msg_list) { bool load_summary = ensemble_config_has_impl_type(enkf_state->ensemble_config, SUMMARY); if (load_summary) { - int load_start = run_arg_get_load_start( run_arg ); + int load_start = run_arg_get_load_start( run_arg ); - if (load_start == 0) /* Do not attempt to load the "S0000" summary results. */ + if (load_start == 0) { /* Do not attempt to load the "S0000" summary results. */ load_start++; + } { /* Looking for summary files on disk, and loading them. */ @@ -576,12 +602,7 @@ static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enk enkf_fs_type * result_fs = run_arg_get_result_fs( run_arg ); /** OK - now we have actually loaded the ecl_sum instance, or ecl_sum == NULL. */ if (summary != NULL) { - int_vector_type * time_index; - { - time_map_type * time_map = enkf_fs_get_time_map( result_fs ); - time_map_summary_update( time_map , summary ); - time_index = time_map_alloc_index_map( time_map , summary ); - } + int_vector_type * time_index = __enkf_state_get_time_index(result_fs, summary); /* Now there are two related / conflicting(?) systems for @@ -591,9 +612,9 @@ static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enk */ /*Check the loaded summary against the reference ecl_sum_type */ - if (!enkf_state_report_step_compatible(enkf_state, summary)) - *result |= REPORT_STEP_INCOMPATIBLE; - + if (!enkf_state_report_step_compatible(enkf_state, summary)) { + *result |= REPORT_STEP_INCOMPATIBLE; + } /* The actual loading internalizing - from ecl_sum -> enkf_node. */ @@ -602,29 +623,44 @@ static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enk int_vector_iset_block( time_index , 0 , load_start , -1 ); int_vector_resize( time_index , step2 + 1); - { - hash_iter_type * iter = hash_iter_alloc( enkf_state->node_hash ); - - while ( !hash_iter_is_complete(iter) ) { - enkf_node_type * node = hash_iter_get_next_value(iter); - if (enkf_node_get_var_type(node) == DYNAMIC_RESULT && - enkf_node_get_impl_type(node) == SUMMARY) { - { + + const summary_key_matcher_type * matcher = ensemble_config_get_summary_key_matcher(enkf_state->ensemble_config); + const ecl_smspec_type * smspec = ecl_sum_get_smspec(summary); + + for(int i = 0; i < ecl_smspec_num_nodes(smspec); i++) { + const smspec_node_type * smspec_node = ecl_smspec_iget_node(smspec, i); + const char * key = smspec_node_get_gen_key1(smspec_node); + + if(summary_key_matcher_match_summary_key(matcher, key)) { + summary_key_set_type * key_set = enkf_fs_get_summary_key_set(result_fs); + summary_key_set_add_summary_key(key_set, key); + + enkf_config_node_type * config_node = ensemble_config_get_or_create_summary_node(enkf_state->ensemble_config, key); + enkf_node_type * node = enkf_state_get_or_create_node(enkf_state, config_node); + enkf_node_try_load_vector( node , result_fs , iens , FORECAST ); // Ensure that what is currently on file is loaded before we update. - if (enkf_node_forward_load_vector( node , run_arg_get_runpath( run_arg ) , summary , NULL , time_index , iens)) - enkf_node_store_vector( node , result_fs , iens , FORECAST ); - else { - *result |= LOAD_FAILURE; - ert_log_add_fmt_message( 3 , NULL , "[%03d:----] Failed to load data for vector node:%s.",iens , enkf_node_get_key( node )); - if (interactive) - stringlist_append_owned_ref( msg_list , util_alloc_sprintf("Failed to load vector:%s" , enkf_node_get_key( node ))); - } - } + + enkf_node_forward_load_vector( node , run_arg_get_runpath( run_arg ) , summary , NULL , time_index , iens); + enkf_node_store_vector( node , result_fs , iens , FORECAST ); + } + } + + /* */ + stringlist_type * keys = summary_key_matcher_get_keys(matcher); + for(int i = 0; i < stringlist_get_size(keys); i++) { + const char * key = stringlist_iget(keys, i); + if(summary_key_matcher_summary_key_is_required(matcher, key)) { + if(!ecl_smspec_has_general_var(smspec, key)) { + *result |= LOAD_FAILURE; + ert_log_add_fmt_message( 3 , NULL , "[%03d:----] Failed to load data for vector node: %s", iens , key); + if (interactive) { + stringlist_append_owned_ref( msg_list , util_alloc_sprintf("Failed to load vector: %s" , key)); + } + } } - } - - hash_iter_free(iter); } + + stringlist_free(keys); ecl_sum_free( summary ); int_vector_free( time_index ); return true; @@ -633,8 +669,9 @@ static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enk return false; } } - } else + } else { return true; + } } @@ -665,6 +702,61 @@ static char * __realloc_static_kw(char * kw , int occurence) { } +static void enkf_state_internalize_custom_kw(enkf_state_type * enkf_state, + run_arg_type * run_arg, + const model_config_type * model_config, + int * result, + bool interactive, + stringlist_type * msg_list) { + + member_config_type * my_config = enkf_state->my_config; + const int iens = member_config_get_iens( my_config ); + stringlist_type * custom_kw_keys = ensemble_config_alloc_keylist_from_impl_type(enkf_state->ensemble_config, CUSTOM_KW); + enkf_fs_type * result_fs = run_arg_get_result_fs(run_arg); + const int report_step = 0; + + custom_kw_config_set_type * config_set = enkf_fs_get_custom_kw_config_set(result_fs); + custom_kw_config_set_reset(config_set); + + for (int ikey=0; ikey < stringlist_get_size(custom_kw_keys); ikey++) { + const char* custom_kw_key = stringlist_iget(custom_kw_keys, ikey); + enkf_node_type * node = enkf_state_get_node(enkf_state, custom_kw_key); + + if (enkf_node_vector_storage(node)) { + util_abort("%s: Vector storage not correctly implemented for CUSTOM_KW\n", __func__); + } else { + if (enkf_node_internalize(node, report_step)) { + if (enkf_node_has_func(node, forward_load_func)) { + if (enkf_node_forward_load(node, run_arg_get_runpath(run_arg), NULL, NULL, report_step, iens)) { + node_id_type node_id = {.report_step = report_step, .iens = iens, .state = FORECAST}; + + enkf_node_store(node, result_fs, false, node_id); + + const enkf_config_node_type * config_node = enkf_node_get_config(node); + const custom_kw_config_type * custom_kw_config = (custom_kw_config_type*) enkf_config_node_get_ref(config_node); + custom_kw_config_set_add_config(config_set, custom_kw_config); + + if (interactive) { + enkf_state_log_custom_kw_load(node, report_step, msg_list); + } + + } else { + *result |= LOAD_FAILURE; + ert_log_add_fmt_message(1, stderr, "[%03d:%04d] Failed load data for node: %s.", iens , report_step, enkf_node_get_key(node)); + + if (interactive) { + stringlist_append_owned_ref(msg_list, util_alloc_sprintf("Failed to load: %s at step: %d", enkf_node_get_key(node), report_step)); + } + } + } + } + } + } + + stringlist_free(custom_kw_keys); +} + + static void enkf_state_internalize_GEN_DATA(enkf_state_type * enkf_state , run_arg_type * run_arg , @@ -981,7 +1073,8 @@ static void enkf_state_internalize_results(enkf_state_type * enkf_state , run_ar } enkf_state_internalize_GEN_DATA(enkf_state , run_arg , model_config , last_report , result , interactive , msg_list); - } + enkf_state_internalize_custom_kw(enkf_state, run_arg, model_config, result, interactive, msg_list); + } } @@ -1612,9 +1705,6 @@ void enkf_state_init_eclipse(enkf_state_type *enkf_state, const run_arg_type * r const member_config_type * my_config = enkf_state->my_config; const ecl_config_type * ecl_config = enkf_state->shared_info->ecl_config; { - if (!run_arg_is_ready(run_arg)) - util_abort("%s: must initialize run parameters with enkf_state_init_run() first \n",__func__); - if (member_config_pre_clear_runpath( my_config )) util_clear_directory( run_arg_get_runpath( run_arg ) , true , false ); @@ -1805,7 +1895,6 @@ static bool enkf_state_complete_forward_modelOK(enkf_state_type * enkf_state , r ert_log_add_fmt_message( 2 , NULL , "[%03d:%04d-%04d] Results loaded successfully." , iens , run_arg_get_step1(run_arg), run_arg_get_step2(run_arg)); enkf_state_clear_runpath( enkf_state , run_arg ); - run_arg_set_ready( run_arg , false ); run_arg_complete_run(run_arg); /* free() on runpath */ } return (0 == result) ? true : false; diff --git a/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c b/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c index 5a88d74f10..e910137aff 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c @@ -1,19 +1,19 @@ /* - copyright (c) 2011 statoil asa, norway. - - the file 'ensemble_config.c' is part of ert - ensemble based reservoir tool. - - ert 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. - - ert 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + copyright (c) 2011 statoil asa, norway. + + the file 'ensemble_config.c' is part of ert - ensemble based reservoir tool. + + ert 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. + + ert 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -44,7 +44,7 @@ #include <ert/sched/sched_file.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/enkf/enkf_config_node.h> #include <ert/enkf/enkf_types.h> @@ -66,19 +66,22 @@ #include <ert/enkf/ecl_config.h> #include <ert/enkf/config_keys.h> #include <ert/enkf/enkf_defaults.h> +#include <ert/enkf/summary_key_matcher.h> +#include <ert/enkf/custom_kw_config_set.h> #define ENSEMBLE_CONFIG_TYPE_ID 8825306 struct ensemble_config_struct { UTIL_TYPE_ID_DECLARATION; - pthread_mutex_t mutex; - char * gen_kw_format_string; /* format string used when creating gen_kw search/replace strings. */ - hash_type * config_nodes; /* a hash of enkf_config_node instances - which again conatin pointers to e.g. field_config objects. */ - field_trans_table_type * field_trans_table; /* a table of the transformations which are available to apply on fields. */ - const ecl_sum_type * refcase; /* a ecl_sum reference instance - can be null (not owned by the ensemble + pthread_mutex_t mutex; + char * gen_kw_format_string; /* format string used when creating gen_kw search/replace strings. */ + hash_type * config_nodes; /* a hash of enkf_config_node instances - which again conatin pointers to e.g. field_config objects. */ + field_trans_table_type * field_trans_table; /* a table of the transformations which are available to apply on fields. */ + const ecl_sum_type * refcase; /* a ecl_sum reference instance - can be null (not owned by the ensemble config). is only used to check that summary keys are valid when adding. */ - bool have_forward_init; + bool have_forward_init; + summary_key_matcher_type * summary_key_matcher; }; @@ -138,7 +141,7 @@ const char * ensemble_config_get_gen_kw_format( const ensemble_config_type * ens void ensemble_config_set_refcase( ensemble_config_type * ensemble_config , const ecl_sum_type * refcase) { ensemble_config->refcase = refcase; } - + @@ -147,12 +150,13 @@ ensemble_config_type * ensemble_config_alloc( ) { UTIL_TYPE_ID_INIT( ensemble_config , ENSEMBLE_CONFIG_TYPE_ID ); ensemble_config->config_nodes = hash_alloc(); - ensemble_config->field_trans_table = field_trans_table_alloc(); + ensemble_config->field_trans_table = field_trans_table_alloc(); ensemble_config->refcase = NULL; ensemble_config->gen_kw_format_string = util_alloc_string_copy( DEFAULT_GEN_KW_TAG_FORMAT ); ensemble_config->have_forward_init = false; + ensemble_config->summary_key_matcher = summary_key_matcher_alloc(); pthread_mutex_init( &ensemble_config->mutex , NULL); - + return ensemble_config; } @@ -161,6 +165,7 @@ ensemble_config_type * ensemble_config_alloc( ) { void ensemble_config_free(ensemble_config_type * ensemble_config) { hash_free( ensemble_config->config_nodes ); field_trans_table_free( ensemble_config->field_trans_table ); + summary_key_matcher_free(ensemble_config->summary_key_matcher); free( ensemble_config->gen_kw_format_string ); free( ensemble_config ); } @@ -198,10 +203,6 @@ enkf_var_type ensemble_config_var_type(const ensemble_config_type *ensemble_conf - - - - bool ensemble_config_has_key(const ensemble_config_type * ensemble_config , const char * key) { return hash_has_key( ensemble_config->config_nodes , key); } @@ -218,11 +219,18 @@ enkf_config_node_type * ensemble_config_get_node(const ensemble_config_type * en } } +enkf_config_node_type * ensemble_config_get_or_create_summary_node(ensemble_config_type * ensemble_config, const char * key) { + if (!hash_has_key(ensemble_config->config_nodes , key)) { + ensemble_config_add_summary(ensemble_config, key, LOAD_FAIL_SILENT); + } + + return ensemble_config_get_node(ensemble_config, key); +} -/** +/** this will remove the config node indexed by key, it will use the function hash_safe_del(), which is thread_safe, and will not fail - if the node has already been removed from the hash. + if the node has already been removed from the hash. however - it is extremely important to ensure that all storage nodes (which point to the config nodes) have been deleted before @@ -243,9 +251,9 @@ bool ensemble_config_have_forward_init( const ensemble_config_type * ensemble_co void ensemble_config_add_node( ensemble_config_type * ensemble_config , enkf_config_node_type * node) { if (node) { const char * key = enkf_config_node_get_key( node ); - if (ensemble_config_has_key(ensemble_config , key)) + if (ensemble_config_has_key(ensemble_config , key)) util_abort("%s: a configuration object:%s has already been added - aborting \n",__func__ , key); - + hash_insert_hash_owned_ref(ensemble_config->config_nodes , key , node , enkf_config_node_free__); ensemble_config->have_forward_init |= enkf_config_node_use_forward_init( node ); } else @@ -254,10 +262,10 @@ void ensemble_config_add_node( ensemble_config_type * ensemble_config , enkf_con -enkf_config_node_type * ensemble_config_add_STATIC_node(ensemble_config_type * ensemble_config , +enkf_config_node_type * ensemble_config_add_STATIC_node(ensemble_config_type * ensemble_config , const char * key) { - - if (ensemble_config_has_key(ensemble_config , key)) + + if (ensemble_config_has_key(ensemble_config , key)) util_abort("%s: a configuration object:%s has already been added - aborting \n",__func__ , key); { enkf_config_node_type * node = enkf_config_node_alloc(STATIC_STATE , STATIC , false , key , NULL , NULL , NULL , NULL); @@ -275,7 +283,7 @@ enkf_config_node_type * ensemble_config_add_STATIC_node(ensemble_config_type * void ensemble_config_ensure_static_key(ensemble_config_type * ensemble_config , const char * kw ) { pthread_mutex_lock( &ensemble_config->mutex ); { - if (!ensemble_config_has_key(ensemble_config , kw)) + if (!ensemble_config_has_key(ensemble_config , kw)) ensemble_config_add_STATIC_node(ensemble_config , kw ); } pthread_mutex_unlock( &ensemble_config->mutex ); @@ -302,14 +310,14 @@ void ensemble_config_clear_obs_keys(ensemble_config_type * ensemble_config) { -void ensemble_config_add_config_items(config_type * config) { +void ensemble_config_add_config_items(config_parser_type * config) { config_schema_item_type * item; - /** + /** the two fault types are just added to the config object only to be able to print suitable messages before exiting. */ - + item = config_add_schema_item(config , "HAVANA_FAULT" , false ); config_schema_item_set_argc_minmax(item , 2 , 2); @@ -319,25 +327,26 @@ void ensemble_config_add_config_items(config_type * config) { /*****************************************************************/ - - + + item = config_add_schema_item(config , GEN_KW_KEY , false ); config_schema_item_set_argc_minmax(item , 4 , 6); config_schema_item_iset_type( item , 1 , CONFIG_EXISTING_PATH ); config_schema_item_iset_type( item , 3 , CONFIG_EXISTING_PATH ); - - + + item = config_add_key_value( config , GEN_KW_TAG_FORMAT_KEY , false , CONFIG_STRING); item = config_add_schema_item(config , SCHEDULE_PREDICTION_FILE_KEY , false ); /* scedhule_prediction_file filename <parameters:> <init_files:> */ config_schema_item_set_argc_minmax(item , 1 , 3 ); config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - + enkf_config_node_add_GEN_PARAM_config_schema( config ); enkf_config_node_add_GEN_DATA_config_schema( config ); + enkf_config_node_add_CUSTOM_KW_config_schema( config ); item = config_add_schema_item(config , SUMMARY_KEY , false ); /* can have several summary keys on each line. */ config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); @@ -347,12 +356,13 @@ void ensemble_config_add_config_items(config_type * config) { item = config_add_schema_item( config , SURFACE_KEY , false ); config_schema_item_set_argc_minmax(item , 4 , 5 ); - /* + + /* the way config info is entered for fields is unfortunate because it is difficult/impossible to let the config system handle run time validation of the input. */ - + item = config_add_schema_item(config , FIELD_KEY , false ); config_schema_item_set_argc_minmax(item , 2 , CONFIG_DEFAULT_ARG_MAX); config_schema_item_add_required_children(item , GRID_KEY); /* if you are using a field - you must have a grid. */ @@ -365,8 +375,8 @@ void ensemble_config_add_config_items(config_type * config) { combination of input parameters. It is possible to specify an invalid input combination; that should be identified with a call to gen_data_config_is_valid() in the calling scope. - - + + PARAMETER: init_file_fmt != NULL enkf_outfile_fmt != NULL enkf_infile_fmt == NULL @@ -377,44 +387,43 @@ void ensemble_config_add_config_items(config_type * config) { DYNAMIC_RESULT: init_file_fmt == NULL enkf_outfile_fmt == NULL - enkf_infile_fmt != NULL + enkf_infile_fmt != NULL */ - -void ensemble_config_init_GEN_DATA( ensemble_config_type * ensemble_config , const config_type * config) { - const config_content_item_type * item = config_get_content_item( config , GEN_DATA_KEY ); - if (item != NULL) { +void ensemble_config_init_GEN_DATA( ensemble_config_type * ensemble_config , const config_content_type * config) { + if (config_content_has_item(config , GEN_DATA_KEY)) { + const config_content_item_type * item = config_content_get_item( config , GEN_DATA_KEY ); int i; for (i=0; i < config_content_item_get_size(item); i++) { const config_content_node_type * node = config_content_item_iget_node( item , i ); enkf_config_node_type * config_node = enkf_config_node_alloc_GEN_DATA_from_config( node ); if (config_node) ensemble_config_add_node( ensemble_config , config_node ); - + } } } -void ensemble_config_init_GEN_PARAM( ensemble_config_type * ensemble_config , const config_type * config) { +void ensemble_config_init_GEN_PARAM( ensemble_config_type * ensemble_config , const config_content_type * config) { /* gen_param - should be unified with the gen_data*/ - const config_content_item_type * item = config_get_content_item( config , GEN_PARAM_KEY ); - if (item != NULL) { + if (config_content_has_item(config , GEN_PARAM_KEY)) { + const config_content_item_type * item = config_content_get_item( config , GEN_PARAM_KEY ); for (int i=0; i < config_content_item_get_size(item); i++) { const config_content_node_type * node = config_content_item_iget_node( item , i ); enkf_config_node_type * config_node = enkf_config_node_alloc_GEN_PARAM_from_config( node ); if (config_node) ensemble_config_add_node( ensemble_config , config_node ); - + } } } -void ensemble_config_init_GEN_KW( ensemble_config_type * ensemble_config , const config_type * config ) { - const config_content_item_type * gen_kw_item = config_get_content_item( config , GEN_KW_KEY ); - if (gen_kw_item != NULL) { +void ensemble_config_init_GEN_KW( ensemble_config_type * ensemble_config , const config_content_type * config ) { + if (config_content_has_item(config , GEN_KW_KEY)) { + const config_content_item_type * gen_kw_item = config_content_get_item( config , GEN_KW_KEY ); int i; for (i=0; i < config_content_item_get_size( gen_kw_item ); i++) { config_content_node_type * node = config_content_item_iget_node( gen_kw_item , i ); @@ -430,18 +439,18 @@ void ensemble_config_init_GEN_KW( ensemble_config_type * ensemble_config , const const char * forward_string = hash_safe_get( opt_hash , FORWARD_INIT_KEY ); enkf_config_node_type * config_node; bool forward_init = false; - + if (forward_string) { if (!util_sscanf_bool( forward_string , &forward_init)) fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string); } - + config_node = ensemble_config_add_gen_kw( ensemble_config , key , forward_init); - enkf_config_node_update_gen_kw( config_node , - enkf_outfile , - template_file , - parameter_file , - hash_safe_get( opt_hash , MIN_STD_KEY ) , + enkf_config_node_update_gen_kw( config_node , + enkf_outfile , + template_file , + parameter_file , + hash_safe_get( opt_hash , MIN_STD_KEY ) , hash_safe_get( opt_hash , INIT_FILES_KEY)); } hash_free( opt_hash ); @@ -449,18 +458,38 @@ void ensemble_config_init_GEN_KW( ensemble_config_type * ensemble_config , const } } +void ensemble_config_init_CUSTOM_KW(ensemble_config_type * ensemble_config, const config_content_type * config) { + if (config_content_has_item(config, CUSTOM_KW_KEY)) { + const config_content_item_type * custom_kw_item = config_content_get_item(config, CUSTOM_KW_KEY); + + for (int i = 0; i < config_content_item_get_size(custom_kw_item); i++) { + config_content_node_type * node = config_content_item_iget_node(custom_kw_item, i); + const char * key = config_content_node_iget(node, 0); + const char * result_file = config_content_node_iget_as_path(node, 1); + const char * output_file = NULL; -void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , const config_type * config ) { - const config_content_item_type * item = config_get_content_item( config , SURFACE_KEY ); - if (item != NULL) { + if(config_content_node_get_size(node) > 2) { + output_file = config_content_node_iget_as_path(node, 2); + } + + enkf_config_node_type * config_node = ensemble_config_add_custom_kw(ensemble_config, key, result_file, output_file); + enkf_config_node_update_custom_kw(config_node, result_file, output_file); + enkf_config_node_set_internalize(config_node, 0); + } + } +} + +void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , const config_content_type * config ) { + if (config_content_has_item(config , SURFACE_KEY)) { + const config_content_item_type * item = config_content_get_item( config , SURFACE_KEY ); int i; for (i=0; i < config_content_item_get_size( item ); i++) { const config_content_node_type * node = config_content_item_iget_node( item , i ); const char * key = config_content_node_iget( node , 0 ); { hash_type * options = hash_alloc(); /* INIT_FILE:<init_files> OUTPUT_FILE:<outfile> BASE_SURFACE:<base_file> */ - + config_content_node_init_opt_hash( node , options , 1 ); { const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); @@ -469,12 +498,12 @@ void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , cons const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); const char * forward_string = hash_safe_get( options , FORWARD_INIT_KEY ); bool forward_init = false; - + if (forward_string) { if (!util_sscanf_bool( forward_string , &forward_init)) fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string); } - + if ((init_file_fmt == NULL) || (output_file == NULL) || (base_surface == NULL)) { fprintf(stderr,"** error: when entering a surface you must provide arguments:\n"); fprintf(stderr,"** %s:/path/to/input/files%%d \n",INIT_FILES_KEY); @@ -482,7 +511,7 @@ void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , cons fprintf(stderr,"** %s:base_surface_file\n",BASE_SURFACE_KEY); exit(1); } - + { enkf_config_node_type * config_node = ensemble_config_add_surface( ensemble_config , key , forward_init); enkf_config_node_update_surface( config_node , base_surface , init_file_fmt , output_file , min_std_file ); @@ -495,30 +524,30 @@ void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , cons } -void ensemble_config_init_SUMMARY( ensemble_config_type * ensemble_config , const config_type * config , const ecl_sum_type * refcase) { - const config_content_item_type * item = config_get_content_item( config , SUMMARY_KEY ); - - if (item != NULL) { +void ensemble_config_init_SUMMARY( ensemble_config_type * ensemble_config , const config_content_type * config , const ecl_sum_type * refcase) { + if (config_content_has_item(config , SUMMARY_KEY)) { + const config_content_item_type * item = config_content_get_item( config , SUMMARY_KEY ); int i; for (i=0; i < config_content_item_get_size( item ); i++) { const config_content_node_type * node = config_content_item_iget_node( item , i ); int j; for (j= 0; j < config_content_node_get_size( node ); j++) { const char * key = config_content_node_iget( node , j ); - + summary_key_matcher_add_summary_key(ensemble_config->summary_key_matcher, key); + if (util_string_has_wildcard( key )) { + //todo: DEPRECATED. In the Future the matcher should take care of this. if (ensemble_config->refcase != NULL) { int k; stringlist_type * keys = stringlist_alloc_new ( ); - ecl_sum_select_matching_general_var_list( ensemble_config->refcase , key , keys ); /* expanding the wildcard notatition with help of the refcase. */ - for (k=0; k < stringlist_get_size( keys ); k++) + ecl_sum_select_matching_general_var_list( ensemble_config->refcase , key , keys ); /* expanding the wildcard notation with help of the refcase. */ + for (k=0; k < stringlist_get_size( keys ); k++) ensemble_config_add_summary(ensemble_config , stringlist_iget(keys , k) , LOAD_FAIL_SILENT ); stringlist_free( keys ); - } else - util_exit("error: when using summary wildcards like: \"%s\" you must supply a valid refcase.\n",key); - } else + } + } else ensemble_config_add_summary(ensemble_config , key , LOAD_FAIL_SILENT); } } @@ -526,23 +555,23 @@ void ensemble_config_init_SUMMARY( ensemble_config_type * ensemble_config , cons } -void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid) { - const config_content_item_type * item = config_get_content_item( config , FIELD_KEY ); - if (item != NULL) { +void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const config_content_type * config , ecl_grid_type * grid) { + if (config_content_has_item(config , FIELD_KEY)) { + const config_content_item_type * item = config_content_get_item( config , FIELD_KEY ); int i; for (i=0; i < config_content_item_get_size( item ); i++) { const config_content_node_type * node = config_content_item_iget_node( item , i ); const char * key = config_content_node_iget( node , 0 ); const char * var_type_string = config_content_node_iget( node , 1 ); enkf_config_node_type * config_node; - + { hash_type * options = hash_alloc(); - + int truncation = TRUNCATE_NONE; double value_min = -1; double value_max = -1; - + config_content_node_init_opt_hash( node , options , 2 ); if (hash_has_key( options , MIN_KEY)) { truncation |= TRUNCATE_MIN; @@ -553,8 +582,8 @@ void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const truncation |= TRUNCATE_MAX; value_max = atof(hash_get( options , MAX_KEY)); } - - + + if (strcmp(var_type_string , DYNAMIC_KEY) == 0) { config_node = ensemble_config_add_field( ensemble_config , key , grid , false); enkf_config_node_update_state_field( config_node , truncation , value_min , value_max ); @@ -572,14 +601,14 @@ void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string); } config_node = ensemble_config_add_field( ensemble_config , key , grid , forward_init); - enkf_config_node_update_parameter_field( config_node, - ecl_file , - init_file_fmt , - min_std_file , - truncation , - value_min , - value_max , - init_transform , + enkf_config_node_update_parameter_field( config_node, + ecl_file , + init_file_fmt , + min_std_file , + truncation , + value_min , + value_max , + init_transform , output_transform ); } else if (strcmp(var_type_string , GENERAL_KEY) == 0) { /* General - not really interesting .. */ @@ -597,22 +626,22 @@ void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const if (!util_sscanf_bool( forward_string , &forward_init)) fprintf(stderr,"** Warning: parsing %s as bool failed - using FALSE \n",forward_string); } - + config_node = ensemble_config_add_field( ensemble_config , key , grid , forward_init); enkf_config_node_update_general_field( config_node, - ecl_file , - enkf_infile , - init_file_fmt , - min_std_file , - truncation , value_min , value_max , - init_transform , - input_transform , + ecl_file , + enkf_infile , + init_file_fmt , + min_std_file , + truncation , value_min , value_max , + init_transform , + input_transform , output_transform); - - } else + + } else util_abort("%s: field type: %s is not recognized\n",__func__ , var_type_string); - + hash_free( options ); } } @@ -627,32 +656,34 @@ void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const impossible to use wildcards when expanding summary variables. */ -void ensemble_config_init(ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid, const ecl_sum_type * refcase) { +void ensemble_config_init(ensemble_config_type * ensemble_config , const config_content_type * config , ecl_grid_type * grid, const ecl_sum_type * refcase) { int i; ensemble_config_set_refcase( ensemble_config , refcase ); - if (config_item_set( config , GEN_KW_TAG_FORMAT_KEY)) - ensemble_config_set_gen_kw_format( ensemble_config , config_iget( config , GEN_KW_TAG_FORMAT_KEY , 0 , 0 )); - + if (config_content_has_item( config , GEN_KW_TAG_FORMAT_KEY)) { + ensemble_config_set_gen_kw_format( ensemble_config , config_content_iget( config , GEN_KW_TAG_FORMAT_KEY , 0 , 0 )); + } + ensemble_config_init_GEN_PARAM( ensemble_config , config ); ensemble_config_init_GEN_DATA( ensemble_config , config ); - ensemble_config_init_GEN_KW(ensemble_config , config ); + ensemble_config_init_CUSTOM_KW(ensemble_config, config); + ensemble_config_init_GEN_KW(ensemble_config , config ); ensemble_config_init_SURFACE( ensemble_config , config ); - + ensemble_config_init_SUMMARY( ensemble_config , config , refcase ); - + ensemble_config_init_FIELD( ensemble_config , config , grid ); - - + + /* Containers - this must come last, to ensure that the other nodes have been added. */ { - for (i=0; i < config_get_occurences(config , CONTAINER_KEY ); i++) { - const stringlist_type * container_kw_list = config_iget_stringlist_ref(config , CONTAINER_KEY , i); + for (i=0; i < config_content_get_occurences(config , CONTAINER_KEY ); i++) { + const stringlist_type * container_kw_list = config_content_iget_stringlist_ref(config , CONTAINER_KEY , i); const char * container_key = stringlist_iget( container_kw_list , 0 ); enkf_config_node_type * container_node = ensemble_config_add_container( ensemble_config , container_key ); - + for (int j= 1; j < stringlist_get_size( container_kw_list ); j++) { - const char * child_key = stringlist_iget( container_kw_list , j); + const char * child_key = stringlist_iget( container_kw_list , j); enkf_config_node_update_container( container_node , ensemble_config_get_node( ensemble_config , child_key )); } } @@ -675,7 +706,6 @@ void ensemble_config_init(ensemble_config_type * ensemble_config , const config_ will be NULL, that also applies if no object is found. */ - const enkf_config_node_type * ensemble_config_user_get_node(const ensemble_config_type * config , const char * full_key, char ** index_key ) { const enkf_config_node_type * node = NULL; @@ -683,7 +713,7 @@ const enkf_config_node_type * ensemble_config_user_get_node(const ensemble_confi int keys; int key_length = 1; int offset; - + *index_key = NULL; util_split_string(full_key , USER_KEY_JOIN_STRING , &keys , &key_list); while (node == NULL && key_length <= keys) { @@ -699,7 +729,7 @@ const enkf_config_node_type * ensemble_config_user_get_node(const ensemble_confi if (offset < strlen( full_key )) *index_key = util_alloc_string_copy(&full_key[offset+1]); } - + util_free_stringlist(key_list , keys); return node; } @@ -718,7 +748,7 @@ stringlist_type * ensemble_config_alloc_keylist(const ensemble_config_type * con ensemble_config_alloc_keylist_from_var_type( config , parameter + dynamic_state); */ - + stringlist_type * ensemble_config_alloc_keylist_from_var_type(const ensemble_config_type * config , int var_mask) { stringlist_type * key_list = stringlist_alloc_new(); hash_iter_type * iter = hash_iter_alloc(config->config_nodes); @@ -726,7 +756,7 @@ stringlist_type * ensemble_config_alloc_keylist_from_var_type(const ensemble_con while (!hash_iter_is_complete( iter )) { const char * key = hash_iter_get_next_key(iter); enkf_var_type var_type = enkf_config_node_get_var_type( hash_get(config->config_nodes , key)); - + if (var_type & var_mask) stringlist_append_copy( key_list , key ); } @@ -752,17 +782,17 @@ stringlist_type * ensemble_config_alloc_keylist_from_impl_type(const ensemble_co bool ensemble_config_has_impl_type(const ensemble_config_type * config, const ert_impl_type impl_type) { - bool ret = false; + bool ret = false; hash_iter_type * iter = hash_iter_alloc(config->config_nodes); while (!hash_iter_is_complete( iter )) { const char * key = hash_iter_get_next_key(iter); if (enkf_config_node_get_impl_type( hash_get(config->config_nodes , key)) == impl_type) { - ret = true; - break; + ret = true; + break; } } hash_iter_free(iter); - return ret; + return ret; } @@ -783,7 +813,7 @@ int ensemble_config_get_observations( const ensemble_config_type * config , enkf if (config_node != NULL) { num_obs = enkf_config_node_load_obs( config_node , enkf_obs , index_key , obs_count , obs_time , y , std); util_safe_free( index_key ); - } + } return num_obs; } @@ -791,7 +821,7 @@ int ensemble_config_get_observations( const ensemble_config_type * config , enkf /*****************************************************************/ -/* +/* the ensemble_config_add_xxx() functions below will create a new xxx instance and add it to the ensemble_config; the return value from the functions is the newly created config_node instances. @@ -814,13 +844,36 @@ enkf_config_node_type * ensemble_config_add_gen_kw( ensemble_config_type * confi return config_node; } +enkf_config_node_type * ensemble_config_add_custom_kw(ensemble_config_type * config, const char * key, const char * result_file, const char * output_file) { + enkf_config_node_type * config_node = enkf_config_node_new_custom_kw(key, result_file, output_file); + ensemble_config_add_node(config, config_node); + return config_node; +} + +void ensemble_config_update_custom_kw_config(ensemble_config_type * config, custom_kw_config_set_type * config_set) { + stringlist_type * keys = custom_kw_config_set_get_keys_alloc(config_set); + + for(int i = 0; i < stringlist_get_size(keys); i++) { + const char * key = stringlist_iget(keys, i); + if(!ensemble_config_has_key(config, key)) { + ensemble_config_add_custom_kw(config, key, NULL, NULL); + printf("[%s] CustomKW key: '%s' not in ensemble! Adding from storage.\n", __func__, key); + } + + enkf_config_node_type * config_node = ensemble_config_get_node(config, key); + custom_kw_config_type * custom_kw_config = (custom_kw_config_type*) enkf_config_node_get_ref(config_node); + + custom_kw_config_set_update_config(config_set, custom_kw_config); + } + stringlist_free(keys); +} /** this function ensures that object contains a node with 'key' and type == summary. - + if the @refcase pointer is different from NULL the key will be validated. keys which do not exist in the refcase will be ignored, a warning will be printed on stderr and the function will return @@ -832,23 +885,29 @@ enkf_config_node_type * ensemble_config_add_summary(ensemble_config_type * ensem if (hash_has_key(ensemble_config->config_nodes, key)) { config_node = hash_get(ensemble_config->config_nodes, key); - if (enkf_config_node_get_impl_type( config_node ) != SUMMARY) + if (enkf_config_node_get_impl_type( config_node ) != SUMMARY) { util_abort("%s: ensemble key:%s already exists - but it is not of summary type\n",__func__ , key); - { - summary_config_type * summary_config = enkf_config_node_get_ref( config_node ); - summary_config_update_load_fail_mode( summary_config , load_fail ); } + + summary_config_type * summary_config = enkf_config_node_get_ref( config_node ); + summary_config_update_load_fail_mode( summary_config , load_fail ); + } else { - if ((ensemble_config->refcase == NULL) || (ecl_sum_has_general_var( ensemble_config->refcase , key ))) { - config_node = enkf_config_node_alloc_summary( key , load_fail); - ensemble_config_add_node(ensemble_config , config_node ); - } else - fprintf(stderr,"** warning: the refcase:%s does not contain the summary key:\"%s\" - will be ignored.\n", ecl_sum_get_case( ensemble_config->refcase ) , key); + config_node = enkf_config_node_alloc_summary( key , load_fail); + ensemble_config_add_node(ensemble_config , config_node ); } return config_node; } +enkf_config_node_type * ensemble_config_add_summary_observation(ensemble_config_type * ensemble_config , const char * key , load_fail_type load_fail) { + enkf_config_node_type * config_node = ensemble_config_add_summary(ensemble_config, key, load_fail); + + summary_key_matcher_add_summary_key(ensemble_config->summary_key_matcher, key); + + return config_node; +} + enkf_config_node_type * ensemble_config_add_surface( ensemble_config_type * ensemble_config , const char * key , bool forward_init) { enkf_config_node_type * config_node = enkf_config_node_new_surface( key , forward_init ); @@ -865,9 +924,9 @@ enkf_config_node_type * ensemble_config_add_container( ensemble_config_type * en bool random_key = false; if (key == NULL) { local_key = util_calloc( 11 , sizeof * local_key ); - sprintf(local_key , "%ld" , random() % 10000000 ); + sprintf(local_key , "%ld" , random() % 10000000 ); random_key = true; - } + } { enkf_config_node_type * config_node = enkf_config_node_new_container( local_key ); @@ -879,7 +938,9 @@ enkf_config_node_type * ensemble_config_add_container( ensemble_config_type * en } - +const summary_key_matcher_type * ensemble_config_get_summary_key_matcher(const ensemble_config_type * ensemble_config) { + return ensemble_config->summary_key_matcher; +} /*****************************************************************/ @@ -904,7 +965,7 @@ void ensemble_config_fprintf_config( ensemble_config_type * ensemble_config , FI stringlist_free( gen_kw_keys ); } - + /* Writing FIELD nodes. */ { stringlist_type * field_keys = ensemble_config_alloc_keylist_from_impl_type( ensemble_config , FIELD ); @@ -936,7 +997,7 @@ void ensemble_config_fprintf_config( ensemble_config_type * ensemble_config , FI stringlist_free( summary_keys ); } fprintf(stream , "\n"); - + /* Writing GEN_DATA nodes. */ { @@ -950,3 +1011,9 @@ void ensemble_config_fprintf_config( ensemble_config_type * ensemble_config , FI } fprintf(stream , "\n\n"); } + + + +int ensemble_config_get_size(const ensemble_config_type * ensemble_config ) { + return hash_get_size( ensemble_config->config_nodes ); +} diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c b/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c index 1acd29813c..d00995fc54 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_report_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_report_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -26,7 +26,7 @@ #include <ert/util/vector.h> #include <ert/util/subst_list.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/ecl/ecl_sum.h> @@ -37,7 +37,7 @@ #define WELL_LIST_TAG "$WELL_LIST" #define GROUP_LIST_TAG "$GROUP_LIST" -#define PLOT_CASE_TAG "$PLOT_CASE" +#define PLOT_CASE_TAG "$PLOT_CASE" #define USER_TAG "$USER" #define CONFIG_FILE_TAG "$CONFIG_FILE" @@ -67,7 +67,7 @@ int ert_report_list_get_latex_timeout( const ert_report_list_type * report_list static void ert_report_list_init_large_report( ert_report_list_type * report_list ) { if (report_list->init_large_report) { - printf("Running script \'fmtutil --all\' to regenerate pdflatex config information ..... "); + printf("Running script \'fmtutil --all\' to regenerate pdflatex config information ..... "); fflush(stdout); util_fork_exec("fmtutil" , 1 , (const char *[1]) {"--all"} , true , NULL , NULL , NULL , "/dev/null" , "/dev/null"); printf("\n"); @@ -163,7 +163,7 @@ bool ert_report_list_add_report( ert_report_list_type * report_list , const char } -void ert_report_list_free( ert_report_list_type * report_list ){ +void ert_report_list_free( ert_report_list_type * report_list ){ stringlist_free( report_list->path_list ); stringlist_free( report_list->group_list ); stringlist_free( report_list->well_list ); @@ -234,7 +234,7 @@ void ert_report_list_create( ert_report_list_type * report_list , const char * c ert_report_list_init_large_report( report_list ); for (int ir = 0; ir < vector_get_size( report_list->report_list ); ir++) { ert_report_type * ert_report = vector_iget( report_list->report_list , ir); - + if (verbose) { printf("Creating report: %s/%s.pdf [Work-path:%s] ....... " , target_path , ert_report_get_basename( ert_report ) , ert_report_get_work_path( ert_report )); fflush( stdout ); @@ -252,80 +252,80 @@ void ert_report_list_create( ert_report_list_type * report_list , const char * c } -void ert_report_list_site_init( ert_report_list_type * report_list , config_type * config ) { +void ert_report_list_site_init( ert_report_list_type * report_list , config_content_type * content ) { /* Installing the directories to search in. */ - for (int i=0; i < config_get_occurences( config , REPORT_SEARCH_PATH_KEY ); i++) { - const stringlist_type * path_list = config_iget_stringlist_ref( config , REPORT_SEARCH_PATH_KEY , i); - for (int j=0; j < stringlist_get_size( path_list ); j++) + for (int i=0; i < config_content_get_occurences( content , REPORT_SEARCH_PATH_KEY ); i++) { + const stringlist_type * path_list = config_content_iget_stringlist_ref( content , REPORT_SEARCH_PATH_KEY , i); + for (int j=0; j < stringlist_get_size( path_list ); j++) ert_report_list_add_path( report_list , stringlist_iget( path_list , j )); } } -void ert_report_list_init( ert_report_list_type * report_list , config_type * config , const ecl_sum_type * refcase) { +void ert_report_list_init( ert_report_list_type * report_list , config_content_type * config , const ecl_sum_type * refcase) { ert_report_list_site_init( report_list , config ); - if (config_item_set( config , REPORT_LARGE_KEY)) - ert_report_list_set_large_report(report_list , config_get_value_as_bool( config , REPORT_LARGE_KEY )); - - if (config_item_set( config , REPORT_TIMEOUT_KEY)) - ert_report_list_set_latex_timeout( report_list , config_get_value_as_int( config , REPORT_TIMEOUT_KEY )); - + if (config_content_has_item( config , REPORT_LARGE_KEY)) + ert_report_list_set_large_report(report_list , config_content_get_value_as_bool( config , REPORT_LARGE_KEY )); + + if (config_content_has_item( config , REPORT_TIMEOUT_KEY)) + ert_report_list_set_latex_timeout( report_list , config_content_get_value_as_int( config , REPORT_TIMEOUT_KEY )); + /* Installing the list of reports. */ - for (int i=0; i < config_get_occurences( config , REPORT_LIST_KEY ); i++) { - const stringlist_type * list = config_iget_stringlist_ref( config , REPORT_LIST_KEY , i); + for (int i=0; i < config_content_get_occurences( config , REPORT_LIST_KEY ); i++) { + const stringlist_type * list = config_content_iget_stringlist_ref( config , REPORT_LIST_KEY , i); for (int j=0; j < stringlist_get_size( list ); j++) { if (!ert_report_list_add_report( report_list , stringlist_iget( list , j ))) fprintf(stderr,"** Warning: Could not find report template:%s - ignored\n", stringlist_iget( list , j )); } } - + /* Installing the list of report wells */ - for (int i=0; i < config_get_occurences( config , REPORT_WELL_LIST_KEY ); i++) { - const stringlist_type * well_list = config_iget_stringlist_ref( config , REPORT_WELL_LIST_KEY , i); - for (int j=0; j < stringlist_get_size( well_list ); j++) + for (int i=0; i < config_content_get_occurences( config , REPORT_WELL_LIST_KEY ); i++) { + const stringlist_type * well_list = config_content_iget_stringlist_ref( config , REPORT_WELL_LIST_KEY , i); + for (int j=0; j < stringlist_get_size( well_list ); j++) ert_report_list_add_wells( report_list , refcase , stringlist_iget( well_list , j )); - } - + } + /* Installing the list of report groups */ - for (int i=0; i < config_get_occurences( config , REPORT_GROUP_LIST_KEY ); i++) { - const stringlist_type * group_list = config_iget_stringlist_ref( config , REPORT_GROUP_LIST_KEY , i); - for (int j=0; j < stringlist_get_size( group_list ); j++) + for (int i=0; i < config_content_get_occurences( config , REPORT_GROUP_LIST_KEY ); i++) { + const stringlist_type * group_list = config_content_iget_stringlist_ref( config , REPORT_GROUP_LIST_KEY , i); + for (int j=0; j < stringlist_get_size( group_list ); j++) ert_report_list_add_groups( report_list , refcase , stringlist_iget( group_list , j )); - } - + } + /* Installing arbitrary context keys. */ - for (int i=0; i < config_get_occurences( config , REPORT_CONTEXT_KEY ); i++) { - const char * key = config_iget( config , REPORT_CONTEXT_KEY , i , 0 ); - const char * value = config_iget( config , REPORT_CONTEXT_KEY , i , 1 ); + for (int i=0; i < config_content_get_occurences( config , REPORT_CONTEXT_KEY ); i++) { + const char * key = config_content_iget( config , REPORT_CONTEXT_KEY , i , 0 ); + const char * value = config_content_iget( config , REPORT_CONTEXT_KEY , i , 1 ); ert_report_list_add_global_context( report_list , key , value ); - } - + } + /* Installing the target path for reports*/ - if (config_item_set(config , REPORT_PATH_KEY)) - ert_report_list_set_target_path( report_list , config_iget( config , REPORT_PATH_KEY , 0 , 0)); + if (config_content_has_item(config , REPORT_PATH_KEY)) + ert_report_list_set_target_path( report_list , config_content_iget( config , REPORT_PATH_KEY , 0 , 0)); - ert_report_list_add_global_context( report_list , CONFIG_FILE_TAG , config_get_config_file( config , true )); + ert_report_list_add_global_context( report_list , CONFIG_FILE_TAG , config_content_get_config_file( config , true )); ert_report_list_add_global_context( report_list , USER_TAG , getenv("USER")); } -void ert_report_list_add_config_items( config_type * config ) { +void ert_report_list_add_config_items( config_parser_type * config ) { config_schema_item_type * item; - + item = config_add_schema_item(config , REPORT_LIST_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); item = config_add_schema_item(config , REPORT_CONTEXT_KEY , false ); config_schema_item_set_argc_minmax(item , 2 , 2); - + item = config_add_schema_item(config , REPORT_PATH_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1); item = config_add_schema_item( config , REPORT_WELL_LIST_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); - + item = config_add_schema_item( config , REPORT_GROUP_LIST_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_run_context.c b/ThirdParty/Ert/devel/libenkf/src/ert_run_context.c index 3dda7c8317..4ad919df74 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_run_context.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_run_context.c @@ -156,10 +156,9 @@ static ert_run_context_type * ert_run_context_alloc(const bool_vector_type * iac context->run_mode = run_mode; context->init_mode = init_mode; context->iter = iter; - - context->init_fs = init_fs; - context->result_fs = result_fs; - context->update_target_fs = update_target_fs; + ert_run_context_set_init_fs(context, init_fs); + ert_run_context_set_result_fs(context, result_fs); + ert_run_context_set_update_target_fs(context, update_target_fs); context->step1 = 0; context->step2 = 0; @@ -266,6 +265,14 @@ UTIL_IS_INSTANCE_FUNCTION( ert_run_context , ERT_RUN_CONTEXT_TYPE_ID ); void ert_run_context_free( ert_run_context_type * context ) { + if (context->result_fs) { + enkf_fs_decrease_write_count(context->result_fs); + } + + if (context->update_target_fs) { + enkf_fs_decrease_write_count(context->update_target_fs); + } + vector_free( context->run_args ); bool_vector_free( context->iactive ); int_vector_free( context->iens_map ); @@ -359,5 +366,22 @@ enkf_fs_type * ert_run_context_get_update_target_fs(const ert_run_context_type * } } +void ert_run_context_set_init_fs(ert_run_context_type * context, enkf_fs_type * init_fs) { + context->init_fs = (init_fs) ? init_fs : NULL; +} +void ert_run_context_set_result_fs(ert_run_context_type * context, enkf_fs_type * result_fs) { + if (result_fs) { + context->result_fs = result_fs; + enkf_fs_increase_write_count(result_fs); + } else + context->result_fs = NULL; +} +void ert_run_context_set_update_target_fs(ert_run_context_type * context, enkf_fs_type * update_target_fs) { + if (update_target_fs) { + context->update_target_fs = update_target_fs; + enkf_fs_increase_write_count(update_target_fs); + } else + context->update_target_fs = NULL; +} diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_template.c b/ThirdParty/Ert/devel/libenkf/src/ert_template.c index db02b383c4..408ebe6820 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_template.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_template.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ert_template.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ert_template.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> #include <stdlib.h> @@ -43,7 +43,7 @@ struct ert_template_struct { /* Plural - many templates. */ struct ert_templates_struct { UTIL_TYPE_ID_DECLARATION; - subst_list_type * parent_subst; + subst_list_type * parent_subst; hash_type * templates; }; @@ -77,9 +77,9 @@ ert_template_type * ert_template_alloc( const char * template_file , const char ert_template_type * template = util_malloc( sizeof * template); UTIL_TYPE_ID_INIT(template , ERT_TEMPLATE_TYPE_ID); template->template = template_alloc( template_file , false , parent_subst); /* The templates are instantiated with internalize_template == false; - this means that substitutions are performed on the filename of the + this means that substitutions are performed on the filename of the template itself .*/ - + template->target_file = NULL; ert_template_set_target_file( template , target_file ); return template; @@ -111,7 +111,7 @@ void ert_template_set_args_from_string( ert_template_type * template, const char UTIL_SAFE_CAST_FUNCTION( ert_template , ERT_TEMPLATE_TYPE_ID ) - + void ert_template_free__(void * arg) { ert_template_free( ert_template_safe_cast( arg )); } @@ -138,7 +138,7 @@ ert_templates_type * ert_templates_alloc( subst_list_type * parent_subst ) { ert_templates_type * templates = util_malloc( sizeof * templates ); UTIL_TYPE_ID_INIT( templates , ERT_TEMPLATES_TYPE_ID ); templates->templates = hash_alloc(); - templates->parent_subst = parent_subst; + templates->parent_subst = parent_subst; return templates; } @@ -157,14 +157,14 @@ void ert_templates_del_template( ert_templates_type * ert_templates , const char ert_template_type * ert_templates_add_template( ert_templates_type * ert_templates , const char * key , const char * template_file , const char * target_file, const char * arg_string) { ert_template_type * template = ert_template_alloc( template_file , target_file , ert_templates->parent_subst); ert_template_set_args_from_string( template , arg_string ); /* Arg_string can be NULL */ - - /** + + /** If key == NULL the function will generate a key after the following algorithm: 1. It tries with the basename of the template file. 2. It tries with the basename of the template file, and a counter. */ - + if (key == NULL) { char * new_key = NULL; char * base_name; @@ -211,26 +211,26 @@ stringlist_type * ert_templates_alloc_list( ert_templates_type * ert_templates) } -void ert_templates_init( ert_templates_type * templates , const config_type * config ) { - const config_content_item_type * template_item = config_get_content_item( config , RUN_TEMPLATE_KEY ); - if (template_item != NULL) { +void ert_templates_init( ert_templates_type * templates , const config_content_type * config ) { + if (config_content_has_item( config , RUN_TEMPLATE_KEY)) { + const config_content_item_type * template_item = config_content_get_item( config , RUN_TEMPLATE_KEY ); for (int i=0; i < config_content_item_get_size( template_item ); i++) { config_content_node_type * template_node = config_content_item_iget_node( template_item , i ); - const char * template_file = config_content_node_iget_as_path(template_node , 0 ); + const char * template_file = config_content_node_iget_as_path(template_node , 0 ); const char * target_file = config_content_node_iget( template_node , 1 ); - + ert_template_type * template = ert_templates_add_template( templates , NULL , template_file , target_file , NULL); - + for (int iarg = 2; iarg < config_content_node_get_size( template_node ); iarg++) { char * key , *value; const char * key_value = config_content_node_iget( template_node , iarg ); util_binary_split_string( key_value , "=:" , true , &key , &value); - - if (value != NULL) + + if (value != NULL) ert_template_add_arg( template ,key , value ); else - fprintf(stderr,"** Warning - failed to parse argument:%s as key:value - ignored \n",config_iget( config , "RUN_TEMPLATE" , i , iarg )); - + fprintf(stderr,"** Warning - failed to parse argument:%s as key:value - ignored \n",config_content_iget( config , "RUN_TEMPLATE" , i , iarg )); + free( key ); util_safe_free( value ); } @@ -243,7 +243,7 @@ void ert_templates_fprintf_config( const ert_templates_type * ert_templates , FI if (hash_get_size( ert_templates->templates ) > 0 ) { fprintf( stream , CONFIG_COMMENTLINE_FORMAT ); fprintf( stream , CONFIG_COMMENT_FORMAT , "Here comes configuration information about RUN-TIME templates instantiated by ERT."); - + { hash_iter_type * iter = hash_iter_alloc( ert_templates->templates ); while( !hash_iter_is_complete( iter )) { diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_test_context.c b/ThirdParty/Ert/devel/libenkf/src/ert_test_context.c index 15a0fe3c74..faeac2f0b3 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_test_context.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_test_context.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'ert_test_context.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ert_test_context.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -42,13 +42,13 @@ struct ert_test_context_struct { UTIL_IS_INSTANCE_FUNCTION( ert_test_context , ERT_TEST_CONTEXT_TYPE_ID ) -static ert_test_context_type * ert_test_context_alloc__( const char * test_name , const char * model_config , const char * site_config, bool python_mode) { +static ert_test_context_type * ert_test_context_alloc__( const char * test_name , const char * model_config , bool python_mode) { ert_test_context_type * test_context = util_malloc( sizeof * test_context ); UTIL_TYPE_ID_INIT( test_context , ERT_TEST_CONTEXT_TYPE_ID ); /* This environment variable is set to ensure that test context will - parse the correct files when loading site config. + parse the correct files when loading site config. */ if (python_mode) setenv("ERT_UI_MODE" , "gui" , 1); @@ -62,7 +62,7 @@ static ert_test_context_type * ert_test_context_alloc__( const char * test_name test_work_area_copy_parent_content(test_context->work_area , model_config ); { char * config_file = util_split_alloc_filename( model_config ); - test_context->enkf_main = enkf_main_bootstrap( site_config , config_file , true , false ); + test_context->enkf_main = enkf_main_bootstrap(config_file , true , false ); free( config_file ); } test_context->rng = rng_alloc( MZRAN , INIT_DEV_URANDOM ); @@ -74,13 +74,13 @@ static ert_test_context_type * ert_test_context_alloc__( const char * test_name return test_context; } -ert_test_context_type * ert_test_context_alloc( const char * test_name , const char * model_config , const char * site_config) { - return ert_test_context_alloc__( test_name , model_config , site_config , false ); +ert_test_context_type * ert_test_context_alloc( const char * test_name , const char * model_config) { + return ert_test_context_alloc__( test_name , model_config , false ); } -ert_test_context_type * ert_test_context_alloc_python( const char * test_name , const char * model_config , const char * site_config) { - return ert_test_context_alloc__( test_name , model_config , site_config , true ); +ert_test_context_type * ert_test_context_alloc_python( const char * test_name , const char * model_config) { + return ert_test_context_alloc__( test_name , model_config , true ); } @@ -100,10 +100,10 @@ void ert_test_context_free( ert_test_context_type * test_context ) { if (test_context->enkf_main) enkf_main_free( test_context->enkf_main ); - + if (test_context->work_area) test_work_area_free( test_context->work_area ); - + if (test_context->rng) rng_free( test_context->rng ); @@ -152,7 +152,7 @@ bool ert_test_context_run_worklow( ert_test_context_type * test_context , const return false; } } - + bool ert_test_context_run_worklow_job( ert_test_context_type * test_context , const char * job_name, const stringlist_type * args) { diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c b/ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c index f79eee6f94..e622ea51ba 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_workflow_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_workflow_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -29,7 +29,7 @@ #include <ert/util/subst_list.h> #include <ert/util/type_macros.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_error.h> #include <ert/config/config_schema_item.h> @@ -99,17 +99,17 @@ workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflo workflow_type * workflow = workflow_alloc( workflow_file , workflow_list->joblist ); char * name; - if (workflow_name == NULL) + if (workflow_name == NULL) util_alloc_file_components( workflow_file , NULL , &name , NULL ); - else + else name = (char *) workflow_name; - hash_insert_hash_owned_ref( workflow_list->workflows , name , workflow , workflow_free__); + hash_insert_hash_owned_ref( workflow_list->workflows , name , workflow , workflow_free__); if (hash_has_key( workflow_list->alias_map , name)) hash_del( workflow_list->alias_map , name); - if (workflow_name == NULL) + if (workflow_name == NULL) free( name ); return workflow; @@ -120,7 +120,7 @@ workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflo void ert_workflow_list_add_alias( ert_workflow_list_type * workflow_list , const char * real_name , const char * alias) { - if (!util_string_equal( real_name , alias)) + if (!util_string_equal( real_name , alias)) hash_insert_ref( workflow_list->alias_map , alias , real_name ); } @@ -128,13 +128,13 @@ void ert_workflow_list_add_alias( ert_workflow_list_type * workflow_list , const void ert_workflow_list_add_job( ert_workflow_list_type * workflow_list , const char * job_name , const char * config_file ) { char * name = (char *) job_name; - if (job_name == NULL) + if (job_name == NULL) util_alloc_file_components( config_file , NULL , &name , NULL ); - - if (!workflow_joblist_add_job_from_file( workflow_list->joblist , name , config_file )) + + if (!workflow_joblist_add_job_from_file( workflow_list->joblist , name , config_file )) fprintf(stderr,"** Warning: failed to add workflow job:%s from:%s \n",name , config_file ); - if (job_name == NULL) + if (job_name == NULL) free(name); } @@ -156,17 +156,17 @@ void ert_workflow_list_add_jobs_in_directory( ert_workflow_list_type * workflow_ if (entry != NULL) { if ((strcmp(entry->d_name , ".") != 0) && (strcmp(entry->d_name , "..") != 0)) { char * full_path = util_alloc_filename( path , entry->d_name , NULL ); - + if (util_is_file( full_path )) { if (ert_log_is_open()) ert_log_add_message( 1 , NULL , util_alloc_sprintf("Adding workflow job:%s " , full_path ), true); ert_workflow_list_add_job( workflow_list , entry->d_name , full_path ); } - + free( full_path ); } - } else + } else break; } closedir( dirH ); @@ -175,23 +175,28 @@ void ert_workflow_list_add_jobs_in_directory( ert_workflow_list_type * workflow_ } -void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_type * config ) { +stringlist_type * ert_workflow_list_get_job_names(const ert_workflow_list_type * workflow_list) { + return workflow_joblist_get_job_names(workflow_list->joblist); +} + + +void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_content_type * config ) { /* Adding jobs */ { - const config_content_item_type * jobpath_item = config_get_content_item( config , WORKFLOW_JOB_DIRECTORY_KEY); - if (jobpath_item != NULL) { + if (config_content_has_item( config , WORKFLOW_JOB_DIRECTORY_KEY)) { + const config_content_item_type * jobpath_item = config_content_get_item( config , WORKFLOW_JOB_DIRECTORY_KEY); for (int i=0; i < config_content_item_get_size( jobpath_item ); i++) { config_content_node_type * path_node = config_content_item_iget_node( jobpath_item , i ); - - for (int j=0; j < config_content_node_get_size( path_node ); j++) + + for (int j=0; j < config_content_node_get_size( path_node ); j++) ert_workflow_list_add_jobs_in_directory( workflow_list , config_content_node_iget_as_abspath( path_node , j ) ); } } } - + { - const config_content_item_type * job_item = config_get_content_item( config , LOAD_WORKFLOW_JOB_KEY); - if (job_item != NULL) { + if (config_content_has_item( config , LOAD_WORKFLOW_JOB_KEY)) { + const config_content_item_type * job_item = config_content_get_item( config , LOAD_WORKFLOW_JOB_KEY); for (int i=0; i < config_content_item_get_size( job_item ); i++) { config_content_node_type * job_node = config_content_item_iget_node( job_item , i ); const char * config_file = config_content_node_iget_as_path( job_node , 0 ); @@ -200,18 +205,17 @@ void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_typ } } } - + /* Adding workflows */ { - const config_content_item_type * workflow_item = config_get_content_item( config , LOAD_WORKFLOW_KEY); - - if (workflow_item != NULL) { + if (config_content_has_item( config , LOAD_WORKFLOW_KEY)) { + const config_content_item_type * workflow_item = config_content_get_item( config , LOAD_WORKFLOW_KEY); for (int i=0; i < config_content_item_get_size( workflow_item ); i++) { config_content_node_type * workflow_node = config_content_item_iget_node( workflow_item , i ); const char * workflow_file = config_content_node_iget_as_path( workflow_node , 0 ); const char * workflow_name = config_content_node_safe_iget( workflow_node , 1 ); - + ert_workflow_list_add_workflow( workflow_list , workflow_file , workflow_name ); } } @@ -219,7 +223,7 @@ void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_typ } -void ert_workflow_list_add_config_items( config_type * config ) { +void ert_workflow_list_add_config_items( config_parser_type * config ) { config_schema_item_type * item = config_add_schema_item( config , WORKFLOW_JOB_DIRECTORY_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); config_schema_item_iset_type( item , 0 , CONFIG_PATH ); @@ -227,7 +231,7 @@ void ert_workflow_list_add_config_items( config_type * config ) { item = config_add_schema_item( config , LOAD_WORKFLOW_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 2 ); config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - + item = config_add_schema_item( config , LOAD_WORKFLOW_JOB_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 2 ); config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); @@ -245,8 +249,8 @@ workflow_type * ert_workflow_list_get_workflow(ert_workflow_list_type * workflo } bool ert_workflow_list_has_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name ) { - return - hash_has_key( workflow_list->workflows , workflow_name ) || + return + hash_has_key( workflow_list->workflows , workflow_name ) || hash_has_key( workflow_list->alias_map , workflow_name); } diff --git a/ThirdParty/Ert/devel/libenkf/src/field_config.c b/ThirdParty/Ert/devel/libenkf/src/field_config.c index 9153ad4b48..ef6f9eaa28 100644 --- a/ThirdParty/Ert/devel/libenkf/src/field_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/field_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'field_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'field_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -26,6 +26,7 @@ #include <ert/ecl/ecl_grid.h> #include <ert/ecl/ecl_kw.h> #include <ert/ecl/ecl_util.h> +#include <ert/ecl/ecl_endian_flip.h> #include <ert/rms/rms_file.h> #include <ert/rms/rms_util.h> @@ -130,7 +131,7 @@ struct field_config_struct { bool keep_inactive_cells; /* Whether the data contains only active cells or active and inactive cells */ ecl_grid_type * grid; /* A shared reference to the grid this field is defined on. */ bool private_grid; - + int truncation; /* How the field should be trunacted before exporting for simulation, and for the inital import. OR'd combination of truncation_type from enkf_types.h*/ double min_value; /* The min value used in truncation. */ double max_value; /* The maximum value used in truncation. */ @@ -141,7 +142,7 @@ struct field_config_struct { ecl_type_enum internal_ecl_type; ecl_type_enum export_ecl_type; bool __enkf_mode; /* See doc of functions field_config_set_key() / field_config_enkf_OFF() */ - bool write_compressed; + bool write_compressed; field_type_enum type; field_type * min_std; @@ -150,7 +151,7 @@ struct field_config_struct { field_func_type * output_transform; /* Function to apply to the data before they are exported - NULL: no transform. */ field_func_type * init_transform; /* Function to apply on the data when they are loaded the first time - i.e. initialized. NULL : no transform*/ field_func_type * input_transform; /* Function to apply on the data when they are loaded from the forward model - i.e. for dynamic data. */ - + char * output_transform_name; char * init_transform_name; char * input_transform_name; @@ -254,7 +255,7 @@ field_file_format_type field_config_default_export_format(const char * filename) used IMPORT must be used in the datafile instead of INCLUDE. This gives faster ECLIPSE startup time, but is (unfortunately) quite unstandard. */ - + char * extension; util_alloc_file_components(filename , NULL,NULL,&extension); if (extension != NULL) { @@ -263,10 +264,10 @@ field_file_format_type field_config_default_export_format(const char * filename) export_format = ECL_GRDECL_FILE; else if (strcmp(extension , "ROFF") == 0) export_format = RMS_ROFF_FILE; - + free(extension); } - + } return export_format; } @@ -333,9 +334,10 @@ file. It can determine the following three types of files: field_file_format_type field_config_guess_file_type(const char * filename ) { bool fmt_file = util_fmt_bit8(filename ); FILE * stream = util_fopen(filename , "r"); - + fortio_type * fortio = fortio_alloc_FILE_wrapper(NULL , ECL_ENDIAN_FLIP , fmt_file , false , stream); field_file_format_type file_type; - if (ecl_kw_is_kw_file(stream , fmt_file )) + + if (ecl_kw_is_kw_file(fortio)) file_type = ECL_KW_FILE; else if (rms_file_is_roff(stream)) file_type = RMS_ROFF_FILE; @@ -344,6 +346,7 @@ field_file_format_type field_config_guess_file_type(const char * filename ) { else file_type = UNDEFINED_FORMAT; /* MUST Check on this return value */ + fortio_free_FILE_wrapper( fortio ); fclose(stream); return file_type; } @@ -352,7 +355,7 @@ field_file_format_type field_config_guess_file_type(const char * filename ) { field_type * field_config_get_min_std( const field_config_type * field_config ) { return field_config->min_std; -} +} field_file_format_type field_config_get_export_format(const field_config_type * field_config) { @@ -397,7 +400,7 @@ const char * field_config_get_output_transform_name( const field_config_type * f void field_config_set_grid(field_config_type * config, ecl_grid_type * grid , bool private_grid) { if ((config->private_grid) && (config->grid != NULL)) ecl_grid_free( config->grid ); - + config->grid = grid; config->private_grid = private_grid; @@ -415,13 +418,13 @@ const char * field_config_get_grid_name( const field_config_type * config) { /* - The return value from this function is hardly usable. + The return value from this function is hardly usable. */ field_config_type * field_config_alloc_empty( const char * ecl_kw_name , ecl_grid_type * ecl_grid , field_trans_table_type * trans_table, bool keep_inactive_cells ) { field_config_type * config = util_malloc(sizeof *config); UTIL_TYPE_ID_INIT( config , FIELD_CONFIG_ID); - + config->keep_inactive_cells = keep_inactive_cells; config->ecl_kw_name = util_alloc_string_copy( ecl_kw_name ); config->private_grid = false; @@ -435,25 +438,25 @@ field_config_type * field_config_alloc_empty( const char * ecl_kw_name , ecl_gri config->output_transform_name = NULL; config->input_transform_name = NULL; config->init_transform_name = NULL; - + config->truncation = TRUNCATE_NONE; config->min_std = NULL; config->trans_table = trans_table; - + field_config_set_grid(config , ecl_grid , false); /* The grid is (currently) set on allocation and can NOT be updated afterwards. */ field_config_set_ecl_type( config , ECL_FLOAT_TYPE ); /* This is the internal type - currently not exported any API to change it. */ return config; } - + static void field_config_set_init_transform( field_config_type * config , const char * __init_transform_name ) { const char * init_transform_name = NULL; - if (field_trans_table_has_key( config->trans_table , __init_transform_name)) + if (field_trans_table_has_key( config->trans_table , __init_transform_name)) init_transform_name = __init_transform_name; - - + + config->init_transform_name = util_realloc_string_copy( config->init_transform_name , init_transform_name ); if (init_transform_name != NULL) config->init_transform = field_trans_table_lookup( config->trans_table , init_transform_name); @@ -464,10 +467,10 @@ static void field_config_set_init_transform( field_config_type * config , const static void field_config_set_output_transform( field_config_type * config , const char * __output_transform_name ) { const char * output_transform_name = NULL; - if (field_trans_table_has_key( config->trans_table , __output_transform_name)) + if (field_trans_table_has_key( config->trans_table , __output_transform_name)) output_transform_name = __output_transform_name; - - + + config->output_transform_name = util_realloc_string_copy( config->output_transform_name , output_transform_name ); if (output_transform_name != NULL) config->output_transform = field_trans_table_lookup( config->trans_table , output_transform_name); @@ -478,10 +481,10 @@ static void field_config_set_output_transform( field_config_type * config , cons static void field_config_set_input_transform( field_config_type * config , const char * __input_transform_name ) { const char * input_transform_name = NULL; - if (field_trans_table_has_key( config->trans_table , __input_transform_name)) + if (field_trans_table_has_key( config->trans_table , __input_transform_name)) input_transform_name = __input_transform_name; - - + + config->input_transform_name = util_realloc_string_copy( config->input_transform_name , input_transform_name ); if (input_transform_name != NULL) config->input_transform = field_trans_table_lookup( config->trans_table , input_transform_name); @@ -494,50 +497,50 @@ static void field_config_set_input_transform( field_config_type * config , const void field_config_update_state_field( field_config_type * config, int truncation, double min_value , double max_value) { field_config_set_truncation( config ,truncation , min_value , max_value ); config->type = ECLIPSE_RESTART; - + /* Setting all the defaults for state_fields, i.e. PRESSURE / SGAS / SWAT ... */ config->import_format = ECL_FILE; config->export_format = ECL_FILE; - + field_config_set_output_transform( config , NULL ); field_config_set_input_transform( config , NULL ); field_config_set_init_transform( config , NULL ); } - - - -void field_config_update_parameter_field( field_config_type * config , int truncation, double min_value , double max_value, + + + +void field_config_update_parameter_field( field_config_type * config , int truncation, double min_value , double max_value, field_file_format_type export_format , /* This can be guessed with the field_config_default_export_format( ecl_file ) function. */ const char * init_transform , const char * output_transform ) { field_config_set_truncation( config , truncation , min_value , max_value ); config->type = ECLIPSE_PARAMETER; - + config->export_format = export_format; config->import_format = UNDEFINED_FORMAT; /* Guess from filename when loading. */ config->input_transform = NULL; - field_config_set_input_transform( config , NULL ); - field_config_set_init_transform( config , init_transform ); - field_config_set_output_transform( config , output_transform ); + field_config_set_input_transform( config , NULL ); + field_config_set_init_transform( config , init_transform ); + field_config_set_output_transform( config , output_transform ); } -void field_config_update_general_field( field_config_type * config , int truncation, double min_value , double max_value, +void field_config_update_general_field( field_config_type * config , int truncation, double min_value , double max_value, field_file_format_type export_format , /* This can be guessed with the field_config_default_export_format( ecl_file ) function. */ - const char * init_transform , - const char * input_transform , + const char * init_transform , + const char * input_transform , const char * output_transform ) { field_config_set_truncation( config , truncation , min_value , max_value ); config->type = GENERAL; - + config->export_format = export_format; config->import_format = UNDEFINED_FORMAT; /* Guess from filename when loading. */ - field_config_set_input_transform( config , input_transform ); - field_config_set_init_transform( config , init_transform ); - field_config_set_output_transform( config , output_transform ); + field_config_set_input_transform( config , input_transform ); + field_config_set_init_transform( config , init_transform ); + field_config_set_output_transform( config , output_transform ); } @@ -547,7 +550,7 @@ void field_config_update_general_field( field_config_type * config , int truncat ECLIPSE_PARAMETER: export_format != UNDEFINED_FORMAT ECLIPSE_RESTART : Validation can be finalized at the enkf_config_node level. - + GENERAL : export_format != UNDEFINED_FORMAT */ @@ -562,7 +565,7 @@ bool field_config_is_valid( const field_config_type * field_config ) { case ECLIPSE_RESTART: break; case GENERAL: - if (field_config->export_format == UNDEFINED_FORMAT) + if (field_config->export_format == UNDEFINED_FORMAT) valid = false; break; default: @@ -933,19 +936,19 @@ void field_config_assert_binary( const field_config_type * config1 , const field The input string is assumed to have offset one, and the return values (by reference) are offset zero. */ - + bool field_config_parse_user_key__( const char * index_key , int *i , int *j , int *k) { int length; { - int_vector_type * indices = string_util_alloc_value_list( index_key ); + int_vector_type * indices = string_util_alloc_value_list( index_key ); length = int_vector_size( indices ); if (length == 3) { *i = int_vector_iget( indices , 0) - 1; *j = int_vector_iget( indices , 1) - 1; *k = int_vector_iget( indices , 2) - 1; - } + } int_vector_free( indices ); } @@ -965,7 +968,7 @@ int field_config_parse_user_key(const field_config_type * config, const char * i int active_index = field_config_active_index(config , *i,*j,*k); if (active_index < 0) return_value = 3; /* ijk corresponds to an inactive cell. */ - } else + } else return_value = 2; /* ijk is outside the grid. */ } else return_value = 1; /* Could not be parsed to three integers. */ @@ -978,11 +981,11 @@ int field_config_parse_user_key(const field_config_type * config, const char * i ecl_grid_type * field_config_get_grid(const field_config_type * config) { return config->grid; } -void field_config_fprintf_config( const field_config_type * config , - enkf_var_type var_type , - const char * outfile , - const char * infile , - const char * min_std_file , +void field_config_fprintf_config( const field_config_type * config , + enkf_var_type var_type , + const char * outfile , + const char * infile , + const char * min_std_file , FILE * stream) { if (var_type == PARAMETER) { diff --git a/ThirdParty/Ert/devel/libenkf/src/gen_data.c b/ThirdParty/Ert/devel/libenkf/src/gen_data.c index b85dae165c..174d29cbd7 100644 --- a/ThirdParty/Ert/devel/libenkf/src/gen_data.c +++ b/ThirdParty/Ert/devel/libenkf/src/gen_data.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'gen_data.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'gen_data.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -53,7 +53,7 @@ data) is determined at the enkf_node level, and no busissiness of the gen_data implementation. */ - + @@ -79,7 +79,7 @@ int gen_data_get_size( const gen_data_type * gen_data ) { } /** - It is a bug to call this before some function has set the size. + It is a bug to call this before some function has set the size. */ void gen_data_realloc_data(gen_data_type * gen_data) { int byte_size = gen_data_config_get_byte_size(gen_data->config , gen_data->current_report_step ); @@ -91,7 +91,7 @@ void gen_data_realloc_data(gen_data_type * gen_data) { gen_data_type * gen_data_alloc(const gen_data_config_type * config) { gen_data_type * gen_data = util_malloc(sizeof * gen_data); gen_data->config = (gen_data_config_type *) config; - gen_data->data = NULL; + gen_data->data = NULL; gen_data->__type_id = GEN_DATA; gen_data->active_mask = bool_vector_alloc( 0 , true ); gen_data->current_report_step = -1; /* God - if you ever read this .... */ @@ -102,7 +102,7 @@ gen_data_type * gen_data_alloc(const gen_data_config_type * config) { void gen_data_copy(const gen_data_type * src , gen_data_type * target) { if (src->config == target->config) { target->current_report_step = src->current_report_step; - + if (src->data != NULL) { int byte_size = gen_data_config_get_byte_size( src->config , src->current_report_step ); target->data = util_realloc_copy(target->data , src->data , byte_size ); @@ -110,7 +110,7 @@ void gen_data_copy(const gen_data_type * src , gen_data_type * target) { } else util_abort("%s: do not share config object \n",__func__); } - + void gen_data_free(gen_data_type * gen_data) { @@ -140,15 +140,15 @@ bool gen_data_write_to_buffer(const gen_data_type * gen_data , buffer_type * buf { bool write = write_zero_size; int size = gen_data_config_get_data_size( gen_data->config , report_step ); - if (size > 0) + if (size > 0) write = true; - + if (write) { int byte_size = gen_data_config_get_byte_size( gen_data->config , report_step ); buffer_fwrite_int( buffer , GEN_DATA ); buffer_fwrite_int( buffer , size ); buffer_fwrite_int( buffer , report_step); /* Why the heck do I need to store this ???? It was a mistake ...*/ - + buffer_fwrite_compressed( buffer , gen_data->data , byte_size); return true; } else @@ -165,7 +165,7 @@ void gen_data_read_from_buffer(gen_data_type * gen_data , buffer_type * buffer , buffer_fskip_int( buffer ); /* Skipping report_step from the buffer - was a mistake to store it - I think ... */ { size_t byte_size = size * ecl_util_get_sizeof_ctype( gen_data_config_get_internal_type ( gen_data->config )); - size_t compressed_size = buffer_get_remaining_size( buffer ); + size_t compressed_size = buffer_get_remaining_size( buffer ); gen_data->data = util_realloc( gen_data->data , byte_size ); buffer_fread_compressed( buffer , compressed_size , gen_data->data , byte_size ); } @@ -197,7 +197,7 @@ void gen_data_deserialize(gen_data_type * gen_data , node_id_type node_id , cons const gen_data_config_type *config = gen_data->config; const int data_size = gen_data_config_get_data_size( gen_data->config , gen_data->current_report_step ); ecl_type_enum ecl_type = gen_data_config_get_internal_type(config); - + enkf_matrix_deserialize( gen_data->data , data_size , ecl_type , active_list , A , row_offset , column); } } @@ -207,8 +207,8 @@ void gen_data_deserialize(gen_data_type * gen_data , node_id_type node_id , cons /* This function sets the data field of the gen_data instance after the - data has been loaded from file. -*/ + data has been loaded from file. +*/ static void gen_data_set_data__(gen_data_type * gen_data , int size, int report_step , ecl_type_enum load_type , const void * data) { gen_data_assert_size(gen_data , size, report_step); @@ -232,7 +232,7 @@ static void gen_data_set_data__(gen_data_type * gen_data , int size, int report_ } } } - + static bool gen_data_fload_active__(gen_data_type * gen_data, const char * filename, int size) { @@ -276,7 +276,7 @@ static bool gen_data_fload_active__(gen_data_type * gen_data, const char * filen } return file_exists; } - + /** This functions loads data from file. Observe that there is *NO* @@ -284,7 +284,7 @@ static bool gen_data_fload_active__(gen_data_type * gen_data, const char * filen how much can be successfully loaded. The file is loaded with the gen_common_fload_alloc() function, and - can be in formatted ASCII or binary_float / binary_double. + can be in formatted ASCII or binary_float / binary_double. When the read is complete it is checked/verified with the config object that this file was as long as the others we have loaded for @@ -300,7 +300,7 @@ bool gen_data_fload_with_report_step( gen_data_type * gen_data , const char * fi void * buffer = NULL; int size = 0; ecl_type_enum load_type; - + if ( file_exists ) { ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config); gen_data_file_format_type input_format = gen_data_config_get_input_format( gen_data->config ); @@ -312,7 +312,7 @@ bool gen_data_fload_with_report_step( gen_data_type * gen_data , const char * fi } gen_data_set_data__(gen_data , size , report_step , load_type , buffer ); util_safe_free(buffer); - } + } return file_exists; } @@ -337,11 +337,11 @@ bool gen_data_forward_load(gen_data_type * gen_data , const char * ecl_file , co owned by the config object. Observe that there is *NO* header information in this file. We just read floating point numbers until we reach EOF. - + When the read is complete it is checked/verified with the config object that this file was as long as the files we have loaded for other members. - + If gen_data_config_alloc_initfile() returns NULL that means that the gen_data instance does not have any init function - that is OK. */ @@ -349,13 +349,13 @@ bool gen_data_forward_load(gen_data_type * gen_data , const char * ecl_file , co bool gen_data_initialize(gen_data_type * gen_data , int iens , const char * init_file , rng_type * rng) { - bool ret = false; + bool ret = false; if (init_file) { if (!gen_data_fload_with_report_step(gen_data , init_file , 0)) util_abort("%s: could not find file:%s \n",__func__ , init_file); - ret = true; + ret = true; } - return ret; + return ret; } @@ -370,7 +370,7 @@ static void gen_data_ecl_write_ASCII(const gen_data_type * gen_data , const char gen_data_config_get_template_data( gen_data->config , &template_buffer , &template_data_offset , &template_buffer_size , &template_data_skip); util_fwrite( template_buffer , 1 , template_data_offset , stream , __func__); } - + { ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config); const int size = gen_data_config_get_data_size( gen_data->config , gen_data->current_report_step ); @@ -383,10 +383,10 @@ static void gen_data_ecl_write_ASCII(const gen_data_type * gen_data , const char double * double_data = (double *) gen_data->data; for (i=0; i < size; i++) fprintf(stream , "%lg\n",double_data[i]); - } else + } else util_abort("%s: internal error - wrong type \n",__func__); } - + if (export_format == ASCII_TEMPLATE) { int new_offset = template_data_offset + template_data_skip; util_fwrite( &template_buffer[new_offset] , 1 , template_buffer_size - new_offset , stream , __func__); @@ -408,7 +408,7 @@ gen_data_file_format_type gen_data_guess_export_type( const gen_data_type * gen_ gen_data_file_format_type export_type = gen_data_config_get_output_format( gen_data->config ); if (export_type == GEN_DATA_UNDEFINED) export_type = gen_data_config_get_input_format( gen_data->config ); - + if (export_type == GEN_DATA_UNDEFINED) util_abort("%s: both input_format and output_format are set to UNDEFINED \n",__func__); return export_type; @@ -434,7 +434,7 @@ void gen_data_export(const gen_data_type * gen_data , const char * full_path , g } } -/** +/** It is the enkf_node layer which knows whether the node actually has any data to export. If it is not supposed to write data to the forward model, i.e. it is of enkf_type 'dynamic_result' that is @@ -443,9 +443,9 @@ void gen_data_export(const gen_data_type * gen_data , const char * full_path , g void gen_data_ecl_write(const gen_data_type * gen_data , const char * run_path , const char * eclfile , void * filestream) { - if (eclfile != NULL) { + if (eclfile != NULL) { char * full_path = util_alloc_filename( run_path , eclfile , NULL); - + gen_data_file_format_type export_type = gen_data_config_get_output_format( gen_data->config ); gen_data_export( gen_data , full_path , export_type , filestream ); free( full_path ); @@ -461,7 +461,7 @@ static void gen_data_assert_index(const gen_data_type * gen_data, int index) { double gen_data_iget_double(const gen_data_type * gen_data, int index) { - gen_data_assert_index(gen_data , index); + gen_data_assert_index(gen_data , index); { ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config); if (internal_type == ECL_DOUBLE_TYPE) { @@ -477,7 +477,7 @@ double gen_data_iget_double(const gen_data_type * gen_data, int index) { void gen_data_export_data(const gen_data_type * gen_data , double_vector_type * export_data) { ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config); - if (internal_type == ECL_DOUBLE_TYPE) + if (internal_type == ECL_DOUBLE_TYPE) double_vector_memcpy_from_data( export_data , (const double *) gen_data->data , gen_data_get_size( gen_data )); else { double_vector_reset( export_data ); @@ -507,9 +507,9 @@ bool gen_data_user_get(const gen_data_type * gen_data, const char * index_key, i *value = gen_data_iget_double( gen_data , index ); return true; } - } + } } - + return false; } @@ -532,7 +532,7 @@ void gen_data_clear( gen_data_type * gen_data ) { double * data = (double * ) gen_data->data; for (int i = 0; i < data_size; i++) data[i] = 0; - } + } } @@ -540,7 +540,7 @@ void gen_data_clear( gen_data_type * gen_data ) { void gen_data_isqrt(gen_data_type * gen_data) { const int data_size = gen_data_config_get_data_size( gen_data->config , gen_data->current_report_step ); const ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config); - + if (internal_type == ECL_FLOAT_TYPE) { float * data = (float *) gen_data->data; for (int i=0; i < data_size; i++) @@ -556,7 +556,7 @@ void gen_data_isqrt(gen_data_type * gen_data) { void gen_data_iadd(gen_data_type * gen_data1, const gen_data_type * gen_data2) { - //gen_data_config_assert_binary(gen_data1->config , gen_data2->config , __func__); + //gen_data_config_assert_binary(gen_data1->config , gen_data2->config , __func__); { const int data_size = gen_data_config_get_data_size( gen_data1->config , gen_data1->current_report_step ); const ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data1->config); @@ -579,7 +579,7 @@ void gen_data_iadd(gen_data_type * gen_data1, const gen_data_type * gen_data2) { void gen_data_imul(gen_data_type * gen_data1, const gen_data_type * gen_data2) { - //gen_data_config_assert_binary(gen_data1->config , gen_data2->config , __func__); + //gen_data_config_assert_binary(gen_data1->config , gen_data2->config , __func__); { const int data_size = gen_data_config_get_data_size( gen_data1->config , gen_data1->current_report_step ); const ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data1->config); @@ -593,7 +593,7 @@ void gen_data_imul(gen_data_type * gen_data1, const gen_data_type * gen_data2) { } else if (internal_type == ECL_DOUBLE_TYPE) { double * data1 = (double *) gen_data1->data; const double * data2 = (const double *) gen_data2->data; - for (i = 0; i < data_size; i++) + for (i = 0; i < data_size; i++) data1[i] *= data2[i]; } } @@ -601,7 +601,7 @@ void gen_data_imul(gen_data_type * gen_data1, const gen_data_type * gen_data2) { void gen_data_iaddsqr(gen_data_type * gen_data1, const gen_data_type * gen_data2) { - //gen_data_config_assert_binary(gen_data1->config , gen_data2->config , __func__); + //gen_data_config_assert_binary(gen_data1->config , gen_data2->config , __func__); { const int data_size = gen_data_config_get_data_size( gen_data1->config , gen_data1->current_report_step ); const ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data1->config); @@ -623,7 +623,7 @@ void gen_data_iaddsqr(gen_data_type * gen_data1, const gen_data_type * gen_data2 void gen_data_scale(gen_data_type * gen_data, double scale_factor) { - //gen_data_config_assert_unary(gen_data->config, __func__); + //gen_data_config_assert_unary(gen_data->config, __func__); { const int data_size = gen_data_config_get_data_size( gen_data->config , gen_data->current_report_step ); const ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config); @@ -671,7 +671,7 @@ void gen_data_copy_to_double_vector(const gen_data_type * gen_data , double_vect else \ inflation_data[i] = 1.0; \ } \ -} +} /** @@ -688,14 +688,14 @@ void gen_data_set_inflation(gen_data_type * inflation , const gen_data_type * st float * inflation_data = (float *) inflation->data; const float * std_data = (const float *) std->data; const float * min_std_data = (const float *) min_std->data; - + INFLATE(inflation_data , std_data , min_std_data ); - + } else { double * inflation_data = (double *) inflation->data; const double * std_data = (const double *) std->data; const double * min_std_data = (const double *) min_std->data; - + INFLATE(inflation_data , std_data , min_std_data ); } } diff --git a/ThirdParty/Ert/devel/libenkf/src/gen_data_config.c b/ThirdParty/Ert/devel/libenkf/src/gen_data_config.c index e32a5cc0ec..5178d69e37 100644 --- a/ThirdParty/Ert/devel/libenkf/src/gen_data_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/gen_data_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'gen_data_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'gen_data_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -27,7 +27,7 @@ #include <ert/util/string_util.h> #include <ert/util/type_macros.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/ecl/ecl_util.h> #include <ert/enkf/enkf_macros.h> @@ -57,17 +57,17 @@ struct gen_data_config_struct { CONFIG_STD_FIELDS; char * key; /* The key this gen_data instance is known under - needed for debugging. */ ecl_type_enum internal_type; /* The underlying type (float | double) of the data in the corresponding gen_data instances. */ - char * template_file; + char * template_file; char * template_buffer; /* Buffer containing the content of the template - read and internalized at boot time. */ char * template_key; int template_data_offset; /* The offset into the template buffer before the data should come. */ - int template_data_skip; /* The length of data identifier in the template.*/ + int template_data_skip; /* The length of data identifier in the template.*/ int template_buffer_size; /* The total size (bytes) of the template buffer .*/ gen_data_file_format_type input_format; /* The format used for loading gen_data instances when the forward model has completed *AND* for loading the initial files.*/ gen_data_file_format_type output_format; /* The format used when gen_data instances are written to disk for the forward model. */ int_vector_type * data_size_vector; /* Data size, i.e. number of elements , indexed with report_step */ int_vector_type * active_report_steps; /* The report steps where we expect to load data for this instance. */ - pthread_mutex_t update_lock; + pthread_mutex_t update_lock; /*****************************************************************/ /* All the fields below this line are related to the capability of the forward model to deactivate elements in a gen_data @@ -100,14 +100,19 @@ ecl_type_enum gen_data_config_get_internal_type(const gen_data_config_type * con /** If current_size as queried from config->data_size_vector == -1 - (i.e. not set); we seek through + (i.e. not set); we seek through */ -int gen_data_config_get_data_size( const gen_data_config_type * config , int report_step) { +int gen_data_config_get_data_size__( const gen_data_config_type * config , int report_step) { int current_size = int_vector_safe_iget( config->data_size_vector , report_step ); - if (current_size < 0) + return current_size; +} + +int gen_data_config_get_data_size( const gen_data_config_type * config , int report_step) { + int current_size = gen_data_config_get_data_size__(config , report_step); + if (current_size < 0) util_abort("%s: Size not set for object:%s report_step:%d - internal error: \n",__func__ , config->key , report_step); - return current_size; + return current_size; } @@ -116,7 +121,7 @@ int gen_data_config_get_initial_size( const gen_data_config_type * config ) { int initial_size = int_vector_safe_iget( config->data_size_vector , 0); if (initial_size < 0) initial_size = 0; - + return initial_size; } @@ -130,8 +135,8 @@ int gen_data_config_get_byte_size( const gen_data_config_type * config , int rep static void gen_data_config_reset_template( gen_data_config_type * config ) { - util_safe_free( config->template_buffer ); - util_safe_free( config->template_key ); + util_safe_free( config->template_buffer ); + util_safe_free( config->template_key ); util_safe_free( config->template_file ); config->template_file = NULL; @@ -161,7 +166,7 @@ static gen_data_config_type * gen_data_config_alloc( const char * key , bool dyn config->output_format = GEN_DATA_UNDEFINED; config->data_size_vector = int_vector_alloc( 0 , -1 ); /* The default value: -1 - indicates "NOT SET" */ config->active_report_steps= int_vector_alloc( 0 , 0 ); - config->active_mask = bool_vector_alloc(0 , true ); /* Elements are explicitly set to FALSE - this MUST default to true. */ + config->active_mask = bool_vector_alloc(0 , true ); /* Elements are explicitly set to FALSE - this MUST default to true. */ config->active_report_step = -1; config->ens_size = -1; config->read_fs = NULL; @@ -176,12 +181,12 @@ static gen_data_config_type * gen_data_config_alloc( const char * key , bool dyn gen_data_config_type * gen_data_config_alloc_GEN_PARAM( const char * key , gen_data_file_format_type output_format , gen_data_file_format_type input_format) { gen_data_config_type * config = gen_data_config_alloc( key , false ); - if (input_format == ASCII_TEMPLATE) + if (input_format == ASCII_TEMPLATE) util_abort("%s: Sorry can not use INPUT_FORMAT:ASCII_TEMPLATE\n",__func__); - + if (output_format == GEN_DATA_UNDEFINED || input_format == GEN_DATA_UNDEFINED) util_abort("%s: Sorry must specify valid values for both input and output format\n",__func__); - + config->output_format = output_format; config->input_format = input_format; return config; @@ -191,25 +196,25 @@ gen_data_config_type * gen_data_config_alloc_GEN_PARAM( const char * key , gen_d gen_data_config_type * gen_data_config_alloc_GEN_DATA_result( const char * key , gen_data_file_format_type input_format) { gen_data_config_type * config = gen_data_config_alloc( key , true ); - if (input_format == ASCII_TEMPLATE) + if (input_format == ASCII_TEMPLATE) util_abort("%s: Sorry can not use INPUT_FORMAT:ASCII_TEMPLATE\n",__func__); - + if (input_format == GEN_DATA_UNDEFINED) util_abort("%s: Sorry must specify valid values for input format.\n",__func__); - + config->input_format = input_format; return config; } gen_data_config_type * gen_data_config_alloc_GEN_DATA_state( const char * key , gen_data_file_format_type output_format , gen_data_file_format_type input_format) { gen_data_config_type * config = gen_data_config_alloc( key , true ); - - if (input_format == ASCII_TEMPLATE) + + if (input_format == ASCII_TEMPLATE) util_abort("%s: Sorry can not use INPUT_FORMAT:ASCII_TEMPLATE\n",__func__); - + if (output_format == GEN_DATA_UNDEFINED || input_format == GEN_DATA_UNDEFINED) util_abort("%s: Sorry must specify valid values for both input and output format\n",__func__); - + config->output_format = output_format; config->input_format = input_format; return config; @@ -242,7 +247,7 @@ bool gen_data_config_set_template( gen_data_config_type * config , const char * } else template_valid = false; } - + if (template_valid) { gen_data_config_reset_template(config); @@ -252,7 +257,7 @@ bool gen_data_config_set_template( gen_data_config_type * config , const char * config->template_buffer_size = template_buffer_size; if (template_data_key != NULL) { data_ptr = strstr(config->template_buffer , template_data_key); - if (data_ptr == NULL) + if (data_ptr == NULL) util_abort("%s: template:%s can not be used - could not find data key:%s \n",__func__ , template_ecl_file , template_data_key); else { config->template_data_offset = data_ptr - config->template_buffer; @@ -263,15 +268,15 @@ bool gen_data_config_set_template( gen_data_config_type * config , const char * config->template_data_offset = strlen( config->template_buffer ); config->template_data_skip = 0; } - + config->template_file = util_realloc_string_copy( config->template_file , template_ecl_file ); config->template_key = util_realloc_string_copy( config->template_key , template_data_key ); - + if (config->output_format != ASCII_TEMPLATE) fprintf(stderr,"**WARNING: The template settings will ignored for key:%s - use OUTPUT_FORMAT:ASCII_TEMPLATE to get template behaviour\n", config->key); } - } + } return template_valid; } @@ -281,7 +286,7 @@ const char * gen_data_config_get_template_file( const gen_data_config_type * con } const char * gen_data_config_get_template_key( const gen_data_config_type * config ) { - return config->template_key; + return config->template_key; } @@ -296,7 +301,7 @@ const char * gen_data_config_get_template_key( const gen_data_config_type * conf This function takes a string representation of one of the gen_data_file_format_type values, and returns the corresponding integer value. - + Will return gen_data_undefined if the string is not recognized, calling scope must check on this return value. */ @@ -304,9 +309,9 @@ const char * gen_data_config_get_template_key( const gen_data_config_type * conf gen_data_file_format_type gen_data_config_check_format( const void * format_string ) { gen_data_file_format_type type = GEN_DATA_UNDEFINED; - + if (format_string != NULL) { - + if (strcmp(format_string , "ASCII") == 0) type = ASCII; else if (strcmp(format_string , "ASCII_TEMPLATE") == 0) @@ -315,9 +320,9 @@ gen_data_file_format_type gen_data_config_check_format( const void * format_stri type = BINARY_DOUBLE; else if (strcmp(format_string , "BINARY_FLOAT") == 0) type = BINARY_FLOAT; - + } - + return type; } @@ -330,7 +335,7 @@ gen_data_file_format_type gen_data_config_check_format( const void * format_stri TEMPLATE:/some/template/file KEY:<SomeKeyFoundInTemplate> ECL_FILE:<filename to write EnKF ==> Forward model> (In the case of gen_param - this is extracted in the calling scope). - RESULT_FILE:<filename to read EnKF <== Forward model> + RESULT_FILE:<filename to read EnKF <== Forward model> */ @@ -340,13 +345,13 @@ gen_data_file_format_type gen_data_config_check_format( const void * format_stri void gen_data_config_free(gen_data_config_type * config) { int_vector_free( config->data_size_vector ); int_vector_free( config->active_report_steps ); - + util_safe_free( config->key ); util_safe_free( config->template_buffer ); util_safe_free( config->template_file ); util_safe_free( config->template_key ); bool_vector_free( config->active_mask ); - + free(config); } @@ -357,16 +362,16 @@ void gen_data_config_free(gen_data_config_type * config) { This function gets a size (from a gen_data) instance, and verifies that the size agrees with the currently stored size and report_step. If the report_step is new we just record the new info, - otherwise it will break hard. + otherwise it will break hard. */ /** Does not work properly with: - + 1. keep_run_path - the load_file will be left hanging around - and loaded again and again. 2. Doing forward several steps - how to (time)index the files? - + */ @@ -378,13 +383,13 @@ void gen_data_config_assert_size(gen_data_config_type * config , int data_size, int_vector_iset( config->data_size_vector , report_step , data_size ); current_size = data_size; } - + if (current_size != data_size) { util_abort("%s: Size mismatch when loading:%s from file - got %d elements - expected:%d [report_step:%d] \n", - __func__ , + __func__ , gen_data_config_get_key( config ), - data_size , - current_size , + data_size , + current_size , report_step); } } @@ -398,8 +403,8 @@ void gen_data_config_assert_size(gen_data_config_type * config , int data_size, is handled through this function. When all ensemble members have called this function the mask config->active_mask should be true ONLY for the elements which are true for all members. - - This MUST be called after gen_data_config_assert_size(). + + This MUST be called after gen_data_config_assert_size(). */ void gen_data_config_update_active(gen_data_config_type * config, int report_step , const bool_vector_type * data_mask) { @@ -413,7 +418,7 @@ void gen_data_config_update_active(gen_data_config_type * config, int report_ste bool_vector_iset( config->active_mask , int_vector_iget( config->data_size_vector , report_step ) - 1 , true ); config->mask_modified = true; } - + { int i; for (i=0; i < bool_vector_size( data_mask ); i++) { @@ -422,8 +427,8 @@ void gen_data_config_update_active(gen_data_config_type * config, int report_ste config->mask_modified = true; } } - } - + } + if (config->mask_modified) { /** The global mask has been modified after the last load; @@ -431,7 +436,7 @@ void gen_data_config_update_active(gen_data_config_type * config, int report_ste */ char * filename = util_alloc_sprintf("%s_active" , config->key ); FILE * stream = enkf_fs_open_case_tstep_file( config->write_fs , filename , report_step , "w"); - + bool_vector_fwrite( config->active_mask , stream ); fclose( stream ); @@ -450,14 +455,14 @@ bool gen_data_config_has_active_mask( const gen_data_config_type * config , enkf { char * filename = util_alloc_sprintf("%s_active" , config->key ); FILE * stream = enkf_fs_open_excase_tstep_file( fs , filename , report_step); - - if (stream == NULL) + + if (stream == NULL) has_mask = false; else { has_mask = true; fclose( stream ); - } - + } + free( filename ); } return has_mask; @@ -478,7 +483,7 @@ void gen_data_config_load_active( gen_data_config_type * config , enkf_fs_type * if (!config->dynamic) return; /* This is used as a GEN_PARAM instance - and the loading of mask is not an option. */ - + pthread_mutex_lock( &config->update_lock ); { if ( force_load || (int_vector_iget( config->data_size_vector , report_step ) > 0)) { @@ -498,7 +503,7 @@ void gen_data_config_load_active( gen_data_config_type * config , enkf_fs_type * fprintf(stderr," 2: The size of the gen_data vectors has not been set\n"); fprintf(stderr,"\n"); fprintf(stderr,"We can not create a suitable active_mask. Code should call gen_data_config_has_active_mask()\n\n"); - + util_abort("%s: fatal internal error - could not create a suitable active_mask \n",__func__); } else { fprintf(stdout,"** Info: could not locate active data elements file %s, filling active vector with true all elements active \n",filename); @@ -560,17 +565,17 @@ bool gen_data_config_is_dynamic( const gen_data_config_type * config ) { return config->dynamic; } -void gen_data_config_get_template_data( const gen_data_config_type * config , - char ** template_buffer , - int * template_data_offset , - int * template_buffer_size , +void gen_data_config_get_template_data( const gen_data_config_type * config , + char ** template_buffer , + int * template_data_offset , + int * template_buffer_size , int * template_data_skip) { - + *template_buffer = config->template_buffer; *template_data_offset = config->template_data_offset; *template_buffer_size = config->template_buffer_size; *template_data_skip = config->template_data_skip; - + } @@ -587,7 +592,7 @@ bool gen_data_config_valid_result_format(const char * result_file_fmt) { } else return false; } - + const char * gen_data_config_get_key( const gen_data_config_type * config) { return config->key; @@ -617,13 +622,13 @@ static const char * gen_data_config_format_name( gen_data_file_format_type forma } -void gen_data_config_fprintf_config( const gen_data_config_type * config , enkf_var_type var_type , const char * outfile , const char * infile , +void gen_data_config_fprintf_config( const gen_data_config_type * config , enkf_var_type var_type , const char * outfile , const char * infile , const char * min_std_file , FILE * stream) { - if (var_type == PARAMETER) + if (var_type == PARAMETER) fprintf( stream , CONFIG_VALUE_FORMAT , outfile ); else fprintf( stream , CONFIG_OPTION_FORMAT , ECL_FILE_KEY , outfile ); - + if (min_std_file != NULL) fprintf( stream , CONFIG_OPTION_FORMAT , MIN_STD_KEY , min_std_file ); diff --git a/ThirdParty/Ert/devel/libenkf/src/gen_kw.c b/ThirdParty/Ert/devel/libenkf/src/gen_kw.c index f4ef4c8aa9..b0a0402d02 100644 --- a/ThirdParty/Ert/devel/libenkf/src/gen_kw.c +++ b/ThirdParty/Ert/devel/libenkf/src/gen_kw.c @@ -262,8 +262,14 @@ void gen_kw_write_export_file(const gen_kw_type * gen_kw, FILE * filestream) { const char * parameter = gen_kw_config_iget_name(gen_kw->config , ikw); int width = 60 - (strlen(key) + strlen(parameter) + 1); double transformed_value = gen_kw_config_transform( gen_kw->config , ikw , gen_kw->data[ikw] ); - const char * print_string = util_alloc_sprintf("%s:%s %e\n", key, parameter, width, transformed_value); - fprintf(filestream, print_string); + const char * print_string = util_alloc_sprintf("%s:%s %g\n", key, parameter, width, transformed_value); + fprintf(filestream, "%s", print_string); + + if (gen_kw_config_should_use_log_scale(gen_kw->config, ikw)) { + double log_transformed_value = log10(transformed_value); + const char * print_log_string = util_alloc_sprintf("LOG10_%s:%s %g\n", key, parameter, width, log_transformed_value); + fprintf(filestream, "%s", print_log_string); + } } } diff --git a/ThirdParty/Ert/devel/libenkf/src/gen_kw_config.c b/ThirdParty/Ert/devel/libenkf/src/gen_kw_config.c index 23c23f416d..65c475d09e 100644 --- a/ThirdParty/Ert/devel/libenkf/src/gen_kw_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/gen_kw_config.c @@ -138,7 +138,7 @@ void gen_kw_config_set_parameter_file( gen_kw_config_type * config , const char fscanf_return = fscanf(stream , "%s" , parameter_name); if (fscanf_return == 1) { gen_kw_parameter_type * parameter = gen_kw_parameter_alloc( parameter_name , config->tag_fmt); - trans_func_type * trans_func = trans_func_fscanf_alloc( stream ); + trans_func_type * trans_func = trans_func_fscanf_alloc( stream, parameter_file ); gen_kw_parameter_set_trans_func( parameter , trans_func ); vector_append_owned_ref( config->parameters , parameter , gen_kw_parameter_free__ ); diff --git a/ThirdParty/Ert/devel/libenkf/src/gen_obs.c b/ThirdParty/Ert/devel/libenkf/src/gen_obs.c index 8eb71ea6e9..bee7d5720f 100644 --- a/ThirdParty/Ert/devel/libenkf/src/gen_obs.c +++ b/ThirdParty/Ert/devel/libenkf/src/gen_obs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'gen_obs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'gen_obs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -44,26 +44,36 @@ general observation is just a vector of numbers - where EnKF has no understanding whatsover of the type of these data. The actual data is supposed to be found in a file. - + Currently it can only observe gen_data instances - but that should be generalized. */ - +/* + The std_scaling field of the xxx_obs structure can be used to scale + the standard deviation used for the observations, either to support + workflows with multiple data assimilation or to reduce the effect of + observation correlations. + + When querying for the observation standard deviation using + gen_obs_iget_std() the user input value of standard deviation will + be returned, whereas when the function gen_obs_measure() is used the + std_scaling will be incorporated in the result. +*/ #define GEN_OBS_TYPE_ID 77619 struct gen_obs_struct { UTIL_TYPE_ID_DECLARATION; - int obs_size; /* This is the total size of the observation vector. */ + int obs_size; /* This is the total size of the observation vector. */ int * data_index_list; /* The indexes which are observed in the corresponding gen_data instance - of length obs_size. */ bool observe_all_data; /* Flag which indiactes whether all data in the gen_data instance should be observed - in that case we must do a size comparizon-check at use time. */ double * obs_data; /* The observed data. */ - double * obs_std; /* The observed standard deviation. */ + double * obs_std; /* The observed standard deviation. */ + double * std_scaling; /* Scaling factor for the standard deviation */ - char * obs_key; /* The key this observation is held by - in the enkf_obs structur (only for debug messages). */ - char * obs_file; /* The file holding the observation. */ + char * obs_key; /* The key this observation is held by - in the enkf_obs structur (only for debug messages). */ gen_data_file_format_type obs_format; /* The format, i.e. ASCII, binary_double or binary_float, of the observation file. */ matrix_type * error_covar; gen_data_config_type * data_config; @@ -78,16 +88,20 @@ static UTIL_SAFE_CAST_FUNCTION(gen_obs , GEN_OBS_TYPE_ID) void gen_obs_free(gen_obs_type * gen_obs) { util_safe_free(gen_obs->obs_data); util_safe_free(gen_obs->obs_std); - util_safe_free(gen_obs->obs_file); util_safe_free(gen_obs->data_index_list); util_safe_free(gen_obs->obs_key); + util_safe_free(gen_obs->std_scaling); if (gen_obs->error_covar != NULL) matrix_free( gen_obs->error_covar ); - + free(gen_obs); } +static double IGET_SCALED_STD(const gen_obs_type * gen_obs, int index) { + return gen_obs->obs_std[index] * gen_obs->std_scaling[index]; +} + /** This function loads the actual observations from disk, and @@ -98,54 +112,97 @@ void gen_obs_free(gen_obs_type * gen_obs) { The file with observations should be a long vector of 2N elements, where the first N elements are data values, and the last N values are the corresponding standard deviations. - + The file is loaded with the gen_common_fload_alloc() function, and can be in formatted ASCII or binary_float / binary_double. Observe that there is *NO* header information in this file. */ -static void gen_obs_load_observation(gen_obs_type * gen_obs, double scalar_value , double scalar_error) { +static void gen_obs_set_data(gen_obs_type * gen_obs, int buffer_size , const double * buffer) { + gen_obs->obs_size = buffer_size / 2; + gen_obs->obs_data = util_realloc(gen_obs->obs_data , gen_obs->obs_size * sizeof * gen_obs->obs_data ); + gen_obs->obs_std = util_realloc(gen_obs->obs_std , gen_obs->obs_size * sizeof * gen_obs->obs_std ); + gen_obs->std_scaling = util_realloc(gen_obs->std_scaling , gen_obs->obs_size * sizeof * gen_obs->std_scaling ); + gen_obs->data_index_list = util_realloc(gen_obs->data_index_list , gen_obs->obs_size * sizeof * gen_obs->data_index_list ); + { + int iobs; + double * double_buffer = (double * ) buffer; + for (iobs = 0; iobs < gen_obs->obs_size; iobs++) { + gen_obs->obs_data[iobs] = double_buffer[2*iobs]; + gen_obs->obs_std[iobs] = double_buffer[2*iobs + 1]; + gen_obs->std_scaling[iobs] = 1.0; + gen_obs->data_index_list[iobs] = iobs; + + } + } +} + + +void gen_obs_load_observation(gen_obs_type * gen_obs, const char * obs_file) { ecl_type_enum load_type; void * buffer; - - gen_obs->obs_size = 0; - if (gen_obs->obs_file != NULL) - buffer = gen_common_fload_alloc(gen_obs->obs_file , gen_obs->obs_format , ECL_DOUBLE_TYPE , &load_type , &gen_obs->obs_size); - else { - double * double_buffer = util_calloc(2 , sizeof * double_buffer ); - buffer = double_buffer; - double_buffer[0] = scalar_value; - double_buffer[1] = scalar_error; - load_type = ECL_DOUBLE_TYPE; - gen_obs->obs_size = 2; - } + int buffer_size = 0; + buffer = gen_common_fload_alloc(obs_file , gen_obs->obs_format , ECL_DOUBLE_TYPE , &load_type , &buffer_size); /** Ensure that the data is of type double. */ if (load_type == ECL_FLOAT_TYPE) { double * double_data = util_calloc(gen_obs->obs_size , sizeof * double_data ); - util_float_to_double(double_data , (const float *) buffer , gen_obs->obs_size); + util_float_to_double(double_data , (const float *) buffer , buffer_size); free(buffer); buffer = double_data; } - gen_obs->obs_size /= 2; /* Originally contains BOTH data and std. */ - gen_obs->obs_data = util_realloc(gen_obs->obs_data , gen_obs->obs_size * sizeof * gen_obs->obs_data ); - gen_obs->obs_std = util_realloc(gen_obs->obs_std , gen_obs->obs_size * sizeof * gen_obs->obs_std ); - { - int iobs; - double * double_buffer = (double * ) buffer; - for (iobs = 0; iobs < gen_obs->obs_size; iobs++) { - gen_obs->obs_data[iobs] = double_buffer[2*iobs]; - gen_obs->obs_std[iobs] = double_buffer[2*iobs + 1]; - } - - } + gen_obs_set_data( gen_obs , buffer_size , buffer ); free(buffer); } +void gen_obs_set_scalar( gen_obs_type * gen_obs , double scalar_value , double scalar_std) { + double buffer[2] = { scalar_value , scalar_std }; + gen_obs_set_data( gen_obs , 2 , buffer ); +} + +void gen_obs_attach_data_index( gen_obs_type * obs , const int_vector_type * data_index ) { + util_safe_free( obs->data_index_list ); + obs->data_index_list = int_vector_alloc_data_copy( data_index ); + obs->observe_all_data = false; +} + + +void gen_obs_load_data_index( gen_obs_type * obs , const char * data_index_file) { + /* Parsing an a file with integers. */ + util_safe_free( obs->data_index_list ); + obs->data_index_list = gen_common_fscanf_alloc( data_index_file , ECL_INT_TYPE , &obs->obs_size); + obs->observe_all_data = false; +} + + +void gen_obs_parse_data_index( gen_obs_type * obs , const char * data_index_string) { + /* Parsing a string of the type "1,3,5,9-100,200,202,300-1000" */ + int_vector_type * index_list = string_util_alloc_active_list( data_index_string ); + int_vector_shrink( index_list ); + gen_obs_attach_data_index( obs , index_list ); + int_vector_free( index_list ); +} + + + +gen_obs_type * gen_obs_alloc__(gen_data_config_type * data_config , const char * obs_key) { + gen_obs_type * obs = util_malloc(sizeof * obs); + UTIL_TYPE_ID_INIT( obs , GEN_OBS_TYPE_ID ); + obs->obs_data = NULL; + obs->obs_std = NULL; + obs->std_scaling = NULL; + obs->data_index_list = NULL; + obs->obs_format = ASCII; /* Hardcoded for now. */ + obs->obs_key = util_alloc_string_copy( obs_key ); + obs->data_config = data_config; + obs->observe_all_data = true; + obs->error_covar = NULL; + return obs; +} /** @@ -167,50 +224,22 @@ static void gen_obs_load_observation(gen_obs_type * gen_obs, double scalar_value gen_obs_type * gen_obs_alloc(gen_data_config_type * data_config , const char * obs_key , const char * obs_file , double scalar_value , double scalar_error , const char * data_index_file , const char * data_index_string , const char * error_covar_file) { - gen_obs_type * obs = util_malloc(sizeof * obs); + gen_obs_type * obs = gen_obs_alloc__( data_config , obs_key ); + if (obs_file) + gen_obs_load_observation(obs , obs_file ); /* The observation data is loaded - and internalized at boot time - even though it might not be needed for a long time. */ + else + gen_obs_set_scalar( obs , scalar_value , scalar_error ); + - UTIL_TYPE_ID_INIT( obs , GEN_OBS_TYPE_ID ); - obs->obs_data = NULL; - obs->obs_std = NULL; - obs->obs_file = util_alloc_string_copy( obs_file ); - obs->obs_format = ASCII; /* Hardcoded for now. */ - obs->obs_key = util_alloc_string_copy( obs_key ); - obs->data_config = data_config; + if (data_index_file) + gen_obs_load_data_index( obs , data_index_file ); + else if (data_index_string) + gen_obs_parse_data_index( obs , data_index_string ); - gen_obs_load_observation(obs , scalar_value , scalar_error); /* The observation data is loaded - and internalized at boot time - even though it might not be needed for a long time. */ - if ((data_index_file == NULL) && (data_index_string == NULL)) { - /* - We observe all the elements in the remote (gen_data) instance, - and the data_index_list just becomes a identity mapping. - - At use time we must verify that the size of the observation - corresponds to the size of the gen_data_instance; that this - check is needed is indicated by the boolean flag - observe_all_data. - */ - obs->data_index_list = util_calloc( obs->obs_size , sizeof * obs->data_index_list ); - for (int i =0; i < obs->obs_size; i++) - obs->data_index_list[i] = i; - obs->observe_all_data = true; - } else { - obs->observe_all_data = false; - if (data_index_file != NULL) - /* Parsing an a file with integers. */ - obs->data_index_list = gen_common_fscanf_alloc( data_index_file , ECL_INT_TYPE , &obs->obs_size); - else - /* Parsing a string of the type "1,3,5,9-100,200,202,300-1000" */ - { - int_vector_type * index_list = string_util_alloc_active_list( data_index_string ); - int_vector_shrink( index_list ); - obs->data_index_list = int_vector_get_ptr( index_list ); - obs->obs_size = int_vector_size( index_list ); - int_vector_free_container( index_list ); - } - } if (error_covar_file != NULL) { FILE * stream = util_fopen( error_covar_file , "r"); - + obs->error_covar = matrix_alloc( obs->obs_size , obs->obs_size ); matrix_fscanf_data( obs->error_covar , false , stream ); @@ -226,14 +255,14 @@ gen_obs_type * gen_obs_alloc(gen_data_config_type * data_config , const char * o static void gen_obs_assert_data_size(const gen_obs_type * gen_obs, const gen_data_type * gen_data) { if (gen_obs->observe_all_data) { int data_size = gen_data_get_size( gen_data ); - if (gen_obs->obs_size != data_size) + if (gen_obs->obs_size != data_size) util_abort("%s: size mismatch: Observation: %s:%d Data: %s:%d \n" , __func__ , gen_obs->obs_key , gen_obs->obs_size , gen_data_get_key( gen_data ) , data_size); - - } + + } /* Else the user has explicitly entered indices to observe in the gen_data instances, and we just have to trust them (however the - gen_data_iget() does a range check. + gen_data_iget() does a range check. */ } @@ -243,7 +272,8 @@ double gen_obs_chi2(const gen_obs_type * gen_obs , const gen_data_type * gen_dat { double sum_chi2 = 0; for (int iobs = 0; iobs < gen_obs->obs_size; iobs++) { - double x = (gen_data_iget_double( gen_data , gen_obs->data_index_list[iobs]) - gen_obs->obs_data[iobs]) / gen_obs->obs_std[iobs]; + double d = gen_data_iget_double( gen_data , gen_obs->data_index_list[iobs]); + double x = (d - gen_obs->obs_data[iobs]) / gen_obs->obs_std[iobs]; sum_chi2 += x*x; } return sum_chi2; @@ -259,7 +289,7 @@ void gen_obs_measure(const gen_obs_type * gen_obs , const gen_data_type * gen_da meas_block_type * meas_block = meas_data_add_block( meas_data , gen_obs->obs_key , node_id.report_step , active_size ); active_mode_type active_mode = active_list_get_mode( __active_list ); const bool_vector_type * forward_model_active = gen_data_config_get_active_mask( gen_obs->data_config ); - + int iobs; if (active_mode == ALL_ACTIVE) { for (iobs = 0; iobs < gen_obs->obs_size; iobs++) { @@ -273,9 +303,9 @@ void gen_obs_measure(const gen_obs_type * gen_obs , const gen_data_type * gen_da meas_block_iset( meas_block , node_id.iens , iobs , gen_data_iget_double( gen_data , data_index )); } } else if ( active_mode == PARTLY_ACTIVE) { - const int * active_list = active_list_get_active( __active_list ); + const int * active_list = active_list_get_active( __active_list ); int index; - + for (index = 0; index < active_size; index++) { iobs = active_list[ index ]; int data_index = gen_obs->data_index_list[iobs] ; @@ -297,18 +327,18 @@ void gen_obs_get_observations(gen_obs_type * gen_obs , obs_data_type * obs_data, gen_data_config_load_active( gen_obs->data_config , fs, report_step , true); forward_model_active = gen_data_config_get_active_mask( gen_obs->data_config ); } - + { int iobs; active_mode_type active_mode = active_list_get_mode( __active_list ); obs_block_type * obs_block = obs_data_add_block( obs_data , gen_obs->obs_key , gen_obs->obs_size , NULL , false); - + if (active_mode == ALL_ACTIVE) { - for (iobs = 0; iobs < gen_obs->obs_size; iobs++) - obs_block_iset( obs_block , iobs , gen_obs->obs_data[iobs] , gen_obs->obs_std[iobs]); - + for (iobs = 0; iobs < gen_obs->obs_size; iobs++) + obs_block_iset( obs_block , iobs , gen_obs->obs_data[iobs] , IGET_SCALED_STD( gen_obs , iobs )); + /* Setting some of the elements as missing, i.e. deactivated by the forward model. */ - if (forward_model_active != NULL) { + if (forward_model_active != NULL) { for (iobs = 0; iobs < gen_obs->obs_size; iobs++) { int data_index = gen_obs->data_index_list[ iobs ]; if (!bool_vector_iget( forward_model_active , data_index )) @@ -316,16 +346,16 @@ void gen_obs_get_observations(gen_obs_type * gen_obs , obs_data_type * obs_data, } } } else if (active_mode == PARTLY_ACTIVE) { - const int * active_list = active_list_get_active( __active_list ); + const int * active_list = active_list_get_active( __active_list ); int active_size = active_list_get_active_size( __active_list , gen_obs->obs_size); int index; - + for (index = 0; index < active_size; index++) { iobs = active_list[index]; - obs_block_iset( obs_block , iobs , gen_obs->obs_data[iobs] , gen_obs->obs_std[iobs] ); + obs_block_iset( obs_block , iobs , gen_obs->obs_data[iobs] , IGET_SCALED_STD( gen_obs , iobs )); { int data_index = gen_obs->data_index_list[ iobs ]; - if ((forward_model_active != NULL) && (!bool_vector_iget( forward_model_active , data_index ))) + if ((forward_model_active != NULL) && (!bool_vector_iget( forward_model_active , data_index ))) obs_block_iset_missing( obs_block , iobs ); } } @@ -344,8 +374,8 @@ void gen_obs_get_observations(gen_obs_type * gen_obs , obs_data_type * obs_data, ---- --- [ 6.0 ] ----\ - [ 2.0 ] \---> [ 6.3 ] - [ 3.0 ] ---------> [ 2.8 ] + [ 2.0 ] \---> [ 6.3 ] + [ 3.0 ] ---------> [ 2.8 ] [ 2.0 ] /---> [ 4.3 ] [ 4.5 ] ----/ @@ -367,18 +397,18 @@ void gen_obs_get_observations(gen_obs_type * gen_obs , obs_data_type * obs_data, The function gen_obs_user_get_with_data_index() will do the translation from data based indexing to observation based indexing, i.e. - - gen_obs_user_get_with_data_index("4") + + gen_obs_user_get_with_data_index("4") will do an inverse lookup of the '4' and further call gen_obs_user_get("2") */ - -void gen_obs_user_get(const gen_obs_type * gen_obs , const char * index_key , double * value , double * std , bool * valid) { - int index; + +void gen_obs_user_get(const gen_obs_type * gen_obs , const char * index_key , double * value , double * std , bool * valid) { + int index; *valid = false; if (util_sscanf_int( index_key , &index)) { @@ -391,7 +421,8 @@ void gen_obs_user_get(const gen_obs_type * gen_obs , const char * index_key , do } -void gen_obs_user_get_with_data_index(const gen_obs_type * gen_obs , const char * index_key , double * value , double * std , bool * valid) { + +void gen_obs_user_get_with_data_index(const gen_obs_type * gen_obs , const char * index_key , double * value , double * std , bool * valid) { if (gen_obs->observe_all_data) /* The observation and data vectors are equally long - no reverse lookup necessary. */ gen_obs_user_get(gen_obs , index_key , value , std , valid); @@ -399,12 +430,12 @@ void gen_obs_user_get_with_data_index(const gen_obs_type * gen_obs , const char *valid = false; int data_index; if (util_sscanf_int( index_key , &data_index )) { - int obs_index = 0; + int obs_index = 0; do { - if (gen_obs->data_index_list[ obs_index ] == data_index) + if (gen_obs->data_index_list[ obs_index ] == data_index) /* Found it - will use the 'obs_index' value. */ break; - + obs_index++; } while (obs_index < gen_obs->obs_size); if (obs_index < gen_obs->obs_size) { /* The reverse lookup succeeded. */ @@ -416,42 +447,53 @@ void gen_obs_user_get_with_data_index(const gen_obs_type * gen_obs , const char } } -void gen_obs_scale_std(gen_obs_type * gen_obs, double std_multiplier) { - for (int i = 0; i < gen_obs->obs_size; i++) { - gen_obs->obs_std[i] *= std_multiplier; +void gen_obs_update_std_scale(gen_obs_type * gen_obs, double std_multiplier, const active_list_type * active_list) { + if (active_list_get_mode( active_list ) == ALL_ACTIVE) { + for (int i = 0; i < gen_obs->obs_size; i++) + gen_obs->std_scaling[i] = std_multiplier; + } else { + const int * active_index = active_list_get_active( active_list ); + int size = active_list_get_active_size( active_list , gen_obs->obs_size ); + for (int i=0; i < size; i++) { + int obs_index = active_index[i]; + gen_obs->std_scaling[ obs_index ] = std_multiplier; + } } } -void gen_obs_scale_std__(void * gen_obs, double std_multiplier) { - gen_obs_type * observation = gen_obs_safe_cast(gen_obs); - gen_obs_scale_std(observation, std_multiplier); -} + int gen_obs_get_size(const gen_obs_type * gen_obs){ return gen_obs->obs_size; } double gen_obs_iget_std(const gen_obs_type * gen_obs, int index){ - return gen_obs->obs_std[index]; + return gen_obs->obs_std[index]; } -double gen_obs_iget_data(const gen_obs_type * gen_obs, int index){ - return gen_obs->obs_data[index]; +double gen_obs_iget_std_scaling(const gen_obs_type * gen_obs, int index) { + return gen_obs->std_scaling[index]; +} + + +double gen_obs_iget_value(const gen_obs_type * gen_obs, int index){ + return gen_obs->obs_data[index]; } int gen_obs_get_obs_index(const gen_obs_type * gen_obs, int index){ - if(index < 0 || index >= gen_obs->obs_size){ - util_abort("[Gen_Obs] Index out of bounds %d [0, %d]", index, gen_obs->obs_size - 1); - } - if (gen_obs->observe_all_data){ - return index; - } else { - return gen_obs->data_index_list[index]; - } + if(index < 0 || index >= gen_obs->obs_size){ + util_abort("[Gen_Obs] Index out of bounds %d [0, %d]", index, gen_obs->obs_size - 1); + } + + if (gen_obs->observe_all_data){ + return index; + } else { + return gen_obs->data_index_list[index]; + } } - + /*****************************************************************/ UTIL_IS_INSTANCE_FUNCTION(gen_obs , GEN_OBS_TYPE_ID) VOID_FREE(gen_obs) @@ -459,3 +501,4 @@ VOID_GET_OBS(gen_obs) VOID_MEASURE(gen_obs , gen_data) VOID_USER_GET_OBS(gen_obs) VOID_CHI2(gen_obs , gen_data) +VOID_UPDATE_STD_SCALE(gen_obs) diff --git a/ThirdParty/Ert/devel/libenkf/src/local_config.c b/ThirdParty/Ert/devel/libenkf/src/local_config.c index 64b143ca55..b885f1ba39 100644 --- a/ThirdParty/Ert/devel/libenkf/src/local_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/local_config.c @@ -35,7 +35,7 @@ #include <ert/enkf/local_updatestep.h> #include <ert/enkf/local_config.h> #include <ert/enkf/local_dataset.h> -#include <ert/enkf/local_obsset.h> +#include <ert/enkf/local_obsdata.h> #include <ert/enkf/local_context.h> #include <ert/enkf/ensemble_config.h> #include <ert/enkf/enkf_obs.h> @@ -64,8 +64,8 @@ CREATE_MINISTEP [NAME_OF_MINISTEP OBSSET_NAME] ----------------------------------------------- This function will create a new ministep with the name 'NAME_OF_MINISTEP'. The ministep will be based on the observation -set given by OBSSET_NAME (which must be created first).The ministep -is then ready for adding data. Before the ministep can be used you +set given by OBSSET_NAME (which must be created first).The ministep +is then ready for adding data. Before the ministep can be used you must attach it to an updatestep with the ATTACH_MINISTEP command CREATE_DATASET [NAME_OF_DATASET] @@ -268,24 +268,24 @@ of the cells" in one direction. ECLREGION_SELECT_PLANE [ECLREGION_NAME nx ny nz px py pz sign SELECT] --------------------------------------------------------- -Will select all points which have positive (sign > 0) distance to -the plane defined by normal vector n = (nx,ny,nz) and point -p = (px,py,pz). If sign < 0 all cells with negative distance to +Will select all points which have positive (sign > 0) distance to +the plane defined by normal vector n = (nx,ny,nz) and point +p = (px,py,pz). If sign < 0 all cells with negative distance to plane will be selected. ECLREGION_SELECT_IN_POLYGON [ECLREGION_NAME POLYGON_NAME SELECT] --------------------------------------------------- Well select all the points which are inside the polygon with name -'POLYGON_NAME'. The polygon should have been created with command +'POLYGON_NAME'. The polygon should have been created with command CREATE_POLYGON or loaded with command 'LOAD_POLYGON' first. CREATE_POLYGON [POLYGON_NAME num_points x1 y1 x2 y2 x3 y3 ....] --------------------------------------------------------------- -Will create a geo_polygon instance based on the coordinate list: -(x1,y1), (x2,y2), (x3,y3), ... The polygon should not be explicitly -closed - i.e. you should in general have (x1,y1) != (xn,yn). The +Will create a geo_polygon instance based on the coordinate list: +(x1,y1), (x2,y2), (x3,y3), ... The polygon should not be explicitly +closed - i.e. you should in general have (x1,y1) != (xn,yn). The polygon will be stored under the name 'POLYGON_NAME' - which should later be used when referring to the polygon in region select operations. @@ -307,15 +307,15 @@ have a base surface available for the CREATE_SURFACE_REGION command. CREATE_SURFACE_REGION [REGION_NAME BASE_SURFACE PRESELECT] ---------------------------------------------------------------- Will create a new surface region object which can be used to select -and deselect parts of a surface. The region will be called 'REGION_NAME' -and it will be based on the surface given by 'BASE_SURFACE'. 'PRESELECT' +and deselect parts of a surface. The region will be called 'REGION_NAME' +and it will be based on the surface given by 'BASE_SURFACE'. 'PRESELECT' is a boolean 'TRUE' or 'FALSE' which determines whether the region is created with all points selected, or no points selected. SURFACE_REGION_SELECT_IN_POLYGON [REGION_NAME POLYGON_NAME SELECT] -------------------------------------------------------------------- -Well select|deselect all the points in the surface which are inside the +Well select|deselect all the points in the surface which are inside the polygon. @@ -323,15 +323,15 @@ SURFACE_REGION_SELECT_LINE [ REGION_NAME X1 Y1 X2 Y2 SIGN SELECT] ------------------------------------------------------------------ Well select|deselect all the points which are above|below the line: (x1,y1) -> (x2,y2) -If SIGN is positive the select will apply to all points with a -positive (right hand system) distance to the line; if SIGN is negative +If SIGN is positive the select will apply to all points with a +positive (right hand system) distance to the line; if SIGN is negative the selector will apply to all points with a negative distance to the line. ADD_DATA_SURFACE [ DATASET_NAME SURFACE_NAME REGION NAME] ------------------------------------------------------------------- Will add the node 'SURFACE_NAME' (not one of the loaded surfaces, but -an enkf_node object) to the dataset 'DATASET_NAME'. Only the elements +an enkf_node object) to the dataset 'DATASET_NAME'. Only the elements in the region 'REGION_NAME' will be added. Typically SURFACE_REGION_SELECT_xxxx has been used first to build a suitable region selection. @@ -376,26 +376,26 @@ Second example: CREATE_DATASET SURFACE_DATA -- We load a surface from file which will be used as a base-surface when --- selecting active elements in surfaces. We give the surface the name +-- selecting active elements in surfaces. We give the surface the name -- 'BASE_SURFACE' - the surface should be in irap format. LOAD_SURFACE BASE_SURFACE Surface/base.irap -- We load two polygons in irap format; the polygons ire called 'North' --- and 'South'. Alternatively we can create a polygon with CREATE_POLYGON +-- and 'South'. Alternatively we can create a polygon with CREATE_POLYGON -- command: LOAD_POLYGON North Polygon/north.irap LOAD_POLYGON South Polygon/south.irap --- We create a new surface region - a surface region is a set of +-- We create a new surface region - a surface region is a set of -- points in a surface; the region need not be mathematically connected. -- The surface region is called myRegion - it is based on 'BASE_SURFACE' -- surface, and we start out with no elements selected. CREATE_SURFACE_REGION myRegion BASE_SURFACE False --- We update the region selection in 'myRegion' be selecting all the +-- We update the region selection in 'myRegion' be selecting all the -- points which are inside the two polygons 'North' and 'South': SURFACE_REGION_SELECT_IN_POLYGON myRegion North True SURFACE_REGION_SELECT_IN_POLYGON myRegion South True @@ -449,7 +449,7 @@ ADD_DATA_SURFACE ALL_DATA BOTTOM myRegion | | | | | +----------------------------------------------------------------------------+ | | | - | | + | | | +----------------- local_ministep_type --------------------------------------+ | | | | | | | / +--- local_dataset_type ---+ | | @@ -488,7 +488,7 @@ local_obsset_type: This is a collection of observation data; there is exactly one local_obsset for each local_ministep. local_dataset_type: This is a collection of data/parameters which - should be updated together in the EnKF updating. + should be updated together in the EnKF updating. How the local_dataset_type is configured is quite important for the @@ -510,7 +510,7 @@ core EnKF updating: UPDATE_RESULTS and SINGLE_NODE_UPDATE settings in the config file: UPDATE_RESULTS: Determines whether variables with enkf_type == - DYNAMIC_RESULT should be updated. + DYNAMIC_RESULT should be updated. SINGLE_NODE_UPDATE: If SINGLE_NODE_UPDATE is set to true the ALL_ACTIVE configuration will consist of maaany @@ -527,7 +527,7 @@ struct local_config_struct { hash_type * updatestep_storage; /* These three hash tables are the 'holding area' for the local_updatestep, */ hash_type * ministep_storage; /* local_ministep instances. */ hash_type * dataset_storage; - hash_type * obsset_storage; + hash_type * obsdata_storage; stringlist_type * config_files; }; @@ -537,7 +537,7 @@ static void local_config_clear( local_config_type * local_config ) { hash_clear( local_config->updatestep_storage ); hash_clear( local_config->ministep_storage ); hash_clear( local_config->dataset_storage ); - hash_clear( local_config->obsset_storage ); + hash_clear( local_config->obsdata_storage ); vector_clear( local_config->updatestep ); } @@ -551,7 +551,7 @@ local_config_type * local_config_alloc( ) { local_config->updatestep_storage = hash_alloc(); local_config->ministep_storage = hash_alloc(); local_config->dataset_storage = hash_alloc(); - local_config->obsset_storage = hash_alloc(); + local_config->obsdata_storage = hash_alloc(); local_config->updatestep = vector_alloc_new(); local_config->config_files = stringlist_alloc_new(); @@ -595,15 +595,15 @@ local_updatestep_type * local_config_alloc_updatestep( local_config_type * local local_ministep_type * local_config_alloc_ministep( local_config_type * local_config , const char * key , const char * obsset_name) { - local_obsset_type * obsset = hash_get( local_config->obsset_storage , obsset_name ); - local_ministep_type * ministep = local_ministep_alloc( key , obsset); + local_obsdata_type * obsdata = hash_get( local_config->obsdata_storage , obsset_name ); + local_ministep_type * ministep = local_ministep_alloc( key , obsdata ); hash_insert_hash_owned_ref( local_config->ministep_storage , key , ministep , local_ministep_free__); return ministep; } -local_obsset_type * local_config_alloc_obsset( local_config_type * local_config , const char * obsset_name ) { - local_obsset_type * obsset = local_obsset_alloc( obsset_name ); - hash_insert_hash_owned_ref( local_config->obsset_storage , obsset_name , obsset , local_obsset_free__); +local_obsdata_type * local_config_alloc_obsset( local_config_type * local_config , const char * obsset_name ) { + local_obsdata_type * obsset = local_obsdata_alloc( obsset_name ); + hash_insert_hash_owned_ref( local_config->obsdata_storage , obsset_name , obsset , local_obsdata_free__); return obsset; } @@ -619,18 +619,18 @@ local_dataset_type * local_config_alloc_dataset( local_config_type * local_confi local_dataset_type * local_config_alloc_dataset_copy( local_config_type * local_config , const char * src_key , const char * target_key) { local_dataset_type * src_dataset = hash_get( local_config->dataset_storage , src_key ); local_dataset_type * copy_dataset = local_dataset_alloc_copy( src_dataset , target_key ); - + hash_insert_hash_owned_ref( local_config->dataset_storage , target_key , copy_dataset , local_dataset_free__); return copy_dataset; } -local_obsset_type * local_config_alloc_obsset_copy( local_config_type * local_config , const char * src_key , const char * target_key) { - local_obsset_type * src_obsset = hash_get( local_config->obsset_storage , src_key ); - local_obsset_type * copy_obsset = local_obsset_alloc_copy( src_obsset , target_key ); - - hash_insert_hash_owned_ref( local_config->obsset_storage , target_key , copy_obsset , local_obsset_free__); - return copy_obsset; +local_obsdata_type * local_config_alloc_obsdata_copy( local_config_type * local_config , const char * src_key , const char * target_key) { + local_obsdata_type * src_obsdata = hash_get( local_config->obsdata_storage , src_key ); + local_obsdata_type * copy_obsdata = local_obsdata_alloc_copy( src_obsdata , target_key ); + + hash_insert_hash_owned_ref( local_config->obsdata_storage , target_key , copy_obsdata , local_obsdata_free__); + return copy_obsdata; } @@ -640,12 +640,14 @@ local_ministep_type * local_config_get_ministep( const local_config_type * local } -local_obsset_type * local_config_get_obsset( const local_config_type * local_config , const char * key) { - local_obsset_type * obsset = hash_get( local_config->obsset_storage , key ); - return obsset; +local_obsdata_type * local_config_get_obsdata( const local_config_type * local_config , const char * key) { + local_obsdata_type * obsdata = hash_get( local_config->obsdata_storage , key ); + return obsdata; } + + local_dataset_type * local_config_get_dataset( const local_config_type * local_config , const char * key) { local_dataset_type * dataset = hash_get( local_config->dataset_storage , key ); return dataset; @@ -670,7 +672,7 @@ const local_updatestep_type * local_config_iget_updatestep( const local_config_t time-index, revert to the default. */ updatestep = local_config->default_updatestep; - + if (updatestep == NULL) util_exit("%s: fatal error. No report step information for step:%d - and no default \n",__func__ , index); @@ -693,7 +695,7 @@ local_updatestep_type * local_config_get_updatestep( const local_config_type * l void local_config_set_updatestep(local_config_type * local_config, int step1 , int step2 , const char * key) { local_updatestep_type * updatestep = hash_get( local_config->updatestep_storage , key ); int step; - + for ( step = step1; step < step2 + 1; step++) vector_safe_iset_ref(local_config->updatestep , step , updatestep ); @@ -970,8 +972,8 @@ static void local_config_init_cmd_table( hash_type * cmd_table ) { hash_insert_int(cmd_table , ECLREGION_SELECT_IN_POLYGON_STRING , ECLREGION_SELECT_IN_POLYGON); hash_insert_int(cmd_table , CREATE_POLYGON_STRING , CREATE_POLYGON ); hash_insert_int(cmd_table , LOAD_POLYGON_STRING , LOAD_POLYGON ); - hash_insert_int(cmd_table , LOAD_SURFACE_STRING , LOAD_SURFACE ); - hash_insert_int(cmd_table , CREATE_SURFACE_REGION_STRING , CREATE_SURFACE_REGION ); + hash_insert_int(cmd_table , LOAD_SURFACE_STRING , LOAD_SURFACE ); + hash_insert_int(cmd_table , CREATE_SURFACE_REGION_STRING , CREATE_SURFACE_REGION ); hash_insert_int(cmd_table , SURFACE_REGION_SELECT_IN_POLYGON_STRING, SURFACE_REGION_SELECT_IN_POLYGON); hash_insert_int(cmd_table , SURFACE_REGION_SELECT_LINE_STRING , SURFACE_REGION_SELECT_LINE); hash_insert_int(cmd_table , ADD_DATA_SURFACE_STRING , ADD_DATA_SURFACE); @@ -1034,7 +1036,7 @@ static void local_config_COPY_DATASET( local_config_type * config , local_contex static void local_config_COPY_OBSSET( local_config_type * config , local_context_type * context , FILE * stream , bool binary) { char * src_name = read_alloc_string( stream , binary ); char * target_name = read_alloc_string( stream , binary ); - local_config_alloc_obsset_copy( config , src_name , target_name ); + local_config_alloc_obsdata_copy( config , src_name , target_name ); free( target_name ); free( src_name ); } @@ -1067,8 +1069,25 @@ static void local_config_ADD_OBS( local_config_type * config , local_context_typ char * obs_name = read_alloc_string( stream , binary ); char * obs_key = read_alloc_string( stream , binary ); { - local_obsset_type * obsset = local_config_get_obsset( config , obs_name ); - local_obsset_add_obs( obsset , obs_key ); + local_obsdata_type * obsdata = local_config_get_obsdata( config , obs_name ); + local_obsdata_node_type * obsdata_node = local_obsdata_node_alloc( obs_key ); + + /* + The local_obsdata_node should hold it's own active time-step + information. The problem is that currenty the active timesteps + for observations is configured/maintained/used in two different + locations: + + 1: The local_obsdata_node type contains a list of active time + steps for this particular node. + + 2: The time steps to use are arguments to the various update + algorithms; this is very much EnKF heritage. + + The second alternative should be eradicted. + */ + + local_obsdata_add_node( obsdata , obsdata_node); } free( obs_name ); free( obs_key ); @@ -1079,8 +1098,9 @@ static void local_config_ACTIVE_LIST_ADD_OBS_INDEX( local_config_type * config , char * obs_key = read_alloc_string( stream , binary ); int index = read_int( stream , binary ); { - local_obsset_type * obsset = local_config_get_obsset( config , obs_name ); - active_list_type * active_list = local_obsset_get_obs_active_list( obsset , obs_key ); + local_obsdata_type * obsdata = local_config_get_obsdata( config , obs_name ); + local_obsdata_node_type * obsdata_node = local_obsdata_get( obsdata , obs_key ); + active_list_type * active_list = local_obsdata_node_get_active_list( obsdata_node ); active_list_add_index( active_list , index ); } free( obs_name ); @@ -1106,11 +1126,12 @@ static void local_config_ACTIVE_LIST_ADD_MANY_OBS_INDEX( local_config_type * con int_vector_type * int_vector = int_vector_alloc(0,0); char * obs_name = read_alloc_string( stream , binary ); char * obs_key = read_alloc_string( stream , binary ); - + read_int_vector( stream , binary , int_vector); { - local_obsset_type * obsset = local_config_get_obsset( config , obs_name ); - active_list_type * active_list = local_obsset_get_obs_active_list( obsset , obs_key ); + local_obsdata_type * obsdata = local_config_get_obsdata( config , obs_name ); + local_obsdata_node_type * obsdata_node = local_obsdata_get( obsdata , obs_key ); + active_list_type * active_list = local_obsdata_node_get_active_list( obsdata_node ); for (int i = 0; i < int_vector_size( int_vector ); i++) active_list_add_index( active_list , int_vector_iget(int_vector , i)); } @@ -1141,7 +1162,7 @@ static void local_config_INSTALL_UPDATESTEP( local_config_type * config , local_ char * update_name = read_alloc_string( stream , binary ); { int step1,step2; - + step1 = read_int( stream , binary ); step2 = read_int( stream , binary ); local_config_set_updatestep( config , step1 , step2 , update_name ); @@ -1171,8 +1192,8 @@ static void local_config_DEL_OBS( local_config_type * config , local_context_typ char * obs_name = read_alloc_string( stream , binary ); char * obs_key = read_alloc_string( stream , binary ); { - local_obsset_type * obsset = local_config_get_obsset( config , obs_name ); - local_obsset_del_obs( obsset , obs_key ); + local_obsdata_type * obsdata = local_config_get_obsdata( config , obs_name ); + local_obsdata_del_node( obsdata , obs_key ); } free( obs_name ); free( obs_key ); @@ -1190,8 +1211,8 @@ static void local_config_DATASET_DEL_ALL_DATA( local_config_type * config , loca static void local_config_OBSSET_DEL_ALL_OBS( local_config_type * config , local_context_type * context , FILE * stream , bool binary) { char * obs_name = read_alloc_string( stream , binary ); { - local_obsset_type * obsset = local_config_get_obsset( config , obs_name ); - local_obsset_clear( obsset ); + local_obsdata_type * obsdata = local_config_get_obsdata( config , obs_name ); + local_obsdata_clear( obsdata ); } free( obs_name ); } @@ -1208,7 +1229,7 @@ static void local_config_ADD_FIELD( local_config_type * config , local_context_t { active_list_type * active_list = local_dataset_get_node_active_list( dataset , field_name ); const int_vector_type * region_active = ecl_region_get_active_list( region ); - + for (int i=0; i < int_vector_size( region_active ); i++) active_list_add_index( active_list , int_vector_iget( region_active , i ) ); } @@ -1230,7 +1251,7 @@ static void local_config_LOAD_FILE( local_config_type * config , local_context_t char * file_name = read_alloc_string( stream , binary ); local_context_load_file( context , file_name , file_key ); /* */ - + free( file_key ); free( file_name ); } @@ -1245,14 +1266,14 @@ static void local_config_ECLREGION_SELECT_BOX( local_config_type * config , loca int k1 = read_int( stream , binary ) - 1; int k2 = read_int( stream , binary ) - 1; bool select = read_bool( stream , binary ); - + ecl_region_type * region = local_context_get_ecl_region( context , region_name ); - + if (select) ecl_region_select_from_ijkbox( region , i1 , i2 , j1 , j2 , k1 , k2); else ecl_region_deselect_from_ijkbox( region , i1 , i2 , j1 , j2 , k1 , k2); - + free( region_name ); } @@ -1265,9 +1286,9 @@ static void local_config_ECLREGION_SELECT_SLICE( local_config_type * config , lo bool select = read_bool( stream , binary ); ecl_region_type * region = local_context_get_ecl_region( context , region_name ); - + util_strupr( dir ); - + if (strcmp( dir , "X") == 0) { if (select) ecl_region_select_i1i2( region , n1 , n2 ); @@ -1285,7 +1306,7 @@ static void local_config_ECLREGION_SELECT_SLICE( local_config_type * config , lo ecl_region_deselect_k1k2( region , n1 , n2 ); } else util_abort("%s: slice direction:%s not recognized \n",__func__ , dir ); - + free(dir ); free( region_name ); } @@ -1314,20 +1335,20 @@ static void local_config_ECLREGION_SELECT_VALUE( local_config_type * config , lo ecl_kw_type * ecl_kw; ecl_region_type * region; - { + { stringlist_type * key_list = stringlist_alloc_from_split( master_key , ":"); ecl_file_type * ecl_file = local_context_get_file( context , stringlist_iget(key_list , 0 ) ); int key_nr = 0; if (stringlist_get_size( key_list ) == 3) util_sscanf_int( stringlist_iget( key_list , 2 ) , &key_nr ); - + ecl_kw = ecl_file_iget_named_kw( ecl_file , stringlist_iget( key_list , 1 ) , key_nr); stringlist_free( key_list ); } region = local_context_get_ecl_region( context , region_name ); - + if (cmd == ECLREGION_SELECT_VALUE_EQUAL) { int value; util_sscanf_int( value_string , &value ); @@ -1338,7 +1359,7 @@ static void local_config_ECLREGION_SELECT_VALUE( local_config_type * config , lo } else { double value; util_sscanf_double( value_string , &value ); - + if (cmd == ECLREGION_SELECT_VALUE_LESS) { if (select) ecl_region_select_smaller( region , ecl_kw , value ); @@ -1350,7 +1371,7 @@ static void local_config_ECLREGION_SELECT_VALUE( local_config_type * config , lo else ecl_region_deselect_larger( region , ecl_kw , value); } - + } } free( master_key ); @@ -1366,18 +1387,18 @@ static void local_config_ECLREGION_SELECT_PLANE( local_config_type * config , lo bool select; ecl_region_type * region; char * region_name = read_alloc_string( stream , binary ); - + normal_vec[0] = read_double( stream , binary ); normal_vec[1] = read_double( stream , binary ); normal_vec[2] = read_double( stream , binary ); - + p0[0] = read_double( stream , binary ); p0[1] = read_double( stream , binary ); p0[2] = read_double( stream , binary ); - + sign = read_double( stream , binary); select = read_bool( stream , binary ); - + region = local_context_get_ecl_region( context , region_name ); if (select) { if (sign > 0) @@ -1401,14 +1422,14 @@ static void local_config_CREATE_POLYGON( local_config_type * config , local_cont { geo_polygon_type * polygon = local_context_get_polygon( context , polygon_name ); int num_points = read_int( stream , binary ); - + if (num_points < 2) util_abort("%s: error when parsing CREATE_POLYGON - need at least 3 points in polygon\n",__func__); - + for (int i=0; i < num_points; i++) { double x = read_double( stream , binary ); double y = read_double( stream , binary ); - + geo_polygon_add_point( polygon , x , y ); } } @@ -1427,7 +1448,7 @@ static void local_config_LOAD_POLYGON( local_config_type * config , local_contex static void local_config_ECLREGION_SELECT_IN_POLYGON( local_config_type * config , local_context_type * context , FILE * stream , bool binary) { - + char * region_name = read_alloc_string( stream , binary ); char * polygon_name = read_alloc_string( stream , binary ); bool select = read_bool( stream , binary ); @@ -1437,7 +1458,7 @@ static void local_config_ECLREGION_SELECT_IN_POLYGON( local_config_type * config polygon = local_context_get_polygon( context , polygon_name ); region = local_context_get_ecl_region( context , region_name ); - if (select) + if (select) ecl_region_select_inside_polygon( region , polygon ); else ecl_region_select_inside_polygon( region , polygon ); @@ -1450,21 +1471,21 @@ static void local_config_ECLREGION_SELECT_IN_POLYGON( local_config_type * config static void local_config_LOAD_SURFACE( local_config_type * config , local_context_type * context , FILE * stream , bool binary) { char * surface_name = read_alloc_string( stream , binary ); char * surface_file = read_alloc_string( stream , binary ); - + local_context_load_surface( context , surface_name , surface_file ); - + free( surface_file ); free( surface_name ); } static void local_config_CREATE_SURFACE_REGION( local_config_type * config , local_context_type * context , FILE * stream , bool binary) { - char * region_name = read_alloc_string( stream , binary ); - char * base_surface = read_alloc_string( stream , binary ); - bool preselect = read_bool( stream , binary ); - + char * region_name = read_alloc_string( stream , binary ); + char * base_surface = read_alloc_string( stream , binary ); + bool preselect = read_bool( stream , binary ); + local_context_create_surface_region( context , base_surface , region_name , preselect); - + free( region_name ); free( base_surface); } @@ -1473,7 +1494,7 @@ static void local_config_CREATE_SURFACE_REGION( local_config_type * config , loc static void local_config_SURFACE_REGION_SELECT_IN_POLYGON( local_config_type * config , local_context_type * context , FILE * stream , bool binary) { char * region_name = read_alloc_string( stream , binary ); char * polygon_name = read_alloc_string( stream , binary ); - bool select = read_bool( stream , binary ); + bool select = read_bool( stream , binary ); geo_region_type * region = local_context_get_surface_region( context , region_name ); geo_polygon_type * polygon = local_context_get_polygon( context , polygon_name ); @@ -1491,13 +1512,13 @@ static void local_config_SURFACE_REGION_SELECT_LINE( local_config_type * config double xcoords[2]; double ycoords[2]; char * region_name = read_alloc_string( stream , binary ); - xcoords[0] = read_double( stream , binary ); - ycoords[0] = read_double( stream , binary ); - xcoords[1] = read_double( stream , binary ); - ycoords[1] = read_double( stream , binary ); + xcoords[0] = read_double( stream , binary ); + ycoords[0] = read_double( stream , binary ); + xcoords[1] = read_double( stream , binary ); + ycoords[1] = read_double( stream , binary ); sign = read_double( stream , binary ); - select = read_bool( stream , binary ); - + select = read_bool( stream , binary ); + geo_region_type * region = local_context_get_surface_region( context , region_name ); if (select) { @@ -1528,8 +1549,8 @@ static void local_config_ADD_DATA_SURFACE( local_config_type * config , local_co { active_list_type * active_list = local_dataset_get_node_active_list( dataset , surface_name ); const int_vector_type * region_active = geo_region_get_index_list( region ); - - for (int i=0; i < int_vector_size( region_active ); i++) + + for (int i=0; i < int_vector_size( region_active ); i++) active_list_add_index( active_list , int_vector_iget( region_active , i ) ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/local_context.c b/ThirdParty/Ert/devel/libenkf/src/local_context.c index a81861a0d7..bb2ac13648 100644 --- a/ThirdParty/Ert/devel/libenkf/src/local_context.c +++ b/ThirdParty/Ert/devel/libenkf/src/local_context.c @@ -106,7 +106,7 @@ static void local_context_add_polygon__( local_context_type * context , const ch } void local_context_add_polygon( local_context_type * context , const char * polygon_name ) { - geo_polygon_type * polygon = geo_polygon_alloc( ); + geo_polygon_type * polygon = geo_polygon_alloc( polygon_name ); local_context_add_polygon__(context , polygon_name , polygon ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/local_ministep.c b/ThirdParty/Ert/devel/libenkf/src/local_ministep.c index 71bdc262f6..e96d226ca2 100644 --- a/ThirdParty/Ert/devel/libenkf/src/local_ministep.c +++ b/ThirdParty/Ert/devel/libenkf/src/local_ministep.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'local_ministep.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'local_ministep.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -24,10 +24,10 @@ #include <ert/util/util.h> #include <ert/enkf/enkf_macros.h> -#include <ert/enkf/local_config.h> +#include <ert/enkf/local_config.h> #include <ert/enkf/local_ministep.h> #include <ert/enkf/local_dataset.h> -#include <ert/enkf/local_obsset.h> +#include <ert/enkf/local_obsdata.h> /** This file implements a 'ministep' configuration for active / @@ -53,7 +53,7 @@ struct local_ministep_struct { UTIL_TYPE_ID_DECLARATION; char * name; /* A name used for this ministep - string is also used as key in a hash table holding this instance. */ hash_type * datasets; /* A hash table of local_dataset_type instances - indexed by the name of the datasets. */ - local_obsset_type * observations; + local_obsdata_type * observations; }; @@ -65,14 +65,14 @@ struct local_ministep_struct { UTIL_SAFE_CAST_FUNCTION(local_ministep , LOCAL_MINISTEP_TYPE_ID) UTIL_IS_INSTANCE_FUNCTION(local_ministep , LOCAL_MINISTEP_TYPE_ID) -local_ministep_type * local_ministep_alloc(const char * name , local_obsset_type * observations) { +local_ministep_type * local_ministep_alloc(const char * name , local_obsdata_type * observations) { local_ministep_type * ministep = util_malloc( sizeof * ministep ); ministep->name = util_alloc_string_copy( name ); ministep->observations = observations; ministep->datasets = hash_alloc(); UTIL_TYPE_ID_INIT( ministep , LOCAL_MINISTEP_TYPE_ID); - + return ministep; } @@ -127,7 +127,7 @@ void local_ministep_free__(void * arg) { 2. The newly added elements will be assigned an active_list instance with mode ALL_ACTIVE. -*/ +*/ @@ -141,7 +141,7 @@ local_dataset_type * local_ministep_get_dataset( const local_ministep_type * min return hash_get( ministep->datasets, dataset_name ); } -local_obsset_type * local_ministep_get_obsset( const local_ministep_type * ministep ) { +local_obsdata_type * local_ministep_get_obsdata( const local_ministep_type * ministep ) { return ministep->observations; } @@ -160,7 +160,7 @@ hash_iter_type * local_ministep_alloc_dataset_iter( const local_ministep_type * void local_ministep_fprintf( const local_ministep_type * ministep , FILE * stream ) { - fprintf(stream , "%s %s %s\n", local_config_get_cmd_string( CREATE_MINISTEP ), ministep->name , local_obsset_get_name( ministep->observations) ); + fprintf(stream , "%s %s %s\n", local_config_get_cmd_string( CREATE_MINISTEP ), ministep->name , local_obsdata_get_name( ministep->observations) ); { hash_iter_type * dataset_iter = hash_iter_alloc( ministep->datasets ); while (!hash_iter_is_complete( dataset_iter )) { diff --git a/ThirdParty/Ert/devel/libenkf/src/local_obsdata.c b/ThirdParty/Ert/devel/libenkf/src/local_obsdata.c index c1a76315df..e4f4f40672 100644 --- a/ThirdParty/Ert/devel/libenkf/src/local_obsdata.c +++ b/ThirdParty/Ert/devel/libenkf/src/local_obsdata.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - + Copyright (C) 2013 Statoil ASA, Norway. + The file 'local_obsdata.c' - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -37,6 +37,7 @@ struct local_obsdata_struct { UTIL_IS_INSTANCE_FUNCTION( local_obsdata , LOCAL_OBSDATA_TYPE_ID ) +static UTIL_SAFE_CAST_FUNCTION( local_obsdata , LOCAL_OBSDATA_TYPE_ID ) local_obsdata_type * local_obsdata_alloc( const char * name) { local_obsdata_type * data = util_malloc( sizeof * data ); @@ -56,6 +57,19 @@ local_obsdata_type * local_obsdata_alloc_wrapper( local_obsdata_node_type * node } +local_obsdata_type * local_obsdata_alloc_copy( const local_obsdata_type * src, const char * target_key) { + local_obsdata_type * target = local_obsdata_alloc( target_key ); + int i; + for (i=0; i < local_obsdata_get_size( src ); i++ ) { + const local_obsdata_node_type * src_node = local_obsdata_iget( src , i ); + local_obsdata_node_type * target_node = local_obsdata_node_alloc_copy( src_node ); + local_obsdata_add_node( target , target_node ); + } + return target; +} + + + void local_obsdata_free( local_obsdata_type * data ) { vector_free( data->nodes_list ); hash_free( data->nodes_map ); @@ -63,6 +77,12 @@ void local_obsdata_free( local_obsdata_type * data ) { free( data ); } +void local_obsdata_free__( void * arg) { + local_obsdata_type * data = local_obsdata_safe_cast( arg ); + return local_obsdata_free( data ); +} + + const char * local_obsdata_get_name( const local_obsdata_type * data) { return data->name; } @@ -81,7 +101,7 @@ int local_obsdata_get_size( const local_obsdata_type * data ) { bool local_obsdata_add_node( local_obsdata_type * data , local_obsdata_node_type * node ) { const char * key = local_obsdata_node_get_key( node ); if (local_obsdata_has_node(data , key)) - return false; + return false; else { vector_append_owned_ref( data->nodes_list , node , local_obsdata_node_free__ ); hash_insert_ref( data->nodes_map , key , node ); @@ -89,12 +109,39 @@ bool local_obsdata_add_node( local_obsdata_type * data , local_obsdata_node_type } } + void local_obsdata_del_node( local_obsdata_type * data , const char * key) { + local_obsdata_node_type * node = local_obsdata_get( data , key ); + int index = vector_find( data->nodes_list , node ); -const local_obsdata_node_type * local_obsdata_iget( const local_obsdata_type * data , int index) { - return vector_iget_const( data->nodes_list , index ); + hash_del( data->nodes_map , key ); + vector_idel( data->nodes_list , index ); +} + + + void local_obsdata_clear( local_obsdata_type * data ) { + hash_clear( data->nodes_map ); + vector_clear( data->nodes_list ); + } + + +local_obsdata_node_type * local_obsdata_iget( const local_obsdata_type * data , int index) { + return vector_iget( data->nodes_list , index ); +} + + +local_obsdata_node_type * local_obsdata_get( const local_obsdata_type * data , const char * key) { + return hash_get( data->nodes_map , key ); } bool local_obsdata_has_node( const local_obsdata_type * data , const char * key) { return hash_has_key( data->nodes_map , key ); } + +void local_obsdata_reset_tstep_list( local_obsdata_type * data , const int_vector_type * step_list) { + int i; + for (i=0; i < local_obsdata_get_size( data ); i++ ) { + local_obsdata_node_type * node = local_obsdata_iget( data , i ); + local_obsdata_node_reset_tstep_list(node, step_list); + } +} diff --git a/ThirdParty/Ert/devel/libenkf/src/local_obsdata_node.c b/ThirdParty/Ert/devel/libenkf/src/local_obsdata_node.c index 8c9303b318..fc2daa2ca8 100644 --- a/ThirdParty/Ert/devel/libenkf/src/local_obsdata_node.c +++ b/ThirdParty/Ert/devel/libenkf/src/local_obsdata_node.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - + Copyright (C) 2013 Statoil ASA, Norway. + The file 'local_obsdata_node.c' - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -21,35 +21,55 @@ #include <ert/util/util.h> #include <ert/util/int_vector.h> -#include <ert/enkf/obs_tstep_list.h> #include <ert/enkf/local_obsdata_node.h> - #define LOCAL_OBSDATA_NODE_TYPE_ID 84441309 struct local_obsdata_node_struct { UTIL_TYPE_ID_DECLARATION; char * obs_key; active_list_type * active_list; - obs_tstep_list_type * tstep_list; + int_vector_type * tstep_list; + bool all_timestep_active; }; UTIL_IS_INSTANCE_FUNCTION( local_obsdata_node , LOCAL_OBSDATA_NODE_TYPE_ID ) +UTIL_SAFE_CAST_FUNCTION( local_obsdata_node , LOCAL_OBSDATA_NODE_TYPE_ID ) -static UTIL_SAFE_CAST_FUNCTION( local_obsdata_node , LOCAL_OBSDATA_NODE_TYPE_ID ) - -local_obsdata_node_type * local_obsdata_node_alloc( const char * obs_key ) { +static local_obsdata_node_type * local_obsdata_node_alloc__( const char * obs_key ) { local_obsdata_node_type * node = util_malloc( sizeof * node ); UTIL_TYPE_ID_INIT( node , LOCAL_OBSDATA_NODE_TYPE_ID ); node->obs_key = util_alloc_string_copy( obs_key ); + node->active_list = NULL; + node->tstep_list = NULL; + node->all_timestep_active = true; + return node; +} + + +local_obsdata_node_type * local_obsdata_node_alloc( const char * obs_key ) { + local_obsdata_node_type * node = local_obsdata_node_alloc__(obs_key); + node->active_list = active_list_alloc( ); - node->tstep_list = obs_tstep_list_alloc( ); + node->tstep_list = int_vector_alloc(0,0); + return node; } +local_obsdata_node_type * local_obsdata_node_alloc_copy( const local_obsdata_node_type * src) { + local_obsdata_node_type * target = local_obsdata_node_alloc__( src->obs_key ); + + target->active_list = active_list_alloc_copy( src->active_list ); + target->tstep_list = int_vector_alloc_copy( src->tstep_list ); + + return target; +} + + + void local_obsdata_node_copy_active_list( local_obsdata_node_type * node , const active_list_type * active_list) { active_list_copy( node->active_list , active_list ); } @@ -62,8 +82,12 @@ const char * local_obsdata_node_get_key( const local_obsdata_node_type * node ) void local_obsdata_node_free( local_obsdata_node_type * node ) { - active_list_free( node->active_list ); - obs_tstep_list_free( node->tstep_list ); + if (node->active_list) + active_list_free( node->active_list ); + + if (node->tstep_list) + int_vector_free( node->tstep_list ); + free( node->obs_key ); free( node ); } @@ -81,16 +105,62 @@ active_list_type * local_obsdata_node_get_active_list( const local_obsdata_node_ } -const obs_tstep_list_type * local_obsdata_node_get_tstep_list( const local_obsdata_node_type * node) { +const int_vector_type * local_obsdata_node_get_tstep_list( const local_obsdata_node_type * node) { + if (node->all_timestep_active) + util_abort("%s: internal error: When the all_timestep_active() switch is set to true you can not ASK for timestep\n",__func__); + return node->tstep_list; } +/* + This a temporarary function to support the change local_obsset -> + local_obsdata; should eventually be removed. +*/ + +void local_obsdata_node_reset_tstep_list( local_obsdata_node_type * node , const int_vector_type * step_list) { + int_vector_free(node->tstep_list); + node->tstep_list = int_vector_alloc_copy( step_list ); + node->all_timestep_active = false; +} + + +bool local_obsdata_node_all_timestep_active( const local_obsdata_node_type * node) { + return node->all_timestep_active; +} + +/** + Observe that this function check for explicitly added timestep, + i.e. if the all_timestep_active flag is set to true this will + return false. +*/ + +bool local_obsdata_node_has_tstep( const local_obsdata_node_type * node , int tstep) { + const int_vector_type * tstep_list = node->tstep_list; + if (int_vector_index_sorted( tstep_list , tstep) == -1) + return false; + else + return true; +} + void local_obsdata_node_add_tstep( local_obsdata_node_type * node, int tstep) { - obs_tstep_list_add_tstep( node->tstep_list , tstep ); + if (!local_obsdata_node_has_tstep( node , tstep)) { + if (int_vector_size( node->tstep_list )) { + int last = int_vector_get_last( node->tstep_list ); + int_vector_append( node->tstep_list , tstep ); + if (tstep < last) + int_vector_sort( node->tstep_list); + } else + int_vector_append( node->tstep_list , tstep ); + } + node->all_timestep_active = false; } + + void local_obsdata_node_add_range( local_obsdata_node_type * node, int step1 , int step2) { - obs_tstep_list_add_range( node->tstep_list , step1 , step2); + int tstep; + for (tstep = step1; tstep <= step2; tstep++) + local_obsdata_node_add_tstep( node , tstep ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/local_obsset.c b/ThirdParty/Ert/devel/libenkf/src/local_obsset.c deleted file mode 100644 index 2bb094f653..0000000000 --- a/ThirdParty/Ert/devel/libenkf/src/local_obsset.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'local_obsset.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <stdbool.h> - -#include <ert/util/util.h> -#include <ert/util/hash.h> - -#include <ert/enkf/active_list.h> -#include <ert/enkf/local_obsset.h> -#include <ert/enkf/local_config.h> - -#define LOCAL_OBSSET_TYPE_ID 991534 - -struct local_obsset_struct { - UTIL_TYPE_ID_DECLARATION; - char * name; - hash_type * observations; /* Hash table of active_list instances. */ -}; - - -static UTIL_SAFE_CAST_FUNCTION( local_obsset , LOCAL_OBSSET_TYPE_ID ) - -local_obsset_type * local_obsset_alloc( const char * name ) { - local_obsset_type * obsset = util_malloc( sizeof * obsset); - UTIL_TYPE_ID_INIT( obsset , LOCAL_OBSSET_TYPE_ID ); - obsset->name = util_alloc_string_copy( name ); - obsset->observations = hash_alloc(); - return obsset; -} - - -local_obsset_type * local_obsset_alloc_copy( local_obsset_type * src_dataset , const char * copy_name ) { - local_obsset_type * copy_dataset = local_obsset_alloc( copy_name ); - hash_iter_type * node_iter = hash_iter_alloc( src_dataset->observations ); - - while (!hash_iter_is_complete( node_iter )) { - const char * key = hash_iter_get_next_key( node_iter ); - active_list_type * active_list = active_list_alloc_copy( hash_get( src_dataset->observations , key ) ); - hash_insert_hash_owned_ref( copy_dataset->observations , key , active_list , active_list_free__); - } - - hash_iter_free( node_iter ); - return copy_dataset; -} - - - -void local_obsset_free( local_obsset_type * obsset ) { - hash_free( obsset->observations ); - free( obsset->name ); - free( obsset ); -} - - -void local_obsset_free__( void * arg ) { - local_obsset_type * obsset = local_obsset_safe_cast( arg ); - local_obsset_free( obsset ); -} - - -void local_obsset_add_obs(local_obsset_type * obsset, const char * obs_key) { - if (hash_has_key( obsset->observations , obs_key )) - util_abort("%s: tried to add existing observation key:%s \n",__func__ , obs_key); - - hash_insert_hash_owned_ref( obsset->observations , obs_key , active_list_alloc( ALL_ACTIVE ) , active_list_free__); -} - - -void local_obsset_del_obs( local_obsset_type * obsset , const char * obs_key) { - hash_del( obsset->observations , obs_key ); -} - -void local_obsset_clear( local_obsset_type * obsset ) { - hash_clear( obsset->observations ); -} - -const char * local_obsset_get_name( const local_obsset_type * obsset ) { - return obsset->name; -} - - -void local_obsset_fprintf(local_obsset_type * obsset , FILE * stream) { - hash_iter_type * obs_iter = hash_iter_alloc( obsset->observations ); - while (!hash_iter_is_complete( obs_iter )) { - const char * obs_key = hash_iter_get_next_key( obs_iter ); - active_list_type * active_list = hash_get( obsset->observations , obs_key ); - - fprintf(stream , "%s %s %s\n", local_config_get_cmd_string( ADD_OBS ) , obsset->name , obs_key ); - active_list_fprintf( active_list , true , obs_key , stream ); - } - hash_iter_free( obs_iter ); -} - - -active_list_type * local_obsset_get_obs_active_list( const local_obsset_type * obsset , const char * obs_key ) { - return hash_get( obsset->observations , obs_key ); -} - - -hash_iter_type * local_obsset_alloc_obs_iter( const local_obsset_type * obsset ) { - return hash_iter_alloc( obsset->observations ); -} diff --git a/ThirdParty/Ert/devel/libenkf/src/local_updatestep.c b/ThirdParty/Ert/devel/libenkf/src/local_updatestep.c index bbfc1d20e9..0ebeff175c 100644 --- a/ThirdParty/Ert/devel/libenkf/src/local_updatestep.c +++ b/ThirdParty/Ert/devel/libenkf/src/local_updatestep.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'local_updatestep.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'local_updatestep.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <ert/util/util.h> @@ -48,17 +48,17 @@ UTIL_SAFE_CAST_FUNCTION(local_updatestep , LOCAL_UPDATESTEP_TYPE_ID) local_updatestep_type * local_updatestep_alloc( const char * name ) { local_updatestep_type * updatestep = util_malloc( sizeof * updatestep ); - + UTIL_TYPE_ID_INIT( updatestep , LOCAL_UPDATESTEP_TYPE_ID ); updatestep->name = util_alloc_string_copy( name ); updatestep->ministep = vector_alloc_new(); - + return updatestep; } /** - Observe that use_count values are not copied. + Observe that use_count values are not copied. */ local_updatestep_type * local_updatestep_alloc_copy( const local_updatestep_type * src , const char * name ) { local_updatestep_type * new = local_updatestep_alloc( name ); @@ -92,8 +92,8 @@ local_ministep_type * local_updatestep_iget_ministep( const local_updatestep_typ } -local_obsset_type * local_updatestep_iget_obsset( const local_updatestep_type * updatestep , int index) { - return local_ministep_get_obsset( vector_iget( updatestep->ministep , index ) ); +local_obsdata_type * local_updatestep_iget_obsdata( const local_updatestep_type * updatestep , int index) { + return local_ministep_get_obsdata( vector_iget( updatestep->ministep , index ) ); } @@ -102,7 +102,7 @@ int local_updatestep_get_num_ministep( const local_updatestep_type * updatestep) } const char * local_updatestep_get_name( const local_updatestep_type * updatestep ) { - return updatestep->name; + return updatestep->name; } diff --git a/ThirdParty/Ert/devel/libenkf/src/meas_data.c b/ThirdParty/Ert/devel/libenkf/src/meas_data.c index 5c4d5a7be8..318a4ad7c5 100644 --- a/ThirdParty/Ert/devel/libenkf/src/meas_data.c +++ b/ThirdParty/Ert/devel/libenkf/src/meas_data.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'meas_data.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'meas_data.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -30,9 +30,9 @@ #include <ert/util/util.h> #include <ert/util/hash.h> #include <ert/util/matrix.h> -#include <ert/util/set.h> #include <ert/util/vector.h> #include <ert/util/int_vector.h> +#include <ert/util/type_vector_functions.h> #include <ert/enkf/meas_data.h> @@ -42,58 +42,63 @@ struct meas_data_struct { UTIL_TYPE_ID_DECLARATION; - int ens_size; - vector_type * data; + int active_ens_size; + vector_type * data; pthread_mutex_t data_mutex; - set_type * lookup_keys; /* Mangled obs_key and report_step */ + hash_type * blocks; + bool_vector_type * ens_mask; }; struct meas_block_struct { UTIL_TYPE_ID_DECLARATION; - int ens_size; + int active_ens_size; int obs_size; int ens_stride; int obs_stride; int data_size; - int report_step; /* Not really necessary ?? */ char * obs_key; double * data; bool * active; + bool stat_calculated; + const bool_vector_type * ens_mask; + int_vector_type * index_map; }; -static UTIL_SAFE_CAST_FUNCTION( meas_block , MEAS_BLOCK_TYPE_ID ) +UTIL_SAFE_CAST_FUNCTION( meas_block , MEAS_BLOCK_TYPE_ID ) /** Observe that meas_block instance must be allocated with a correct value for obs_size; it can not grow during use, and it does also not count the number of elements added. - + Observe that the input argument @obs_size should be the total size of the observation; if parts of the observation have been excluded due to local analysis it should still be included in the @obs_size value. */ -static meas_block_type * meas_block_alloc( const char * obs_key , int report_step , int ens_size , int obs_size) { +meas_block_type * meas_block_alloc( const char * obs_key , const bool_vector_type * ens_mask , int obs_size) { meas_block_type * meas_block = util_malloc( sizeof * meas_block ); UTIL_TYPE_ID_INIT( meas_block , MEAS_BLOCK_TYPE_ID ); - meas_block->ens_size = ens_size; + meas_block->active_ens_size = bool_vector_count_equal( ens_mask , true ); + meas_block->ens_mask = ens_mask; meas_block->obs_size = obs_size; meas_block->obs_key = util_alloc_string_copy( obs_key ); - meas_block->data = util_calloc( (ens_size + 2) * obs_size , sizeof * meas_block->data ); - meas_block->active = util_calloc( obs_size , sizeof * meas_block->active ); + meas_block->data = util_calloc( (meas_block->active_ens_size + 2) * obs_size , sizeof * meas_block->data ); + meas_block->active = util_calloc( obs_size , sizeof * meas_block->active ); meas_block->ens_stride = 1; - meas_block->obs_stride = ens_size + 2; - meas_block->data_size = (ens_size + 2) * obs_size; - meas_block->report_step = report_step; + meas_block->obs_stride = meas_block->active_ens_size + 2; + meas_block->data_size = (meas_block->active_ens_size + 2) * obs_size; + meas_block->index_map = bool_vector_alloc_active_index_list( meas_block->ens_mask , -1); { int i; - for (i=0; i <obs_size; i++) + for (i=0; i < obs_size; i++) meas_block->active[i] = false; } + meas_block->stat_calculated = false; return meas_block; } @@ -101,7 +106,7 @@ static void meas_block_fprintf( const meas_block_type * meas_block , FILE * stre int iens; int iobs; for (iobs = 0; iobs < meas_block->obs_size; iobs++) { - for (iens = 0; iens < meas_block->ens_size; iens++) { + for (iens = 0; iens < meas_block->active_ens_size; iens++) { int index = iens * meas_block->ens_stride + iobs * meas_block->obs_stride; fprintf(stream , " %10.2f ", meas_block->data[ index ]); } @@ -110,10 +115,11 @@ static void meas_block_fprintf( const meas_block_type * meas_block , FILE * stre } -static void meas_block_free( meas_block_type * meas_block ) { +void meas_block_free( meas_block_type * meas_block ) { free( meas_block->obs_key ); free( meas_block->data ); free( meas_block->active ); + int_vector_free( meas_block->index_map ); free( meas_block ); } @@ -129,9 +135,9 @@ static void meas_block_initS( const meas_block_type * meas_block , matrix_type * int obs_offset = *__obs_offset; for (int iobs =0; iobs < meas_block->obs_size; iobs++) { if (meas_block->active[iobs]) { - for (int iens =0; iens < meas_block->ens_size; iens++) { + for (int iens =0; iens < meas_block->active_ens_size; iens++) { int obs_index = iens * meas_block->ens_stride + iobs* meas_block->obs_stride; - + matrix_iset( S , obs_offset, iens , meas_block->data[ obs_index ]); } obs_offset++; @@ -140,61 +146,112 @@ static void meas_block_initS( const meas_block_type * meas_block , matrix_type * *__obs_offset = obs_offset; } +bool meas_block_iens_active( const meas_block_type * meas_block , int iens) { + return bool_vector_iget( meas_block->ens_mask , iens); +} + +/* static void meas_data_assign_block( meas_block_type * target_block , const meas_block_type * src_block , int target_iens , int src_iens ) { int iobs; - for (iobs =0; iobs < target_block->obs_size; iobs++) { + for (iobs =0; iobs < target_block->obs_size; iobs++) { int target_index = target_iens * target_block->ens_stride + iobs * target_block->obs_stride; int src_index = src_iens * src_block->ens_stride + iobs * src_block->obs_stride; target_block->data[ target_index ] = src_block->data[ src_index ]; } + target_block->stat_calculated = false; } +*/ - -void meas_block_calculate_ens_stats( meas_block_type * meas_block ) { +static void meas_block_calculate_ens_stats( meas_block_type * meas_block ) { bool include_inactive = true; int iobs , iens; - for (iobs =0; iobs < meas_block->obs_size; iobs++) { - if (meas_block->active[iobs] || include_inactive) { + for (iobs =0; iobs < meas_block->obs_size; iobs++) { + if (meas_block->active[iobs] || include_inactive) { double M1 = 0; double M2 = 0; - for (iens =0; iens < meas_block->ens_size; iens++) { + for (iens =0; iens < meas_block->active_ens_size; iens++) { int index = iens * meas_block->ens_stride + iobs * meas_block->obs_stride; M1 += meas_block->data[ index ]; M2 += meas_block->data[ index ] * meas_block->data[ index ]; } { - int mean_index = (meas_block->ens_size + 0) * meas_block->ens_stride + iobs * meas_block->obs_stride; - int std_index = (meas_block->ens_size + 1) * meas_block->ens_stride + iobs * meas_block->obs_stride; - double mean = M1 / meas_block->ens_size; - double var = M2 / meas_block->ens_size - mean * mean; + int mean_index = (meas_block->active_ens_size + 0) * meas_block->ens_stride + iobs * meas_block->obs_stride; + int std_index = (meas_block->active_ens_size + 1) * meas_block->ens_stride + iobs * meas_block->obs_stride; + double mean = M1 / meas_block->active_ens_size; + double var = M2 / meas_block->active_ens_size - mean * mean; meas_block->data[ mean_index ] = mean; meas_block->data[ std_index ] = sqrt( util_double_max( 0.0 , var)); } } } + meas_block->stat_calculated = true; } +static void meas_block_assert_ens_stat( meas_block_type * meas_block ) { + if (!meas_block->stat_calculated) + meas_block_calculate_ens_stats( meas_block ); +} + + +static void meas_block_assert_iens_active( const meas_block_type * meas_block , int iens) { + if (!bool_vector_iget( meas_block->ens_mask , iens )) + util_abort("%s: fatal error - trying to access inactive ensemble member:%d \n",__func__ , iens); +} + void meas_block_iset( meas_block_type * meas_block , int iens , int iobs , double value) { - int index = iens * meas_block->ens_stride + iobs * meas_block->obs_stride; - meas_block->data[ index ] = value; - if (!meas_block->active[ iobs ]) - meas_block->active[ iobs ] = true; + meas_block_assert_iens_active( meas_block , iens ); + { + int active_iens = int_vector_iget( meas_block->index_map , iens ); + int index = active_iens * meas_block->ens_stride + iobs * meas_block->obs_stride; + meas_block->data[ index ] = value; + if (!meas_block->active[ iobs ]) + meas_block->active[ iobs ] = true; + + meas_block->stat_calculated = false; + } +} + +double meas_block_iget( const meas_block_type * meas_block , int iens , int iobs) { + meas_block_assert_iens_active( meas_block , iens ); + { + int active_iens = int_vector_iget( meas_block->index_map , iens ); + int index = active_iens * meas_block->ens_stride + iobs * meas_block->obs_stride; + return meas_block->data[ index ]; + } } -double meas_block_iget_ens_std( const meas_block_type * meas_block , int iobs) { - int std_index = (meas_block->ens_size + 1) * meas_block->ens_stride + iobs * meas_block->obs_stride; - return meas_block->data[ std_index ]; +static int meas_block_get_active_obs_size( const meas_block_type * meas_block ) { + int obs_size = 0; + int i; + + for (i=0; i < meas_block->obs_size; i++) + if (meas_block->active[i]) + obs_size++; + + return obs_size; } -double meas_block_iget_ens_mean( const meas_block_type * meas_block , int iobs) { - int mean_index = meas_block->ens_size * meas_block->ens_stride + iobs * meas_block->obs_stride; - return meas_block->data[ mean_index ]; +double meas_block_iget_ens_std( meas_block_type * meas_block , int iobs) { + meas_block_assert_ens_stat( meas_block ); + { + int std_index = (meas_block->active_ens_size + 1) * meas_block->ens_stride + iobs * meas_block->obs_stride; + return meas_block->data[ std_index ]; + } +} + + +double meas_block_iget_ens_mean( meas_block_type * meas_block , int iobs) { + meas_block_assert_ens_stat( meas_block ); + { + int mean_index = meas_block->active_ens_size * meas_block->ens_stride + iobs * meas_block->obs_stride; + return meas_block->data[ mean_index ]; + } } @@ -204,66 +261,84 @@ bool meas_block_iget_active( const meas_block_type * meas_block , int iobs) { void meas_block_deactivate( meas_block_type * meas_block , int iobs ) { - if (meas_block->active[ iobs ]) + if (meas_block->active[ iobs ]) meas_block->active[ iobs ] = false; + meas_block->stat_calculated = false; } -int meas_block_get_total_size( const meas_block_type * meas_block ) { +int meas_block_get_total_obs_size( const meas_block_type * meas_block ) { return meas_block->obs_size; } +int meas_block_get_active_ens_size( const meas_block_type * meas_block ) { + return meas_block->active_ens_size; +} + + +int meas_block_get_total_ens_size( const meas_block_type * meas_block ) { + return bool_vector_size( meas_block->ens_mask ); +} + + + + + /*****************************************************************/ UTIL_IS_INSTANCE_FUNCTION( meas_data , MEAS_DATA_TYPE_ID ) -meas_data_type * meas_data_alloc( const int_vector_type * ens_active_list ) { - int ens_size = int_vector_size( ens_active_list ); - if (ens_size <= 0) - util_abort("%s: ens_size must be > 0 - aborting \n",__func__); - { - meas_data_type * meas = util_malloc(sizeof * meas ); - UTIL_TYPE_ID_INIT( meas , MEAS_DATA_TYPE_ID ); - - meas->ens_size = ens_size; - meas->data = vector_alloc_new(); - meas->lookup_keys = set_alloc_empty(); - pthread_mutex_init( &meas->data_mutex , NULL ); - - return meas; - } +meas_data_type * meas_data_alloc( const bool_vector_type * ens_mask ) { + meas_data_type * meas = util_malloc(sizeof * meas ); + UTIL_TYPE_ID_INIT( meas , MEAS_DATA_TYPE_ID ); + + meas->data = vector_alloc_new(); + meas->blocks = hash_alloc(); + meas->ens_mask = bool_vector_alloc_copy( ens_mask ); + meas->active_ens_size = bool_vector_count_equal( ens_mask , true ); + pthread_mutex_init( &meas->data_mutex , NULL ); + + return meas; } void meas_data_free(meas_data_type * matrix) { vector_free( matrix->data ); - set_free( matrix->lookup_keys ); + hash_free( matrix->blocks ); + bool_vector_free( matrix->ens_mask ); free( matrix ); } void meas_data_reset(meas_data_type * matrix) { - set_clear( matrix->lookup_keys ); + hash_clear( matrix->blocks ); vector_clear( matrix->data ); /* Will dump and discard all the meas_block instances. */ } +/* + The obs_key is not alone unique over different report steps. +*/ +static char * meas_data_alloc_key( const char * obs_key , int report_step) { + return util_alloc_sprintf( "%s-%d" , obs_key , report_step ); +} + /** - The code actually adding new blocks to the vector must be run in single-thread mode. + The code actually adding new blocks to the vector must be run in single-thread mode. */ meas_block_type * meas_data_add_block( meas_data_type * matrix , const char * obs_key , int report_step , int obs_size) { - char * lookup_key = util_alloc_sprintf( "%s-%d" , obs_key , report_step ); /* The obs_key is not alone unique over different report steps. */ + char * lookup_key = meas_data_alloc_key( obs_key , report_step ); pthread_mutex_lock( &matrix->data_mutex ); { - if (!set_has_key( matrix->lookup_keys , lookup_key )) { - meas_block_type * new_block = meas_block_alloc(obs_key , report_step , matrix->ens_size , obs_size); + if (!hash_has_key( matrix->blocks , lookup_key )) { + meas_block_type * new_block = meas_block_alloc(obs_key , matrix->ens_mask , obs_size); vector_append_owned_ref( matrix->data , new_block , meas_block_free__ ); - set_add_key( matrix->lookup_keys , lookup_key ); + hash_insert_ref( matrix->blocks , lookup_key , new_block ); } } pthread_mutex_unlock( &matrix->data_mutex ); @@ -272,8 +347,19 @@ meas_block_type * meas_data_add_block( meas_data_type * matrix , const char * ob } +/* + Observe that the key should compare with the keys created by meas_data_alloc_key(). +*/ +bool meas_data_has_block( const meas_data_type * matrix , const char * lookup_key) { + return hash_has_key( matrix->blocks , lookup_key); +} -meas_block_type * meas_data_iget_block( meas_data_type * matrix , int block_nr) { +meas_block_type * meas_data_get_block( const meas_data_type * matrix , const char * lookup_key) { + return hash_get( matrix->blocks , lookup_key ); +} + + +meas_block_type * meas_data_iget_block( const meas_data_type * matrix , int block_nr) { return vector_iget( matrix->data , block_nr); } @@ -283,10 +369,23 @@ const meas_block_type * meas_data_iget_block_const( const meas_data_type * matri } +int meas_data_get_active_obs_size( const meas_data_type * matrix ) { + int obs_size = 0; + + for (int block_nr = 0; block_nr < vector_get_size( matrix->data ); block_nr++) { + const meas_block_type * meas_block = vector_iget_const( matrix->data , block_nr); + obs_size += meas_block_get_active_obs_size( meas_block ); + } + + return obs_size; +} + + + -matrix_type * meas_data_allocS(const meas_data_type * matrix, int active_size) { - int obs_offset = 0; - matrix_type * S = matrix_alloc( active_size , matrix->ens_size ); +matrix_type * meas_data_allocS(const meas_data_type * matrix) { + int obs_offset = 0; + matrix_type * S = matrix_alloc( meas_data_get_active_obs_size( matrix ) , matrix->active_ens_size); for (int block_nr = 0; block_nr < vector_get_size( matrix->data ); block_nr++) { const meas_block_type * meas_block = vector_iget_const( matrix->data , block_nr); @@ -306,23 +405,35 @@ int meas_data_get_nrobs( const meas_data_type * meas_data ) { } -int meas_data_get_ens_size( const meas_data_type * meas_data ) { - return meas_data->ens_size; +int meas_data_get_active_ens_size( const meas_data_type * meas_data ) { + return meas_data->active_ens_size; +} + + +int meas_data_get_total_ens_size( const meas_data_type * meas_data ) { + return bool_vector_size( meas_data->ens_mask ); } +int meas_data_get_num_blocks( const meas_data_type * meas_data ) { + return vector_get_size( meas_data->data ); +} + + + +/* void meas_data_assign_vector(meas_data_type * target_matrix, const meas_data_type * src_matrix , int target_index , int src_index) { - if (target_matrix->ens_size != src_matrix->ens_size) + if (target_matrix->active_ens_size != src_matrix->active_ens_size) util_abort("%s: size mismatch \n",__func__); - + for (int block_nr = 0; block_nr < vector_get_size( target_matrix->data ); block_nr++) { meas_block_type * target_block = meas_data_iget_block( target_matrix , block_nr ); const meas_block_type * src_block = meas_data_iget_block_const( src_matrix , block_nr ); - + meas_data_assign_block( target_block , src_block , target_index , src_index ); } } - +*/ diff --git a/ThirdParty/Ert/devel/libenkf/src/misfit_ranking.c b/ThirdParty/Ert/devel/libenkf/src/misfit_ranking.c index cc8551c2fd..6774ed69ad 100644 --- a/ThirdParty/Ert/devel/libenkf/src/misfit_ranking.c +++ b/ThirdParty/Ert/devel/libenkf/src/misfit_ranking.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'misfit_ranking.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'misfit_ranking.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -71,14 +71,14 @@ void misfit_ranking_display( const misfit_ranking_type * misfit_ranking , FILE * return; } } - + { int i; double summed_up = 0.0; stringlist_type * obs_keys = hash_alloc_stringlist( obs_hash ); int num_obs = stringlist_get_size( obs_keys ); int num_obs_total = num_obs * ens_size; // SHould not count failed/missing members ... - + fprintf(stream,"\n\n"); fprintf(stream," # Realization Normalized misfit Total misfit\n"); fprintf(stream,"-------------------------------------------------------\n"); @@ -89,14 +89,14 @@ void misfit_ranking_display( const misfit_ranking_type * misfit_ranking , FILE * summed_up = summed_up+total_misfit; fprintf(stream,"%3d %3d %10.3f %10.3f \n",i,iens,normalized_misfit,total_misfit); } - + { double normalized_summed_up = sqrt(summed_up / (num_obs_total * ens_size)); fprintf(stream," All %10.3f %10.3f \n",normalized_summed_up,summed_up); } fprintf(stream,"-------------------------------------------------------\n"); } - + } @@ -107,10 +107,10 @@ void misfit_ranking_fprintf( const misfit_ranking_type * misfit_ranking , const const int * permutations = misfit_ranking->sort_permutation; double summed_up = 0.0; { - // All this whitespace is finely tuned and highly significant .... - const char * key_fmt = " %18s "; + // All this whitespace is finely tuned and highly significant .... + const char * key_fmt = " %18s "; const char * value_fmt = " %10.3f %8.3f"; - const char * start_fmt = " %2d %3d %7.3f %8.3f"; + const char * start_fmt = " %2d %3d %7.3f %8.3f"; hash_type * obs_hash = vector_iget( misfit_ranking->ensemble , 0); stringlist_type * obs_keys = hash_alloc_stringlist( obs_hash ); @@ -120,14 +120,14 @@ void misfit_ranking_fprintf( const misfit_ranking_type * misfit_ranking , const stringlist_sort( obs_keys , enkf_util_compare_keys__ ); fprintf(stream , " Overall "); - for (iobs =0; iobs < num_obs; iobs++) + for (iobs =0; iobs < num_obs; iobs++) fprintf(stream , key_fmt , stringlist_iget( obs_keys , iobs )); fprintf(stream , "\n"); fprintf(stream , " # Realization Norm Total"); - for (iobs =0; iobs < num_obs; iobs++) + for (iobs =0; iobs < num_obs; iobs++) fprintf(stream , " Norm Total"); - + fprintf(stream , "\n"); for (int i = 0; i < ens_size; i++) { int iens = permutations[i]; @@ -146,8 +146,8 @@ void misfit_ranking_fprintf( const misfit_ranking_type * misfit_ranking , const double summed_up_normalized = sqrt(summed_up / (num_obs_total * ens_size)); fprintf(stream , " All %7.3f %8.3f" , summed_up_normalized , summed_up); for (iobs = 0; iobs < num_obs; iobs++){ - double single_value_summed_up = 0.0; - for (int i = 0; i < ens_size; i++) { + double single_value_summed_up = 0.0; + for (int i = 0; i < ens_size; i++) { single_value_summed_up = single_value_summed_up + hash_get_double( obs_hash , stringlist_iget( obs_keys , iobs )); } double single_value_summed_up_normalized=sqrt(single_value_summed_up / (num_obs_total * ens_size)); @@ -178,10 +178,10 @@ misfit_ranking_type * misfit_ranking_alloc(const misfit_ensemble_type * misfit_ const int ens_size = misfit_ensemble_get_ens_size( misfit_ensemble ); int iens; misfit_ranking_type * ranking = misfit_ranking_alloc_empty(ens_size); - + for (iens = 0; iens < ens_size; iens++) { const misfit_member_type * misfit_member = misfit_ensemble_iget_member( misfit_ensemble , iens ); /* Lookup in the master ensemble. */ - + { double iens_valid = true; double total = 0; @@ -196,7 +196,7 @@ misfit_ranking_type * misfit_ranking_alloc(const misfit_ensemble_type * misfit_ } else iens_valid = true; } - if (iens_valid) + if (iens_valid) misfit_ranking_iset( ranking , iens , obs_hash , total ); else misfit_ranking_iset_invalid( ranking , iens ); @@ -230,12 +230,12 @@ void misfit_ranking_free__( void * arg ) { void misfit_ranking_iset( misfit_ranking_type * misfit_ranking , int iens , hash_type * obs_hash , double total_misfit) { if (iens > vector_get_size(misfit_ranking->ensemble)) vector_grow_NULL( misfit_ranking->ensemble , iens ); - + if (obs_hash != NULL) vector_iset_owned_ref( misfit_ranking->ensemble , iens , obs_hash , hash_free__ ); else vector_iset_ref( misfit_ranking->ensemble , iens , NULL ); - + double_vector_iset( misfit_ranking->total , iens , total_misfit ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/model_config.c b/ThirdParty/Ert/devel/libenkf/src/model_config.c index 00c0ba6350..e3a1d5d9e5 100644 --- a/ThirdParty/Ert/devel/libenkf/src/model_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/model_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'model_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'model_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <sys/types.h> @@ -32,7 +32,8 @@ #include <ert/sched/history.h> #include <ert/sched/sched_file.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/ecl/ecl_sum.h> #include <ert/ecl/ecl_util.h> @@ -77,24 +78,24 @@ struct model_config_struct { UTIL_TYPE_ID_DECLARATION; stringlist_type * case_names; /* A list of "iens -> name" mappings - can be NULL. */ - char * case_table_file; - forward_model_type * forward_model; /* The forward_model - as loaded from the config file. Each enkf_state object internalizes its private copy of the forward_model. */ + char * case_table_file; + forward_model_type * forward_model; /* The forward_model - as loaded from the config file. Each enkf_state object internalizes its private copy of the forward_model. */ time_map_type * external_time_map; history_type * history; /* The history object. */ - path_fmt_type * current_runpath; /* path_fmt instance for runpath - runtime the call gets arguments: (iens, report_step1 , report_step2) - i.e. at least one %d must be present.*/ + path_fmt_type * current_runpath; /* path_fmt instance for runpath - runtime the call gets arguments: (iens, report_step1 , report_step2) - i.e. at least one %d must be present.*/ char * current_path_key; - hash_type * runpath_map; + hash_type * runpath_map; char * jobname_fmt; /* Format string with one '%d' for the jobname - can be NULL in which case the eclbase name will be used. */ - enkf_sched_type * enkf_sched; /* The enkf_sched object controlling when the enkf is ON|OFF, strides in report steps and special forward model - allocated on demand - right before use. */ + enkf_sched_type * enkf_sched; /* The enkf_sched object controlling when the enkf is ON|OFF, strides in report steps and special forward model - allocated on demand - right before use. */ char * enkf_sched_file; /* THe name of file containg enkf schedule information - can be NULL to get default behaviour. */ char * enspath; char * rftpath; char * select_case; fs_driver_impl dbase_type; - bool has_prediction; + bool has_prediction; int max_internal_submit; /* How many times to retry if the load fails. */ history_source_type history_source; - const ecl_sum_type * refcase; /* A pointer to the refcase - can be NULL. Observe that this ONLY a pointer + const ecl_sum_type * refcase; /* A pointer to the refcase - can be NULL. Observe that this ONLY a pointer to the ecl_sum instance owned and held by the ecl_config object. */ char * gen_kw_export_file_name; @@ -138,7 +139,7 @@ void model_config_set_case_table( model_config_type * model_config , int ens_siz if (model_config->case_table_file != NULL) { /* Clear the current selection */ free( model_config->case_table_file ); stringlist_free( model_config->case_names ); - + model_config->case_table_file = NULL; model_config->case_names = NULL; } @@ -162,7 +163,7 @@ void model_config_set_case_table( model_config_type * model_config , int ens_siz for (int i = case_size; i < ens_size; i++) stringlist_append_owned_ref( model_config->case_names , util_alloc_sprintf("case_%04d" , i)); fprintf(stderr, "** Warning: mismatch between NUM_REALIZATIONS:%d and size of CASE_TABLE:%d - using \'case_nnnn\' for the last cases %d.\n", ens_size , case_size , ens_size - case_size); - } else if (case_size > ens_size) + } else if (case_size > ens_size) fprintf(stderr, "** Warning: mismatch between NUM_REALIZATIONS:%d and CASE_TABLE:%d - only the %d realizations will be used.\n", ens_size , case_size , ens_size); } @@ -177,7 +178,7 @@ void model_config_add_runpath( model_config_type * model_config , const char * p /* If the path_key does not exists it will return false and stay - silent. + silent. */ bool model_config_select_runpath( model_config_type * model_config , const char * path_key) { @@ -230,10 +231,10 @@ const char * model_config_get_gen_kw_export_file( const model_config_type * mode enkf_sched_free( model_config->enkf_sched ); if (run_mode == ENKF_ASSIMILATION) - model_config->enkf_sched = enkf_sched_fscanf_alloc(model_config->enkf_sched_file , - model_config_get_last_history_restart(model_config) , + model_config->enkf_sched = enkf_sched_fscanf_alloc(model_config->enkf_sched_file , + model_config_get_last_history_restart(model_config) , run_mode); - + } @@ -275,7 +276,7 @@ fs_driver_impl model_config_get_dbase_type(const model_config_type * model_confi } const ecl_sum_type * model_config_get_refcase( const model_config_type * model_config ) { - return model_config->refcase; + return model_config->refcase; } void * model_config_get_dbase_args( const model_config_type * model_config ) { @@ -297,9 +298,9 @@ history_source_type model_config_get_history_source( const model_config_type * m void model_config_select_schedule_history( model_config_type * model_config , const sched_file_type * sched_file) { if (model_config->history != NULL) history_free( model_config->history ); - + if (sched_file != NULL) { - model_config->history = history_alloc_from_sched_file( SUMMARY_KEY_JOIN_STRING , sched_file); + model_config->history = history_alloc_from_sched_file( SUMMARY_KEY_JOIN_STRING , sched_file); model_config->history_source = SCHEDULE; } else util_abort("%s: internal error - trying to select HISTORY_SOURCE:SCHEDULE - but no Schedule file has been loaded.\n",__func__); @@ -311,7 +312,7 @@ void model_config_select_refcase_history( model_config_type * model_config , con history_free( model_config->history ); if (refcase != NULL) { - model_config->history = history_alloc_from_refcase( refcase , use_history ); + model_config->history = history_alloc_from_refcase( refcase , use_history ); model_config->history_source = SCHEDULE; } else util_abort("%s: internal error - trying to load history from REFCASE - but no REFCASE has been loaded.\n",__func__); @@ -347,18 +348,19 @@ model_config_type * model_config_alloc() { model_config->current_runpath = NULL; model_config->current_path_key = NULL; model_config->enkf_sched = NULL; - model_config->enkf_sched_file = NULL; + model_config->enkf_sched_file = NULL; model_config->case_table_file = NULL; - model_config->select_case = NULL; + model_config->select_case = NULL; model_config->history = NULL; model_config->jobname_fmt = NULL; model_config->forward_model = NULL; model_config->external_time_map = NULL; model_config->internalize_state = bool_vector_alloc( 0 , false ); - model_config->__load_eclipse_restart = bool_vector_alloc( 0 , false ); + model_config->__load_eclipse_restart = bool_vector_alloc( 0 , false ); model_config->history_source = HISTORY_SOURCE_INVALID; - model_config->runpath_map = hash_alloc(); + model_config->runpath_map = hash_alloc(); model_config->gen_kw_export_file_name = NULL; + model_config->refcase = NULL; model_config_set_enspath( model_config , DEFAULT_ENSPATH ); model_config_set_rftpath( model_config , DEFAULT_RFTPATH ); @@ -367,7 +369,7 @@ model_config_type * model_config_alloc() { model_config_add_runpath( model_config , DEFAULT_RUNPATH_KEY , DEFAULT_RUNPATH); model_config_select_runpath( model_config , DEFAULT_RUNPATH_KEY ); model_config_set_gen_kw_export_file(model_config, DEFAULT_GEN_KW_EXPORT_FILE); - + return model_config; } @@ -376,18 +378,18 @@ bool model_config_select_history( model_config_type * model_config , history_sou bool selectOK = false; if (source_type == SCHEDULE && sched_file != NULL) { - model_config_select_schedule_history( model_config , sched_file ); + model_config_select_schedule_history( model_config , sched_file ); selectOK = true; } if (((source_type == REFCASE_HISTORY) || (source_type == REFCASE_SIMULATED)) && refcase != NULL) { if (source_type == REFCASE_HISTORY) - model_config_select_refcase_history( model_config , refcase , true); + model_config_select_refcase_history( model_config , refcase , true); else - model_config_select_refcase_history( model_config , refcase , false); + model_config_select_refcase_history( model_config , refcase , false); selectOK = true; } - + return selectOK; } @@ -396,50 +398,50 @@ static bool model_config_select_any_history( model_config_type * model_config , bool selectOK = false; if (sched_file != NULL) { - model_config_select_schedule_history( model_config , sched_file ); + model_config_select_schedule_history( model_config , sched_file ); selectOK = true; } else if ( refcase != NULL ) { - model_config_select_refcase_history( model_config , refcase , true); + model_config_select_refcase_history( model_config , refcase , true); selectOK = true; } - + return selectOK; } -void model_config_init(model_config_type * model_config , - const config_type * config , - int ens_size , - const ext_joblist_type * joblist , - int last_history_restart , - const sched_file_type * sched_file , +void model_config_init(model_config_type * model_config , + const config_content_type * config , + int ens_size , + const ext_joblist_type * joblist , + int last_history_restart , + const sched_file_type * sched_file , const ecl_sum_type * refcase) { - + model_config->forward_model = forward_model_alloc( joblist ); model_config_set_refcase( model_config , refcase ); - - if (config_item_set( config , FORWARD_MODEL_KEY )) { - char * config_string = config_alloc_joined_string( config , FORWARD_MODEL_KEY , " "); + + if (config_content_has_item( config , FORWARD_MODEL_KEY )) { + char * config_string = config_content_alloc_joined_string( config , FORWARD_MODEL_KEY , " "); forward_model_parse_init( model_config->forward_model , config_string ); free(config_string); } - if (config_item_set( config , ENKF_SCHED_FILE_KEY)) - model_config_set_enkf_sched_file(model_config , config_get_value(config , ENKF_SCHED_FILE_KEY )); - - if (config_item_set( config, RUNPATH_KEY)) { - model_config_add_runpath( model_config , DEFAULT_RUNPATH_KEY , config_get_value(config , RUNPATH_KEY) ); + if (config_content_has_item( config , ENKF_SCHED_FILE_KEY)) + model_config_set_enkf_sched_file(model_config , config_content_get_value(config , ENKF_SCHED_FILE_KEY )); + + if (config_content_has_item( config, RUNPATH_KEY)) { + model_config_add_runpath( model_config , DEFAULT_RUNPATH_KEY , config_content_get_value(config , RUNPATH_KEY) ); model_config_select_runpath( model_config , DEFAULT_RUNPATH_KEY ); } { history_source_type source_type = DEFAULT_HISTORY_SOURCE; - if (config_item_set( config , HISTORY_SOURCE_KEY)) { - const char * history_source = config_iget(config , HISTORY_SOURCE_KEY, 0,0); + if (config_content_has_item( config , HISTORY_SOURCE_KEY)) { + const char * history_source = config_content_iget(config , HISTORY_SOURCE_KEY, 0,0); source_type = history_get_source_type( history_source ); } @@ -447,17 +449,17 @@ void model_config_init(model_config_type * model_config , if (!model_config_select_history( model_config , DEFAULT_HISTORY_SOURCE , sched_file , refcase )) if (!model_config_select_any_history( model_config , sched_file , refcase)) fprintf(stderr,"** Warning:: Do not have enough information to select a history source \n"); - + } - + if (model_config->history != NULL) { int num_restart = model_config_get_last_history_restart(model_config); bool_vector_iset( model_config->internalize_state , num_restart - 1 , false ); bool_vector_iset( model_config->__load_eclipse_restart , num_restart - 1 , false ); } - if (config_item_set( config , TIME_MAP_KEY)) { - const char * filename = config_get_value_as_path( config , TIME_MAP_KEY); + if (config_content_has_item( config , TIME_MAP_KEY)) { + const char * filename = config_content_get_value_as_path( config , TIME_MAP_KEY); time_map_type * time_map = time_map_alloc(); if (time_map_fscanf( time_map , filename)) model_config->external_time_map = time_map; @@ -466,7 +468,7 @@ void model_config_init(model_config_type * model_config , fprintf(stderr,"** ERROR: Loading external time map from:%s failed \n", filename); } } - + /* @@ -475,42 +477,41 @@ void model_config_init(model_config_type * model_config , as (quite) plain GEN_KW instance. Here we just check if it is present or not. */ - - if (config_item_set(config , SCHEDULE_PREDICTION_FILE_KEY)) + + if (config_content_has_item(config , SCHEDULE_PREDICTION_FILE_KEY)) model_config->has_prediction = true; else model_config->has_prediction = false; - if (config_item_set(config , CASE_TABLE_KEY)) - model_config_set_case_table( model_config , ens_size , config_iget( config , CASE_TABLE_KEY , 0,0)); - - if (config_item_set( config , ENSPATH_KEY)) - model_config_set_enspath( model_config , config_get_value(config , ENSPATH_KEY)); + if (config_content_has_item(config , CASE_TABLE_KEY)) + model_config_set_case_table( model_config , ens_size , config_content_iget( config , CASE_TABLE_KEY , 0,0)); + + if (config_content_has_item( config , ENSPATH_KEY)) + model_config_set_enspath( model_config , config_content_get_value(config , ENSPATH_KEY)); - if (config_item_set( config , JOBNAME_KEY)) - model_config_set_jobname_fmt( model_config , config_get_value(config , JOBNAME_KEY)); + if (config_content_has_item( config , JOBNAME_KEY)) + model_config_set_jobname_fmt( model_config , config_content_get_value(config , JOBNAME_KEY)); - if (config_item_set( config , RFTPATH_KEY)) - model_config_set_rftpath( model_config , config_get_value(config , RFTPATH_KEY)); - - if (config_item_set( config , DBASE_TYPE_KEY)) - model_config_set_dbase_type( model_config , config_get_value(config , DBASE_TYPE_KEY)); - - if (config_item_set( config , MAX_RESAMPLE_KEY)) - model_config_set_max_internal_submit( model_config , config_get_value_as_int( config , MAX_RESAMPLE_KEY )); + if (config_content_has_item( config , RFTPATH_KEY)) + model_config_set_rftpath( model_config , config_content_get_value(config , RFTPATH_KEY)); + + if (config_content_has_item( config , DBASE_TYPE_KEY)) + model_config_set_dbase_type( model_config , config_content_get_value(config , DBASE_TYPE_KEY)); + + if (config_content_has_item( config , MAX_RESAMPLE_KEY)) + model_config_set_max_internal_submit( model_config , config_content_get_value_as_int( config , MAX_RESAMPLE_KEY )); { const char * export_file_name; - if (config_item_set( config , GEN_KW_EXPORT_FILE_KEY)) - export_file_name = config_get_value(config, GEN_KW_EXPORT_FILE_KEY); + if (config_content_has_item( config , GEN_KW_EXPORT_FILE_KEY)) + export_file_name = config_content_get_value(config, GEN_KW_EXPORT_FILE_KEY); else export_file_name = DEFAULT_GEN_KW_EXPORT_FILE; model_config_set_gen_kw_export_file(model_config, export_file_name); } - } @@ -536,10 +537,10 @@ void model_config_free(model_config_type * model_config) { if (model_config->history) history_free(model_config->history); - + if (model_config->forward_model) forward_model_free(model_config->forward_model); - + if (model_config->external_time_map) time_map_free( model_config->external_time_map ); @@ -548,7 +549,7 @@ void model_config_free(model_config_type * model_config) { bool_vector_free(model_config->__load_eclipse_restart); hash_free(model_config->runpath_map); - if (model_config->case_names) + if (model_config->case_names) stringlist_free( model_config->case_names ); free(model_config); } @@ -620,7 +621,7 @@ void model_config_init_internalization( model_config_type * config ) { /** This function sets the internalize_state flag to true for report_step. Because of the coupling to the __load_eclipse_restart variable - this function can __ONLY__ be used to set internalize to true. + this function can __ONLY__ be used to set internalize to true. */ void model_config_set_internalize_state( model_config_type * config , int report_step) { @@ -659,7 +660,7 @@ void model_config_fprintf_config( const model_config_type * model_config , int e fprintf( stream , CONFIG_KEY_FORMAT , CASE_TABLE_KEY ); fprintf( stream , CONFIG_ENDVALUE_FORMAT , model_config->case_table_file ); } - fprintf( stream , CONFIG_KEY_FORMAT , FORWARD_MODEL_KEY); + fprintf( stream , CONFIG_KEY_FORMAT , FORWARD_MODEL_KEY); forward_model_fprintf( model_config->forward_model , stream ); fprintf( stream , CONFIG_KEY_FORMAT , RUNPATH_KEY ); @@ -669,7 +670,7 @@ void model_config_fprintf_config( const model_config_type * model_config , int e fprintf( stream , CONFIG_KEY_FORMAT , ENKF_SCHED_FILE_KEY ); fprintf( stream , CONFIG_ENDVALUE_FORMAT , model_config->enkf_sched_file ); } - + fprintf( stream , CONFIG_KEY_FORMAT , ENSPATH_KEY ); fprintf( stream , CONFIG_ENDVALUE_FORMAT , model_config->enspath ); @@ -681,13 +682,13 @@ void model_config_fprintf_config( const model_config_type * model_config , int e fprintf( stream , CONFIG_ENDVALUE_FORMAT , model_config->select_case ); } - fprintf( stream , CONFIG_KEY_FORMAT , MAX_RESAMPLE_KEY ); + fprintf( stream , CONFIG_KEY_FORMAT , MAX_RESAMPLE_KEY ); { char max_retry_string[16]; sprintf( max_retry_string , "%d" ,model_config->max_internal_submit); fprintf( stream , CONFIG_ENDVALUE_FORMAT , max_retry_string); } - + fprintf(stream , CONFIG_KEY_FORMAT , HISTORY_SOURCE_KEY); fprintf(stream , CONFIG_ENDVALUE_FORMAT , history_get_source_string( model_config->history_source )); diff --git a/ThirdParty/Ert/devel/libenkf/src/obs_data.c b/ThirdParty/Ert/devel/libenkf/src/obs_data.c index 38de798359..1d1390838b 100644 --- a/ThirdParty/Ert/devel/libenkf/src/obs_data.c +++ b/ThirdParty/Ert/devel/libenkf/src/obs_data.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'obs_data.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'obs_data.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -84,23 +84,25 @@ struct obs_block_struct { double * value; double * std; - int * active_mode; + active_type * active_mode; int active_size; matrix_type * error_covar; bool error_covar_owner; /* If true the error_covar matrix is free'd when construction of the R matrix is complete. */ + double global_std_scaling; }; struct obs_data_struct { vector_type * data; /* vector with obs_block instances. */ + double global_std_scaling; }; static UTIL_SAFE_CAST_FUNCTION(obs_block , OBS_BLOCK_TYPE_ID ) -static obs_block_type * obs_block_alloc( const char * obs_key , int obs_size , matrix_type * error_covar , bool error_covar_owner) { +obs_block_type * obs_block_alloc( const char * obs_key , int obs_size , matrix_type * error_covar , bool error_covar_owner, double global_std_scaling) { obs_block_type * obs_block = util_malloc( sizeof * obs_block ); UTIL_TYPE_ID_INIT( obs_block , OBS_BLOCK_TYPE_ID ); @@ -111,6 +113,7 @@ static obs_block_type * obs_block_alloc( const char * obs_key , int obs_size , m obs_block->active_mode = util_calloc( obs_size , sizeof * obs_block->active_mode ); obs_block->error_covar = error_covar; obs_block->error_covar_owner = error_covar_owner; + obs_block->global_std_scaling = global_std_scaling; { for (int iobs = 0; iobs < obs_size; iobs++) obs_block->active_mode[iobs] = LOCAL_INACTIVE; @@ -121,7 +124,7 @@ static obs_block_type * obs_block_alloc( const char * obs_key , int obs_size , m -static void obs_block_free( obs_block_type * obs_block ) { +void obs_block_free( obs_block_type * obs_block ) { free( obs_block->obs_key ); free( obs_block->value ); free( obs_block->std ); @@ -158,14 +161,14 @@ void obs_block_iset( obs_block_type * obs_block , int iobs , double value , doub } void obs_block_iset_missing( obs_block_type * obs_block , int iobs ) { - if (obs_block->active_mode[ iobs ] == ACTIVE) + if (obs_block->active_mode[ iobs ] == ACTIVE) obs_block->active_size--; obs_block->active_mode[iobs] = MISSING; } double obs_block_iget_std( const obs_block_type * obs_block , int iobs) { - return obs_block->std[ iobs ]; + return obs_block->std[ iobs ] * obs_block->global_std_scaling; } @@ -185,6 +188,13 @@ int obs_block_get_size( const obs_block_type * obs_block ) { } +int obs_block_get_active_size( const obs_block_type * obs_block ) { + return obs_block->active_size; +} + + + + /*Function that sets each element of the scaling factor equal to 1 divided by the prior standard deviation (from the obs_data input file. */ @@ -193,7 +203,7 @@ static void obs_block_init_scaling( const obs_block_type * obs_block , double * int iobs; for (iobs =0; iobs < obs_block->size; iobs++) { if (obs_block->active_mode[iobs] == ACTIVE) { - scale_factor[ obs_offset ] = 1.0 / obs_block->std[ iobs ]; + scale_factor[ obs_offset ] = 1.0 / obs_block_iget_std(obs_block, iobs); obs_offset++; } } @@ -239,10 +249,10 @@ static void obs_block_initR( const obs_block_type * obs_block , matrix_type * R, int iactive = 0; for (iobs =0; iobs < obs_block->size; iobs++) { if (obs_block->active_mode[iobs] == ACTIVE) { - double var = obs_block->std[iobs] * obs_block->std[iobs]; + double var = obs_block_iget_std(obs_block, iobs) * obs_block_iget_std(obs_block, iobs); matrix_iset_safe(R , obs_offset + iactive, obs_offset + iactive, var); iactive++; - } + } } } else { int row_active = 0; /* We have a covar matrix */ @@ -259,7 +269,7 @@ static void obs_block_initR( const obs_block_type * obs_block , matrix_type * R, } } } - + *__obs_offset = obs_offset + obs_block->active_size; if ((obs_block->error_covar_owner) && (obs_block->error_covar != NULL)) matrix_free( obs_block->error_covar ); @@ -273,14 +283,14 @@ static void obs_block_initE( const obs_block_type * obs_block , matrix_type * E, int iobs; for (iobs =0; iobs < obs_block->size; iobs++) { if (obs_block->active_mode[iobs] == ACTIVE) { - double factor = obs_block->std[iobs] * sqrt( ens_size / pert_var[ obs_offset ]); - for (int iens = 0; iens < ens_size; iens++) + double factor = obs_block_iget_std(obs_block, iobs) * sqrt( ens_size / pert_var[ obs_offset ]); + for (int iens = 0; iens < ens_size; iens++) matrix_imul(E , obs_offset , iens , factor ); obs_offset++; } } - + *__obs_offset = obs_offset; } @@ -291,14 +301,14 @@ static void obs_block_initE_non_centred( const obs_block_type * obs_block , matr int iobs; for (iobs =0; iobs < obs_block->size; iobs++) { if (obs_block->active_mode[iobs] == ACTIVE) { - double factor = obs_block->std[iobs]; - for (int iens = 0; iens < ens_size; iens++) + double factor = obs_block_iget_std(obs_block, iobs); + for (int iens = 0; iens < ens_size; iens++) matrix_imul(E , obs_offset , iens , factor ); obs_offset++; } } - + *__obs_offset = obs_offset; } @@ -310,34 +320,37 @@ static void obs_block_initD( const obs_block_type * obs_block , matrix_type * D, int iobs; for (iobs =0; iobs < obs_block->size; iobs++) { if (obs_block->active_mode[iobs] == ACTIVE) { - for (int iens = 0; iens < ens_size; iens++) + for (int iens = 0; iens < ens_size; iens++) matrix_iadd(D , obs_offset , iens , obs_block->value[ iobs ]); - + obs_offset++; } } - + *__obs_offset = obs_offset; } +/*****************************************************************/ -obs_data_type * obs_data_alloc() { + +obs_data_type * obs_data_alloc(double global_std_scaling) { obs_data_type * obs_data = util_malloc(sizeof * obs_data ); obs_data->data = vector_alloc_new(); + obs_data->global_std_scaling = global_std_scaling; obs_data_reset(obs_data); return obs_data; } -void obs_data_reset(obs_data_type * obs_data) { +void obs_data_reset(obs_data_type * obs_data) { vector_clear( obs_data->data ); } obs_block_type * obs_data_add_block( obs_data_type * obs_data , const char * obs_key , int obs_size , matrix_type * error_covar, bool error_covar_owner) { - obs_block_type * new_block = obs_block_alloc( obs_key , obs_size , error_covar , error_covar_owner); + obs_block_type * new_block = obs_block_alloc( obs_key , obs_size , error_covar , error_covar_owner, obs_data->global_std_scaling); vector_append_owned_ref( obs_data->data , new_block , obs_block_free__ ); return new_block; } @@ -360,45 +373,46 @@ void obs_data_free(obs_data_type * obs_data) { -matrix_type * obs_data_allocE(const obs_data_type * obs_data , rng_type * rng , int ens_size, int active_size ) { +matrix_type * obs_data_allocE(const obs_data_type * obs_data , rng_type * rng , int active_ens_size ) { double *pert_mean , *pert_var; matrix_type * E; int iens, iobs_active; - - E = matrix_alloc( active_size , ens_size); + int active_obs_size = obs_data_get_active_size( obs_data ); + + E = matrix_alloc( active_obs_size , active_ens_size); - pert_mean = util_calloc(active_size , sizeof * pert_mean ); - pert_var = util_calloc(active_size , sizeof * pert_var ); + pert_mean = util_calloc(active_obs_size , sizeof * pert_mean ); + pert_var = util_calloc(active_obs_size , sizeof * pert_var ); { - double * tmp = util_calloc( active_size * ens_size , sizeof * tmp ); + double * tmp = util_calloc( active_obs_size * active_ens_size , sizeof * tmp ); int i,j; int k = 0; - - enkf_util_rand_stdnormal_vector(active_size * ens_size , tmp , rng); - for (j=0; j < ens_size; j++) { - for (i=0; i < active_size; i++) { + + enkf_util_rand_stdnormal_vector(active_obs_size * active_ens_size , tmp , rng); + for (j=0; j < active_ens_size; j++) { + for (i=0; i < active_obs_size; i++) { matrix_iset( E , i , j , tmp[k]); k++; } } free(tmp); } - - for (iobs_active = 0; iobs_active < active_size; iobs_active++) { + + for (iobs_active = 0; iobs_active < active_obs_size; iobs_active++) { pert_mean[iobs_active] = 0; pert_var[iobs_active] = 0; } - - for (iens = 0; iens < ens_size; iens++) - for (iobs_active = 0; iobs_active < active_size; iobs_active++) + + for (iens = 0; iens < active_ens_size; iens++) + for (iobs_active = 0; iobs_active < active_obs_size; iobs_active++) pert_mean[iobs_active] += matrix_iget(E , iobs_active , iens); - - for (iobs_active = 0; iobs_active < active_size; iobs_active++) - pert_mean[iobs_active] /= ens_size; - for (iens = 0; iens < ens_size; iens++) { - for (iobs_active = 0; iobs_active < active_size; iobs_active++) { + for (iobs_active = 0; iobs_active < active_obs_size; iobs_active++) + pert_mean[iobs_active] /= active_ens_size; + + for (iens = 0; iens < active_ens_size; iens++) { + for (iobs_active = 0; iobs_active < active_obs_size; iobs_active++) { double tmp; matrix_iadd(E , iobs_active , iens , -pert_mean[iobs_active]); tmp = matrix_iget(E , iobs_active , iens); @@ -407,7 +421,7 @@ matrix_type * obs_data_allocE(const obs_data_type * obs_data , rng_type * rng , } /* - The actual observed data are not accessed before this last block. + The actual observed data are not accessed before this last block. */ { int obs_offset = 0; @@ -430,19 +444,19 @@ matrix_type * obs_data_allocE(const obs_data_type * obs_data , rng_type * rng , and variance (covariance) specified in the input (obs_data) file. NOTICE THE DIFFERENCE WITH allocE, WHERE THE RETURNED MATRIX IS CENTRED */ - -matrix_type * obs_data_allocE_non_centred(const obs_data_type * obs_data , rng_type * rng , int ens_size, int active_size ) { + +matrix_type * obs_data_allocE_non_centred(const obs_data_type * obs_data , rng_type * rng , int ens_size) { matrix_type * E; - - E = matrix_alloc( active_size , ens_size); + int active_size = obs_data_get_active_size( obs_data ); + E = matrix_alloc( active_size , ens_size); { double * tmp = util_calloc( active_size * ens_size , sizeof * tmp ); int i,j; int k = 0; - - enkf_util_rand_stdnormal_vector(active_size * ens_size , tmp , rng); + + enkf_util_rand_stdnormal_vector(active_size * ens_size , tmp , rng); for (j=0; j < ens_size; j++) { for (i=0; i < active_size; i++) { matrix_iset( E , i , j , tmp[k]); @@ -451,10 +465,10 @@ matrix_type * obs_data_allocE_non_centred(const obs_data_type * obs_data , rng_t } free(tmp); } - + /* - The actual observed data are not accessed before this last block. + The actual observed data are not accessed before this last block. */ { int obs_offset = 0; @@ -481,7 +495,7 @@ matrix_type * obs_data_allocD(const obs_data_type * obs_data , const matrix_type obs_block_initD( obs_block , D , &obs_offset); } } - + matrix_set_name( D , "D"); matrix_assert_finite( D ); return D; @@ -490,9 +504,8 @@ matrix_type * obs_data_allocD(const obs_data_type * obs_data , const matrix_type - - -matrix_type * obs_data_allocR(const obs_data_type * obs_data , int active_size) { +matrix_type * obs_data_allocR(const obs_data_type * obs_data) { + int active_size = obs_data_get_active_size( obs_data ); matrix_type * R = matrix_alloc( active_size , active_size ); { int obs_offset = 0; @@ -501,7 +514,7 @@ matrix_type * obs_data_allocR(const obs_data_type * obs_data , int active_size) obs_block_initR( obs_block , R , &obs_offset); } } - + matrix_set_name( R , "R"); matrix_assert_finite( R ); return R; @@ -515,7 +528,7 @@ matrix_type * obs_data_alloc_innov(const obs_data_type * obs_data , const meas_d for (int block_nr = 0; block_nr < vector_get_size( obs_data->data ); block_nr++) { const obs_block_type * obs_block = vector_iget_const( obs_data->data , block_nr ); const meas_block_type * meas_block = meas_data_iget_block_const( meas_data , block_nr ); - + obs_block_init_innov( obs_block , meas_block , innov , &obs_offset); } } @@ -523,13 +536,14 @@ matrix_type * obs_data_alloc_innov(const obs_data_type * obs_data , const meas_d } */ -matrix_type * obs_data_allocdObs(const obs_data_type * obs_data , int active_size) { +matrix_type * obs_data_allocdObs(const obs_data_type * obs_data ) { + int active_size = obs_data_get_active_size( obs_data ); matrix_type * dObs = matrix_alloc( active_size , 1 ); { int obs_offset = 0; for (int block_nr = 0; block_nr < vector_get_size( obs_data->data ); block_nr++) { const obs_block_type * obs_block = vector_iget_const( obs_data->data , block_nr ); - + obs_block_initdObs( obs_block , dObs , &obs_offset); } } @@ -537,53 +551,80 @@ matrix_type * obs_data_allocdObs(const obs_data_type * obs_data , int active_siz } +static void obs_data_scale_matrix__(matrix_type * m , const double * scale_factor) { + const int rows = matrix_get_rows( m ); + const int columns = matrix_get_columns( m ); + int i, j; -void obs_data_scale(const obs_data_type * obs_data , matrix_type *S , matrix_type *E , matrix_type *D , matrix_type *R , matrix_type * dObs) { - const int nrobs_active = matrix_get_rows( S ); - const int ens_size = matrix_get_columns( S ); + for (i = 0; i < columns; i++) + for (j = 0; j < rows; j++) + matrix_imul(m , j,i, scale_factor[j]); + +} + + +static void obs_data_scale_Rmatrix__( matrix_type * R , const double * scale_factor) { + int nrobs_active = matrix_get_rows( R ); + + /* Scale the error covariance matrix*/ + for (int i=0; i < nrobs_active; i++) + for (int j=0; j < nrobs_active; j++) + matrix_imul(R , i , j , scale_factor[i] * scale_factor[j]); +} + + +static double * obs_data_alloc_scale_factor(const obs_data_type * obs_data ) { + int nrobs_active = obs_data_get_active_size( obs_data ); double * scale_factor = util_calloc(nrobs_active , sizeof * scale_factor ); - int iens, iobs_active; - - { - int obs_offset = 0; - for (int block_nr = 0; block_nr < vector_get_size( obs_data->data ); block_nr++) { - const obs_block_type * obs_block = vector_iget_const( obs_data->data , block_nr ); - - /* Init. the scaling factor ( 1/std(dObs) ) */ - obs_block_init_scaling( obs_block , scale_factor , &obs_offset); - } + int obs_offset = 0; + for (int block_nr = 0; block_nr < vector_get_size( obs_data->data ); block_nr++) { + const obs_block_type * obs_block = vector_iget_const( obs_data->data , block_nr ); + + /* Init. the scaling factor ( 1/std(dObs) ) */ + obs_block_init_scaling( obs_block , scale_factor , &obs_offset); } + return scale_factor; +} - for (iens = 0; iens < ens_size; iens++) { - for (iobs_active = 0; iobs_active < nrobs_active; iobs_active++) { - /* Scale the forecasted data so that they (in theory) have the same variance - (if the prior distribution for the observation errors is correct) */ - matrix_imul(S , iobs_active , iens , scale_factor[iobs_active]); +void obs_data_scale_matrix(const obs_data_type * obs_data , matrix_type * matrix) { + double * scale_factor = obs_data_alloc_scale_factor( obs_data ); + obs_data_scale_matrix__( matrix , scale_factor ); + free( scale_factor ); +} - if (D != NULL) - /* Scale the combined data matrix: D = DObs + E - S, where DObs is the iobs_active times ens_size matrix where - each column contains a copy of the observed data - */ - matrix_imul(D , iobs_active , iens , scale_factor[iobs_active]); - if (E != NULL) - /* Same with E (used for low rank representation of the error covariance matrix*/ - matrix_imul(E , iobs_active , iens , scale_factor[iobs_active]); - } - } - +void obs_data_scale_Rmatrix(const obs_data_type * obs_data , matrix_type * R) { + double * scale_factor = obs_data_alloc_scale_factor( obs_data ); + obs_data_scale_Rmatrix__( R , scale_factor ); + free( scale_factor ); +} + + +void obs_data_scale(const obs_data_type * obs_data , matrix_type *S , matrix_type *E , matrix_type *D , matrix_type *R , matrix_type * dObs) { + double * scale_factor = obs_data_alloc_scale_factor( obs_data ); + + /* Scale the forecasted data so that they (in theory) have the same variance + (if the prior distribution for the observation errors is correct) */ + obs_data_scale_matrix__( S , scale_factor ); + + /* Scale the combined data matrix: D = DObs + E - S, where DObs is the iobs_active times ens_size matrix where + each column contains a copy of the observed data + */ + if (D != NULL) + obs_data_scale_matrix__( D , scale_factor ); + + /* Same with E (used for low rank representation of the error covariance matrix*/ + if (E != NULL) + obs_data_scale_matrix__( E , scale_factor ); + if (dObs != NULL) - for (iobs_active = 0; iobs_active < nrobs_active; iobs_active++) - matrix_imul( dObs , iobs_active , 0 , scale_factor[iobs_active]); - - if (R != NULL) { - /* Scale the error covariance matrix*/ - for (int i=0; i < nrobs_active; i++) - for (int j=0; j < nrobs_active; j++) - matrix_imul(R , i , j , scale_factor[i] * scale_factor[j]); - } + obs_data_scale_matrix__( dObs , scale_factor ); + + if (R != NULL) + obs_data_scale_Rmatrix__(R , scale_factor); + free(scale_factor); } @@ -593,12 +634,12 @@ void obs_data_scale_kernel(const obs_data_type * obs_data , matrix_type *S , mat const int ens_size = matrix_get_columns( S ); double * scale_factor = util_calloc(nrobs_active , sizeof * scale_factor ); int iens, iobs_active; - + { int obs_offset = 0; for (int block_nr = 0; block_nr < vector_get_size( obs_data->data ); block_nr++) { const obs_block_type * obs_block = vector_iget_const( obs_data->data , block_nr ); - + /* Init. the scaling factor ( 1/std(dObs) ) */ obs_block_init_scaling( obs_block , scale_factor , &obs_offset); } @@ -608,28 +649,28 @@ void obs_data_scale_kernel(const obs_data_type * obs_data , matrix_type *S , mat for (iens = 0; iens < ens_size; iens++) { for (iobs_active = 0; iobs_active < nrobs_active; iobs_active++) { - /* Scale the forecasted data so that they (in theory) have the same variance + /* Scale the forecasted data so that they (in theory) have the same variance (if the prior distribution for the observation errors is correct) */ matrix_imul(S , iobs_active , iens , scale_factor[iobs_active]); if (D != NULL) - /* Scale the combined data matrix: D = DObs + E - S, where DObs is the iobs_active times ens_size matrix where + /* Scale the combined data matrix: D = DObs + E - S, where DObs is the iobs_active times ens_size matrix where each column contains a copy of the observed data */ matrix_imul(D , iobs_active , iens , scale_factor[iobs_active]); - + if (E != NULL) /* Same with E (used for low rank representation of the error covariance matrix*/ matrix_imul(E , iobs_active , iens , scale_factor[iobs_active]); } } - + /* Scale the vector of observed data*/ if (dObs != NULL) { - for (iobs_active = 0; iobs_active < nrobs_active; iobs_active++) + for (iobs_active = 0; iobs_active < nrobs_active; iobs_active++) dObs[iobs_active] *= scale_factor[iobs_active]; } - + free(scale_factor); } @@ -637,7 +678,7 @@ void obs_data_scale_kernel(const obs_data_type * obs_data , matrix_type *S , mat -int obs_data_get_active_size( obs_data_type * obs_data ) { +int obs_data_get_active_size( const obs_data_type * obs_data ) { int active_size = 0; for (int block_nr = 0; block_nr < vector_get_size( obs_data->data ); block_nr++) { const obs_block_type * obs_block = vector_iget_const( obs_data->data , block_nr ); diff --git a/ThirdParty/Ert/devel/libenkf/src/obs_tstep_list.c b/ThirdParty/Ert/devel/libenkf/src/obs_tstep_list.c deleted file mode 100644 index 1b515a9fd8..0000000000 --- a/ThirdParty/Ert/devel/libenkf/src/obs_tstep_list.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'obs_tstep_list.c' - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. -*/ -#include <stdlib.h> - -#include <ert/util/type_macros.h> -#include <ert/util/util.h> -#include <ert/util/int_vector.h> - -#include <ert/enkf/obs_tstep_list.h> - - -#define OBS_TSTEP_LIST_TYPE_ID 84865209 - -struct obs_tstep_list_struct { - UTIL_TYPE_ID_DECLARATION; - bool all_active; - int_vector_type * tstep_list; -}; - - -UTIL_IS_INSTANCE_FUNCTION( obs_tstep_list , OBS_TSTEP_LIST_TYPE_ID ) - - -obs_tstep_list_type * obs_tstep_list_alloc() { - obs_tstep_list_type * list = util_malloc( sizeof * list ); - UTIL_TYPE_ID_INIT( list , OBS_TSTEP_LIST_TYPE_ID ); - list->all_active = true; - list->tstep_list = int_vector_alloc(0,0); - return list; -} - - -void obs_tstep_list_free( obs_tstep_list_type * list ) { - free( list ); -} - - - -bool obs_tstep_list_all_active( const obs_tstep_list_type * list ) { - return list->all_active; -} - - -bool obs_tstep_list_contains( const obs_tstep_list_type * list , int tstep) { - if (int_vector_index_sorted( list->tstep_list , tstep) == -1) - return false; - else - return true; -} - - - -void obs_tstep_list_add_tstep( obs_tstep_list_type * list , int tstep) { - if (!obs_tstep_list_contains( list , tstep)) { - if (int_vector_size( list->tstep_list )) { - int last = int_vector_get_last( list->tstep_list ); - int_vector_append( list->tstep_list , tstep ); - if (tstep < last) - int_vector_sort( list->tstep_list); - } else - int_vector_append( list->tstep_list , tstep ); - } - list->all_active = false; -} - - -void obs_tstep_list_add_range( obs_tstep_list_type * list , int step1 , int step2) { - int tstep; - for (tstep = step1; tstep <= step2; tstep++) - obs_tstep_list_add_tstep( list , tstep ); -} - - -int obs_tstep_list_get_size( const obs_tstep_list_type * list ) { - return int_vector_size( list->tstep_list ); -} - - -int obs_tstep_list_iget( const obs_tstep_list_type * list , int index) { - return int_vector_iget( list->tstep_list , index); -} - - -int obs_tstep_list_get_last( const obs_tstep_list_type * list ) { - return int_vector_get_last( list->tstep_list ); -} diff --git a/ThirdParty/Ert/devel/libenkf/src/obs_vector.c b/ThirdParty/Ert/devel/libenkf/src/obs_vector.c index b144a5f6bb..c099df771f 100644 --- a/ThirdParty/Ert/devel/libenkf/src/obs_vector.c +++ b/ThirdParty/Ert/devel/libenkf/src/obs_vector.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'obs_vector.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'obs_vector.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -48,23 +48,25 @@ #include <ert/enkf/active_list.h> #include <ert/enkf/enkf_state.h> #include <ert/enkf/enkf_defaults.h> +#include <ert/enkf/local_obsdata_node.h> #define OBS_VECTOR_TYPE_ID 120086 struct obs_vector_struct { UTIL_TYPE_ID_DECLARATION; - obs_free_ftype *freef; /* Function used to free an observation node. */ - obs_get_ftype *get_obs; /* Function used to build the 'd' vector. */ - obs_meas_ftype *measure; /* Function used to measure on the state, and add to to the S matrix. */ - obs_user_get_ftype *user_get; /* Function to get an observation based on KEY:INDEX input from user.*/ - obs_chi2_ftype *chi2; /* Function to evaluate chi-squared for an observation. */ - obs_scale_std_ftype *scale_std; /* Function to scale the standard deviation with a given factor */ - - vector_type * nodes; - char * obs_key; /* The key this observation vector has in the enkf_obs layer. */ + obs_free_ftype *freef; /* Function used to free an observation node. */ + obs_get_ftype *get_obs; /* Function used to build the 'd' vector. */ + obs_meas_ftype *measure; /* Function used to measure on the state, and add to to the S matrix. */ + obs_user_get_ftype *user_get; /* Function to get an observation based on KEY:INDEX input from user.*/ + obs_chi2_ftype *chi2; /* Function to evaluate chi-squared for an observation. */ + obs_update_std_scale_ftype *update_std_scale; /* Function to scale the standard deviation with a given factor */ + + vector_type * nodes; + char * obs_key; /* The key this observation vector has in the enkf_obs layer. */ enkf_config_node_type * config_node; /* The config_node of the node type we are observing - shared reference */ - obs_impl_type obs_type; + obs_impl_type obs_type; int num_active; /* The total number of timesteps where this observation is active (i.e. nodes[ ] != NULL) */ + int_vector_type * step_list; }; @@ -89,26 +91,35 @@ static void obs_vector_prefer_RESTART_warning() { -static int __conf_instance_get_restart_nr(const conf_instance_type * conf_instance, const char * obs_key , time_map_type * obs_time , bool prefer_restart) { +static int __conf_instance_get_restart_nr(const conf_instance_type * conf_instance, const char * obs_key , time_map_type * time_map , bool prefer_restart) { int obs_restart_nr = -1; /* To shut up compiler warning. */ - + if(conf_instance_has_item(conf_instance, "RESTART")) { obs_restart_nr = conf_instance_get_item_value_int(conf_instance, "RESTART"); - if (obs_restart_nr > time_map_get_last_step( obs_time)) - util_abort("%s: Observation %s occurs at restart %i, but history file has only %i restarts.\n", __func__, obs_key, obs_restart_nr, time_map_get_last_step( obs_time)); - } else if(conf_instance_has_item(conf_instance, "DATE")) { - time_t obs_date = conf_instance_get_item_value_time_t(conf_instance, "DATE" ); - obs_restart_nr = time_map_lookup_time( obs_time , obs_date ); - if (prefer_restart) - obs_vector_prefer_RESTART_warning(); - } else if (conf_instance_has_item(conf_instance, "DAYS")) { - double days = conf_instance_get_item_value_double(conf_instance, "DAYS"); - obs_restart_nr = time_map_lookup_days( obs_time , days ); - if (prefer_restart) - obs_vector_prefer_RESTART_warning(); - } else - util_abort("%s: Internal error. Invalid conf_instance?\n", __func__); - + if (obs_restart_nr > time_map_get_last_step( time_map)) + util_abort("%s: Observation %s occurs at restart %i, but history file has only %i restarts.\n", __func__, obs_key, obs_restart_nr, time_map_get_last_step( time_map )); + } else { + time_t obs_time = time_map_get_start_time( time_map ); + + if(conf_instance_has_item(conf_instance, "DATE")) { + obs_time = conf_instance_get_item_value_time_t(conf_instance, "DATE" ); + if (prefer_restart) + obs_vector_prefer_RESTART_warning(); + } else if (conf_instance_has_item(conf_instance, "DAYS")) { + double days = conf_instance_get_item_value_double(conf_instance, "DAYS"); + util_inplace_forward_days( &obs_time , days ); + if (prefer_restart) + obs_vector_prefer_RESTART_warning(); + } else if (conf_instance_has_item(conf_instance, "HOURS")) { + double hours = conf_instance_get_item_value_double(conf_instance, "HOURS"); + util_inplace_forward_seconds( &obs_time , hours * 3600 ); + if (prefer_restart) + obs_vector_prefer_RESTART_warning(); + } else + util_abort("%s: Internal error. Invalid conf_instance?\n", __func__); + + obs_restart_nr = time_map_lookup_time_with_tolerance( time_map , obs_time , 30 , 30 ); + } if (obs_restart_nr < 0) util_abort("%s: Failed to look up restart nr correctly \n",__func__); @@ -123,60 +134,61 @@ static int __conf_instance_get_restart_nr(const conf_instance_type * conf_instan static void obs_vector_resize(obs_vector_type * vector , int new_size) { int current_size = vector_get_size( vector->nodes ); int i; - - for (i=current_size; i < new_size; i++) + + for (i=current_size; i < new_size; i++) vector_append_ref( vector->nodes , NULL); - + } obs_vector_type * obs_vector_alloc(obs_impl_type obs_type , const char * obs_key , enkf_config_node_type * config_node, int num_reports) { obs_vector_type * vector = util_malloc(sizeof * vector ); - + UTIL_TYPE_ID_INIT( vector , OBS_VECTOR_TYPE_ID); vector->freef = NULL; vector->measure = NULL; vector->get_obs = NULL; vector->user_get = NULL; vector->chi2 = NULL; - vector->scale_std = NULL; + vector->update_std_scale = NULL; + vector->step_list = int_vector_alloc(0,0); switch (obs_type) { case(SUMMARY_OBS): - vector->freef = summary_obs_free__; - vector->measure = summary_obs_measure__; - vector->get_obs = summary_obs_get_observations__; - vector->user_get = summary_obs_user_get__; - vector->chi2 = summary_obs_chi2__; - vector->scale_std = summary_obs_scale_std__; + vector->freef = summary_obs_free__; + vector->measure = summary_obs_measure__; + vector->get_obs = summary_obs_get_observations__; + vector->user_get = summary_obs_user_get__; + vector->chi2 = summary_obs_chi2__; + vector->update_std_scale = summary_obs_update_std_scale__; break; case(BLOCK_OBS): - vector->freef = block_obs_free__; - vector->measure = block_obs_measure__; - vector->get_obs = block_obs_get_observations__; - vector->user_get = block_obs_user_get__; - vector->chi2 = block_obs_chi2__; - vector->scale_std = block_obs_scale_std__; + vector->freef = block_obs_free__; + vector->measure = block_obs_measure__; + vector->get_obs = block_obs_get_observations__; + vector->user_get = block_obs_user_get__; + vector->chi2 = block_obs_chi2__; + vector->update_std_scale = block_obs_update_std_scale__; break; case(GEN_OBS): - vector->freef = gen_obs_free__; - vector->measure = gen_obs_measure__; - vector->get_obs = gen_obs_get_observations__; - vector->user_get = gen_obs_user_get__; - vector->chi2 = gen_obs_chi2__; - vector->scale_std = gen_obs_scale_std__; + vector->freef = gen_obs_free__; + vector->measure = gen_obs_measure__; + vector->get_obs = gen_obs_get_observations__; + vector->user_get = gen_obs_user_get__; + vector->chi2 = gen_obs_chi2__; + vector->update_std_scale = gen_obs_update_std_scale__; break; default: util_abort("%s: internal error - obs_type:%d not recognized \n",__func__ , obs_type); } - + vector->obs_type = obs_type; vector->config_node = config_node; vector->obs_key = util_alloc_string_copy( obs_key ); vector->num_active = 0; vector->nodes = vector_alloc_new(); obs_vector_resize(vector , num_reports + 1); /* +1 here ?? Ohh - these +/- problems. */ - + return vector; } @@ -210,6 +222,7 @@ enkf_config_node_type * obs_vector_get_config_node(const obs_vector_type * obs_v void obs_vector_free(obs_vector_type * obs_vector) { vector_free( obs_vector->nodes ); free(obs_vector->obs_key); + int_vector_free(obs_vector->step_list); free(obs_vector); } @@ -230,7 +243,7 @@ static void obs_vector_assert_node_type( const obs_vector_type * obs_vector , co util_abort("%s: Error in type check: \n",__func__); type_OK = false; } - if (!type_OK) + if (!type_OK) util_abort("%s: Type mismatch when trying to add observation node to observation vector \n",__func__); } @@ -261,9 +274,12 @@ void obs_vector_clear_nodes( obs_vector_type * obs_vector ) { void obs_vector_install_node(obs_vector_type * obs_vector , int index , void * node) { obs_vector_assert_node_type( obs_vector , node ); { - if (vector_iget_const( obs_vector->nodes , index ) == NULL) + if (vector_iget_const( obs_vector->nodes , index ) == NULL) { obs_vector->num_active++; - + int_vector_append( obs_vector->step_list , index ); + int_vector_sort( obs_vector->step_list ); + } + vector_iset_owned_ref( obs_vector->nodes , index , node , obs_vector->freef ); } } @@ -307,7 +323,7 @@ int obs_vector_get_active_report_step(const obs_vector_type * vector) { } if (active_step < 0) util_abort("%s: internal error - mismatch in obs_vector->nodes and obs_vector->num_active \n",__func__); - + return active_step; } else { util_abort("%s: when calling this function the number of active report steps MUST BE 1 - you had: %d \n",__func__ , vector->num_active); @@ -316,15 +332,19 @@ int obs_vector_get_active_report_step(const obs_vector_type * vector) { } +const int_vector_type * obs_vector_get_step_list(const obs_vector_type * vector) { + return vector->step_list; +} + bool obs_vector_iget_active(const obs_vector_type * vector, int index) { /* We accept this ... */ if (index >= vector_get_size( vector->nodes )) return false; - + { void * obs_data = vector_iget( vector->nodes , index ); - if (obs_data != NULL) + if (obs_data != NULL) return true; else return false; @@ -332,8 +352,8 @@ bool obs_vector_iget_active(const obs_vector_type * vector, int index) { } -/* - Will happily return NULL if index is not active. +/* + Will happily return NULL if index is not active. */ void * obs_vector_iget_node(const obs_vector_type * vector, int index) { return vector_iget( vector->nodes , index ); @@ -376,7 +396,7 @@ int obs_vector_get_last_active_step(const obs_vector_type * obs_vector) { const void * obs_node = vector_iget_const( obs_vector->nodes , step ); if (obs_node) break; - + step--; if (step < 0) break; @@ -398,7 +418,7 @@ void obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector_type * obs_vector , con if(!conf_instance_is_of_class(conf_instance, "SUMMARY_OBSERVATION")) util_abort("%s: internal error. expected \"SUMMARY_OBSERVATION\" instance, got \"%s\".\n", __func__, conf_instance_get_class_name_ref(conf_instance) ); - + { double obs_value = conf_instance_get_item_value_double(conf_instance, "VALUE" ); double obs_error = conf_instance_get_item_value_double(conf_instance, "ERROR" ); @@ -412,17 +432,17 @@ void obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector_type * obs_vector , con int day,month,year; time_t start_time = time_map_iget( obs_time , 0 ); util_set_date_values( start_time , &day , &month , &year); - + fprintf(stderr,"** ERROR: It is unfortunately not possible to use summary observations from the\n"); fprintf(stderr," start of the simulation. Problem with observation:%s at %02d/%02d/%4d\n",obs_key , day,month,year); exit(1); - } + } { if (strcmp( error_mode , "REL") == 0) obs_error *= obs_value; - else if (strcmp( error_mode , "RELMIN") == 0) + else if (strcmp( error_mode , "RELMIN") == 0) obs_error = util_double_max( min_error , obs_error * obs_value ); - + obs_vector_add_summary_obs( obs_vector , obs_restart_nr , sum_key , obs_key , obs_value , obs_error , NULL , 0); } } @@ -436,27 +456,27 @@ obs_vector_type * obs_vector_alloc_from_GENERAL_OBSERVATION(const conf_instance_ util_abort("%s: internal error. expected \"GENERAL_OBSERVATION\" instance, got \"%s\".\n", __func__, conf_instance_get_class_name_ref(conf_instance) ); const char * obs_key = conf_instance_get_name_ref(conf_instance); - const char * state_kw = conf_instance_get_item_value_ref( conf_instance, "DATA" ); + const char * state_kw = conf_instance_get_item_value_ref( conf_instance, "DATA" ); if (ensemble_config_has_key( ensemble_config , state_kw )) { const char * obs_key = conf_instance_get_name_ref(conf_instance); int obs_restart_nr = __conf_instance_get_restart_nr(conf_instance , obs_key , obs_time , true); const char * index_file = NULL; const char * index_list = NULL; const char * obs_file = NULL; - const char * error_covar_file = NULL; + const char * error_covar_file = NULL; if (conf_instance_has_item(conf_instance , "INDEX_FILE")) - index_file = conf_instance_get_item_value_ref( conf_instance, "INDEX_FILE" ); + index_file = conf_instance_get_item_value_ref( conf_instance, "INDEX_FILE" ); if (conf_instance_has_item(conf_instance , "INDEX_LIST")) - index_list = conf_instance_get_item_value_ref( conf_instance, "INDEX_LIST" ); + index_list = conf_instance_get_item_value_ref( conf_instance, "INDEX_LIST" ); if (conf_instance_has_item(conf_instance , "OBS_FILE")) - obs_file = conf_instance_get_item_value_ref( conf_instance, "OBS_FILE" ); - + obs_file = conf_instance_get_item_value_ref( conf_instance, "OBS_FILE" ); + if (conf_instance_has_item(conf_instance , "ERROR_COVAR")) - error_covar_file = conf_instance_get_item_value_ref( conf_instance, "ERROR_COVAR" ); - + error_covar_file = conf_instance_get_item_value_ref( conf_instance, "ERROR_COVAR" ); + { obs_vector_type * obs_vector = NULL; const enkf_config_node_type * config_node = ensemble_config_get_node( ensemble_config , state_kw); @@ -466,16 +486,16 @@ obs_vector_type * obs_vector_alloc_from_GENERAL_OBSERVATION(const conf_instance_ double scalar_value = -1; gen_obs_type * gen_obs ; const gen_data_config_type * config = enkf_config_node_get_ref( config_node ); - - if (gen_data_config_has_report_step( config , obs_restart_nr)) { + + if (gen_data_config_has_report_step( config , obs_restart_nr)) { obs_vector = obs_vector_alloc( GEN_OBS , obs_key , ensemble_config_get_node(ensemble_config , state_kw ), time_map_get_last_step( obs_time )); if (conf_instance_has_item(conf_instance , "VALUE")) { scalar_value = conf_instance_get_item_value_double(conf_instance , "VALUE"); scalar_error = conf_instance_get_item_value_double(conf_instance , "ERROR"); } - + /** The config system has ensured that we have either OBS_FILE or (VALUE and ERROR). */ - gen_obs = gen_obs_alloc( enkf_config_node_get_ref( config_node ) , obs_key , obs_file , scalar_value , scalar_error , index_file , index_list , error_covar_file); + gen_obs = gen_obs_alloc( enkf_config_node_get_ref( config_node ) , obs_key , obs_file , scalar_value , scalar_error , index_file , index_list , error_covar_file); obs_vector_install_node( obs_vector , obs_restart_nr , gen_obs ); } else fprintf(stderr,"** ERROR: The GEN_DATA node:%s is not configured to load from report step:%d - the observation:%s will be ignored\n", state_kw , obs_restart_nr , obs_key); @@ -497,43 +517,43 @@ obs_vector_type * obs_vector_alloc_from_GENERAL_OBSERVATION(const conf_instance_ // Should check the refcase for key - if it is != NULL. -bool obs_vector_load_from_HISTORY_OBSERVATION(obs_vector_type * obs_vector , - const conf_instance_type * conf_instance , - time_map_type * obs_time , - const history_type * history , - ensemble_config_type * ensemble_config, +bool obs_vector_load_from_HISTORY_OBSERVATION(obs_vector_type * obs_vector , + const conf_instance_type * conf_instance , + time_map_type * obs_time , + const history_type * history , + ensemble_config_type * ensemble_config, double std_cutoff ) { if(!conf_instance_is_of_class(conf_instance, "HISTORY_OBSERVATION")) util_abort("%s: internal error. expected \"HISTORY_OBSERVATION\" instance, got \"%s\".\n",__func__, conf_instance_get_class_name_ref(conf_instance) ); - + { bool initOK = false; int size , restart_nr; double_vector_type * value = double_vector_alloc(0,0); double_vector_type * std = double_vector_alloc(0,0); - bool_vector_type * valid = bool_vector_alloc(0 , false); - + bool_vector_type * valid = bool_vector_alloc(0 , false); + /* The auto_corrf parameters can not be "segmentized" */ double auto_corrf_param = -1; const char * auto_corrf_name = NULL; - - + + double error = conf_instance_get_item_value_double(conf_instance, "ERROR" ); double error_min = conf_instance_get_item_value_double(conf_instance, "ERROR_MIN" ); const char * error_mode = conf_instance_get_item_value_ref( conf_instance, "ERROR_MODE"); const char * sum_key = conf_instance_get_name_ref( conf_instance ); - + if(conf_instance_has_item(conf_instance, "AUTO_CORRF")) { auto_corrf_name = conf_instance_get_item_value_ref( conf_instance , "AUTO_CORRF"); auto_corrf_param = conf_instance_get_item_value_double(conf_instance, "AUTO_CORRF_PARAM"); - if(conf_instance_has_item(conf_instance, "AUTO_CORRF_PARAM")) + if(conf_instance_has_item(conf_instance, "AUTO_CORRF_PARAM")) auto_corrf_param = conf_instance_get_item_value_double(conf_instance, "AUTO_CORRF_PARAM"); else util_abort("%s: When specifying AUTO_CORRF you must also give a vlaue for AUTO_CORRF_PARAM",__func__); } - - + + // Get time series data from history object and allocate size = time_map_get_last_step( obs_time ); if (history_init_ts( history , sum_key , value , valid )) { @@ -552,44 +572,44 @@ bool obs_vector_load_from_HISTORY_OBSERVATION(obs_vector_type * obs_vector , } } else util_abort("%s: Internal error. Unknown error mode \"%s\"\n", __func__, error_mode); - - + + // Handle SEGMENTs which can be used to customize the observation error. */ { stringlist_type * segment_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(conf_instance, "SEGMENT"); stringlist_sort( segment_keys , NULL ); - + int num_segments = stringlist_get_size(segment_keys); - + for(int segment_nr = 0; segment_nr < num_segments; segment_nr++) { const char * segment_name = stringlist_iget(segment_keys, segment_nr); const conf_instance_type * segment_conf = conf_instance_get_sub_instance_ref(conf_instance, segment_name); - + int start = conf_instance_get_item_value_int( segment_conf, "START" ); int stop = conf_instance_get_item_value_int( segment_conf, "STOP" ); double error_segment = conf_instance_get_item_value_double(segment_conf, "ERROR" ); double error_min_segment = conf_instance_get_item_value_double(segment_conf, "ERROR_MIN" ); const char * error_mode_segment = conf_instance_get_item_value_ref( segment_conf, "ERROR_MODE"); - + if(start < 0) { printf("%s: WARNING - Segment out of bounds. Truncating start of segment to 0.\n", __func__); start = 0; } - + if(stop >= size) { printf("%s: WARNING - Segment out of bounds. Truncating end of segment to %d.\n", __func__, size - 1); stop = size -1; } - + if(start > stop) { printf("%s: WARNING - Segment start after stop. Truncating end of segment to %d.\n", __func__, start ); stop = start; } - + // Create the standard deviation vector if(strcmp(error_mode_segment, "ABS") == 0) { for( restart_nr = start; restart_nr <= stop; restart_nr++) @@ -607,21 +627,21 @@ bool obs_vector_load_from_HISTORY_OBSERVATION(obs_vector_type * obs_vector , } stringlist_free(segment_keys); } - - + + /* This is where the summary observations are finally added. */ for (restart_nr = 0; restart_nr < size; restart_nr++) { if (bool_vector_safe_iget( valid , restart_nr)) { if (double_vector_iget( std , restart_nr) > std_cutoff) { - obs_vector_add_summary_obs( obs_vector , restart_nr , sum_key , sum_key , - double_vector_iget( value ,restart_nr) , double_vector_iget( std , restart_nr ) , + obs_vector_add_summary_obs( obs_vector , restart_nr , sum_key , sum_key , + double_vector_iget( value ,restart_nr) , double_vector_iget( std , restart_nr ) , auto_corrf_name , auto_corrf_param); - } else + } else fprintf(stderr,"** Warning: to small observation error in observation %s:%d - ignored. \n", sum_key , restart_nr); } - } + } initOK = true; } double_vector_free(std); @@ -631,15 +651,14 @@ bool obs_vector_load_from_HISTORY_OBSERVATION(obs_vector_type * obs_vector , } } -void obs_vector_scale_std(obs_vector_type * obs_vector, double std_multiplier) { - vector_type * observation_nodes = obs_vector->nodes; - - for (int i=0; i<vector_get_size(observation_nodes); i++) { - if (obs_vector_iget_active(obs_vector, i)) { - void * observation = obs_vector_iget_node(obs_vector, i); - obs_vector->scale_std(observation, std_multiplier); - } - +void obs_vector_scale_std(obs_vector_type * obs_vector, const local_obsdata_node_type * local_node , double std_multiplier) { + const active_list_type * active_list = local_obsdata_node_get_active_list( local_node ); + const int_vector_type * tstep_list = local_obsdata_node_get_tstep_list( local_node ); + for (int i=0; i < int_vector_size( tstep_list ); i++) { + int tstep = int_vector_iget( tstep_list , i ); + void * observation = obs_vector_iget_node(obs_vector, tstep); + if (observation) + obs_vector->update_std_scale(observation, std_multiplier , active_list); } } @@ -658,10 +677,10 @@ static const char * __summary_kw( const char * field_name ) { } -obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_type * conf_instance , - const ecl_grid_type * grid , - time_map_type * obs_time , - const ecl_sum_type * refcase , +obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_type * conf_instance , + const ecl_grid_type * grid , + time_map_type * obs_time , + const ecl_sum_type * refcase , ensemble_config_type * ensemble_config) { if(!conf_instance_is_of_class(conf_instance, "BLOCK_OBSERVATION")) @@ -674,7 +693,7 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty const char * field_name = conf_instance_get_item_value_ref(conf_instance , "FIELD"); const char * sum_kw = NULL; bool OK = true; - + if (strcmp(source_string , "FIELD") == 0) { source_type = SOURCE_FIELD; if (!ensemble_config_has_key( ensemble_config , field_name)) { @@ -684,26 +703,26 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty } else if (strcmp( source_string , "SUMMARY") == 0) { source_type = SOURCE_SUMMARY; sum_kw = __summary_kw( field_name ); - } else + } else util_abort("%s: internal error \n",__func__); - + if (OK) { obs_vector_type * obs_vector = NULL; int size = time_map_get_last_step( obs_time ); int obs_restart_nr ; - + stringlist_type * summary_keys = stringlist_alloc_new(); stringlist_type * obs_pt_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(conf_instance, "OBS"); int num_obs_pts = stringlist_get_size(obs_pt_keys); - + double * obs_value = util_calloc(num_obs_pts , sizeof * obs_value); double * obs_std = util_calloc(num_obs_pts , sizeof * obs_std ); int * obs_i = util_calloc(num_obs_pts , sizeof * obs_i ); int * obs_j = util_calloc(num_obs_pts , sizeof * obs_j ); int * obs_k = util_calloc(num_obs_pts , sizeof * obs_k ); - obs_restart_nr = __conf_instance_get_restart_nr(conf_instance , obs_label , obs_time , false); - + obs_restart_nr = __conf_instance_get_restart_nr(conf_instance , obs_label , obs_time , false); + /** Build the observation. */ for(int obs_pt_nr = 0; obs_pt_nr < num_obs_pts; obs_pt_nr++) { const char * obs_key = stringlist_iget(obs_pt_keys, obs_pt_nr); @@ -712,7 +731,7 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty double error = conf_instance_get_item_value_double(obs_instance, "ERROR"); double value = conf_instance_get_item_value_double(obs_instance, "VALUE"); double min_error = conf_instance_get_item_value_double(obs_instance, "ERROR_MIN"); - + if (strcmp( error_mode , "REL") == 0) error *= value; else if (strcmp( error_mode , "RELMIN") == 0) @@ -720,7 +739,7 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty obs_value[obs_pt_nr] = value; obs_std [obs_pt_nr] = error; - + /** The input values i,j,k come from the user, and are offset 1. They are immediately shifted with -1 to become C-based offset zero. @@ -730,21 +749,21 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty obs_k[obs_pt_nr] = conf_instance_get_item_value_int( obs_instance, "K") - 1; if (source_type == SOURCE_SUMMARY) { - char * summary_key = smspec_alloc_block_ijk_key( SUMMARY_KEY_JOIN_STRING , sum_kw , - obs_i[obs_pt_nr] + 1 , - obs_j[obs_pt_nr] + 1 , + char * summary_key = smspec_alloc_block_ijk_key( SUMMARY_KEY_JOIN_STRING , sum_kw , + obs_i[obs_pt_nr] + 1 , + obs_j[obs_pt_nr] + 1 , obs_k[obs_pt_nr] + 1 ); - + stringlist_append_owned_ref( summary_keys , summary_key ); } } - + if (source_type == SOURCE_FIELD) { const enkf_config_node_type * config_node = ensemble_config_get_node( ensemble_config , field_name); - const field_config_type * field_config = enkf_config_node_get_ref( config_node ); + const field_config_type * field_config = enkf_config_node_get_ref( config_node ); block_obs_type * block_obs = block_obs_alloc_complete(obs_label, source_type , NULL , field_config , grid , num_obs_pts, obs_i, obs_j, obs_k, obs_value, obs_std); - + if (block_obs != NULL) { obs_vector = obs_vector_alloc( BLOCK_OBS , obs_label , ensemble_config_get_node(ensemble_config , field_name), size ); obs_vector_install_node( obs_vector , obs_restart_nr , block_obs); @@ -756,9 +775,9 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty const char * sum_key = stringlist_iget( summary_keys , i ); if (!ecl_sum_has_key(refcase , sum_key)) { /* - If the + If the */ - fprintf(stderr,"** Warning missing summary %s for cell: (%d,%d,%d) in refcase - make sure that \"BPR %d %d %d\" is included in ECLIPSE summary specification \n" , + fprintf(stderr,"** Warning missing summary %s for cell: (%d,%d,%d) in refcase - make sure that \"BPR %d %d %d\" is included in ECLIPSE summary specification \n" , sum_key , obs_i[i]+1 , obs_j[i]+1 , obs_k[i]+1 , obs_i[i]+1 , obs_j[i]+1 , obs_k[i]+1 ); //OK = false; } @@ -770,12 +789,12 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty for (int i=0; i < stringlist_get_size( summary_keys ); i++) { const char * sum_key = stringlist_iget( summary_keys , i ); - enkf_config_node_type * child_node = ensemble_config_add_summary( ensemble_config , sum_key , LOAD_FAIL_WARN ); + enkf_config_node_type * child_node = ensemble_config_add_summary_observation( ensemble_config , sum_key , LOAD_FAIL_WARN ); enkf_config_node_update_container( container_config , child_node ); } - + { - block_obs_type * block_obs = block_obs_alloc_complete(obs_label, source_type , summary_keys , enkf_config_node_get_ref(container_config) , + block_obs_type * block_obs = block_obs_alloc_complete(obs_label, source_type , summary_keys , enkf_config_node_get_ref(container_config) , grid , num_obs_pts, obs_i, obs_j, obs_k, obs_value, obs_std); if (block_obs != NULL) { obs_vector = obs_vector_alloc( BLOCK_OBS , obs_label , container_config, size ); @@ -785,7 +804,7 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty } } else util_abort("%s: invalid source value \n",__func__); - + free(obs_value); free(obs_std); free(obs_i); @@ -793,7 +812,7 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty free(obs_k); stringlist_free(obs_pt_keys); stringlist_free(summary_keys); - + return obs_vector; } else { fprintf(stderr,"** Warning the ensemble key:%s does not exist - observation:%s not added \n", field_name , obs_label); @@ -804,32 +823,31 @@ obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_ty void obs_vector_iget_observations(const obs_vector_type * obs_vector, int report_step , obs_data_type * obs_data, const active_list_type * active_list, enkf_fs_type * fs) { void * obs_node = vector_iget( obs_vector->nodes , report_step ); - if ( obs_node != NULL) + if ( obs_node != NULL) obs_vector->get_obs(obs_node , obs_data , fs, report_step , active_list); } -void obs_vector_measure(const obs_vector_type * obs_vector , - enkf_fs_type * fs , - state_enum state , - int report_step , - const int_vector_type * ens_active_list , - meas_data_type * meas_data , +void obs_vector_measure(const obs_vector_type * obs_vector , + enkf_fs_type * fs , + state_enum state , + int report_step , + const int_vector_type * ens_active_list , + meas_data_type * meas_data , const active_list_type * active_list) { - + void * obs_node = vector_iget( obs_vector->nodes , report_step ); if ( obs_node != NULL ) { enkf_node_type * enkf_node = enkf_node_deep_alloc( obs_vector->config_node ); - node_id_type node_id = { .report_step = report_step , - .state = state , + node_id_type node_id = { .report_step = report_step , + .state = state , .iens = 0 }; for (int active_iens_index =0; active_iens_index < int_vector_size( ens_active_list ); active_iens_index++) { node_id.iens = int_vector_iget( ens_active_list , active_iens_index ); - + enkf_node_load(enkf_node , fs , node_id); - node_id.iens = active_iens_index; obs_vector->measure(obs_node , enkf_node_value_ptr(enkf_node) , node_id , meas_data , active_list); } @@ -850,21 +868,21 @@ static bool obs_vector_has_data_at_report_step( const obs_vector_type * obs_vect return false; } } - } - - /* + } + + /* Will return true unconditionally if we do not have observation data at this report step; - or alternatively if the active_mask is all false. + or alternatively if the active_mask is all false. */ - return true; -} + return true; +} /* The has_vector_data() function will only check that we have a vector stored, and not the actual length of the vector. This means we can be fooled if the stored vector is shorter than what the observation - requires. + requires. Should ideally check that the vector is long enough, but that requires changes in the enkf_node api for vector storage. @@ -892,9 +910,9 @@ static bool obs_vector_has_vector_data( const obs_vector_type * obs_vector , con -bool obs_vector_has_data( const obs_vector_type * obs_vector , const bool_vector_type * active_mask , enkf_fs_type * fs) { +bool obs_vector_has_data( const obs_vector_type * obs_vector , const bool_vector_type * active_mask , enkf_fs_type * fs) { const enkf_config_node_type * data_config = obs_vector->config_node; - if (enkf_config_node_vector_storage( data_config )) + if (enkf_config_node_vector_storage( data_config )) return obs_vector_has_vector_data( obs_vector , active_mask , fs ); else { for (int report_step = 0; report_step < vector_get_size( obs_vector->nodes ); report_step++) { @@ -927,10 +945,10 @@ bool obs_vector_has_data( const obs_vector_type * obs_vector , const bool_vector */ -static double obs_vector_chi2__(const obs_vector_type * obs_vector , int report_step , const enkf_node_type * node, node_id_type node_id) { +static double obs_vector_chi2__(const obs_vector_type * obs_vector , int report_step , const enkf_node_type * node, node_id_type node_id) { void * obs_node = vector_iget( obs_vector->nodes , report_step ); - if ( obs_node != NULL) + if ( obs_node != NULL) return obs_vector->chi2( obs_node , enkf_node_value_ptr( node ), node_id); else return 0.0; /* Observation not active for this report step. */ @@ -944,10 +962,10 @@ static double obs_vector_chi2__(const obs_vector_type * obs_vector , int report_ double obs_vector_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , node_id_type node_id) { enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node ); double chi2 = 0; - - if (enkf_node_try_load( enkf_node , fs , node_id)) + + if (enkf_node_try_load( enkf_node , fs , node_id)) chi2 = obs_vector_chi2__(obs_vector , node_id.report_step , enkf_node , node_id); - + enkf_node_free( enkf_node ); return chi2; } @@ -967,16 +985,16 @@ double obs_vector_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , //This will not work for container observations ..... -void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector , - enkf_fs_type * fs, - bool_vector_type * valid , - int step1 , - int step2 , - int iens1 , - int iens2 , - state_enum load_state , +void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector , + enkf_fs_type * fs, + bool_vector_type * valid , + int step1 , + int step2 , + int iens1 , + int iens2 , + state_enum load_state , double ** chi2) { - + int step; enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node ); node_id_type node_id; @@ -988,12 +1006,12 @@ void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector , void * obs_node = vector_iget( obs_vector->nodes , step); if (obs_node == NULL) { - for (iens = iens1; iens < iens2; iens++) + for (iens = iens1; iens < iens2; iens++) chi2[step][iens] = 0; } else { for (iens = iens1; iens < iens2; iens++) { node_id.iens = iens; - if (enkf_node_try_load( enkf_node , fs , node_id)) + if (enkf_node_try_load( enkf_node , fs , node_id)) chi2[step][iens] = obs_vector_chi2__(obs_vector , step , enkf_node , node_id); else { chi2[step][iens] = 0; @@ -1018,14 +1036,14 @@ void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector , double obs_vector_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , int iens, state_enum load_state) { int report_step; double sum_chi2 = 0; - enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node ); + enkf_node_type * enkf_node = enkf_node_deep_alloc( obs_vector->config_node ); node_id_type node_id = {.report_step = 0, .iens = iens , .state = load_state }; for (report_step = 0; report_step < vector_get_size( obs_vector->nodes ); report_step++) { if (vector_iget(obs_vector->nodes , report_step) != NULL) { node_id.report_step = report_step; - if (enkf_node_try_load( enkf_node , fs , node_id)) + if (enkf_node_try_load( enkf_node , fs , node_id)) sum_chi2 += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id); } @@ -1035,7 +1053,7 @@ double obs_vector_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * } -/** +/** This function will sum up all timesteps of the obs_vector, for all ensemble members. */ @@ -1045,7 +1063,7 @@ void obs_vector_ensemble_total_chi2(const obs_vector_type * obs_vector , enkf_fs int report_step; int iens; char * msg_text = NULL; - + for (iens = 0; iens < ens_size; iens++) sum_chi2[iens] = 0; @@ -1057,7 +1075,7 @@ void obs_vector_ensemble_total_chi2(const obs_vector_type * obs_vector , enkf_fs { node_id_type node_id = {.report_step = 0, .iens = iens , .state = load_state }; enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node ); - for (report_step = 0; report_step < vector_get_size( obs_vector->nodes); report_step++) { + for (report_step = 0; report_step < vector_get_size( obs_vector->nodes); report_step++) { if (verbose) { msg_text = util_realloc_sprintf( msg_text , "%s[%03d]" , obs_vector->obs_key , report_step); msg_update(msg , msg_text); @@ -1067,7 +1085,7 @@ void obs_vector_ensemble_total_chi2(const obs_vector_type * obs_vector , enkf_fs for (iens = 0; iens < ens_size; iens++) { node_id.iens = iens; - if (enkf_node_try_load( enkf_node , fs , node_id)) + if (enkf_node_try_load( enkf_node , fs , node_id)) sum_chi2[iens] += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id); } @@ -1087,8 +1105,15 @@ const char * obs_vector_get_obs_key( const obs_vector_type * obs_vector) { } +local_obsdata_node_type * obs_vector_alloc_local_node(const obs_vector_type * obs_vector) { + local_obsdata_node_type * obs_node = local_obsdata_node_alloc( obs_vector->obs_key ); + local_obsdata_node_reset_tstep_list(obs_node, obs_vector->step_list ); + return obs_node; +} + + /*****************************************************************/ VOID_FREE(obs_vector) - + diff --git a/ThirdParty/Ert/devel/libenkf/src/plot_config.c b/ThirdParty/Ert/devel/libenkf/src/plot_config.c index b4efa56192..63c198c29b 100644 --- a/ThirdParty/Ert/devel/libenkf/src/plot_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/plot_config.c @@ -1,30 +1,33 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'plot_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'plot_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <ert/util/util.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> + #include <ert/enkf/plot_config.h> #include <ert/enkf/enkf_defaults.h> #include <ert/enkf/config_keys.h> -/** +/** Struct holding basic information used when plotting. */ @@ -35,8 +38,8 @@ struct plot_config_struct { char * viewer; /* The executable used when displaying the newly created image - can be NULL - in which case the plots are not displayed in any way. */ int errorbar_max; /* If the number of observations is less than this it is plotted with errorbars - otherwise with lines. */ bool plot_errorbar; /*Should the errorbars be plotted*/ - bool plot_refcase; - int height; + bool plot_refcase; + int height; int width; bool logy; }; @@ -62,7 +65,6 @@ void plot_config_set_height(plot_config_type * plot_config , int height) { void plot_config_set_path(plot_config_type * plot_config , const char * plot_path) { plot_config->plot_path = util_realloc_string_copy(plot_config->plot_path , plot_path); - util_make_path( plot_path ); } void plot_config_set_image_type(plot_config_type * plot_config , const char * image_type) { @@ -75,7 +77,7 @@ void plot_config_set_viewer(plot_config_type * plot_config , const char * plot_v plot_config->viewer = util_realloc_string_copy(plot_config->viewer , plot_viewer); else { plot_config->viewer = util_realloc_string_copy(plot_config->viewer , NULL ); - + fprintf(stderr , "\n ---------------------------------------------------------------------\n"); fprintf(stderr , " - The ERT variable \"IMAGE_VIEWER\" has not been set to a valid -\n"); fprintf(stderr , " - value; this means that ERT can not display the plots for you - -\n"); @@ -83,7 +85,7 @@ void plot_config_set_viewer(plot_config_type * plot_config , const char * plot_v fprintf(stderr , " - your favorite image viewer software. -\n"); fprintf(stderr , " - -\n"); fprintf(stderr , " - To actually set the IMAGE_VIEWER add the following in your -\n"); - fprintf(stderr , " - configuration file: -\n"); + fprintf(stderr , " - configuration file: -\n"); fprintf(stderr , " - -\n"); fprintf(stderr , " - IMAGE_VIEWER /path/to/binary/which/can/display/graphical/files -\n"); fprintf(stderr , " ---------------------------------------------------------------------\n\n"); @@ -137,7 +139,7 @@ const char * plot_config_get_image_type(const plot_config_type * plot_config ) const char * plot_config_get_viewer(const plot_config_type * plot_config ) { return plot_config->viewer; -} +} const char * plot_config_get_driver(const plot_config_type * plot_config ) { return plot_config->driver; @@ -177,13 +179,17 @@ plot_config_type * plot_config_alloc_default() { info->plot_path = NULL; info->image_type = NULL; info->viewer = NULL; - info->driver = NULL; + info->driver = NULL; + - plot_config_set_plot_refcase( info , DEFAULT_PLOT_REFCASE); plot_config_set_path(info , DEFAULT_PLOT_PATH ); plot_config_set_image_type(info , DEFAULT_IMAGE_TYPE ); - plot_config_set_viewer(info , DEFAULT_IMAGE_VIEWER ); + + if(util_is_executable(DEFAULT_IMAGE_VIEWER)) { + plot_config_set_viewer(info , DEFAULT_IMAGE_VIEWER ); + } + plot_config_set_driver(info , DEFAULT_PLOT_DRIVER ); plot_config_set_width(info , DEFAULT_PLOT_WIDTH ); plot_config_set_height(info , DEFAULT_PLOT_HEIGHT ); @@ -194,37 +200,37 @@ plot_config_type * plot_config_alloc_default() { } -void plot_config_init(plot_config_type * plot_config , const config_type * config ) { - if (config_item_set( config , PLOT_PATH_KEY)) - plot_config_set_path( plot_config , config_get_value( config , PLOT_PATH_KEY )); +void plot_config_init(plot_config_type * plot_config , const config_content_type * config ) { + if (config_content_has_item( config , PLOT_PATH_KEY)) + plot_config_set_path( plot_config , config_content_get_value( config , PLOT_PATH_KEY )); + + if (config_content_has_item( config , PLOT_DRIVER_KEY)) + plot_config_set_driver( plot_config , config_content_get_value( config , PLOT_DRIVER_KEY )); + + if (config_content_has_item( config , IMAGE_VIEWER_KEY)) + plot_config_set_viewer( plot_config , config_content_get_value( config , IMAGE_VIEWER_KEY )); + + if (config_content_has_item( config , PLOT_DRIVER_KEY)) + plot_config_set_driver( plot_config , config_content_get_value( config , PLOT_DRIVER_KEY )); - if (config_item_set( config , PLOT_DRIVER_KEY)) - plot_config_set_driver( plot_config , config_get_value( config , PLOT_DRIVER_KEY )); - - if (config_item_set( config , IMAGE_VIEWER_KEY)) - plot_config_set_viewer( plot_config , config_get_value( config , IMAGE_VIEWER_KEY )); + if (config_content_has_item( config , PLOT_ERRORBAR_MAX_KEY)) + plot_config_set_errorbar_max( plot_config , config_content_get_value_as_int( config , PLOT_ERRORBAR_MAX_KEY )); - if (config_item_set( config , PLOT_DRIVER_KEY)) - plot_config_set_driver( plot_config , config_get_value( config , PLOT_DRIVER_KEY )); - - if (config_item_set( config , PLOT_ERRORBAR_MAX_KEY)) - plot_config_set_errorbar_max( plot_config , config_get_value_as_int( config , PLOT_ERRORBAR_MAX_KEY )); - - if (config_item_set( config , PLOT_ERRORBAR_KEY)) - plot_config_set_plot_errorbar( plot_config , config_get_value_as_bool( config , PLOT_ERRORBAR_KEY )); + if (config_content_has_item( config , PLOT_ERRORBAR_KEY)) + plot_config_set_plot_errorbar( plot_config , config_content_get_value_as_bool( config , PLOT_ERRORBAR_KEY )); - if (config_item_set( config , PLOT_HEIGHT_KEY)) - plot_config_set_height( plot_config , config_get_value_as_int( config , PLOT_HEIGHT_KEY )); + if (config_content_has_item( config , PLOT_HEIGHT_KEY)) + plot_config_set_height( plot_config , config_content_get_value_as_int( config , PLOT_HEIGHT_KEY )); - if (config_item_set( config , PLOT_WIDTH_KEY)) - plot_config_set_width( plot_config , config_get_value_as_int( config , PLOT_WIDTH_KEY )); + if (config_content_has_item( config , PLOT_WIDTH_KEY)) + plot_config_set_width( plot_config , config_content_get_value_as_int( config , PLOT_WIDTH_KEY )); - if (config_item_set( config , PLOT_REFCASE_KEY)) { - const char * plot_refcase_string = config_get_value( config , PLOT_REFCASE_KEY ); + if (config_content_has_item( config , PLOT_REFCASE_KEY)) { + const char * plot_refcase_string = config_content_get_value( config , PLOT_REFCASE_KEY ); bool plot_refcase; if (!util_sscanf_bool( plot_refcase_string , &plot_refcase)) { fprintf(stderr , - "Warning: The PLOT_REFCASE option should have value True | False. The value:%s will be interpreted as True" , + "Warning: The PLOT_REFCASE option should have value True | False. The value:%s will be interpreted as True" , plot_refcase_string); plot_refcase = true; @@ -234,7 +240,7 @@ void plot_config_init(plot_config_type * plot_config , const config_type * confi } -void plot_config_add_config_items( config_type * config ) { +void plot_config_add_config_items( config_parser_type * config ) { config_add_key_value(config , PLOT_HEIGHT_KEY , false , CONFIG_INT); config_add_key_value(config , PLOT_WIDTH_KEY , false , CONFIG_INT); config_add_key_value(config , PLOT_PATH_KEY , false , CONFIG_STRING); @@ -244,7 +250,7 @@ void plot_config_add_config_items( config_type * config ) { { config_schema_item_type * item; - + item = config_add_key_value(config , IMAGE_TYPE_KEY , false , CONFIG_STRING); config_schema_item_set_common_selection_set( item , 3 , (const char *[3]) {"png" , "jpg" , "psc"}); @@ -269,7 +275,7 @@ void plot_config_fprintf_config( const plot_config_type * plot_config , FILE * s fprintf( stream , CONFIG_COMMENTLINE_FORMAT ); fprintf( stream , CONFIG_COMMENT_FORMAT , "Here comes configuration information related to plot configuration."); fprintf( stream , CONFIG_COMMENT_FORMAT , "When using the GUI only the PLOT_PATH directive is honored."); - + if (!util_string_equal( plot_config->plot_path , DEFAULT_PLOT_PATH)) { fprintf(stream , CONFIG_KEY_FORMAT , PLOT_PATH_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , plot_config->plot_path ); @@ -279,7 +285,7 @@ void plot_config_fprintf_config( const plot_config_type * plot_config , FILE * s fprintf(stream , CONFIG_KEY_FORMAT , IMAGE_TYPE_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , plot_config->image_type ); } - + if (!util_string_equal( plot_config->driver , DEFAULT_PLOT_DRIVER)) { fprintf(stream , CONFIG_KEY_FORMAT , PLOT_DRIVER_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , plot_config->driver ); @@ -313,7 +319,7 @@ void plot_config_fprintf_config( const plot_config_type * plot_config , FILE * s fprintf(stream , CONFIG_INT_FORMAT , plot_config->width ); fprintf(stream , "\n"); } - + fprintf(stream , "\n\n"); } @@ -325,7 +331,7 @@ stringlist_type * plot_config_refcase_fscanf(const char * plot_refcase_file ) { do { stringlist_append_copy( list_of_refcases ,util_fscanf_alloc_line(stream , &at_eof)); } while (!at_eof); - + fclose( stream ); } return list_of_refcases; diff --git a/ThirdParty/Ert/devel/libenkf/src/qc_module.c b/ThirdParty/Ert/devel/libenkf/src/qc_module.c index daad468df1..8659046f78 100644 --- a/ThirdParty/Ert/devel/libenkf/src/qc_module.c +++ b/ThirdParty/Ert/devel/libenkf/src/qc_module.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'qc_module.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'qc_module.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -22,7 +22,7 @@ #include <ert/util/util.h> #include <ert/util/subst_list.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/job_queue/workflow.h> @@ -39,7 +39,7 @@ struct qc_module_struct { char * qc_path; workflow_type * qc_workflow; ert_workflow_list_type * workflow_list; - runpath_list_type * runpath_list; + runpath_list_type * runpath_list; }; @@ -53,7 +53,7 @@ qc_module_type * qc_module_alloc( ert_workflow_list_type * workflow_list , const qc_module->runpath_list = runpath_list_alloc( NULL ); qc_module_set_path( qc_module , qc_path ); qc_module_set_runpath_list_file( qc_module , NULL, RUNPATH_LIST_FILE ); - + return qc_module; } @@ -72,7 +72,7 @@ runpath_list_type * qc_module_get_runpath_list( qc_module_type * qc_module ) { void qc_module_export_runpath_list( const qc_module_type * qc_module ) { runpath_list_fprintf( qc_module->runpath_list ); } - + static void qc_module_set_runpath_list_file__( qc_module_type * qc_module , const char * runpath_list_file) { runpath_list_set_export_file( qc_module->runpath_list , runpath_list_file ); } @@ -85,9 +85,9 @@ void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * else { const char * file = RUNPATH_LIST_FILE; - if (filename != NULL) + if (filename != NULL) file = filename; - + char * file_with_path_prefix = NULL; if (basepath != NULL) { file_with_path_prefix = util_alloc_filename(basepath, file, NULL); @@ -100,7 +100,7 @@ void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * qc_module_set_runpath_list_file__( qc_module , absolute_path ); free( absolute_path ); } - + free(file_with_path_prefix); } } @@ -140,7 +140,7 @@ bool qc_module_run_workflow( const qc_module_type * qc_module , void * self) { const char * export_file = runpath_list_get_export_file( qc_module->runpath_list ); if (!util_file_exists( export_file )) fprintf(stderr,"** Warning: the file:%s with a list of runpath directories was not found - QC workflow wil probably fail.\n" , export_file); - + bool result = ert_workflow_list_run_workflow__( qc_module->workflow_list, qc_module->qc_workflow , verbose , self); return result; } else @@ -162,31 +162,31 @@ const workflow_type * qc_module_get_workflow( const qc_module_type * qc_module ) /*****************************************************************/ -void qc_module_init( qc_module_type * qc_module , const config_type * config) { - if (config_item_set( config , QC_PATH_KEY )) - qc_module_set_path( qc_module , config_get_value( config , QC_PATH_KEY )); - - if (config_item_set( config , QC_WORKFLOW_KEY)) { - const char * qc_workflow = config_get_value_as_path(config , QC_WORKFLOW_KEY); +void qc_module_init( qc_module_type * qc_module , const config_content_type * config) { + if (config_content_has_item( config , QC_PATH_KEY )) + qc_module_set_path( qc_module , config_content_get_value( config , QC_PATH_KEY )); + + if (config_content_has_item( config , QC_WORKFLOW_KEY)) { + const char * qc_workflow = config_content_get_value_as_path(config , QC_WORKFLOW_KEY); qc_module_set_workflow( qc_module , qc_workflow ); } - - if (config_item_set( config, RUNPATH_FILE_KEY)) - qc_module_set_runpath_list_file(qc_module, NULL, config_get_value(config, RUNPATH_FILE_KEY)); + + if (config_content_has_item( config, RUNPATH_FILE_KEY)) + qc_module_set_runpath_list_file(qc_module, NULL, config_content_get_value(config, RUNPATH_FILE_KEY)); } -void qc_module_add_config_items( config_type * config ) { +void qc_module_add_config_items( config_parser_type * config ) { config_schema_item_type * item; - + item = config_add_schema_item( config , QC_PATH_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); item = config_add_schema_item( config , QC_WORKFLOW_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - + item = config_add_schema_item( config , RUNPATH_FILE_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/rng_config.c b/ThirdParty/Ert/devel/libenkf/src/rng_config.c index d7a0a8d66d..cf3122058b 100644 --- a/ThirdParty/Ert/devel/libenkf/src/rng_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/rng_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'rng_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'rng_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -23,7 +23,7 @@ #include <ert/util/rng.h> #include <ert/util/test_util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_schema_item.h> #include <ert/enkf/rng_config.h> @@ -130,25 +130,25 @@ void rng_config_init_rng( const rng_config_type * rng_config, rng_type * rng ) { /*****************************************************************/ -void rng_config_add_config_items( config_type * config ) { +void rng_config_add_config_items( config_parser_type * config ) { config_schema_item_type * item; item= config_add_schema_item( config , STORE_SEED_KEY , false); config_schema_item_set_argc_minmax(item , 1 , 1 ); config_schema_item_iset_type( item , 0 , CONFIG_PATH ); - + item = config_add_schema_item( config , LOAD_SEED_KEY , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); config_schema_item_iset_type( item , 0 , CONFIG_PATH ); } -void rng_config_init( rng_config_type * rng_config , config_type * config ) { - if (config_item_set( config , STORE_SEED_KEY )) - rng_config_set_seed_store_file( rng_config , config_iget(config , STORE_SEED_KEY ,0,0)); - - if (config_item_set( config , LOAD_SEED_KEY )) - rng_config_set_seed_load_file( rng_config , config_iget(config , LOAD_SEED_KEY ,0,0)); +void rng_config_init( rng_config_type * rng_config , config_content_type * config ) { + if (config_content_has_item( config , STORE_SEED_KEY )) + rng_config_set_seed_store_file( rng_config , config_content_iget(config , STORE_SEED_KEY ,0,0)); + + if (config_content_has_item( config , LOAD_SEED_KEY )) + rng_config_set_seed_load_file( rng_config , config_content_iget(config , LOAD_SEED_KEY ,0,0)); } diff --git a/ThirdParty/Ert/devel/libenkf/src/run_arg.c b/ThirdParty/Ert/devel/libenkf/src/run_arg.c index 55214feecb..ad09ae797d 100644 --- a/ThirdParty/Ert/devel/libenkf/src/run_arg.c +++ b/ThirdParty/Ert/devel/libenkf/src/run_arg.c @@ -32,7 +32,6 @@ struct run_arg_struct { UTIL_TYPE_ID_DECLARATION; - bool __ready; /* An attempt to check the internal state - not really used. */ int iens; bool active; /* Is this state object active at all - used for instance in ensemble experiments where only some of the members are integrated. */ int init_step_parameters; /* The report step we initialize parameters from - will often be equal to step1, but can be different. */ @@ -185,16 +184,6 @@ int run_arg_get_load_start( const run_arg_type * run_arg ) { } -bool run_arg_is_ready( const run_arg_type * run_arg) { - return run_arg->__ready; -} - - -void run_arg_set_ready( run_arg_type * run_arg , bool ready) { - run_arg->__ready = ready; -} - - int run_arg_get_step2( const run_arg_type * run_arg ) { return run_arg->step2; } diff --git a/ThirdParty/Ert/devel/libenkf/src/runpath_list.c b/ThirdParty/Ert/devel/libenkf/src/runpath_list.c index 9d111d2aaa..b6c1b4df9c 100644 --- a/ThirdParty/Ert/devel/libenkf/src/runpath_list.c +++ b/ThirdParty/Ert/devel/libenkf/src/runpath_list.c @@ -1,18 +1,18 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - The file 'runpath_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + The file 'runpath_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -199,6 +199,17 @@ int runpath_list_iget_iter( runpath_list_type * list , int index) { return node->iter; } + +char * runpath_list_iget_runpath( runpath_list_type * list , int index) { + const runpath_node_type * node = runpath_list_iget_node( list , index ); + return node->runpath; +} + +char * runpath_list_iget_basename( runpath_list_type * list , int index) { + const runpath_node_type * node = runpath_list_iget_node( list , index ); + return node->basename; +} + void runpath_list_fprintf(runpath_list_type * list ) { pthread_rwlock_rdlock( &list->lock ); { diff --git a/ThirdParty/Ert/devel/libenkf/src/site_config.c b/ThirdParty/Ert/devel/libenkf/src/site_config.c index 79e30253e8..3bcd51e615 100644 --- a/ThirdParty/Ert/devel/libenkf/src/site_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/site_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'site_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'site_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -34,7 +34,7 @@ #include <ert/job_queue/local_driver.h> #include <ert/job_queue/queue_driver.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/config/config_content_item.h> #include <ert/config/config_content_node.h> #include <ert/config/config_schema_item.h> @@ -49,7 +49,7 @@ where this enkf instance is running. Pointers to the fields in this structure are passed on to e.g. the enkf_state->shared_info object, but this struct is the *OWNER* of this information, and hence - responsible for booting and deleting these objects. + responsible for booting and deleting these objects. The settings held by the site_config object are by default set in the site-wide configuration file, but they can also be overridden @@ -61,9 +61,9 @@ -------- When parsing the user configuration file all settings are optional, that means that the required validation of the config system, can - not be used, instead every get must be preceeded by: + not be used, instead every get must be preceeded by: - if (config_item_set(config , KEY)) ... + if (config_content_has_item(config , KEY)) ... Furthermore everything is done twice; first with config as a site-config instance, and later as user-config instance. @@ -87,7 +87,7 @@ #define TORQUE_DRIVER_NAME "TORQUE" struct site_config_struct { - ext_joblist_type * joblist; /* The list of external jobs which have been installed. + ext_joblist_type * joblist; /* The list of external jobs which have been installed. These jobs will be the parts of the forward model. */ hash_type * env_variables_user; /* The environment variables set in the user config file. */ hash_type * env_variables_site; /* The environment variables set in site_config file - not exported. */ @@ -128,6 +128,7 @@ struct site_config_struct { job_queue_type * job_queue; /* The queue instance which will run the external jobs. */ bool user_mode; + bool search_path; }; void site_config_set_umask(site_config_type * site_config, mode_t new_mask) { @@ -207,6 +208,7 @@ site_config_type * site_config_alloc_empty() { site_config_set_manual_url(site_config, DEFAULT_MANUAL_URL); site_config_set_default_browser(site_config, DEFAULT_BROWSER); site_config_set_max_submit(site_config, DEFAULT_MAX_SUBMIT); + site_config->search_path = false; return site_config; } @@ -230,7 +232,7 @@ void site_config_set_license_root_path(site_config_type * site_config, const cha /** Appending /user/pid to the license root path. Everything including the pid is removed when exiting (gracefully ...). - + Dangling license directories after a crash can just be removed. */ site_config->license_root_path = util_realloc_string_copy(site_config->license_root_path, full_license_root_path); @@ -249,11 +251,11 @@ void site_config_init_user_mode(site_config_type * site_config) { /** Will return 0 if the job is added correctly, and a non-zero (not - documented ...) error code if the job is not added. + documented ...) error code if the job is not added. */ int site_config_install_job(site_config_type * site_config, const char * job_name, const char * install_file) { - ext_job_type * new_job = ext_job_fscanf_alloc(job_name, site_config->__license_root_path, site_config->user_mode, install_file); + ext_job_type * new_job = ext_job_fscanf_alloc(job_name, site_config->__license_root_path, site_config->user_mode, install_file, site_config->search_path); if (new_job != NULL) { ext_joblist_add_job(site_config->joblist, job_name, new_job); return 0; @@ -268,9 +270,9 @@ bool site_config_del_job(site_config_type * site_config, const char * job_name) return ext_joblist_del_job(site_config->joblist, job_name); } -static void site_config_add_jobs(site_config_type * site_config, const config_type * config) { - if (config_item_set(config, INSTALL_JOB_KEY)) { - const config_content_item_type * content_item = config_get_content_item(config, INSTALL_JOB_KEY); +static void site_config_add_jobs(site_config_type * site_config, const config_content_type * config) { + if (config_content_has_item(config, INSTALL_JOB_KEY)) { + const config_content_item_type * content_item = config_content_get_item(config, INSTALL_JOB_KEY); int num_jobs = config_content_item_get_size(content_item); for (int job_nr = 0; job_nr < num_jobs; job_nr++) { config_content_node_type * node = config_content_item_iget_node(content_item, job_nr); @@ -280,13 +282,15 @@ static void site_config_add_jobs(site_config_type * site_config, const config_ty site_config_install_job(site_config, job_key, description_file); } } - if (config_item_set(config, INSTALL_JOB_DIRECTORY_KEY)) { - const config_content_item_type * content_item = config_get_content_item(config, INSTALL_JOB_DIRECTORY_KEY); + if (config_content_has_item(config, INSTALL_JOB_DIRECTORY_KEY)) { + const config_content_item_type * content_item = config_content_get_item(config, INSTALL_JOB_DIRECTORY_KEY); int num_dirs = config_content_item_get_size(content_item); + printf("num_dirs = %d \n",num_dirs); for (int dir_nr = 0; dir_nr < num_dirs; dir_nr++) { config_content_node_type * node = config_content_item_iget_node(content_item, dir_nr); const char * directory = config_content_node_iget_as_abspath(node, 0); - ext_joblist_add_jobs_in_directory(site_config->joblist , directory, site_config->__license_root_path, site_config->user_mode ); + + ext_joblist_add_jobs_in_directory(site_config->joblist , directory, site_config->__license_root_path, site_config->user_mode, site_config->search_path ); } } @@ -331,13 +335,13 @@ void site_config_setenv(site_config_type * site_config, const char * variable, c /** Clears all the environment variables set by the user. This is done is follows: - + 1. Iterate through the table config->env_variables_user and call unsetenv() on all of them - + 2. Iterate through the table config->env_variables_site and call setenv() on all of them. - + This way the environment should be identical to what it is after the site parsing is completed. */ @@ -407,7 +411,7 @@ static void site_config_select_job_driver(site_config_type * site_config, const /** These functions can be called repeatedly if you should want to - change driver characteristics run-time. + change driver characteristics run-time. */ static void site_config_select_LOCAL_job_queue(site_config_type * site_config) { site_config_select_job_driver(site_config, LOCAL_DRIVER_NAME); @@ -646,7 +650,7 @@ int site_config_get_max_submit(const site_config_type * site_config) { } static void site_config_install_job_queue(site_config_type * site_config) { - /* + /* All the various driver options are set, unconditionally of which driver is actually selected in the end. */ @@ -654,10 +658,10 @@ static void site_config_install_job_queue(site_config_type * site_config) { site_config_set_job_queue__(site_config, site_config->driver_type); } -void site_config_init_env(site_config_type * site_config, const config_type * config) { +void site_config_init_env(site_config_type * site_config, const config_content_type * config) { { - config_content_item_type * setenv_item = config_get_content_item(config, SETENV_KEY); - if (setenv_item != NULL) { + if (config_content_has_item( config , SETENV_KEY)) { + config_content_item_type * setenv_item = config_content_get_item(config, SETENV_KEY); int i; for (i = 0; i < config_content_item_get_size(setenv_item); i++) { const config_content_node_type * setenv_node = config_content_item_iget_node(setenv_item, i); @@ -670,8 +674,8 @@ void site_config_init_env(site_config_type * site_config, const config_type * co } { - config_content_item_type * path_item = config_get_content_item(config, UPDATE_PATH_KEY); - if (path_item != NULL) { + if (config_content_has_item( config , UPDATE_PATH_KEY)) { + config_content_item_type * path_item = config_content_get_item(config, UPDATE_PATH_KEY); int i; for (i = 0; i < config_content_item_get_size(path_item); i++) { const config_content_node_type * path_node = config_content_item_iget_node(path_item, i); @@ -693,29 +697,29 @@ void site_config_init_env(site_config_type * site_config, const config_type * co */ -bool site_config_init(site_config_type * site_config, const config_type * config) { +bool site_config_init(site_config_type * site_config, const config_content_type * config) { site_config_add_jobs(site_config, config); site_config_init_env(site_config, config); - /* + /* When LSF is used several enviroment variables must be set (by the site wide file) - i.e. the calls to SETENV must come first. */ if (!site_config->user_mode) site_config_create_queue_drivers(site_config); - /* + /* Set the umask for all file creation. A value of '0' will ensure that all files and directories are created with 'equal rights' for everyone - might be handy if you are helping someone... The default statoil value is 0022, i.e. write access is removed from - group and others. + group and others. The string is supposed to be in OCTAL representation (without any prefix characters). */ - if (config_item_set(config, UMASK_KEY)) { - const char * string_mask = config_get_value(config, UMASK_KEY); + if (config_content_has_item(config, UMASK_KEY)) { + const char * string_mask = config_content_get_value(config, UMASK_KEY); mode_t umask_value; if (util_sscanf_octal_int(string_mask, &umask_value)) site_config_set_umask(site_config, umask_value); @@ -723,56 +727,53 @@ bool site_config_init(site_config_type * site_config, const config_type * config util_abort("%s: failed to parse:\"%s\" as a valid octal literal \n", __func__, string_mask); } - if (config_item_set(config, MAX_SUBMIT_KEY)) - site_config_set_max_submit(site_config, config_get_value_as_int(config, MAX_SUBMIT_KEY)); + if (config_content_has_item(config, MAX_SUBMIT_KEY)) + site_config_set_max_submit(site_config, config_content_get_value_as_int(config, MAX_SUBMIT_KEY)); /* LSF options */ { - if (config_item_set(config, LSF_QUEUE_KEY)) - site_config_set_lsf_queue(site_config, config_get_value(config, LSF_QUEUE_KEY)); + if (config_content_has_item(config, LSF_QUEUE_KEY)) + site_config_set_lsf_queue(site_config, config_content_get_value(config, LSF_QUEUE_KEY)); - if (config_item_set(config, LSF_RESOURCES_KEY)) { - char * lsf_resource_request = config_alloc_joined_string(config, LSF_RESOURCES_KEY, " "); + if (config_content_has_item(config, LSF_RESOURCES_KEY)) { + char * lsf_resource_request = config_content_alloc_joined_string(config, LSF_RESOURCES_KEY, " "); site_config_set_lsf_request(site_config, lsf_resource_request); free(lsf_resource_request); } - if (config_item_set(config, MAX_RUNNING_LSF_KEY)) - site_config_set_max_running_lsf(site_config, config_get_value_as_int(config, MAX_RUNNING_LSF_KEY)); + if (config_content_has_item(config, MAX_RUNNING_LSF_KEY)) + site_config_set_max_running_lsf(site_config, config_content_get_value_as_int(config, MAX_RUNNING_LSF_KEY)); - if (config_item_set(config, LSF_SERVER_KEY)) - site_config_set_lsf_server(site_config, config_get_value(config, LSF_SERVER_KEY)); + if (config_content_has_item(config, LSF_SERVER_KEY)) + site_config_set_lsf_server(site_config, config_content_get_value(config, LSF_SERVER_KEY)); } /* RSH options */ { - if (config_item_set(config, RSH_COMMAND_KEY)) - site_config_set_rsh_command(site_config, config_get_value(config, RSH_COMMAND_KEY)); + if (config_content_has_item(config, RSH_COMMAND_KEY)) + site_config_set_rsh_command(site_config, config_content_get_value(config, RSH_COMMAND_KEY)); - if (config_item_set(config, MAX_RUNNING_RSH_KEY)) - site_config_set_max_running_rsh(site_config, config_get_value_as_int(config, MAX_RUNNING_RSH_KEY)); + if (config_content_has_item(config, MAX_RUNNING_RSH_KEY)) + site_config_set_max_running_rsh(site_config, config_content_get_value_as_int(config, MAX_RUNNING_RSH_KEY)); /* Parsing the "host1:4" strings. */ - { - const config_content_item_type * rsh_host_item = config_get_content_item(config, RSH_HOST_KEY); - if (rsh_host_item != NULL) { - stringlist_type * rsh_host_list = config_alloc_complete_stringlist(config, RSH_HOST_KEY); - int i; - for (i = 0; i < stringlist_get_size(rsh_host_list); i++) - site_config_add_rsh_host_from_string(site_config, stringlist_iget(rsh_host_list, i)); - - stringlist_free(rsh_host_list); - } + if (config_content_has_item( config , RSH_HOST_KEY)) { + stringlist_type * rsh_host_list = config_content_alloc_complete_stringlist(config, RSH_HOST_KEY); + int i; + for (i = 0; i < stringlist_get_size(rsh_host_list); i++) + site_config_add_rsh_host_from_string(site_config, stringlist_iget(rsh_host_list, i)); + + stringlist_free(rsh_host_list); } } - if (config_item_set(config, QUEUE_SYSTEM_KEY)) { + if (config_content_has_item(config, QUEUE_SYSTEM_KEY)) { job_driver_type driver_type; { - const char * queue_system = config_get_value(config, QUEUE_SYSTEM_KEY); + const char * queue_system = config_content_get_value(config, QUEUE_SYSTEM_KEY); if (strcmp(queue_system, LSF_DRIVER_NAME) == 0) { driver_type = LSF_DRIVER; } else if (strcmp(queue_system, RSH_DRIVER_NAME) == 0) @@ -790,26 +791,31 @@ bool site_config_init(site_config_type * site_config, const config_type * config } /* Parsing local options */ - if (config_item_set(config, MAX_RUNNING_LOCAL_KEY)) - site_config_set_max_running_local(site_config, config_iget_as_int(config, MAX_RUNNING_LOCAL_KEY, 0, 0)); + if (config_content_has_item(config, MAX_RUNNING_LOCAL_KEY)) + site_config_set_max_running_local(site_config, config_content_iget_as_int(config, MAX_RUNNING_LOCAL_KEY, 0, 0)); - if (config_item_set(config, JOB_SCRIPT_KEY)) - site_config_set_job_script(site_config, config_get_value_as_abspath(config, JOB_SCRIPT_KEY)); + if (config_content_has_item(config, JOB_SCRIPT_KEY)) + site_config_set_job_script(site_config, config_content_get_value_as_abspath(config, JOB_SCRIPT_KEY)); - if (config_item_set(config, LICENSE_PATH_KEY)) - site_config_set_license_root_path(site_config, config_get_value_as_abspath(config, LICENSE_PATH_KEY)); + if (config_content_has_item(config, LICENSE_PATH_KEY)) + site_config_set_license_root_path(site_config, config_content_get_value_as_abspath(config, LICENSE_PATH_KEY)); site_config_install_job_queue(site_config); + if (config_content_has_item(config, EXT_JOB_SEARCH_PATH_KEY)){ + site_config_set_ext_job_search_path(site_config, config_content_get_value_as_bool(config, EXT_JOB_SEARCH_PATH_KEY)); + } + + /* Setting QUEUE_OPTIONS */ { int i; - for (i = 0; i < config_get_occurences(config, QUEUE_OPTION_KEY); i++) { - const stringlist_type * tokens = config_iget_stringlist_ref(config, QUEUE_OPTION_KEY, i); + for (i = 0; i < config_content_get_occurences(config, QUEUE_OPTION_KEY); i++) { + const stringlist_type * tokens = config_content_iget_stringlist_ref(config, QUEUE_OPTION_KEY, i); const char * driver_name = stringlist_iget(tokens, 0); const char * option_key = stringlist_iget(tokens, 1); const char * option_value = stringlist_alloc_joined_substring(tokens, 2, stringlist_get_size(tokens), " "); - /* + /* If it is desirable to keep the exact number of spaces in the option_value it should be quoted with "" in the configuration file. @@ -820,6 +826,11 @@ bool site_config_init(site_config_type * site_config, const config_type * config return true; } +void site_config_set_ext_job_search_path(site_config_type * site_config, bool search_path){ + site_config->search_path = search_path; +} + + void site_config_free(site_config_type * site_config) { ext_joblist_free(site_config->joblist); job_queue_free(site_config->job_queue); @@ -991,7 +1002,7 @@ void site_config_fprintf_config(const site_config_type * site_config, FILE * str /*****************************************************************/ -void site_config_add_queue_config_items(config_type * config, bool site_mode) { +void site_config_add_queue_config_items(config_parser_type * config, bool site_mode) { config_schema_item_type * item = config_add_schema_item(config, QUEUE_SYSTEM_KEY, site_mode); config_schema_item_set_argc_minmax(item, 1, 1); { @@ -1028,7 +1039,7 @@ void site_config_add_queue_config_items(config_type * config, bool site_mode) { config_schema_item_iset_type(item, 0, CONFIG_INT); } -void site_config_add_config_items(config_type * config, bool site_mode) { +void site_config_add_config_items(config_parser_type * config, bool site_mode) { config_schema_item_type * item; ert_workflow_list_add_config_items(config); site_config_add_queue_config_items(config, site_mode); @@ -1119,3 +1130,27 @@ void site_config_add_config_items(config_type * config, bool site_mode) { item = config_add_schema_item( config , ANALYSIS_LOAD_KEY , false ); config_schema_item_set_argc_minmax( item , 2 , 2); } + +const char * site_config_get_location() { + const char * site_config = NULL; + + #ifdef SITE_CONFIG_FILE + site_config = SITE_CONFIG_FILE; + #endif + + const char * env_site_config = getenv("ERT_SITE_CONFIG"); + + if(env_site_config != NULL) { + if (util_file_exists(env_site_config)) { + site_config = env_site_config; + } else { + fprintf(stderr, "The environment variable ERT_SITE_CONFIG points to non-existing file: %s - ignored\n", env_site_config); + } + } + + if (site_config == NULL) { + fprintf(stderr, "**WARNING** main enkf_config file is not set. Use environment variable \"ERT_SITE_CONFIG\" - or recompile.\n"); + } + + return site_config; +} diff --git a/ThirdParty/Ert/devel/libenkf/src/summary_key_matcher.c b/ThirdParty/Ert/devel/libenkf/src/summary_key_matcher.c new file mode 100644 index 0000000000..3e7e4dcdbf --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/summary_key_matcher.c @@ -0,0 +1,77 @@ +#include <ert/enkf/summary_key_matcher.h> + +#include <stdlib.h> +#include <stdbool.h> + +#include <ert/util/util.h> +#include <ert/util/hash.h> +#include <ert/util/stringlist.h> +#include <ert/util/type_macros.h> + +#include <ert/enkf/enkf_types.h> + + + +#define SUMMARY_KEY_MATCHER_TYPE_ID 700672137 + +struct summary_key_matcher_struct { + UTIL_TYPE_ID_DECLARATION; + hash_type * key_set; +}; + + +UTIL_IS_INSTANCE_FUNCTION( summary_key_matcher , SUMMARY_KEY_MATCHER_TYPE_ID ) + + +summary_key_matcher_type * summary_key_matcher_alloc() { + summary_key_matcher_type * matcher = util_malloc(sizeof * matcher); + UTIL_TYPE_ID_INIT( matcher , SUMMARY_KEY_MATCHER_TYPE_ID); + matcher->key_set = hash_alloc(); + return matcher; +} + +void summary_key_matcher_free(summary_key_matcher_type * matcher) { + hash_free(matcher->key_set); + free(matcher); +} + +int summary_key_matcher_get_size(const summary_key_matcher_type * matcher) { + return hash_get_size( matcher->key_set ); +} + +void summary_key_matcher_add_summary_key(summary_key_matcher_type * matcher, const char * summary_key) { + if(!hash_has_key(matcher->key_set, summary_key)) { + hash_insert_int(matcher->key_set, summary_key, !util_string_has_wildcard(summary_key)); + } +} + +bool summary_key_matcher_match_summary_key(const summary_key_matcher_type * matcher, const char * summary_key) { + stringlist_type * keys = hash_alloc_stringlist(matcher->key_set); + bool has_key = false; + + for (int i = 0; i < stringlist_get_size(keys); i++) { + const char * pattern = stringlist_iget(keys, i); + if(util_fnmatch(pattern, summary_key) == 0) { + has_key = true; + break; + } + } + + stringlist_free(keys); + + return has_key; +} + +stringlist_type * summary_key_matcher_get_keys(const summary_key_matcher_type * matcher) { + return hash_alloc_stringlist(matcher->key_set); +} + +bool summary_key_matcher_summary_key_is_required(const summary_key_matcher_type * matcher, const char * summary_key) { + bool is_required = false; + + if(!util_string_has_wildcard(summary_key) && hash_has_key(matcher->key_set, summary_key)) { + is_required = (bool) hash_get_int(matcher->key_set, summary_key); + } + + return is_required; +} \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libenkf/src/summary_key_set.c b/ThirdParty/Ert/devel/libenkf/src/summary_key_set.c new file mode 100644 index 0000000000..2bdc21bc14 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/summary_key_set.c @@ -0,0 +1,170 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + The file 'state_map.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ +#include <stdlib.h> +#include <pthread.h> +#include <stdbool.h> + +#include <ert/util/util.h> +#include <ert/util/hash.h> +#include <ert/util/stringlist.h> +#include <ert/util/type_macros.h> + +#include <ert/enkf/enkf_types.h> +#include <ert/enkf/summary_key_set.h> + + +#define SUMMARY_KEY_SET_TYPE_ID 700672133 + +struct summary_key_set_struct { + UTIL_TYPE_ID_DECLARATION; + hash_type * key_set; + pthread_rwlock_t rw_lock; + bool read_only; +}; + + +UTIL_IS_INSTANCE_FUNCTION( summary_key_set , SUMMARY_KEY_SET_TYPE_ID ) + + +summary_key_set_type * summary_key_set_alloc() { + summary_key_set_type * set = util_malloc(sizeof * set); + UTIL_TYPE_ID_INIT( set , SUMMARY_KEY_SET_TYPE_ID); + set->key_set = hash_alloc(); + pthread_rwlock_init( &set->rw_lock , NULL); + set->read_only = false; + return set; +} + +summary_key_set_type * summary_key_set_alloc_from_file(const char * filename, bool read_only) { + summary_key_set_type * set = summary_key_set_alloc(); + summary_key_set_fread(set, filename); + set->read_only = read_only; + return set; +} + +void summary_key_set_free(summary_key_set_type * set) { + hash_free(set->key_set); + free(set); +} + +int summary_key_set_get_size(summary_key_set_type * set) { + int size; + pthread_rwlock_rdlock( &set->rw_lock ); + { + size = hash_get_size( set->key_set ); + } + pthread_rwlock_unlock( &set->rw_lock ); + return size; +} + + +bool summary_key_set_add_summary_key(summary_key_set_type * set, const char * summary_key) { + bool writable_and_non_existent = true; + + pthread_rwlock_wrlock( &set->rw_lock); + { + + if(hash_has_key(set->key_set, summary_key)) { + writable_and_non_existent = false; + } + + if(set->read_only) { + writable_and_non_existent = false; + } + + if(writable_and_non_existent) { + hash_insert_int(set->key_set, summary_key, 1); + } + } + pthread_rwlock_unlock( &set->rw_lock ); + + return writable_and_non_existent; +} + +bool summary_key_set_has_summary_key(summary_key_set_type * set, const char * summary_key) { + bool has_key = false; + + pthread_rwlock_rdlock( &set->rw_lock ); + { + has_key = hash_has_key(set->key_set, summary_key); + } + pthread_rwlock_unlock( &set->rw_lock ); + + return has_key; +} + +stringlist_type * summary_key_set_get_keys(summary_key_set_type * set) { + stringlist_type * keys; + + pthread_rwlock_rdlock( &set->rw_lock ); + { + keys = hash_alloc_stringlist(set->key_set); + } + pthread_rwlock_unlock( &set->rw_lock ); + + return keys; +} + + +bool summary_key_set_is_read_only(const summary_key_set_type * set) { + return set->read_only; +} + +void summary_key_set_fwrite(summary_key_set_type * set, const char * filename) { + pthread_rwlock_rdlock( &set->rw_lock ); + { + FILE * stream = util_mkdir_fopen(filename , "w"); + if (stream) { + stringlist_type * keys = hash_alloc_stringlist(set->key_set); + stringlist_fwrite(keys, stream); + free(keys); + fclose( stream ); + } else { + util_abort("%s: failed to open: %s for writing \n", __func__, filename); + } + } + pthread_rwlock_unlock( &set->rw_lock ); +} + +bool summary_key_set_fread(summary_key_set_type * set, const char * filename) { + bool file_exists = false; + pthread_rwlock_wrlock( &set->rw_lock ); + { + hash_clear(set->key_set); + + if (util_file_exists(filename)) { + FILE * stream = util_fopen(filename, "r"); + if (stream) { + stringlist_type * key_set = stringlist_fread_alloc(stream); + + for (int i = 0; i < stringlist_get_size(key_set); i++) { + hash_insert_int(set->key_set, stringlist_iget_copy(key_set, i), 1); + } + stringlist_free(key_set); + fclose( stream ); + } else { + util_abort("%s: failed to open: %s for reading \n",__func__ , filename ); + } + file_exists = true; + } + } + pthread_rwlock_unlock( &set->rw_lock ); + return file_exists; +} diff --git a/ThirdParty/Ert/devel/libenkf/src/summary_obs.c b/ThirdParty/Ert/devel/libenkf/src/summary_obs.c index 78cea13aba..ee55391530 100644 --- a/ThirdParty/Ert/devel/libenkf/src/summary_obs.c +++ b/ThirdParty/Ert/devel/libenkf/src/summary_obs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'summary_obs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'summary_obs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -41,12 +41,13 @@ struct summary_obs_struct { UTIL_TYPE_ID_DECLARATION; char * summary_key; /** The observation, in summary.x syntax, e.g. GOPR:FIELD. */ char * obs_key; - + double value; /** Observation value. */ double std; /** Standard deviation of observation. */ + double std_scaling; auto_corrf_ftype * auto_corrf; - double auto_corrf_param; + double auto_corrf_param; }; @@ -92,12 +93,12 @@ static auto_corrf_ftype * summary_obs_lookup_auto_corrf( const char * fname ) { Should check summary_key on alloc. */ summary_obs_type * summary_obs_alloc(const char * summary_key, - const char * obs_key , + const char * obs_key , double value , double std , - const char * auto_corrf_name , + const char * auto_corrf_name , double auto_corrf_param) { - + summary_obs_type * obs = util_malloc(sizeof * obs ); UTIL_TYPE_ID_INIT( obs , SUMMARY_OBS_TYPE_ID ) @@ -105,9 +106,10 @@ summary_obs_type * summary_obs_alloc(const char * summary_key, obs->obs_key = util_alloc_string_copy( obs_key ); obs->value = value; obs->std = std; + obs->std_scaling = 1.0; obs->auto_corrf = summary_obs_lookup_auto_corrf( auto_corrf_name ); obs->auto_corrf_param = auto_corrf_param; - + return obs; } @@ -153,13 +155,13 @@ const char * summary_obs_get_summary_key(const summary_obs_type * summary_obs) void summary_obs_get_observations(const summary_obs_type * summary_obs, obs_data_type * obs_data, enkf_fs_type * fs, - int report_step , + int report_step , const active_list_type * __active_list) { - int active_size = active_list_get_active_size( __active_list , OBS_SIZE ); + int active_size = active_list_get_active_size( __active_list , OBS_SIZE ); if (active_size == 1) { obs_block_type * obs_block = obs_data_add_block( obs_data , summary_obs->obs_key , OBS_SIZE , NULL , false); - obs_block_iset( obs_block , 0 , summary_obs->value , summary_obs->std ); + obs_block_iset( obs_block , 0 , summary_obs->value , summary_obs->std * summary_obs->std_scaling); } } @@ -173,10 +175,10 @@ void summary_obs_measure(const summary_obs_type * obs, const summary_type * summ } } - + double summary_obs_chi2(const summary_obs_type * obs, - const summary_type * summary, + const summary_type * summary, node_id_type node_id) { double x = (summary_get(summary , node_id.report_step , node_id.state) - obs->value) / obs->std; return x*x; @@ -200,13 +202,19 @@ double summary_obs_get_std( const summary_obs_type * summary_obs ) { return summary_obs->std; } -void summary_obs_scale_std(summary_obs_type * summary_obs, double std_multiplier ) { - summary_obs->std = summary_obs->std * std_multiplier; +double summary_obs_get_std_scaling( const summary_obs_type * summary_obs ) { + return summary_obs->std_scaling; } -void summary_obs_scale_std__(void * summary_obs, double std_multiplier ) { - summary_obs_type * observation = summary_obs_safe_cast(summary_obs); - summary_obs_scale_std(observation, std_multiplier); + +void summary_obs_update_std_scale(summary_obs_type * summary_obs, double std_multiplier , const active_list_type * active_list) { + if (active_list_get_mode( active_list ) == ALL_ACTIVE) + summary_obs->std_scaling = std_multiplier; + else { + int size = active_list_get_active_size( active_list , OBS_SIZE ); + if (size > 0) + summary_obs->std_scaling = std_multiplier; + } } @@ -217,3 +225,4 @@ VOID_GET_OBS(summary_obs) VOID_USER_GET_OBS(summary_obs) VOID_MEASURE(summary_obs , summary) VOID_CHI2(summary_obs , summary) +VOID_UPDATE_STD_SCALE(summary_obs); diff --git a/ThirdParty/Ert/devel/libenkf/src/time_map.c b/ThirdParty/Ert/devel/libenkf/src/time_map.c index 9cec901f4c..3606d82c1e 100644 --- a/ThirdParty/Ert/devel/libenkf/src/time_map.c +++ b/ThirdParty/Ert/devel/libenkf/src/time_map.c @@ -1,18 +1,18 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - The file 'time_map.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + The file 'time_map.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -49,7 +49,7 @@ struct time_map_struct { UTIL_SAFE_CAST_FUNCTION( time_map , TIME_MAP_TYPE_ID ) -UTIL_IS_INSTANCE_FUNCTION( time_map , TIME_MAP_TYPE_ID ) +UTIL_IS_INSTANCE_FUNCTION( time_map , TIME_MAP_TYPE_ID ) time_map_type * time_map_alloc( ) { @@ -65,13 +65,14 @@ time_map_type * time_map_alloc( ) { return map; } -bool time_map_is_strict( const time_map_type * time_map ){ +bool time_map_is_strict( const time_map_type * time_map ){ return time_map->strict; } /** The refcase will only be attached if it is consistent with the - current time map. + current time map; we will accept attaching a refcase which is + shorter than the current case. */ bool time_map_attach_refcase( time_map_type * time_map , const ecl_sum_type * refcase) { bool attach_ok = true; @@ -79,17 +80,19 @@ bool time_map_attach_refcase( time_map_type * time_map , const ecl_sum_type * re { int step; - for (step = 0; step < time_map_get_size(time_map); step++) { + int max_step = util_int_min( time_map_get_size(time_map) , ecl_sum_get_last_report_step( refcase ) + 1); + + for (step = 0; step < max_step; step++) { time_t current_time = time_map_iget__( time_map , step ); time_t sim_time = ecl_sum_get_report_time( refcase , step ); - + if (current_time != sim_time) { attach_ok = false; break; } } - - if (attach_ok) + + if (attach_ok) time_map->refcase = refcase; } pthread_rwlock_unlock( &time_map->rw_lock ); @@ -113,7 +116,7 @@ void time_map_set_strict( time_map_type * time_map , bool strict) { time_map_type * time_map_fread_alloc_readonly( const char * filename) { time_map_type * tm = time_map_alloc(); - if (util_file_exists(filename)) + if (util_file_exists(filename)) time_map_fread( tm , filename ); tm->read_only = true; @@ -125,7 +128,7 @@ bool time_map_fscanf(time_map_type * map , const char * filename) { bool fscanf_ok = true; if (util_is_file( filename )) { time_t_vector_type * time_vector = time_t_vector_alloc(0,0); - + { FILE * stream = util_fopen(filename , "r"); time_t last_date = 0; @@ -147,7 +150,7 @@ bool time_map_fscanf(time_map_type * map , const char * filename) { break; } last_date = date; - } else + } else break; } fclose( stream ); @@ -158,11 +161,11 @@ bool time_map_fscanf(time_map_type * map , const char * filename) { for (i=0; i < time_t_vector_size( time_vector ); i++) time_map_update( map , i , time_t_vector_iget( time_vector , i )); } - + } time_t_vector_free( time_vector ); } else - return fscanf_ok = false; + fscanf_ok = false; return fscanf_ok; } @@ -199,15 +202,15 @@ static bool time_map_update__( time_map_type * map , int step , time_t update_ti if (current_time == DEFAULT_TIME) { if (map->refcase) { if (step <= ecl_sum_get_last_report_step( map->refcase )) { - time_t ref_time = ecl_sum_get_report_time( map->refcase , step ); - + time_t ref_time = ecl_sum_get_report_time( map->refcase , step ); + if (ref_time != update_time) { updateOK = false; ert_log_add_message( 1 , NULL , "Tried to load data where report step/data is incompatible with refcase - ignored" , false); - } - } + } + } } - } else if (current_time != update_time) + } else if (current_time != update_time) updateOK = false; @@ -228,8 +231,8 @@ static bool time_map_summary_update__( time_map_type * map , const ecl_sum_type for (step = first_step; step <= last_step; step++) { if (ecl_sum_has_report_step(ecl_sum , step)) { - time_t sim_time = ecl_sum_get_report_time( ecl_sum , step ); - + time_t sim_time = ecl_sum_get_report_time( ecl_sum , step ); + updateOK = (updateOK && time_map_update__( map , step , sim_time )); } } @@ -253,7 +256,7 @@ double time_map_iget_sim_days( time_map_type * map , int step ) { { time_t start_time = time_map_iget__( map , 0 ); time_t sim_time = time_map_iget__( map , step ); - + if (sim_time >= start_time) days = 1.0 * (sim_time - start_time) / (3600 * 24); else @@ -309,10 +312,10 @@ void time_map_fread( time_map_type * map , const char * filename) { if (util_file_exists( filename )) { FILE * stream = util_fopen( filename , "r"); time_t_vector_type * file_map = time_t_vector_fread_alloc( stream ); - - for (int step=0; step < time_t_vector_size( file_map ); step++) + + for (int step=0; step < time_t_vector_size( file_map ); step++) time_map_update__( map , step , time_t_vector_iget( file_map , step )); - + time_t_vector_free( file_map ); fclose( stream ); } @@ -329,12 +332,12 @@ void time_map_fread( time_map_type * map , const char * filename) { /* Observe that the return value from this function is an inclusive value; i.e. it should be permissible to ask for results at this report - step. + step. */ int time_map_get_last_step( time_map_type * map) { int last_step; - + pthread_rwlock_rdlock( &map->rw_lock ); last_step = time_t_vector_size( map->map ) - 1; pthread_rwlock_unlock( &map->rw_lock ); @@ -382,7 +385,7 @@ bool time_map_try_update( time_map_type * map , int step , time_t time) { pthread_rwlock_wrlock( &map->rw_lock ); { updateOK = time_map_update__( map , step , time ); - } + } pthread_rwlock_unlock( &map->rw_lock ); return updateOK; } @@ -391,14 +394,14 @@ bool time_map_try_update( time_map_type * map , int step , time_t time) { bool time_map_summary_update( time_map_type * map , const ecl_sum_type * ecl_sum) { bool updateOK = time_map_try_summary_update( map , ecl_sum ); - + if (!updateOK) { if (map->strict) time_map_summary_update_abort( map , ecl_sum ); else ert_log_add_message(1 , NULL , "Report step/true time inconsistency - data will be ignored" , false); } - + return updateOK; } @@ -423,14 +426,14 @@ int time_map_lookup_time( time_map_type * map , time_t time) { { int current_index = 0; while (true) { - if (current_index >= time_t_vector_size( map->map )) + if (current_index >= time_t_vector_size( map->map )) break; if (time_map_iget__( map , current_index ) == time) { index = current_index; break; } - + current_index++; } } @@ -438,6 +441,63 @@ int time_map_lookup_time( time_map_type * map , time_t time) { return index; } +static bool time_map_valid_time__(const time_map_type * map , time_t time) { + if (time_t_vector_size( map->map ) > 0) { + if ((time >= time_map_iget__(map , 0)) && + (time <= time_map_iget__(map , time_t_vector_size( map->map ) - 1))) + return true; + else + return false; + } else + return false; +} + + + +int time_map_lookup_time_with_tolerance( time_map_type * map , time_t time , int seconds_before_tolerance, int seconds_after_tolerance) { + int nearest_index = -1; + pthread_rwlock_rdlock( &map->rw_lock ); + { + if (time_map_valid_time__( map , time )) { + time_t nearest_diff = 999999999999; + int current_index = 0; + while (true) { + time_t diff = time - time_map_iget__( map , current_index ); + if (diff == 0) { + nearest_index = current_index; + break; + } + + if (abs(diff) < nearest_diff) { + bool inside_tolerance = true; + if (seconds_after_tolerance >= 0) { + if (diff >= seconds_after_tolerance) + inside_tolerance = false; + } + + if (seconds_before_tolerance >= 0) { + if (diff <= -seconds_before_tolerance) + inside_tolerance = false; + } + + if (inside_tolerance) { + nearest_diff = diff; + nearest_index = current_index; + } + } + + current_index++; + + if (current_index >= time_t_vector_size( map->map )) + break; + } + } + } + pthread_rwlock_unlock( &map->rw_lock ); + return nearest_index; +} + + int time_map_lookup_days( time_map_type * map , double sim_days) { int index = -1; @@ -470,18 +530,18 @@ static void time_map_update_abort( time_map_type * map , int step , time_t time) time_t current_time = time_map_iget__( map , step ); int current[3]; int new[3]; - + util_set_date_values( current_time , ¤t[0] , ¤t[1] , ¤t[2]); util_set_date_values( time , &new[0] , &new[1] , &new[2]); - - util_abort("%s: time mismatch for step:%d New: %02d/%02d/%04d existing: %02d/%02d/%04d \n",__func__ , step , - new[0] , new[1] , new[2] , + + util_abort("%s: time mismatch for step:%d New: %02d/%02d/%04d existing: %02d/%02d/%04d \n",__func__ , step , + new[0] , new[1] , new[2] , current[0] , current[1] , current[2]); } static void time_map_summary_update_abort( time_map_type * map , const ecl_sum_type * ecl_sum) { - /* + /* If the normal summary update fails we just play through all time steps to pinpoint exactly the step where the update fails. */ @@ -489,43 +549,43 @@ static void time_map_summary_update_abort( time_map_type * map , const ecl_sum_t int first_step = ecl_sum_get_first_report_step( ecl_sum ); int last_step = ecl_sum_get_last_report_step( ecl_sum ); int step; - + for (step = first_step; step <= last_step; step++) { if (ecl_sum_has_report_step(ecl_sum , step)) { - time_t time = ecl_sum_get_report_time( ecl_sum , step ); - + time_t time = ecl_sum_get_report_time( ecl_sum , step ); + if (map->refcase) { if (ecl_sum_get_last_report_step( ecl_sum ) >= step) { time_t ref_time = ecl_sum_get_report_time( map->refcase , step ); if (ref_time != time) { int ref[3]; int new[3]; - + util_set_date_values( time , &new[0] , &new[1] , &new[2]); util_set_date_values( ref_time , &ref[0] , &ref[1] , &ref[2]); - fprintf(stderr," Time mismatch for step:%d New: %02d/%02d/%04d refcase: %02d/%02d/%04d \n", step , - new[0] , new[1] , new[2] , + fprintf(stderr," Time mismatch for step:%d New: %02d/%02d/%04d refcase: %02d/%02d/%04d \n", step , + new[0] , new[1] , new[2] , ref[0] , ref[1] , ref[2]); } } } - + { time_t current_time = time_map_iget__( map , step ); int current[3]; int new[3]; - + util_set_date_values( current_time , ¤t[0] , ¤t[1] , ¤t[2]); util_set_date_values( time , &new[0] , &new[1] , &new[2]); - - fprintf(stderr,"Time mismatch for step:%d New: %02d/%02d/%04d existing: %02d/%02d/%04d \n",step , - new[0] , new[1] , new[2] , + + fprintf(stderr,"Time mismatch for step:%d New: %02d/%02d/%04d existing: %02d/%02d/%04d \n",step , + new[0] , new[1] , new[2] , current[0] , current[1] , current[2]); } } } - + util_abort("%s: inconsistency when updating time map \n",__func__); } @@ -542,17 +602,17 @@ static void time_map_summary_update_abort( time_map_type * map , const ecl_sum_t instance. The extra timesteps will be ignored, holes in the summary timestep is not allowed - that will lead to a hard crash. - time map Summary + time map Summary ------------------------------------------------- - 0: 01/01/2000 <------- 0: 01/01/2000 - - 1: 01/02/2000 <------- 1: 01/02/2000 - - 2: 01/03/2000 <-\ 2: 02/02/2000 (Ignored) - \ - \-- 3: 01/03/2000 - - 3: 01/04/2000 <------- 4: 01/04/2000 + 0: 01/01/2000 <------- 0: 01/01/2000 + + 1: 01/02/2000 <------- 1: 01/02/2000 + + 2: 01/03/2000 <-\ 2: 02/02/2000 (Ignored) + \ + \-- 3: 01/03/2000 + + 3: 01/04/2000 <------- 4: 01/04/2000 index_map = { 0 , 1 , 3 , 4 } @@ -562,15 +622,15 @@ static void time_map_summary_update_abort( time_map_type * map , const ecl_sum_t long. If timesteps are missing from the summary case we crash hard: - time map Summary + time map Summary ------------------------------------------------- - 0: 01/01/2000 <------- 0: 01/01/2000 - - 1: 01/02/2000 <------- 1: 01/02/2000 - + 0: 01/01/2000 <------- 0: 01/01/2000 + + 1: 01/02/2000 <------- 1: 01/02/2000 + 2: 01/03/2000 ## ERROR -> util_abort() - - 3: 01/04/2000 <------- 2: 01/04/2000 + + 3: 01/04/2000 <------- 2: 01/04/2000 */ @@ -582,7 +642,7 @@ int_vector_type * time_map_alloc_index_map( time_map_type * map , const ecl_sum_ { int time_map_index = 0; int sum_index = 0; - + while (true) { time_t map_time = time_map_iget__( map , time_map_index); if (map_time == DEFAULT_TIME) @@ -590,10 +650,10 @@ int_vector_type * time_map_alloc_index_map( time_map_type * map , const ecl_sum_ { time_t sum_time; - + while (true) { sum_time = ecl_sum_get_report_time( ecl_sum , sum_index ); - + if (sum_time > map_time) { int day,month,year; util_set_date_values( map_time , &day , &month , &year); @@ -604,9 +664,9 @@ int_vector_type * time_map_alloc_index_map( time_map_type * map , const ecl_sum_ break; } else break; - - } - + + } + if (sum_time == map_time) int_vector_iset( index_map , time_map_index , sum_index); else { @@ -614,11 +674,11 @@ int_vector_type * time_map_alloc_index_map( time_map_type * map , const ecl_sum_ break; } - + time_map_index++; if (time_map_index == time_map_get_size( map )) break; - + } } } diff --git a/ThirdParty/Ert/devel/libenkf/src/trans_func.c b/ThirdParty/Ert/devel/libenkf/src/trans_func.c index 9b93ef87c0..bb6dbe499d 100644 --- a/ThirdParty/Ert/devel/libenkf/src/trans_func.c +++ b/ThirdParty/Ert/devel/libenkf/src/trans_func.c @@ -395,22 +395,20 @@ bool trans_func_use_log_scale(const trans_func_type * trans_func) { -trans_func_type * trans_func_fscanf_alloc( FILE * stream ) { +trans_func_type * trans_func_fscanf_alloc( FILE * stream, const char * filename ) { trans_func_type * trans_func; char * func_name; func_name = util_fscanf_alloc_token(stream); + + if (func_name == NULL) { - char * filename = "????"; -#ifdef HAVE_FORK - filename = util_alloc_filename_from_stream( stream ); -#endif fprintf(stderr,"Problem at file:line: %s:%d \n", filename, util_get_current_linenr( stream )); util_abort("%s: could not locate name of transformation - aborting \n",__func__); } trans_func = trans_func_alloc( func_name ); - arg_pack_fscanf( trans_func->params , stream ); + arg_pack_fscanf( trans_func->params , stream, filename ); free( func_name ); return trans_func; diff --git a/ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt index dd151b052a..ecdcbb364a 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt @@ -22,6 +22,7 @@ add_executable( enkf_ert_run_context enkf_ert_run_context.c ) target_link_libraries( enkf_ert_run_context enkf test_util ) add_test( enkf_ert_run_context ${EXECUTABLE_OUTPUT_PATH}/enkf_ert_run_context) + add_executable( enkf_run_arg enkf_run_arg.c ) target_link_libraries( enkf_run_arg enkf test_util ) add_test( enkf_run_arg ${EXECUTABLE_OUTPUT_PATH}/enkf_run_arg) @@ -50,7 +51,7 @@ add_test( enkf_ert_workflow_list ${EXECUTABLE_OUTPUT_PATH}/enkf_ert_workflow_lis add_executable( enkf_obs_fs enkf_obs_fs.c ) target_link_libraries( enkf_obs_fs enkf test_util ) -add_test( enkf_obs_fs ${EXECUTABLE_OUTPUT_PATH}/enkf_obs_fs ${PROJECT_SOURCE_DIR}/test-data/Statoil/config/with_data/config ) +add_test( enkf_obs_fs ${EXECUTABLE_OUTPUT_PATH}/enkf_obs_fs ${PROJECT_SOURCE_DIR}/test-data/Statoil/config/obs_testing/config ) add_executable( enkf_magic_string_in_workflows enkf_magic_string_in_workflows.c ) target_link_libraries( enkf_magic_string_in_workflows enkf test_util ) @@ -60,6 +61,10 @@ add_executable( enkf_obs_vector_fs enkf_obs_vector_fs.c ) target_link_libraries( enkf_obs_vector_fs enkf test_util ) add_test( enkf_obs_vector_fs ${EXECUTABLE_OUTPUT_PATH}/enkf_obs_vector_fs ${PROJECT_SOURCE_DIR}/test-data/Statoil/config/obs_testing/config ) +add_executable( enkf_obs_vector enkf_obs_vector.c ) +target_link_libraries( enkf_obs_vector enkf test_util ) +add_test( enkf_obs_vector ${EXECUTABLE_OUTPUT_PATH}/enkf_obs_vector ) + add_executable( enkf_plot_data_fs enkf_plot_data_fs.c ) target_link_libraries( enkf_plot_data_fs enkf test_util ) @@ -99,9 +104,8 @@ add_test( enkf_analysis_config_ext_module ${EXECUTABLE_OUTPUT_PATH}/enkf_analysi add_executable( enkf_analysis_config_analysis_load enkf_analysis_config_analysis_load.c ) target_link_libraries( enkf_analysis_config_analysis_load enkf test_util) -add_test( enkf_analysis_config_analysis_load ${EXECUTABLE_OUTPUT_PATH}/enkf_analysis_config_analysis_load - ${CMAKE_CURRENT_SOURCE_DIR}/data/config/analysis_load_config - ${CMAKE_CURRENT_SOURCE_DIR}/data/config/analysis_load_site_config) +add_test( enkf_analysis_config_analysis_load ${EXECUTABLE_OUTPUT_PATH}/enkf_analysis_config_analysis_load ${CMAKE_CURRENT_SOURCE_DIR}/data/config/analysis_load_config) +set_property( TEST enkf_analysis_config_analysis_load PROPERTY ENVIRONMENT "ERT_SITE_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/data/config/analysis_load_site_config" ) add_executable( enkf_state_map enkf_state_map.c ) target_link_libraries( enkf_state_map enkf test_util ) @@ -127,10 +131,6 @@ add_executable( enkf_active_list enkf_active_list.c ) target_link_libraries( enkf_active_list enkf test_util) add_test( enkf_active_list ${EXECUTABLE_OUTPUT_PATH}/enkf_active_list ) -add_executable( enkf_obs_tstep_list enkf_obs_tstep_list.c ) -target_link_libraries( enkf_obs_tstep_list enkf test_util) -add_test( enkf_obs_tstep_list ${EXECUTABLE_OUTPUT_PATH}/enkf_obs_tstep_list ) - add_executable( enkf_main enkf_main.c ) target_link_libraries( enkf_main enkf test_util ) add_test( enkf_main ${EXECUTABLE_OUTPUT_PATH}/enkf_main ) @@ -171,6 +171,11 @@ add_test( enkf_analysis_enkf_update_job ${EXECUTABLE_OUTPUT_PATH}/enkf_analysis_ ${PROJECT_SOURCE_DIR}/test-data/Statoil/config/with_data/config ${PROJECT_SOURCE_DIR}/share/workflows/jobs/internal/config/ANALYSIS_ENKF_UPDATE ) +add_executable( enkf_scale_correlated_std enkf_scale_correlated_std.c ) +target_link_libraries( enkf_scale_correlated_std enkf test_util ) +add_test( enkf_scale_correlated_std ${EXECUTABLE_OUTPUT_PATH}/enkf_scale_correlated_std + ${PROJECT_SOURCE_DIR}/test-data/Statoil/config/with_data/config + ${PROJECT_SOURCE_DIR}/share/workflows/jobs/internal/config/STD_SCALE_CORRELATED_OBS ) add_executable( enkf_plot_gen_kw enkf_plot_gen_kw.c ) target_link_libraries( enkf_plot_gen_kw enkf test_util ) @@ -211,6 +216,16 @@ add_test( gen_kw_test ${EXECUTABLE_OUTPUT_PATH}/gen_kw_test ${CMAKE_CURRENT_SOURCE_DIR}/data/config/forward/ert/config_GEN_KW_true) + +add_executable( gen_kw_logarithmic_test gen_kw_logarithmic_test.c ) +target_link_libraries( gen_kw_logarithmic_test enkf test_util ) + +add_test( gen_kw_logarithmic_test + ${EXECUTABLE_OUTPUT_PATH}/gen_kw_logarithmic_test + ${CMAKE_CURRENT_SOURCE_DIR}/data/config/gen_kw_logarithmic/config_GEN_KW_logarithmic) + + + #----------------------------------------------------------------- add_executable( enkf_forward_init_GEN_KW enkf_forward_init_GEN_KW.c ) @@ -459,3 +474,4 @@ set_property( TEST enkf_obs_fs PROPERTY LABELS StatoilData ) set_property( TEST enkf_obs_vector_fs PROPERTY LABELS StatoilData ) set_property( TEST enkf_magic_string_in_workflows PROPERTY LABELS StatoilData ) set_property( TEST enkf_gen_data_config PROPERTY LABELS StatoilData ) +set_property( TEST enkf_scale_correlated_std PROPERTY LABELS StatoilData ) diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/FAULT_TEMPLATE b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/FAULT_TEMPLATE new file mode 100644 index 0000000000..de1f12ca5b --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/FAULT_TEMPLATE @@ -0,0 +1 @@ +<MULTFLT> diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/FAULT_TEMPLATE2 b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/FAULT_TEMPLATE2 new file mode 100644 index 0000000000..bb7d23f1dd --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/FAULT_TEMPLATE2 @@ -0,0 +1 @@ +<MULTFLT2> diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/MULTFLT.TXT b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/MULTFLT.TXT new file mode 100644 index 0000000000..ec7d5e43ed --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/MULTFLT.TXT @@ -0,0 +1 @@ +MULTFLT LOGUNIF 0.0001 0.01 diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/MULTFLT2.TXT b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/MULTFLT2.TXT new file mode 100644 index 0000000000..d2f6e43865 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/MULTFLT2.TXT @@ -0,0 +1 @@ +MULTFLT2 LOGUNIF 0.0000001 0.00001 diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/config_GEN_KW_logarithmic b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/config_GEN_KW_logarithmic new file mode 100644 index 0000000000..8075af97a6 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/config_GEN_KW_logarithmic @@ -0,0 +1,9 @@ +JOBNAME Job%d +RUNPATH simulations/run%d +NUM_REALIZATIONS 1 + +ENSPATH Storage +JOB_SCRIPT script.sh + +GEN_KW MULTFLT FAULT_TEMPLATE MULTFLT.INC MULTFLT.TXT +GEN_KW MULTFLT2 FAULT_TEMPLATE2 MULTFLT2.INC MULTFLT2.TXT diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/script.sh b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/script.sh new file mode 100644 index 0000000000..2f92a600cf --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/gen_kw_logarithmic/script.sh @@ -0,0 +1 @@ +# Completlely stupid - an executable must be present for the testing. diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config.c index b974eb0bdb..1dec82291d 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_analysis_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_analysis_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -25,8 +25,10 @@ #include <ert/util/util.h> #include <ert/util/rng.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> + #include <ert/enkf/analysis_config.h> -#include <ert/config/config.h> #include <ert/enkf/config_keys.h> @@ -54,21 +56,25 @@ void test_min_realizations_percent(const char * num_realizations_str, const char fprintf(config_file_stream, min_realizations_str); fclose(config_file_stream); - config_type * c = config_alloc(); + config_parser_type * c = config_alloc(); config_schema_item_type * item = config_add_schema_item(c , NUM_REALIZATIONS_KEY , true ); config_schema_item_set_default_type(item, CONFIG_INT); config_schema_item_set_argc_minmax( item , 1 , 1); item = config_add_schema_item(c , MIN_REALIZATIONS_KEY , false ); config_schema_item_set_argc_minmax( item , 1 , 2); - test_assert_true(config_parse(c , "config_file" , "--" , NULL , NULL , false , true )); + { + config_content_type * content = config_parse(c , "config_file" , "--" , NULL , NULL , false , true ); + test_assert_true(config_content_is_valid(content)); - analysis_config_type * ac = create_analysis_config( ); - analysis_config_init(ac, c); + analysis_config_type * ac = create_analysis_config( ); + analysis_config_init(ac, content); - test_assert_int_equal( min_realizations , analysis_config_get_min_realisations( ac ) ); + test_assert_int_equal( min_realizations , analysis_config_get_min_realisations( ac ) ); - analysis_config_free( ac ); - config_free( c ); + analysis_config_free( ac ); + config_content_free( content ); + config_free( c ); + } } test_work_area_free(work_area); @@ -130,7 +136,7 @@ void test_stop_long_running( ) { analysis_config_free( ac ); } -int main(int argc , char ** argv) { +int main(int argc , char ** argv) { test_create(); test_min_realisations(); test_continue(); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config_analysis_load.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config_analysis_load.c index dcbb5128c9..361e8fd1b6 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config_analysis_load.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config_analysis_load.c @@ -1,19 +1,19 @@ /* Copyright (C) 2014 Statoil ASA, Norway. - + The file 'enkf_analysis_config_analysis_load.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -29,21 +29,23 @@ #include <ert/enkf/analysis_config.h> int main(int argc , const char ** argv) { - const char * config_file = argv[1]; - const char * site_config_file = argv[2]; + util_install_signals(); + { + const char * config_file = argv[1]; - ert_test_context_type * test_context = ert_test_context_alloc("AnalysisLoadFromSiteConfig" , config_file, site_config_file); - enkf_main_type * enkf_main = ert_test_context_get_main(test_context); + ert_test_context_type * test_context = ert_test_context_alloc("AnalysisLoadFromSiteConfig" , config_file); + enkf_main_type * enkf_main = ert_test_context_get_main(test_context); - test_assert_true(analysis_config_has_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG1")); - analysis_module_type * analysis_module = analysis_config_get_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG1"); - test_assert_string_equal(analysis_module_get_name(analysis_module), "RML_ENKF_SITE_CONFIG1"); + test_assert_true(analysis_config_has_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG1")); + analysis_module_type * analysis_module = analysis_config_get_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG1"); + test_assert_string_equal(analysis_module_get_name(analysis_module), "RML_ENKF_SITE_CONFIG1"); - test_assert_true(analysis_config_has_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG2")); - analysis_module_type * analysis_module2 = analysis_config_get_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG2"); - test_assert_string_equal(analysis_module_get_name(analysis_module2), "RML_ENKF_SITE_CONFIG2"); + test_assert_true(analysis_config_has_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG2")); + analysis_module_type * analysis_module2 = analysis_config_get_module(enkf_main_get_analysis_config(enkf_main), "RML_ENKF_SITE_CONFIG2"); + test_assert_string_equal(analysis_module_get_name(analysis_module2), "RML_ENKF_SITE_CONFIG2"); - ert_test_context_free(test_context); + ert_test_context_free(test_context); + } } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_enkf_update_job.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_enkf_update_job.c index b052507126..16d92e91f2 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_enkf_update_job.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_enkf_update_job.c @@ -29,7 +29,7 @@ void test_update_default(const char * config_file , const char * job_file) { - ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob0" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob0" , config_file); stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "20" ); @@ -43,7 +43,7 @@ void test_update_default(const char * config_file , const char * job_file) { void test_update_selected_step(const char * config_file , const char * job_file) { - ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file); stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "50" ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_update_job.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_update_job.c index 919dc5d2c0..410227252d 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_update_job.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_update_job.c @@ -29,7 +29,7 @@ void test_update_default(const char * config_file , const char * job_file) { - ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob0" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob0" , config_file); stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); @@ -41,7 +41,7 @@ void test_update_default(const char * config_file , const char * job_file) { void test_update_new_case(const char * config_file , const char * job_file) { - ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob1" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob1" , config_file); stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "NewCase" ); @@ -54,7 +54,7 @@ void test_update_new_case(const char * config_file , const char * job_file) { void test_update_new_case_step(const char * config_file , const char * job_file) { - ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file); stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "NewCase" ); @@ -68,7 +68,7 @@ void test_update_new_case_step(const char * config_file , const char * job_file) void test_update_new_case_step_selected(const char * config_file , const char * job_file) { - ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file ); stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "NewCase" ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c index ce5a5c5cd6..b14a428327 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_ecl_config_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_ecl_config_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -24,32 +24,37 @@ #include <ert/util/path_stack.h> #include <ert/util/util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/enkf/ecl_config.h> #include <ert/enkf/ecl_refcase_list.h> int main(int argc , char ** argv) { - const char * config_file = argv[1]; - - ecl_config_type * ecl_config = ecl_config_alloc(); - ecl_refcase_list_type * refcase_list = ecl_config_get_refcase_list( ecl_config ); + util_install_signals(); { - config_type * config = config_alloc(); + const char * config_file = argv[1]; + ecl_config_type * ecl_config = ecl_config_alloc(); + ecl_refcase_list_type * refcase_list = ecl_config_get_refcase_list( ecl_config ); + { + config_parser_type * config = config_alloc(); + config_content_type * content; - ecl_config_add_config_items( config ); - test_assert_true( config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true)); - ecl_config_init( ecl_config , config ); + ecl_config_add_config_items( config ); + content = config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true); - config_free( config ); - } + test_assert_true( config_content_is_valid( content )); + ecl_config_init( ecl_config , content ); - test_assert_true( ecl_config_has_refcase( ecl_config )); - test_assert_int_equal( ecl_refcase_list_get_size( refcase_list) , 17); + config_content_free( content ); + config_free( config ); + } - ecl_config_free( ecl_config ); - + test_assert_true( ecl_config_has_refcase( ecl_config )); + test_assert_int_equal( ecl_refcase_list_get_size( refcase_list) , 17); + ecl_config_free( ecl_config ); + } exit(0); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c index 47449143cc..9979c1ce04 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c @@ -25,7 +25,7 @@ #include <ert/util/thread_pool.h> #include <ert/util/arg_pack.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/ecl/ecl_sum.h> diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c index 15cd8f4c25..18465df59b 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c @@ -25,7 +25,8 @@ #include <ert/util/thread_pool.h> #include <ert/util/arg_pack.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/ecl/ecl_sum.h> @@ -40,14 +41,18 @@ int main(int argc , char ** argv) { const char * config_file = argv[1]; - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); + config_content_type * content; ensemble_config_type * ensemble = ensemble_config_alloc(); enkf_config_node_add_GEN_PARAM_config_schema( config ); - test_assert_true( config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true ) ); - ensemble_config_init_GEN_PARAM( ensemble, config ); - + content = config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true ); + test_assert_true( config_content_is_valid( content ) ); + + ensemble_config_init_GEN_PARAM( ensemble, content ); + + config_content_free( content ); config_free( config ); ensemble_config_free( ensemble ); exit(0); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_run_context.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_run_context.c index ea16a5cd71..af56f81b65 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_run_context.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_run_context.c @@ -30,8 +30,6 @@ void test_create() { bool_vector_iset( iactive , 8 , false ); { enkf_fs_type * init_fs = NULL; - enkf_fs_type * result_fs = NULL; - enkf_fs_type * update_target_fs = NULL; subst_list_type * subst_list = subst_list_alloc( NULL ); path_fmt_type * runpath_fmt = path_fmt_alloc_directory_fmt("/tmp/path/%04d"); ert_run_context_type * context = ert_run_context_alloc_INIT_ONLY( init_fs , iactive , runpath_fmt , subst_list , INIT_CONDITIONAL , 13 ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_test_context.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_test_context.c index 0143841b32..fcf97ab688 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_test_context.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_test_context.c @@ -28,7 +28,7 @@ void test_create_invalid(const char * config_file) { char * cwd0 = util_alloc_cwd(); - ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT" , config_file ); test_assert_true( ert_test_context_is_instance( test_context )); test_assert_NULL( ert_test_context_get_main( test_context )); { @@ -44,7 +44,7 @@ void test_create_invalid(const char * config_file) { void test_create_valid( const char * config_file ) { char * cwd0 = util_alloc_cwd(); - ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT" , config_file ); test_assert_true( ert_test_context_is_instance( test_context )); test_assert_true( enkf_main_is_instance( ert_test_context_get_main( test_context ))); { @@ -59,7 +59,7 @@ void test_create_valid( const char * config_file ) { void test_install_job( const char * config_file, const char * job_file_OK , const char * job_file_ERROR) { - ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file ); test_assert_false( ert_test_context_install_workflow_job( test_context , "JOB" , "File/does/not/exist")); test_assert_false( ert_test_context_install_workflow_job( test_context , "ERROR" , job_file_ERROR)); @@ -71,7 +71,7 @@ void test_install_job( const char * config_file, const char * job_file_OK , cons void test_run_workflow_job( const char * config_file , const char * job_file ) { - ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file ); stringlist_type * args0 = stringlist_alloc_new( ); stringlist_type * args1 = stringlist_alloc_new( ); @@ -89,7 +89,7 @@ void test_run_workflow_job( const char * config_file , const char * job_file ) { void test_install_workflow( const char * config_file , const char * job_file ) { - ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file ); const char * wf_file = "WFLOW"; ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); @@ -107,7 +107,7 @@ void test_install_workflow( const char * config_file , const char * job_file ) { void test_run_workflow(const char * config_file , const char * job_file) { - ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file ); test_assert_false( ert_test_context_run_worklow( test_context , "No-does.not.exist")); ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_workflow_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_workflow_list.c index e8bca24d56..b6ea0e583d 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_workflow_list.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ert_workflow_list.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'enkf_ert_workflow_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'enkf_ert_workflow_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -65,14 +65,14 @@ void test_add_alias( const char * job) { test_assert_true( ert_workflow_list_has_workflow( wf_list , "alias")); test_assert_true( workflow_is_instance( ert_workflow_list_get_workflow( wf_list , "WF"))); test_assert_true( workflow_is_instance( ert_workflow_list_get_workflow( wf_list , "alias"))); - + test_assert_true( workflow_is_instance( ert_workflow_list_add_workflow( wf_list , "WF2" , "WF"))); test_assert_int_equal( 2 , ert_workflow_list_get_size( wf_list )); test_assert_true( ert_workflow_list_has_workflow( wf_list , "WF")); test_assert_true( ert_workflow_list_has_workflow( wf_list , "alias")); test_assert_true( workflow_is_instance( ert_workflow_list_get_workflow( wf_list , "WF"))); test_assert_true( workflow_is_instance( ert_workflow_list_get_workflow( wf_list , "alias"))); - + test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_export_field_test.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_export_field_test.c index 5512df209e..c3fd8a3373 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_export_field_test.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_export_field_test.c @@ -121,7 +121,7 @@ int main(int argc , const char ** argv) { const char * job_file_export_field_ecl_grdecl = argv[3]; const char * job_file_export_field_rms_roff = argv[4]; - ert_test_context_type * test_context = ert_test_context_alloc("ExportFieldsJobs" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("ExportFieldsJobs" , config_file); enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); enkf_main_select_fs( enkf_main , "default" ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_export_inactive_cells.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_export_inactive_cells.c index 6ec0c4c722..70c320a01b 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_export_inactive_cells.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_export_inactive_cells.c @@ -149,7 +149,7 @@ int main(int argc , char ** argv) { const char * key = "PORO"; int iens = 0; - ert_test_context_type * test_context = ert_test_context_alloc("ExportInactiveCellsTest" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("ExportInactiveCellsTest" , config_file); enkf_main_type * enkf_main = ert_test_context_get_main(test_context); enkf_fs_type * fs = enkf_main_get_fs(enkf_main); const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_FIELD.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_FIELD.c index 6763b6bd1d..4c543879e8 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_FIELD.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_FIELD.c @@ -57,7 +57,7 @@ int main(int argc , char ** argv) { test_assert_true( util_sscanf_bool( forward_init_string , &forward_init)); util_clear_directory( "Storage" , true , true ); - enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main = enkf_main_bootstrap( config_file , strict , true ); { enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); enkf_node_type * field_node = enkf_state_get_node( state , "PORO" ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_KW.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_KW.c index be15e6c4fe..315391d640 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_KW.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_KW.c @@ -56,7 +56,7 @@ int main(int argc , char ** argv) { test_assert_true( util_sscanf_bool( forward_init_string , &forward_init)); util_clear_directory( "Storage" , true , true ); - enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main = enkf_main_bootstrap( config_file , strict , true ); { enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); enkf_node_type * gen_kw_node = enkf_state_get_node( state , "MULTFLT" ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_PARAM.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_PARAM.c index f5253585ab..25c0917a11 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_PARAM.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_GEN_PARAM.c @@ -56,7 +56,7 @@ int main(int argc , char ** argv) { test_assert_true( util_sscanf_bool( forward_init_string , &forward_init)); util_clear_directory( "Storage" , true , true ); - enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main = enkf_main_bootstrap( config_file , strict , true ); { enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); enkf_node_type * gen_param_node = enkf_state_get_node( state , "PARAM" ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_SURFACE.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_SURFACE.c index 65cafdc931..b54c91efd7 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_SURFACE.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_SURFACE.c @@ -59,7 +59,7 @@ int main(int argc , char ** argv) { test_assert_true( util_sscanf_bool( forward_init_string , &forward_init)); util_clear_directory( "Storage" , true , true ); - enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main = enkf_main_bootstrap( config_file , strict , true ); { enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); enkf_node_type * surface_node = enkf_state_get_node( state , "SURFACE" ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_transform.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_transform.c index 6855d78ef6..86de504662 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_transform.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_forward_init_transform.c @@ -77,7 +77,7 @@ int main(int argc , char ** argv) { test_work_area_set_store(work_area, true); bool strict = true; - enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main_type * enkf_main = enkf_main_bootstrap( config_file , strict , true ); enkf_fs_type * init_fs = enkf_main_get_fs(enkf_main); enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( init_fs , 0 ,0 , "simulations/run0"); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_fs.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_fs.c index c43975b1ad..284d42057f 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_fs.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_fs.c @@ -16,22 +16,28 @@ for more details. */ - #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <sys/types.h> #include <unistd.h> +#include <pthread.h> +#include <assert.h> +#include <fcntl.h> +#include <sys/mman.h> #include <ert/util/test_util.h> #include <ert/util/test_work_area.h> #include <ert/enkf/enkf_fs.h> +typedef struct +{ + pthread_mutex_t mutex1; + pthread_mutex_t mutex2; +} shared_data; - - - +static shared_data* data = NULL; void test_mount() { test_work_area_type * work_area = test_work_area_alloc("enkf_fs/mount"); @@ -56,7 +62,6 @@ void test_mount() { test_work_area_free( work_area ); } - void test_refcount() { test_work_area_type * work_area = test_work_area_alloc("enkf_fs/refcount"); @@ -69,37 +74,23 @@ void test_refcount() { test_work_area_free( work_area ); } - void createFS() { - pid_t pid = fork(); + + pthread_mutex_lock(&data->mutex1); + pid_t pid = fork(); if (pid == 0) { enkf_fs_type * fs_false = enkf_fs_mount( "mnt" ); test_assert_false(enkf_fs_is_read_only(fs_false)); test_assert_true( util_file_exists("mnt/mnt.lock")); - { - int total_sleep = 0; - while (true) { - if (util_file_exists( "stop")) { - unlink("stop"); - break; - } - - usleep(1000); - total_sleep += 1000; - if (total_sleep > 1000000 * 5) { - fprintf(stderr,"Test failure - never receieved \"stop\" file from parent process \n"); - break; - } - } - } + pthread_mutex_unlock(&data->mutex1); + pthread_mutex_lock(&data->mutex2); enkf_fs_decref( fs_false ); + pthread_mutex_unlock(&data->mutex2); exit(0); - } - usleep(10000); + } } - void test_fwrite_readonly( void * arg ) { enkf_fs_type * fs = enkf_fs_safe_cast( arg ); /* @@ -111,44 +102,51 @@ void test_fwrite_readonly( void * arg ) { enkf_fs_fwrite_node( fs , NULL , "KEY" , PARAMETER , 100 , 1 , FORECAST ); } +void initialise_shared() +{ + // place our shared data in shared memory + int prot = PROT_READ | PROT_WRITE; +#ifdef __linux + int flags = MAP_SHARED | MAP_ANONYMOUS; +#elif __APPLE__ + int flags = MAP_SHARED | MAP_ANON; +#endif + + data = mmap(NULL, sizeof(shared_data), prot, flags, -1, 0); + assert(data); + + // initialise mutex so it works properly in shared memory + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + pthread_mutex_init(&data->mutex1, &attr); + pthread_mutex_init(&data->mutex2, &attr); +} /* - This test needs to fork off a seperate process to test the cross-process file locking. + This test needs to fork off a seperate process to test the cross-process file locking. */ void test_read_only2() { + initialise_shared(); test_work_area_type * work_area = test_work_area_alloc("enkf_fs/read_only2"); enkf_fs_create_fs("mnt" , BLOCK_FS_DRIVER_ID , NULL , false); + pthread_mutex_lock(&data->mutex2); createFS(); - - while (true) { - if (util_file_exists("mnt/mnt.lock")) - break; - } - + pthread_mutex_lock(&data->mutex1); { enkf_fs_type * fs_false = enkf_fs_mount( "mnt" ); test_assert_true(enkf_fs_is_read_only(fs_false)); test_assert_util_abort( "enkf_fs_fwrite_node" , test_fwrite_readonly , fs_false ); enkf_fs_decref( fs_false ); } - { - FILE * stream = util_fopen("stop" , "w"); - fclose( stream ); - } - - while (util_file_exists( "stop")) { - usleep( 1000 ); - } + pthread_mutex_unlock(&data->mutex2); + pthread_mutex_unlock(&data->mutex1); + pthread_mutex_lock(&data->mutex2); test_work_area_free( work_area ); + pthread_mutex_unlock(&data->mutex2); + munmap(data, sizeof(data)); } - - - - - - - int main(int argc, char ** argv) { test_mount(); test_refcount(); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_fs_invalidate_cache.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_fs_invalidate_cache.c index 24a956ff6b..2185ec4bb2 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_fs_invalidate_cache.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_fs_invalidate_cache.c @@ -96,7 +96,7 @@ void test_invalidate_cache(ert_test_context_type * test_context) { int main(int argc, char ** argv) { const char * config_file = argv[1]; test_assert_not_NULL(config_file); - ert_test_context_type * test_context = ert_test_context_alloc("test_context_enkf_fs_test" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("test_context_enkf_fs_test" , config_file); test_assert_not_NULL(test_context); test_invalidate_cache(test_context); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_data_config_parse.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_data_config_parse.c index 93af0fd773..e8abffbe06 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_data_config_parse.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_data_config_parse.c @@ -26,7 +26,8 @@ #include <ert/util/test_work_area.h> #include <ert/util/test_util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/enkf/gen_data_config.h> #include <ert/enkf/enkf_config_node.h> @@ -34,24 +35,29 @@ enkf_config_node_type * parse_alloc_GEN_PARAM( const char * config_string , bool parse_valid) { - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); enkf_config_node_type * enkf_config_node = NULL; - + enkf_config_node_add_GEN_PARAM_config_schema( config ); { FILE * stream = util_fopen("config.txt" , "w"); fprintf(stream , config_string); fclose( stream ); } - - test_assert_bool_equal( parse_valid , config_parse( config , "config.txt" , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_IGNORE , true)); - if (parse_valid) { - const config_content_item_type * config_item = config_get_content_item( config , GEN_PARAM_KEY ); - const config_content_node_type * config_node = config_content_item_iget_node( config_item , 0 ); - enkf_config_node = enkf_config_node_alloc_GEN_PARAM_from_config( config_node ); + { + config_content_type * content = config_parse( config , "config.txt" , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_IGNORE , true); + + test_assert_bool_equal( parse_valid , config_content_is_valid( content )); + if (parse_valid) { + const config_content_item_type * config_item = config_content_get_item( content , GEN_PARAM_KEY ); + const config_content_node_type * config_node = config_content_item_iget_node( config_item , 0 ); + + enkf_config_node = enkf_config_node_alloc_GEN_PARAM_from_config( config_node ); + } + config_content_free( content ); + config_free( config ); } - config_free( config ); return enkf_config_node; } @@ -118,23 +124,28 @@ void test_parse_gen_param() { enkf_config_node_type * parse_alloc_GEN_DATA_result( const char * config_string , bool parse_valid) { - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); enkf_config_node_type * enkf_config_node = NULL; - + enkf_config_node_add_GEN_DATA_config_schema( config ); { FILE * stream = util_fopen("config.txt" , "w"); fprintf(stream , config_string); fclose( stream ); } - test_assert_bool_equal( parse_valid , config_parse( config , "config.txt" , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_IGNORE , true)); - if (parse_valid) { - const config_content_item_type * config_item = config_get_content_item( config , GEN_DATA_KEY ); - const config_content_node_type * config_node = config_content_item_iget_node( config_item , 0 ); - - enkf_config_node = enkf_config_node_alloc_GEN_DATA_from_config( config_node ); + { + config_content_type * content = config_parse( config , "config.txt" , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_IGNORE , true); + test_assert_bool_equal( parse_valid ,config_content_is_valid( content ) ); + if (parse_valid) { + const config_content_item_type * config_item = config_content_get_item( content , GEN_DATA_KEY ); + const config_content_node_type * config_node = config_content_item_iget_node( config_item , 0 ); + + enkf_config_node = enkf_config_node_alloc_GEN_DATA_from_config( config_node ); + } + + config_content_free( content ); + config_free( config ); } - config_free( config ); return enkf_config_node; } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_obs_load.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_obs_load.c index b540dab1c3..89f32777f0 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_obs_load.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_gen_obs_load.c @@ -32,7 +32,7 @@ void test_obs_check_report_steps(const char * config_file ) { - ert_test_context_type * test_context = ert_test_context_alloc( "GEN_OBS" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc( "GEN_OBS" , config_file ); enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); enkf_obs_type * obs = enkf_main_get_obs( enkf_main ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c index 751e5efb85..291f6c8aa1 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c @@ -20,7 +20,7 @@ #include <stdio.h> #include <unistd.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/util/test_util.h> #include <ert/util/util.h> @@ -71,30 +71,33 @@ int main(int argc , char ** argv) { const char * runpath_fmt = "run/iter%d/real%d"; const int iter_count = 10; char * config_file = create_config_file( enspath_fmt , runpath_fmt , iter_count); - - config_type * config = config_alloc(); + + config_parser_type * config = config_alloc(); + config_content_type * content; analysis_iter_config_add_config_items( config ); - - test_assert_true( config_parse( config , config_file , NULL , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true)); - test_assert_true( config_item_set( config , ITER_CASE_KEY )); - test_assert_true( config_item_set( config , ITER_COUNT_KEY )); + content = config_parse( config , config_file , NULL , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true); + test_assert_true( config_content_is_valid( content) ); + + test_assert_true( config_content_has_item( content , ITER_CASE_KEY )); + test_assert_true( config_content_has_item( content , ITER_COUNT_KEY )); { analysis_iter_config_type * iter_config = analysis_iter_config_alloc(); char itercase[50]; sprintf(itercase,DEFAULT_ANALYSIS_ITER_CASE,5); test_assert_string_equal( analysis_iter_config_iget_case( iter_config , 5) , itercase ); - analysis_iter_config_init( iter_config , config ); - + analysis_iter_config_init( iter_config , content ); + test_assert_int_equal( analysis_iter_config_get_num_iterations( iter_config ) , iter_count ); test_assert_string_equal( analysis_iter_config_iget_case( iter_config , 5) , "iter5"); - + analysis_iter_config_free( iter_config ); } remove( config_file ); free( config_file ); + config_content_free( content ); config_free( config ); test_set(); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata.c index 117e7074d9..ed44b2edcc 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_local_obsdata.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_local_obsdata.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -41,12 +41,12 @@ void test_wrapper() { int main(int argc , char ** argv) { local_obsdata_type * obsdata; - + obsdata = local_obsdata_alloc( "KEY"); test_assert_true( local_obsdata_is_instance( obsdata )); test_assert_int_equal( 0 , local_obsdata_get_size( obsdata )); test_assert_string_equal( "KEY" , local_obsdata_get_name( obsdata )); - + { local_obsdata_node_type * obsnode = local_obsdata_node_alloc( "KEY" ); test_assert_true( local_obsdata_add_node( obsdata , obsnode ) ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata_node.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata_node.c index 46c883c458..b37bf28edc 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata_node.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata_node.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_local_obsdata_node.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_local_obsdata_node.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -21,48 +21,77 @@ #include <unistd.h> #include <ert/util/test_util.h> +#include <ert/util/int_vector.h> -#include <ert/enkf/obs_tstep_list.h> #include <ert/enkf/local_obsdata_node.h> #include <ert/enkf/active_list.h> void test_content( local_obsdata_node_type * node ) { const active_list_type * active_list = local_obsdata_node_get_active_list( node ); - + test_assert_not_NULL( active_list ); test_assert_true( active_list_is_instance( active_list )); - test_assert_true( obs_tstep_list_is_instance( local_obsdata_node_get_tstep_list( node ))); { active_list_type * new_active_list = active_list_alloc( ); - + active_list_add_index( new_active_list , 1098 ); - + test_assert_false( active_list_equal( new_active_list , local_obsdata_node_get_active_list( node ))); local_obsdata_node_copy_active_list( node , new_active_list ); test_assert_true( active_list_equal( new_active_list , local_obsdata_node_get_active_list( node ))); - + } { - const obs_tstep_list_type * tstep = local_obsdata_node_get_tstep_list( node ); - + + + local_obsdata_node_add_tstep( node , 20 ); local_obsdata_node_add_tstep( node , 10 ); local_obsdata_node_add_tstep( node , 10 ); // Second add - ignored - local_obsdata_node_add_tstep( node , 20 ); - - test_assert_int_equal( 2 , obs_tstep_list_get_size( tstep )); + + { + const int_vector_type * tstep = local_obsdata_node_get_tstep_list( node ); + test_assert_int_equal( 2 , int_vector_size( tstep )); + test_assert_int_equal( 10 , int_vector_iget( tstep , 0 )); + test_assert_int_equal( 20 , int_vector_iget( tstep , 1 )); + test_assert_true( local_obsdata_node_has_tstep( node , 10 )); + test_assert_true( local_obsdata_node_has_tstep( node , 20 )); + test_assert_false( local_obsdata_node_has_tstep( node , 15 )); + + + local_obsdata_node_add_range( node , 5 , 7 ); + test_assert_true( local_obsdata_node_has_tstep( node , 5 )); + test_assert_true( local_obsdata_node_has_tstep( node , 7 )); + test_assert_int_equal( int_vector_iget( tstep , 2 ) , 7 ); + } } } +void get_tstep_list(void * arg) { + local_obsdata_node_type * node = local_obsdata_node_safe_cast( arg ); + local_obsdata_node_get_tstep_list(node); +} + + + +void test_abort() { + local_obsdata_node_type * node = local_obsdata_node_alloc( "KEY" ); + + test_assert_true( local_obsdata_node_all_timestep_active( node )); + test_assert_util_abort("local_obsdata_node_get_tstep_list", get_tstep_list, node); + local_obsdata_node_free( node ); +} + + int main(int argc , char ** argv) { const char * obs_key = "1234"; { local_obsdata_node_type * node = local_obsdata_node_alloc( obs_key ); - + test_assert_true( local_obsdata_node_is_instance( node )); test_assert_string_equal( obs_key , local_obsdata_node_get_key( node )); test_content( node ); @@ -73,7 +102,9 @@ int main(int argc , char ** argv) { void * node = local_obsdata_node_alloc( obs_key ); local_obsdata_node_free__( node ); } - + + test_abort(); + exit(0); } - + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_magic_string_in_workflows.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_magic_string_in_workflows.c index 1bfae21eab..88bc0a14fd 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_magic_string_in_workflows.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_magic_string_in_workflows.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - + Copyright (C) 2014 Statoil ASA, Norway. + The file 'enkf_magic_string_in_workflows.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -38,10 +38,10 @@ void test_magic_strings( ert_test_context_type * test_context ) { { FILE * stream = util_fopen("magic-list.txt" , "r"); char string[128]; - + fscanf( stream , "%s" , string); test_assert_string_equal( string , enkf_fs_get_case_name( enkf_main_get_fs( enkf_main ))); - + fscanf( stream , "%s" , string); test_assert_string_equal( string , "MagicAllTheWayToWorkFlow"); @@ -59,8 +59,7 @@ void test_has_job(ert_test_context_type * test_context ) { int main( int argc , char ** argv) { const char * model_config = argv[1]; - const char * site_config = NULL; - ert_test_context_type * test_context = ert_test_context_alloc( "MAGIC-STRINGS" , model_config , site_config); + ert_test_context_type * test_context = ert_test_context_alloc( "MAGIC-STRINGS" , model_config); enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); { @@ -69,7 +68,7 @@ int main( int argc , char ** argv) { enkf_main_select_fs(enkf_main , "default"); test_assert_string_equal( "default" , enkf_fs_get_case_name( enkf_main_get_fs( enkf_main ))); test_magic_strings( test_context ); - + enkf_main_select_fs(enkf_main , "extraCase"); test_assert_string_equal( "extraCase" , enkf_fs_get_case_name( enkf_main_get_fs( enkf_main ))); test_magic_strings( test_context ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_main.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_main.c index 7566a33261..32db707aad 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_main.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_main.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_main.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_main.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -58,6 +58,7 @@ void test_create() { int main(int argc , char ** argv) { + util_install_signals(); test_create(); test_case_initialized(); exit(0); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs.c index 05fb217c4f..ce01664b83 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_main_fs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_main_fs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -40,8 +40,7 @@ int main(int argc, char ** argv) { util_alloc_file_components( config_file , NULL , &model_config , NULL); test_work_area_copy_parent_content( work_area , config_file ); { - const char * site_config = "/project/res/etc/ERT/site-config"; - enkf_main_type * enkf_main = enkf_main_bootstrap( site_config , model_config , false , false ); + enkf_main_type * enkf_main = enkf_main_bootstrap( model_config , false , false ); enkf_main_select_fs( enkf_main , "enkf"); test_assert_true( enkf_main_case_is_current( enkf_main , "enkf")); @@ -65,7 +64,7 @@ int main(int argc, char ** argv) { { enkf_fs_type * fs1 = enkf_main_mount_alt_fs( enkf_main , "default" , false ); enkf_fs_type * fs2 = enkf_main_mount_alt_fs( enkf_main , "enkf" , false ); - + test_assert_int_equal( 2 , enkf_fs_get_refcount( enkf_main_get_fs( enkf_main ))); test_assert_int_equal( 2 , enkf_fs_get_refcount( fs2 )); test_assert_int_equal( 1 , enkf_fs_get_refcount( fs1 )); @@ -76,7 +75,7 @@ int main(int argc, char ** argv) { { enkf_fs_type * enkf_fs = enkf_main_mount_alt_fs( enkf_main , "enkf" , false ); - + enkf_main_select_fs( enkf_main , "default"); test_assert_int_equal( 1 , enkf_fs_get_refcount( enkf_main_get_fs( enkf_main ))); enkf_fs_decref( enkf_fs ); @@ -84,7 +83,7 @@ int main(int argc, char ** argv) { { enkf_fs_type * default_fs = enkf_main_mount_alt_fs( enkf_main , "default" , false ); - + test_assert_int_equal( 2 , enkf_fs_get_refcount( enkf_main_get_fs( enkf_main ))); enkf_main_select_fs( enkf_main , "default"); test_assert_int_equal( 2 , enkf_fs_get_refcount( enkf_main_get_fs( enkf_main ))); @@ -95,7 +94,7 @@ int main(int argc, char ** argv) { { enkf_fs_type * fs = enkf_main_mount_alt_fs( enkf_main , "default" , false ); test_assert_int_equal( 2 , enkf_fs_get_refcount( enkf_main_get_fs( enkf_main ))); - + enkf_main_set_fs( enkf_main , fs , NULL ); enkf_fs_decref( fs ); test_assert_int_equal( 1 , enkf_fs_get_refcount( enkf_main_get_fs( enkf_main ))); @@ -103,7 +102,7 @@ int main(int argc, char ** argv) { { enkf_fs_type * fs = enkf_main_mount_alt_fs( enkf_main , "enkf" , false ); enkf_fs_type * current = enkf_main_mount_alt_fs( enkf_main , "default" , false ); - + test_assert_int_equal( 2 , enkf_fs_get_refcount( current )); test_assert_int_equal( 1 , enkf_fs_get_refcount( fs)); enkf_main_set_fs( enkf_main , fs , NULL); @@ -114,8 +113,8 @@ int main(int argc, char ** argv) { enkf_fs_decref( fs); } - - + + test_assert_int_equal( 1 , enkf_fs_get_refcount( enkf_main_get_fs( enkf_main ))); enkf_main_free( enkf_main ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs_current_file_test.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs_current_file_test.c index 8e2ccf8638..2efede5283 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs_current_file_test.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_main_fs_current_file_test.c @@ -26,10 +26,10 @@ #include <ert/enkf/enkf_fs.h> #include <ert/enkf/enkf_main.h> -void test_current_file_not_present_symlink_present(const char * site_config, const char * model_config) { +void test_current_file_not_present_symlink_present(const char * model_config) { test_assert_true(util_file_exists("Storage/enkf")); util_make_slink("enkf", "Storage/current" ); - enkf_main_type * enkf_main = enkf_main_bootstrap( site_config , model_config , false , false ); + enkf_main_type * enkf_main = enkf_main_bootstrap( model_config , false , false ); test_assert_true( enkf_main_case_is_current( enkf_main , "enkf")); test_assert_false(util_file_exists("Storage/current")); test_assert_true(util_file_exists("Storage/current_case")); @@ -39,9 +39,9 @@ void test_current_file_not_present_symlink_present(const char * site_config, con enkf_main_free(enkf_main); } -void test_current_file_present(const char * site_config, const char * model_config) { +void test_current_file_present(const char * model_config) { test_assert_true(util_file_exists("Storage/current_case")); - enkf_main_type * enkf_main = enkf_main_bootstrap( site_config , model_config , false , false ); + enkf_main_type * enkf_main = enkf_main_bootstrap( model_config , false , false ); test_assert_true( enkf_main_case_is_current( enkf_main , "enkf")); test_assert_false(util_file_exists("Storage/current")); char * current_case = enkf_main_read_alloc_current_case_name(enkf_main); @@ -51,8 +51,8 @@ void test_current_file_present(const char * site_config, const char * model_conf } -void test_change_case(const char * site_config, const char * model_config) { - enkf_main_type * enkf_main = enkf_main_bootstrap( site_config , model_config , false , false ); +void test_change_case(const char * model_config) { + enkf_main_type * enkf_main = enkf_main_bootstrap( model_config , false , false ); enkf_main_select_fs( enkf_main , "default"); test_assert_true( enkf_main_case_is_current( enkf_main , "default")); test_assert_false( enkf_main_case_is_current(enkf_main , "enkf")); @@ -86,11 +86,10 @@ int main(int argc, char ** argv) { char * model_config; util_alloc_file_components( config_file , NULL , &model_config , NULL); test_work_area_copy_parent_content( work_area , config_file ); - const char * site_config = "/project/res/etc/ERT/site-config"; - test_current_file_not_present_symlink_present(site_config, model_config); - test_current_file_present(site_config, model_config); - test_change_case(site_config, model_config); + test_current_file_not_present_symlink_present(model_config); + test_current_file_present(model_config); + test_change_case(model_config); free(model_config); test_work_area_free( work_area ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_meas_data.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_meas_data.c index 3954b8acb3..85f0858f10 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_meas_data.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_meas_data.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_meas_data.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_meas_data.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -22,24 +22,54 @@ #include <ert/util/test_util.h> #include <ert/util/int_vector.h> +#include <ert/util/type_vector_functions.h> #include <ert/enkf/meas_data.h> +void meas_block_iset_abort(void * arg) { + meas_block_type * block = meas_block_safe_cast( arg ); + meas_block_iset( block , 0 , 0 , 100); +} + + +void meas_block_iget_abort(void * arg) { + meas_block_type * block = meas_block_safe_cast( arg ); + meas_block_iget( block , 0 , 0 ); +} + + + void create_test() { int_vector_type * ens_active_list = int_vector_alloc(0 , false); + bool_vector_type * ens_mask; int_vector_append( ens_active_list , 10 ); int_vector_append( ens_active_list , 20 ); int_vector_append( ens_active_list , 30 ); + ens_mask = int_vector_alloc_mask(ens_active_list); { - meas_data_type * meas_data = meas_data_alloc( ens_active_list ); - test_assert_int_equal( 3 , meas_data_get_ens_size( meas_data )); - + meas_data_type * meas_data = meas_data_alloc( ens_mask ); + test_assert_int_equal( 3 , meas_data_get_active_ens_size( meas_data )); + + { + meas_block_type * block = meas_data_add_block(meas_data , "OBS" , 10 , 10); + + meas_block_iset(block , 10 , 0 , 100); + test_assert_double_equal( 100 , meas_block_iget( block , 10 , 0 )); + + test_assert_bool_equal( true , meas_block_iens_active( block , 10 )); + test_assert_bool_equal( false , meas_block_iens_active( block , 11 )); + + test_assert_util_abort( "meas_block_assert_iens_active" , meas_block_iset_abort , block); + test_assert_util_abort( "meas_block_assert_iens_active" , meas_block_iget_abort , block); + } meas_data_free( meas_data ); } - + + + bool_vector_free( ens_mask ); int_vector_free( ens_active_list ); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_fs.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_fs.c index a7bf72316e..f3c86c2401 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_fs.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_fs.c @@ -1,30 +1,30 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'enkf_obs_fs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'enkf_obs_fs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdio.h> #include <ert/util/test_util.h> +#include <ert/util/type_vector_functions.h> #include <ert/enkf/enkf_obs.h> #include <ert/enkf/ert_test_context.h> #include <ert/enkf/meas_data.h> #include <ert/enkf/obs_data.h> -#include <ert/enkf/local_obsset.h> #include <ert/enkf/summary_config.h> @@ -33,31 +33,26 @@ void testS( ert_test_context_type * test_context ) { enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main ); enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); - int_vector_type * step_list = int_vector_alloc(0,0); int_vector_type * active_list = int_vector_alloc(0,0); - obs_data_type * obs_data = obs_data_alloc( ); - local_obsset_type * obs_set = local_obsset_alloc( "OBSNAME" ); + obs_data_type * obs_data = obs_data_alloc(1.0); + local_obsdata_type * obs_set = local_obsdata_alloc( "KEY" ); + bool_vector_type * ens_mask; meas_data_type * meas_data; - int active_size = 0; - - { - for (int i= 0; i < enkf_main_get_ensemble_size( enkf_main); i++) - int_vector_append( active_list , i ); - active_size = int_vector_size( active_list ); - } - { - for (int s = 0; s < enkf_main_get_history_length( enkf_main ); s++) - int_vector_append( step_list , s ); - } - meas_data = meas_data_alloc( active_list ); - obs_data = obs_data_alloc( ); + for (int i= 0; i < enkf_main_get_ensemble_size( enkf_main); i++) + int_vector_append( active_list , i ); + ens_mask = int_vector_alloc_mask( active_list); + + obs_data = obs_data_alloc(1.0); + meas_data = meas_data_alloc( ens_mask ); + + enkf_obs_add_local_nodes_with_data( enkf_obs , obs_set , fs , ens_mask ); + enkf_obs_get_obs_and_measure_data( enkf_obs , fs , obs_set, FORECAST , active_list , meas_data , obs_data); - enkf_obs_get_obs_and_measure( enkf_obs , fs , step_list , FORECAST , active_list , meas_data , obs_data , obs_set); { FILE * stream = util_fopen("analysis/Smatrix" , "r"); - matrix_type * S = meas_data_allocS( meas_data , active_size ); + matrix_type * S = meas_data_allocS( meas_data ); matrix_type * S0 = matrix_fread_alloc( stream ); test_assert_true( matrix_equal( S0 , S )); @@ -66,11 +61,11 @@ void testS( ert_test_context_type * test_context ) { matrix_free( S0 ); fclose( stream ); } - int_vector_free( step_list ); int_vector_free( active_list ); meas_data_free( meas_data ); obs_data_free( obs_data ); - local_obsset_free( obs_set ); + local_obsdata_free( obs_set ); + bool_vector_free( ens_mask ); } } @@ -80,11 +75,11 @@ void test_iget(ert_test_context_type * test_context) { enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main ); - test_assert_int_equal( 29 , enkf_obs_get_size( enkf_obs ) ); + test_assert_int_equal( 31 , enkf_obs_get_size( enkf_obs ) ); for (int iobs = 0; iobs < enkf_obs_get_size( enkf_obs ); iobs++) { obs_vector_type * vec1 = enkf_obs_iget_vector( enkf_obs , iobs ); obs_vector_type * vec2 = enkf_obs_get_vector( enkf_obs , obs_vector_get_key( vec1 )); - + test_assert_ptr_equal( vec1 , vec2 ); } } @@ -93,10 +88,10 @@ void test_iget(ert_test_context_type * test_context) { void test_container( ert_test_context_type * test_context ) { enkf_config_node_type * config_node = enkf_config_node_new_container( "CONTAINER" ); enkf_config_node_type * wwct1_node = enkf_config_node_alloc_summary( "WWCT:OP_1" , LOAD_FAIL_SILENT); - enkf_config_node_type * wwct2_node = enkf_config_node_alloc_summary( "WWCT:OP_2" , LOAD_FAIL_SILENT); + enkf_config_node_type * wwct2_node = enkf_config_node_alloc_summary( "WWCT:OP_2" , LOAD_FAIL_SILENT); enkf_config_node_type * wwct3_node = enkf_config_node_alloc_summary( "WWCT:OP_3" , LOAD_FAIL_SILENT); - + enkf_config_node_update_container( config_node , wwct1_node ); enkf_config_node_update_container( config_node , wwct2_node ); enkf_config_node_update_container( config_node , wwct3_node ); @@ -104,24 +99,26 @@ void test_container( ert_test_context_type * test_context ) { enkf_node_type * container = enkf_node_deep_alloc( config_node ); enkf_node_free( container ); } - + enkf_config_node_free( wwct3_node ); enkf_config_node_free( wwct2_node ); - enkf_config_node_free( wwct1_node ); + enkf_config_node_free( wwct1_node ); enkf_config_node_free( config_node ); } int main(int argc , char ** argv) { - const char * config_file = argv[1]; - const char * site_config = NULL; - ert_test_context_type * test_context = ert_test_context_alloc( "ENKF_OBS_FS" , config_file , site_config ); + util_install_signals(); { - testS( test_context ); - test_iget( test_context ); - test_container( test_context ); + const char * config_file = argv[1]; + ert_test_context_type * test_context = ert_test_context_alloc( "ENKF_OBS_FS" , config_file ); + { + testS( test_context ); + test_iget( test_context ); + test_container( test_context ); + } + ert_test_context_free( test_context ); + exit(0); } - ert_test_context_free( test_context ); - exit(0); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tests.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tests.c index 45fdf8d5c3..b317cb42d8 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tests.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tests.c @@ -1,50 +1,62 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_enkf_obs_tests.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_enkf_obs_tests.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <ert/util/test_util.h> + +#include <ert/ecl/ecl_sum.h> +#include <ert/ecl/ecl_grid.h> + #include <ert/enkf/enkf_obs.h> #include <ert/enkf/obs_vector.h> #include <ert/enkf/summary_obs.h> +#include <ert/enkf/ensemble_config.h> + int main(int argc, char ** argv) { - enkf_obs_type * enkf_obs = enkf_obs_alloc(); + history_type * history = NULL; + time_map_type * external_time_map = NULL; + ecl_grid_type * grid = NULL; + ensemble_config_type * ensemble_config = NULL; + ecl_sum_type * refcase = NULL; + + enkf_obs_type * enkf_obs = enkf_obs_alloc(history , external_time_map , grid , refcase , ensemble_config); obs_vector_type * obs_vector = obs_vector_alloc(SUMMARY_OBS, "WWCT", NULL, 2); summary_obs_type * summary_obs1 = summary_obs_alloc( "SummaryKey" , "ObservationKey" , 43.2, 2.0 , AUTO_CORRF_EXP, 42); obs_vector_install_node( obs_vector , 0 , summary_obs1 ); - + summary_obs_type * summary_obs2 = summary_obs_alloc( "SummaryKey2" , "ObservationKey2" , 4.2, 0.1 , AUTO_CORRF_EXP, 42); obs_vector_install_node( obs_vector , 1 , summary_obs2 ); - + obs_vector_type * obs_vector2 = obs_vector_alloc(SUMMARY_OBS, "WWCT2", NULL, 2); summary_obs_type * summary_obs3 = summary_obs_alloc( "SummaryKey" , "ObservationKey" , 43.2, 2.0 , AUTO_CORRF_EXP, 42); obs_vector_install_node( obs_vector2 , 0 , summary_obs3 ); - + summary_obs_type * summary_obs4 = summary_obs_alloc( "SummaryKey2" , "ObservationKey2" , 4.2, 0.1 , AUTO_CORRF_EXP, 42); obs_vector_install_node( obs_vector2 , 1 , summary_obs4 ); - - enkf_obs_add_obs_vector(enkf_obs, "PROP0", obs_vector); - enkf_obs_add_obs_vector(enkf_obs, "PROP", obs_vector2); - + + enkf_obs_add_obs_vector(enkf_obs, obs_vector); + enkf_obs_add_obs_vector(enkf_obs, obs_vector2); + enkf_obs_scale_std(enkf_obs, 3.3); - + enkf_obs_free(enkf_obs); - + exit(0); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tstep_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tstep_list.c deleted file mode 100644 index 73b351dfb8..0000000000 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tstep_list.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_obs_tstep_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. -*/ -#include <stdlib.h> -#include <stdio.h> - -#include <ert/enkf/obs_tstep_list.h> -#include <ert/util/test_util.h> - - -void test_range( ) { - obs_tstep_list_type * tstep_list = obs_tstep_list_alloc(); - - obs_tstep_list_add_range( tstep_list , 10 , 12 ); - test_assert_int_equal( 3, obs_tstep_list_get_size( tstep_list )); - obs_tstep_list_free( tstep_list ); -} - -void test_contains() { - obs_tstep_list_type * tstep_list = obs_tstep_list_alloc(); - - test_assert_false( obs_tstep_list_contains( tstep_list , 0 )); - test_assert_false( obs_tstep_list_contains( tstep_list , 10 )); - test_assert_false( obs_tstep_list_contains( tstep_list , 12 )); - test_assert_false( obs_tstep_list_contains( tstep_list , 15 )); - - obs_tstep_list_add_range( tstep_list , 10 , 12 ); - test_assert_false( obs_tstep_list_contains( tstep_list , 0 )); - test_assert_true( obs_tstep_list_contains( tstep_list , 10 )); - test_assert_true( obs_tstep_list_contains( tstep_list , 12 )); - test_assert_false( obs_tstep_list_contains( tstep_list , 15 )); - - obs_tstep_list_free( tstep_list ); -} - - -int main(int argc , char ** argv) { - obs_tstep_list_type * tstep_list; - - tstep_list = obs_tstep_list_alloc(); - test_assert_true( obs_tstep_list_is_instance( tstep_list )); - test_assert_true( obs_tstep_list_all_active( tstep_list )); - test_assert_int_equal( 0 , obs_tstep_list_get_size( tstep_list )); - - obs_tstep_list_add_tstep( tstep_list , 100 ); - test_assert_int_equal( 1 , obs_tstep_list_get_size( tstep_list )); - test_assert_false( obs_tstep_list_all_active( tstep_list )); - - obs_tstep_list_add_tstep( tstep_list , 101 ); - test_assert_int_equal( 2 , obs_tstep_list_get_size( tstep_list )); - - obs_tstep_list_add_tstep( tstep_list , 101 ); - test_assert_int_equal( 2 , obs_tstep_list_get_size( tstep_list )); - - obs_tstep_list_add_tstep( tstep_list , 1 ); - test_assert_int_equal( 3 , obs_tstep_list_get_size( tstep_list )); - - test_assert_int_equal( 1 , obs_tstep_list_iget( tstep_list , 0 )); - test_assert_int_equal( 100 , obs_tstep_list_iget( tstep_list , 1 )); - test_assert_int_equal( 101 , obs_tstep_list_iget( tstep_list , 2 )); - - test_assert_int_equal( 101 , obs_tstep_list_get_last( tstep_list )); - obs_tstep_list_free( tstep_list ); - - - test_range(); - test_contains(); - exit(0); -} - diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_vector.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_vector.c new file mode 100644 index 0000000000..c2d2a773d2 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_vector.c @@ -0,0 +1,85 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'enkf_obs_vector.c' is part of ERT - Ensemble based + Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#include <stdlib.h> +#include <stdio.h> + +#include <ert/util/test_util.h> +#include <ert/util/type_vector_functions.h> + +#include <ert/enkf/enkf_obs.h> +#include <ert/enkf/ert_test_context.h> +#include <ert/enkf/meas_data.h> +#include <ert/enkf/obs_data.h> +#include <ert/enkf/obs_vector.h> +#include <ert/enkf/summary_obs.h> + + + +void test_create(enkf_config_node_type * config_node ) { + obs_vector_type * obs_vector = obs_vector_alloc( SUMMARY_OBS , "OBS" , config_node , 100 ); + test_assert_true( obs_vector_is_instance( obs_vector )); + { + const int_vector_type * step_list = obs_vector_get_step_list( obs_vector ); + + { + summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0); + obs_vector_install_node( obs_vector , 10 , obs_node ); + test_assert_int_equal( 1 , int_vector_size( step_list )); + test_assert_int_equal( 10 , int_vector_iget( step_list , 0)); + } + + { + summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0); + obs_vector_install_node( obs_vector , 10 , obs_node ); + test_assert_int_equal( 1 , int_vector_size( step_list )); + test_assert_int_equal( 10 , int_vector_iget( step_list , 0)); + } + + { + summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0); + obs_vector_install_node( obs_vector , 5 , obs_node ); + test_assert_int_equal( 2 , int_vector_size( step_list )); + test_assert_int_equal( 5 , int_vector_iget( step_list , 0)); + test_assert_int_equal( 10 , int_vector_iget( step_list , 1)); + } + + { + summary_obs_type * obs_node = summary_obs_alloc( "FOPT" , "FOPT" , 10 , 1 , NULL , 0); + obs_vector_install_node( obs_vector , 15 , obs_node ); + test_assert_int_equal( 3 , int_vector_size( step_list )); + test_assert_int_equal( 5 , int_vector_iget( step_list , 0)); + test_assert_int_equal( 10 , int_vector_iget( step_list , 1)); + test_assert_int_equal( 15 , int_vector_iget( step_list , 2)); + } + } + obs_vector_free( obs_vector ); +} + + + +int main(int argc , char ** argv) { + enkf_config_node_type * config_node = enkf_config_node_alloc_summary("FOPR" , LOAD_FAIL_EXIT); + { + test_create( config_node ); + } + enkf_config_node_free( config_node ); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_vector_fs.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_vector_fs.c index 22a4f8425e..ec00d9f600 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_vector_fs.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_obs_vector_fs.c @@ -1,20 +1,20 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - + Copyright (C) 2014 Statoil ASA, Norway. + The file 'enkf_obs_vector_fs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -25,10 +25,10 @@ #include <ert/enkf/ert_test_context.h> #include <ert/enkf/meas_data.h> #include <ert/enkf/obs_data.h> -#include <ert/enkf/local_obsset.h> #include <ert/enkf/obs_vector.h> #include <ert/util/test_util.h> +#include <ert/util/type_vector_functions.h> void test_valid_obs_vector( enkf_main_type * enkf_main , const char * obs_key) { @@ -36,22 +36,28 @@ void test_valid_obs_vector( enkf_main_type * enkf_main , const char * obs_key) { enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main ); obs_vector_type * obs_vector = enkf_obs_get_vector( enkf_obs , obs_key ); bool_vector_type * active_mask = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true); - + test_assert_true( obs_vector_has_data( obs_vector , active_mask , fs )); bool_vector_free( active_mask ); } +/* + This test will modify the enkf_obs container with invalid data; must + be the last test. +*/ + void test_invalid_obs_vector( enkf_main_type * enkf_main , const char * obs_key) { enkf_fs_type * fs = enkf_main_get_fs(enkf_main); enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main ); obs_vector_type * obs_vector = enkf_obs_get_vector( enkf_obs , obs_key ); bool_vector_type * active_mask = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true); - + test_assert_false( obs_vector_has_data( obs_vector , active_mask , fs )); bool_vector_free( active_mask ); } + void test_container( ert_test_context_type * test_context ) { enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main ); @@ -74,10 +80,16 @@ void test_measure( ert_test_context_type * test_context ) { active_list_type * active_list = active_list_alloc( ); meas_data_type * meas_data_RFT; - for (int i=0; i < enkf_main_get_ensemble_size( enkf_main ); i++) + for (int i=0; i < enkf_main_get_ensemble_size( enkf_main ); i++) int_vector_append( ens_active_list , i ); - meas_data_RFT = meas_data_alloc( ens_active_list ); - + + { + bool_vector_type * ens_mask; + ens_mask = int_vector_alloc_mask( ens_active_list ); + meas_data_RFT = meas_data_alloc( ens_mask ); + bool_vector_free( ens_mask ); + } + obs_vector_measure( rft_obs , fs , FORECAST , 20 , ens_active_list , meas_data_RFT , active_list ); int_vector_free( ens_active_list ); @@ -90,14 +102,14 @@ void test_measure( ert_test_context_type * test_context ) { int main(int argc , char ** argv) { const char * config_file = argv[1]; - ert_test_context_type * context = ert_test_context_alloc( "OBS_VECTOR_FS" , config_file , NULL); + ert_test_context_type * context = ert_test_context_alloc( "OBS_VECTOR_FS" , config_file); enkf_main_type * enkf_main = ert_test_context_get_main( context ); - + { test_valid_obs_vector( enkf_main , "WWCT:OP_3"); - test_invalid_obs_vector( enkf_main , "GOPT:OP"); test_container( context ); test_measure( context ); + test_invalid_obs_vector( enkf_main , "GOPT:OP"); } ert_test_context_free( context ); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_data_fs.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_data_fs.c index 52dc4a776a..29806595f6 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_data_fs.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_data_fs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_plot_data_fs.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_plot_data_fs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -49,7 +49,7 @@ void test_load_GEN_KW( enkf_main_type * enkf_main , const char * key , const cha test_assert_true( enkf_plot_tvector_iget_active( plot_vector , 10 )); test_assert_true( enkf_plot_tvector_iget_active( plot_vector , 20 )); test_assert_true( enkf_plot_tvector_iget_active( plot_vector , 30 )); - + test_assert_false( enkf_plot_tvector_iget_active( plot_vector , 1 )); test_assert_false( enkf_plot_tvector_iget_active( plot_vector , 11 )); test_assert_false( enkf_plot_tvector_iget_active( plot_vector , 21 )); @@ -66,7 +66,7 @@ void test_load_summary( enkf_main_type * enkf_main , const char * summary_key) { ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config( enkf_main ); const enkf_config_node_type * config_node = ensemble_config_get_node( ensemble_config , summary_key ); enkf_plot_data_type * plot_data = enkf_plot_data_alloc( config_node ); - + { enkf_fs_type * enkf_fs = enkf_main_mount_alt_fs( enkf_main , "enkf" , true ); enkf_plot_data_load( plot_data , enkf_fs , NULL , FORECAST , NULL ); @@ -79,7 +79,7 @@ void test_load_summary( enkf_main_type * enkf_main , const char * summary_key) { } enkf_fs_decref( enkf_fs ); } - + { enkf_fs_type * enkf_fs = enkf_main_mount_alt_fs( enkf_main , "default" , true ); enkf_plot_data_load( plot_data , enkf_fs , NULL , FORECAST , NULL ); @@ -104,20 +104,22 @@ void test_load_summary( enkf_main_type * enkf_main , const char * summary_key) { int main(int argc, char ** argv) { - const char * config_file = argv[1]; - test_work_area_type * work_area = test_work_area_alloc( "enkf_main_fs" ); - char * model_config; - util_alloc_file_components( config_file , NULL , &model_config , NULL); - test_work_area_set_store( work_area , true ); - test_work_area_copy_parent_content( work_area , config_file ); + util_install_signals(); { - const char * site_config = "/project/res/etc/ERT/site-config"; - enkf_main_type * enkf_main = enkf_main_bootstrap( site_config , model_config , false , false ); - - test_load_summary(enkf_main , "WWCT:OP_3"); - test_load_GEN_KW( enkf_main , "MULTFLT" , "F3"); - enkf_main_free( enkf_main ); - } - test_work_area_free( work_area ); - exit(0); + const char * config_file = argv[1]; + test_work_area_type * work_area = test_work_area_alloc( "enkf_main_fs" ); + char * model_config; + util_alloc_file_components( config_file , NULL , &model_config , NULL); + test_work_area_set_store( work_area , true ); + test_work_area_copy_parent_content( work_area , config_file ); + { + enkf_main_type * enkf_main = enkf_main_bootstrap( model_config , false , false ); + + test_load_summary(enkf_main , "WWCT:OP_3"); + test_load_GEN_KW( enkf_main , "MULTFLT" , "F3"); + enkf_main_free( enkf_main ); + } + test_work_area_free( work_area ); + exit(0); + } } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gen_kw_fs.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gen_kw_fs.c index 6b43be4c09..749d127dac 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gen_kw_fs.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gen_kw_fs.c @@ -29,7 +29,7 @@ void test_load(const char * config_file) { - ert_test_context_type * test_context = ert_test_context_alloc( "GEN_KW" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc( "GEN_KW" , config_file ); enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); int ens_size = enkf_main_get_ensemble_size( enkf_main ); stringlist_type * param_list = stringlist_alloc_new(); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gendata_fs.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gendata_fs.c index 8d576e935e..3b87bc0421 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gendata_fs.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_plot_gendata_fs.c @@ -86,7 +86,7 @@ void test_gendata( enkf_main_type * enkf_main , const char * obs_key , int repor int main( int argc , char ** argv) { const char * config_file = argv[1]; util_install_signals(); - ert_test_context_type * test_context = ert_test_context_alloc("GENDATA" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc("GENDATA" , config_file ); enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); test_gendata( enkf_main , "GEN_TIMESHIFT" , 60); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c index ef17e90610..7abe9aac96 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c @@ -26,7 +26,7 @@ #include <ert/util/stringlist.h> #include <ert/util/arg_pack.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/ecl/ecl_sum.h> diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c index fa2fe1d285..507cfb5c0c 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c @@ -22,19 +22,24 @@ #include <ert/util/test_util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/enkf/ert_report_list.h> int main(int argc , char ** argv) { - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); ert_report_list_type * report_list = ert_report_list_alloc( NULL , NULL ); test_assert_not_NULL( report_list ); ert_report_list_add_config_items( config ); - test_assert_true( config_parse( config , argv[1] , "--" , NULL, NULL , CONFIG_UNRECOGNIZED_IGNORE , true )); - ert_report_list_init( report_list , config , NULL); - + { + config_content_type * content = config_parse( config , argv[1] , "--" , NULL, NULL , CONFIG_UNRECOGNIZED_IGNORE , true ); + test_assert_true( config_content_is_valid(content) ); + ert_report_list_init( report_list , content , NULL); + config_content_free( content ); + } + test_assert_int_equal( 167 , ert_report_list_get_latex_timeout( report_list )); test_assert_true( ert_report_list_get_init_large_report( report_list )); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c index 5a5b19cfef..47013b22ab 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c @@ -102,14 +102,14 @@ int main(int argc , char ** argv) { test_work_area_type * work_area = test_work_area_alloc("enkf-rng-2" ); test_work_area_copy_directory_content( work_area , config_path ); { - enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , true , true ); + enkf_main_type * enkf_main = enkf_main_bootstrap( config_file , true , true ); enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); rand1 = enkf_state_get_random( state ); enkf_main_free( enkf_main ); } { - enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , true , true ); + enkf_main_type * enkf_main = enkf_main_bootstrap( config_file , true , true ); enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); rand2 = enkf_state_get_random( state ); enkf_main_free( enkf_main ); @@ -117,7 +117,7 @@ int main(int argc , char ** argv) { test_assert_uint_equal( rand1 , rand2 ); { - enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , true , true ); + enkf_main_type * enkf_main = enkf_main_bootstrap( config_file , true , true ); enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); rand2 = enkf_state_get_random( state ); enkf_main_free( enkf_main ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c index d0083cb0bf..6047cd3ab6 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_runpath_list.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_runpath_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -34,9 +34,9 @@ void * add_pathlist( void * arg ) { runpath_list_type * list = arg_pack_iget_ptr( arg_pack , 0 ); int offset = arg_pack_iget_int( arg_pack , 1 ); int bs = arg_pack_iget_int( arg_pack , 2 ); - + int i; - for (i=0; i < bs; i++) + for (i=0; i < bs; i++) runpath_list_add( list , i + offset , 0, "Path" , "Basename"); return NULL; @@ -54,7 +54,7 @@ void test_runpath_list() { runpath_list_add( list , 3 , 1, "path" , "base"); runpath_list_add( list , 2 , 1, "path" , "base"); runpath_list_add( list , 1 , 1, "path" , "base"); - + test_assert_int_equal( runpath_list_size( list ) , 6 ); test_assert_int_equal( runpath_list_iget_iens( list , 0 ) , 3 ); test_assert_int_equal( runpath_list_iget_iens( list , 2 ) , 1 ); @@ -80,7 +80,7 @@ void test_runpath_list() { const int threads = 100; thread_pool_type * tp = thread_pool_alloc( threads , true ); int it; - + for (it = 0; it < threads; it++) { int iens_offset = it * block_size; arg_pack_type * arg_pack = arg_pack_alloc(); @@ -88,7 +88,7 @@ void test_runpath_list() { arg_pack_append_ptr( arg_pack , list ); arg_pack_append_int( arg_pack , iens_offset ); arg_pack_append_int( arg_pack , block_size ); - + thread_pool_add_job( tp , add_pathlist , arg_pack ); } thread_pool_join( tp ); @@ -99,7 +99,7 @@ void test_runpath_list() { for (iens = 0; iens < block_size * threads; iens++) test_assert_int_equal( runpath_list_iget_iens( list , iens ) , iens ); } - + { test_work_area_type * work_area = test_work_area_alloc("enkf_runpath_list" ); runpath_list_fprintf( list ); @@ -127,10 +127,10 @@ void test_runpath_list() { void test_config( const char * config_file ) { - ert_test_context_type * test_context = ert_test_context_alloc( "RUNPATH_FILE" , config_file , NULL ); + ert_test_context_type * test_context = ert_test_context_alloc( "RUNPATH_FILE" , config_file ); enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main ); - + ert_test_context_run_worklow( test_context , "ARGECHO_WF"); { FILE * stream = util_fopen("runpath_list.txt" , "r"); @@ -139,7 +139,7 @@ void test_config( const char * config_file ) { fclose( stream ); test_assert_string_equal( runpath_file , qc_module_get_runpath_list_file( qc_module )); } - + ert_test_context_free( test_context ); } @@ -153,9 +153,12 @@ void test_filename() { } int main(int argc , char ** argv) { - test_runpath_list(); - test_config( argv[1] ); - test_filename(); - exit(0); + util_install_signals(); + { + test_runpath_list(); + test_config( argv[1] ); + test_filename(); + exit(0); + } } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_scale_correlated_std.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_scale_correlated_std.c new file mode 100644 index 0000000000..59fd2aa401 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_scale_correlated_std.c @@ -0,0 +1,61 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'enkf_scale_correlated_std.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include <ert/util/test_util.h> +#include <ert/enkf/ert_test_context.h> + +#include <ert/util/util.h> +#include <ert/util/string_util.h> + +#include <ert/enkf/enkf_main.h> +#include <ert/enkf/enkf_main_jobs.h> + + + + +void test_scaling( ert_test_context_type * test_context , int nobs, const char** obs_keys ) { + stringlist_type * args = stringlist_alloc_new(); + for (int iobs=0; iobs < nobs; iobs++) + stringlist_append_ref( args , obs_keys[iobs]); + + test_assert_true( ert_test_context_run_worklow_job( test_context , "STD_SCALE" , args) ); + stringlist_free( args ); +} + + + +int main(int argc , const char ** argv) { + const char * config_file = argv[1]; + const char * workflow_job_file = argv[2]; + enkf_main_install_SIGNALS(); + { + ert_test_context_type * test_context = ert_test_context_alloc("std_scale_test" , config_file); + + ert_test_context_install_workflow_job( test_context , "STD_SCALE" , workflow_job_file ); + test_scaling(test_context , 1 , ( const char *[1] ) {"WWCT:OP_1"}); + test_scaling(test_context , 2 , ( const char *[2] ) {"WWCT:OP_1", "WWCT:OP_2"}); + test_scaling(test_context , 8 , ( const char *[8] ) {"RPR2_1", "RPR2_2","RPR2_3","RPR2_4","RPR2_5","RPR2_6","RPR2_7","RPR2_8"}); + + ert_test_context_free( test_context ); + } + exit(0); +} diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_select_case_job.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_select_case_job.c index 856239ce4c..20e19df57b 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_select_case_job.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_select_case_job.c @@ -38,7 +38,7 @@ int main(int argc , const char ** argv) { const char * config_file = argv[1]; const char * select_case_job = argv[2]; - ert_test_context_type * test_context = ert_test_context_alloc("SELECT_CASE" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("SELECT_CASE" , config_file ); test_assert_true( ert_test_context_install_workflow_job( test_context , "SELECT_CASE" , select_case_job)); { diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c index af40c8655c..1c8579cf43 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_site_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_site_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -28,7 +28,8 @@ #include <ert/util/arg_pack.h> #include <ert/util/test_work_area.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> #include <ert/ecl/ecl_sum.h> @@ -52,17 +53,23 @@ void test_empty() { void test_init(const char * config_file) { site_config_type * site_config = site_config_alloc_empty(); - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); + config_content_type * content; site_config_add_config_items( config , true ); - if (!config_parse(config , config_file , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , true)) { - config_fprintf_errors( config , true , stdout ); - test_error_exit("Parsing site config file:%s failed \n",config_file ); + content = config_parse(config , config_file , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , true); + if (!config_content_is_valid(content)) { + config_error_type * errors = config_content_get_errors( content ); + config_error_fprintf( errors , true , stderr ); + test_assert_true( false ); } - if (!site_config_init( site_config , config )) - test_error_exit("Loading site_config from config failed\n"); - + if (!site_config_init( site_config , content )) { + printf("Loading site_config from config failed\n"); + test_assert_true( false ); + } + + config_content_free( content ); config_free( config ); site_config_free( site_config ); } @@ -73,7 +80,7 @@ void test_job_script() { { site_config_type * site_config = site_config_alloc_empty(); test_assert_false( site_config_has_job_script( site_config )); - + test_assert_false( site_config_set_job_script( site_config , "/does/not/exist" )); test_assert_false( site_config_has_job_script( site_config )); @@ -104,10 +111,12 @@ void test_job_script() { int main(int argc , char ** argv) { const char * site_config_file = argv[1]; + util_install_signals(); + test_empty(); test_init( site_config_file ); test_job_script(); - + exit(0); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_state_manual_load_test.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_state_manual_load_test.c index b8a8feb7c3..204439adf8 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_state_manual_load_test.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_state_manual_load_test.c @@ -67,7 +67,7 @@ int main(int argc , char ** argv) { test_work_area_copy_directory_content( work_area , root_path ); { bool strict = true; - enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main_type * enkf_main = enkf_main_bootstrap( config_file , strict , true ); test_assert_int_equal( 0 , test_load_manually_to_new_case(enkf_main)); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_state_report_step_compatible.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_state_report_step_compatible.c index 2027cc30a0..e44a3b976f 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_state_report_step_compatible.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_state_report_step_compatible.c @@ -61,7 +61,7 @@ int main(int argc , char ** argv) { test_work_area_copy_directory_content( work_area , root_path ); bool strict = true; - enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main_type * enkf_main = enkf_main_bootstrap( config_file , strict , true ); test_assert_bool_equal(check_compatible , check_ecl_sum_compatible(enkf_main)); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_state_skip_summary_load_test.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_state_skip_summary_load_test.c index 05042a51ac..cca425a95f 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_state_skip_summary_load_test.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_state_skip_summary_load_test.c @@ -62,7 +62,7 @@ int main(int argc , char ** argv) { test_work_area_copy_directory_content( work_area , root_path ); bool strict = true; - enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true ); + enkf_main_type * enkf_main = enkf_main_bootstrap( config_file , strict , true ); test_assert_true( check_ecl_sum_loaded(enkf_main) ); diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c index fa34167b6f..bbeb67ffa8 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_time_map.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_time_map.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -26,6 +26,7 @@ #include <ert/util/thread_pool.h> #include <ert/util/arg_pack.h> #include <ert/util/vector.h> +#include <ert/util/test_work_area.h> #include <ert/ecl/ecl_sum.h> @@ -39,10 +40,10 @@ void ecl_test( const char * ecl_case ) { time_t start_time = ecl_sum_get_start_time( ecl_sum ); time_t end_time = ecl_sum_get_end_time( ecl_sum ); time_map_type * ecl_map = time_map_alloc( ); - + test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) ); test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) ); - + test_assert_time_t_equal( time_map_get_start_time( ecl_map ) , start_time ); test_assert_time_t_equal( time_map_get_end_time( ecl_map ) , end_time ); test_assert_double_equal( time_map_get_end_days( ecl_map ) , ecl_sum_get_sim_length( ecl_sum )); @@ -51,7 +52,7 @@ void ecl_test( const char * ecl_case ) { time_map_update( ecl_map , 1 , 256 ); time_map_set_strict( ecl_map , false ); test_assert_false( time_map_summary_update( ecl_map , ecl_sum )); - + time_map_free( ecl_map ); ecl_sum_free( ecl_sum ); } @@ -61,7 +62,7 @@ static void map_update( void * arg ) { vector_type * arg_vector = vector_safe_cast( arg ); time_map_type * tmap = vector_iget( arg_vector , 0 ); ecl_sum_type * sum = vector_iget( arg_vector , 1 ); - + time_map_summary_update( tmap , sum ); } @@ -81,7 +82,7 @@ void test_inconsistent_summary( const char * case1, const char * case2) { test_assert_util_abort("time_map_summary_update_abort" , map_update , arg); vector_free( arg ); } - + time_map_free( ecl_map ); ecl_sum_free( ecl_sum1 ); ecl_sum_free( ecl_sum2 ); @@ -118,26 +119,47 @@ void test_refcase( const char * refcase_name , const char * case1, const char * time_map_attach_refcase( ecl_map , refcase ); test_assert_true( time_map_summary_update( ecl_map , ecl_sum1 ) ); } - + { time_map_type * ecl_map = time_map_alloc( ); - + time_map_set_strict( ecl_map , false ); time_map_attach_refcase( ecl_map , refcase ); - + test_assert_false( time_map_summary_update( ecl_map , ecl_sum2 ) ); test_assert_int_equal( 25 , time_map_get_size( ecl_map )); test_assert_true( time_map_summary_update( ecl_map , ecl_sum1 ) ); test_assert_int_equal( 63 , time_map_get_size( ecl_map )); } - + { time_map_type * ecl_map = time_map_alloc( ); test_assert_true( time_map_summary_update( ecl_map , ecl_sum2 ) ); test_assert_false( time_map_attach_refcase( ecl_map , refcase )); } - - + + + { + test_work_area_type * work_area = test_work_area_alloc( "time_map/attach_short_refcase"); + { + time_map_type * ecl_map = time_map_alloc( ); + test_assert_true( time_map_summary_update( ecl_map , refcase ) ); + test_assert_true( time_map_update( ecl_map , ecl_sum_get_last_report_step( refcase ) + 1 , ecl_sum_get_end_time( refcase ) + 100 )); + test_assert_true( time_map_update( ecl_map , ecl_sum_get_last_report_step( refcase ) + 2 , ecl_sum_get_end_time( refcase ) + 200 )); + test_assert_true( time_map_update( ecl_map , ecl_sum_get_last_report_step( refcase ) + 3 , ecl_sum_get_end_time( refcase ) + 300 )); + time_map_fwrite( ecl_map , "time_map"); + time_map_free( ecl_map ); + } + { + time_map_type * ecl_map = time_map_alloc( ); + time_map_fread(ecl_map , "time_map"); + test_assert_true( time_map_attach_refcase( ecl_map , refcase ) ); + time_map_free( ecl_map ); + } + test_work_area_free( work_area ); + } + + ecl_sum_free( refcase ); ecl_sum_free( ecl_sum1 ); @@ -152,7 +174,7 @@ void test_index_map( const char * case1, const char * case2 , const char * case3 ecl_sum_type * ecl_sum2 = ecl_sum_fread_alloc_case( case2 , ":"); ecl_sum_type * ecl_sum3 = ecl_sum_fread_alloc_case( case3 , ":"); ecl_sum_type * ecl_sum4 = ecl_sum_fread_alloc_case( case4 , ":"); - + time_map_type * ecl_map = time_map_alloc( ); { @@ -167,7 +189,7 @@ void test_index_map( const char * case1, const char * case2 , const char * case3 int i; for (i=0; i < int_vector_size( index_map ); i++) test_assert_int_equal( i , int_vector_iget( index_map , i )); - + test_assert_int_equal( int_vector_size( index_map ) , ecl_sum_get_last_report_step( ecl_sum1) + 1); int_vector_free( index_map ); } @@ -183,7 +205,7 @@ void test_index_map( const char * case1, const char * case2 , const char * case3 int_vector_free( index_map ); } - + /* case3 has an extra tstep in the middle, and ends prematurely */ test_assert_false( time_map_summary_update( ecl_map , ecl_sum3 ) ); { @@ -203,8 +225,8 @@ void test_index_map( const char * case1, const char * case2 , const char * case3 test_assert_util_abort( "time_map_alloc_index_map" , alloc_index_map , arg); arg_pack_free( arg ); } - - + + time_map_free( ecl_map ); ecl_sum_free( ecl_sum1 ); @@ -218,7 +240,7 @@ void simple_test() { time_map_type * time_map = time_map_alloc( ); test_work_area_type * work_area = test_work_area_alloc("enkf_time_map" ); const char * mapfile = "map"; - + time_map_set_strict( time_map , false ); test_assert_true( time_map_update( time_map , 0 , 100 ) ); test_assert_true( time_map_update( time_map , 1 , 200 ) ); @@ -239,7 +261,7 @@ void simple_test() { time_t mtime1 = util_file_mtime( mapfile ); sleep(2); time_map_fwrite( time_map , mapfile); - + test_assert_time_t_equal( mtime1 , util_file_mtime( mapfile ) ); time_map_update( time_map , 2 , 300 ); time_map_fwrite( time_map , mapfile); @@ -251,7 +273,7 @@ void simple_test() { static void simple_update(void * arg) { time_map_type * tmap = time_map_safe_cast( arg ); - + time_map_update( tmap , 0 , 101 ); } @@ -259,7 +281,7 @@ static void simple_update(void * arg) { void simple_test_inconsistent() { time_map_type * time_map = time_map_alloc( ); - + test_assert_true( time_map_update( time_map , 0 , 100 ) ); time_map_set_strict( time_map , false ); test_assert_false( time_map_update( time_map , 0 , 101 ) ); @@ -291,15 +313,15 @@ void thread_test() { { int pool_size = 1000; thread_pool_type * tp = thread_pool_alloc( pool_size/2 , true ); - + thread_pool_add_job( tp , update_time_map , time_map ); - + thread_pool_join(tp); thread_pool_free(tp); } { int i; - for (i=0; i < MAP_SIZE; i++) + for (i=0; i < MAP_SIZE; i++) test_assert_true( time_map_iget( time_map , i ) == i ); } time_map_free( time_map ); @@ -315,11 +337,11 @@ void test_read_only() { test_assert_true( time_map_is_instance( tm )); test_assert_true( time_map_is_strict( tm )); test_assert_false( time_map_is_readonly( tm )); - + time_map_update( tm , 0 , 0 ); time_map_update( tm , 1 , 10 ); time_map_update( tm , 2 , 20 ); - + time_map_fwrite( tm , "case/files/time-map" ); time_map_free( tm ); } @@ -352,7 +374,7 @@ void test_read_only() { int main(int argc , char ** argv) { - enkf_main_install_SIGNALS(); + enkf_main_install_SIGNALS(); ert_log_init_log(0 , NULL , false ); // Make sure there will be no logging. if (argc == 1) { @@ -365,9 +387,9 @@ int main(int argc , char ** argv) { test_index_map(argv[1] , argv[2] , argv[3] , argv[4]); test_refcase( argv[1] , argv[1] , argv[2] , argv[3] , argv[4]); } - - test_read_only(); - + + test_read_only(); + exit(0); } diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_workflow_job_test.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_workflow_job_test.c index e0a4011f73..b483fe30ea 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/enkf_workflow_job_test.c +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_workflow_job_test.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - + Copyright (C) 2013 Statoil ASA, Norway. + The file 'enkf_workflow_job_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -31,7 +31,7 @@ ert_test_context_type * create_context( const char * config_file, const char * name ) { - ert_test_context_type * test_context = ert_test_context_alloc(name , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc(name , config_file); test_assert_not_NULL(test_context); return test_context; } @@ -60,7 +60,7 @@ void test_init_case_job(ert_test_context_type * test_context, const char * job_n { enkf_fs_type * cur_fs = enkf_main_mount_alt_fs( enkf_main , "new_current_case" , true ); enkf_main_select_fs(enkf_main, "new_current_case"); - + test_assert_ptr_not_equal(cur_fs , enkf_main_get_fs( enkf_main )); stringlist_append_copy( args, "default"); //case to init from @@ -194,21 +194,21 @@ void test_rank_realizations_on_data_job(ert_test_context_type * test_context , c void test_export_ranking(ert_test_context_type * test_context , const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , job_name , job_file ); - + stringlist_append_copy( args , "NameOfDataRanking"); stringlist_append_copy( args , "/tmp/fileToSaveDataRankingIn.txt"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); - + stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking1"); stringlist_append_copy( args , "/tmp/fileToSaveObservationRankingIn1.txt"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); - + stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking6"); stringlist_append_copy( args , "/tmp/fileToSaveObservationRankingIn6.txt"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); - + stringlist_free( args ); } @@ -216,17 +216,17 @@ void test_export_ranking(ert_test_context_type * test_context , const char * job void test_init_misfit_table(ert_test_context_type * test_context , const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , job_name , job_file ); - + enkf_main_type * enkf_main = ert_test_context_get_main(test_context); enkf_fs_type * fs = enkf_main_get_fs(enkf_main); - + misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs ); test_assert_false(misfit_ensemble_initialized(misfit_ensemble)); - + test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); - + test_assert_true(misfit_ensemble_initialized(misfit_ensemble)); - + stringlist_free( args ); } @@ -405,7 +405,7 @@ void test_export_runpath_files(const char * config_file, { int_vector_type * iens_values = int_vector_alloc(1,0); - int_vector_init_range(iens_values, 0, 24, 1); + int_vector_init_range(iens_values, 0, 25, 1); int_vector_type * iter_values = int_vector_alloc(1,0); test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values); @@ -461,7 +461,7 @@ void test_export_runpath_files(const char * config_file, int main(int argc , const char ** argv) { enkf_main_install_SIGNALS(); - + const char * config_file = argv[1]; const char * config_file_iterations = argv[2]; const char * job_file_create_case = argv[3]; diff --git a/ThirdParty/Ert/devel/libenkf/tests/gen_kw_logarithmic_test.c b/ThirdParty/Ert/devel/libenkf/tests/gen_kw_logarithmic_test.c new file mode 100644 index 0000000000..2747b91a2c --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/gen_kw_logarithmic_test.c @@ -0,0 +1,110 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'gen_kw_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include <ert/util/test_util.h> +#include <ert/enkf/ert_test_context.h> +#include <ert/util/util.h> +#include <ert/util/stringlist.h> + +#include <ert/ecl/fortio.h> +#include <ert/util/type_macros.h> +#include <ert/ecl/ecl_endian_flip.h> + +#include <ert/enkf/enkf_main.h> +#include <ert/enkf/enkf_node.h> +#include <ert/enkf/gen_kw.h> +#include <ert/enkf/enkf_state.h> +#include <ert/enkf/run_arg.h> + + + +void test_write_gen_kw_export_file(enkf_main_type * enkf_main) +{ + enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 ); + test_assert_not_NULL(state); + enkf_node_type * enkf_node = enkf_state_get_node( state , "MULTFLT" ); + enkf_node_type * enkf_node2 = enkf_state_get_node( state , "MULTFLT2" ); + test_assert_not_NULL(enkf_node); + test_assert_not_NULL(enkf_node2); + test_assert_true(enkf_node_get_impl_type(enkf_node) == GEN_KW); + test_assert_true(enkf_node_get_impl_type(enkf_node2) == GEN_KW); + + gen_kw_type * gen_kw = enkf_node_value_ptr(enkf_node); + gen_kw_type * gen_kw2 = enkf_node_value_ptr(enkf_node2); + + + { + rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); + const enkf_config_node_type * config = enkf_node_get_config(enkf_node); + const int data_size = enkf_config_node_get_data_size( config, 0 ); + const double mean = 0.0; /* Mean and std are hardcoded - the variability should be in the transformation. */ + const double std = 1.0; + + for (int i=0; i < data_size; ++i) { + double random_number = enkf_util_rand_normal(mean , std , rng); + gen_kw_data_iset(gen_kw, i, random_number); + gen_kw_data_iset(gen_kw2, i, random_number); + } + + rng_free(rng); + } + + + { + enkf_fs_type * init_fs = enkf_main_get_fs( enkf_main ); + run_arg_type * run_arg = run_arg_alloc_INIT_ONLY( init_fs , 0 ,0 , "simulations/run0"); + enkf_state_ecl_write(state, run_arg , init_fs); + test_assert_true(util_file_exists("simulations/run0/parameters.txt")); + run_arg_free( run_arg ); + } + + + { + int buffer_size = 0; + char * file_content = util_fread_alloc_file_content("simulations/run0/parameters.txt", &buffer_size); + + stringlist_type * token_list = stringlist_alloc_from_split(file_content, " \n"); + double value = stringlist_iget_as_double(token_list, 5, NULL); + + test_assert_true(value > 0.0); //Verify precision + test_assert_true(NULL != strstr(file_content, "LOG10_")); //Verify log entry + + stringlist_free(token_list); + free(file_content); + } +} + + + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + ert_test_context_type * test_context = ert_test_context_alloc("gen_kw_logarithmic_test" , config_file ); + enkf_main_type * enkf_main = ert_test_context_get_main(test_context); + + test_assert_not_NULL(enkf_main); + + test_write_gen_kw_export_file(enkf_main); + + ert_test_context_free( test_context ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/gen_kw_test.c b/ThirdParty/Ert/devel/libenkf/tests/gen_kw_test.c index 0512ba60e4..126ea18987 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/gen_kw_test.c +++ b/ThirdParty/Ert/devel/libenkf/tests/gen_kw_test.c @@ -23,6 +23,7 @@ #include <ert/util/test_util.h> #include <ert/enkf/ert_test_context.h> #include <ert/util/util.h> +#include <ert/util/vector.h> #include <ert/ecl/fortio.h> #include <ert/util/type_macros.h> @@ -32,6 +33,7 @@ #include <ert/enkf/enkf_node.h> #include <ert/enkf/enkf_state.h> #include <ert/enkf/run_arg.h> +#include <ert/enkf/gen_kw_config.h> @@ -63,6 +65,7 @@ void test_write_gen_kw_export_file(enkf_main_type * enkf_main) run_arg_type * run_arg = run_arg_alloc_INIT_ONLY( init_fs , 0 ,0 , "simulations/run0"); test_assert_not_NULL(state); enkf_node_type * enkf_node = enkf_state_get_node( state , "MULTFLT" ); + test_assert_not_NULL(enkf_node); const enkf_config_node_type * config_node = enkf_node_get_config(enkf_node); test_assert_not_NULL(config_node); @@ -75,14 +78,52 @@ void test_write_gen_kw_export_file(enkf_main_type * enkf_main) } + +static void read_erroneous_gen_kw_file( void * arg) { + vector_type * arg_vector = vector_safe_cast( arg ); + gen_kw_config_type * gen_kw_config = vector_iget( arg_vector, 0 ); + const char * filename = vector_iget( arg, 1 ); + gen_kw_config_set_parameter_file(gen_kw_config, filename); +} + + +void test_read_erroneous_gen_kw_file() { + const char * parameter_filename = "MULTFLT_with_errors.txt"; + const char * tmpl_filename = "MULTFLT.tmpl"; + + { + FILE * stream = util_fopen(parameter_filename, "w"); + const char * data = util_alloc_sprintf("MULTFLT1 NORMAL 0\nMULTFLT2 RAW\nMULTFLT3 NORMAL 0"); + util_fprintf_string(data, 30, true, stream); + util_fclose(stream); + + FILE * tmpl_stream = util_fopen(tmpl_filename, "w"); + const char * tmpl_data = util_alloc_sprintf("<MULTFLT1> <MULTFLT2> <MULTFLT3>\n"); + util_fprintf_string(tmpl_data, 30, true, tmpl_stream); + util_fclose(tmpl_stream); + } + + gen_kw_config_type * gen_kw_config = gen_kw_config_alloc_empty("MULTFLT", "<%s>"); + vector_type * arg = vector_alloc_new(); + vector_append_ref( arg , gen_kw_config ); + vector_append_ref(arg, parameter_filename); + + test_assert_util_abort("arg_pack_fscanf", read_erroneous_gen_kw_file, arg); + + vector_free(arg); + gen_kw_config_free(gen_kw_config); +} + + int main(int argc , char ** argv) { const char * config_file = argv[1]; - ert_test_context_type * test_context = ert_test_context_alloc("gen_kw_test" , config_file , NULL); + ert_test_context_type * test_context = ert_test_context_alloc("gen_kw_test" , config_file ); enkf_main_type * enkf_main = ert_test_context_get_main(test_context); test_assert_not_NULL(enkf_main); test_write_gen_kw_export_file(enkf_main); test_assert_util_abort("gen_kw_ecl_write", test_send_fortio_to_gen_kw_ecl_write, enkf_main); + test_read_erroneous_gen_kw_file(); ert_test_context_free( test_context ); exit(0); diff --git a/ThirdParty/Ert/devel/libenkf/tests/obs_vector_tests.c b/ThirdParty/Ert/devel/libenkf/tests/obs_vector_tests.c index 17064c4c6b..33485d7c0d 100644 --- a/ThirdParty/Ert/devel/libenkf/tests/obs_vector_tests.c +++ b/ThirdParty/Ert/devel/libenkf/tests/obs_vector_tests.c @@ -32,20 +32,26 @@ bool alloc_strippedparameters_noerrors() { /*******Summary obs tests*******************/ bool scale_std_summary_nodata_no_errors() { obs_vector_type * obs_vector = obs_vector_alloc(SUMMARY_OBS, "WHAT", NULL, 0); - obs_vector_scale_std(obs_vector, 2.0); + local_obsdata_node_type * local_node = obs_vector_alloc_local_node( obs_vector ); + obs_vector_scale_std(obs_vector, local_node , 2.0); obs_vector_free(obs_vector); + local_obsdata_node_free( local_node ); return true; } bool scale_std_summarysingleobservation_no_errors() { obs_vector_type * obs_vector = obs_vector_alloc(SUMMARY_OBS, "WHAT", NULL, 1); - summary_obs_type * summary_obs = summary_obs_alloc("SummaryKey", "ObservationKey", 43.2, 2.0, AUTO_CORRF_EXP, 42); obs_vector_install_node(obs_vector, 0, summary_obs); - test_assert_double_equal(2.0, summary_obs_get_std(summary_obs)); - obs_vector_scale_std(obs_vector, 2.0); - test_assert_double_equal(4.0, summary_obs_get_std(summary_obs)); + test_assert_double_equal(1.0, summary_obs_get_std_scaling(summary_obs)); + + { + local_obsdata_node_type * local_node = obs_vector_alloc_local_node( obs_vector ); + obs_vector_scale_std(obs_vector, local_node , 2.0); + local_obsdata_node_free( local_node ); + } + test_assert_double_equal(2.0, summary_obs_get_std_scaling(summary_obs)); obs_vector_free(obs_vector); return true; @@ -72,12 +78,14 @@ bool scale_std_summarymanyobservations_no_errors() { } test_assert_bool_equal(num_observations, obs_vector_get_num_active(obs_vector)); - - obs_vector_scale_std(obs_vector, scaling_factor); - + { + local_obsdata_node_type * local_node = obs_vector_alloc_local_node( obs_vector ); + obs_vector_scale_std(obs_vector, local_node , scaling_factor); + local_obsdata_node_free( local_node ); + } for (int i = 0; i < num_observations; i++) { summary_obs_type * after_scale = observations[i]; - test_assert_double_equal(i * scaling_factor, summary_obs_get_std(after_scale)); + test_assert_double_equal(scaling_factor, summary_obs_get_std_scaling(after_scale)); } obs_vector_free(obs_vector); @@ -88,7 +96,9 @@ bool scale_std_summarymanyobservations_no_errors() { bool scale_std_block_nodata_no_errors() { obs_vector_type * obs_vector = obs_vector_alloc(BLOCK_OBS, "WHAT", NULL, 0); - obs_vector_scale_std(obs_vector, 2.0); + local_obsdata_node_type * local_node = obs_vector_alloc_local_node( obs_vector ); + obs_vector_scale_std(obs_vector, local_node , 2.0); + local_obsdata_node_free( local_node ); obs_vector_free(obs_vector); return true; } @@ -149,14 +159,19 @@ bool scale_std_block100observations_no_errors() { } } - obs_vector_scale_std(obs_vector, scale_factor); + { + local_obsdata_node_type * local_node = obs_vector_alloc_local_node( obs_vector ); + obs_vector_scale_std(obs_vector, local_node , scale_factor); + local_obsdata_node_free( local_node ); + } for (int i = 0; i < num_observations; i++) { for (int point_nr = 0; point_nr < num_points; point_nr++) { double value, std; block_obs_iget(observations[i], point_nr, &value, &std); test_assert_double_equal(obs_value, value); - test_assert_double_equal(obs_std * scale_factor, std); + test_assert_double_equal(obs_std , std); + test_assert_double_equal(scale_factor , block_obs_iget_std_scaling( observations[i] , point_nr)); } } @@ -169,8 +184,10 @@ bool scale_std_block100observations_no_errors() { bool scale_std_gen_nodata_no_errors() { obs_vector_type * obs_vector = obs_vector_alloc(GEN_OBS, "WHAT", NULL, 0); - obs_vector_scale_std(obs_vector, 2.0); + local_obsdata_node_type * local_node = obs_vector_alloc_local_node( obs_vector ); + obs_vector_scale_std(obs_vector, local_node , 2.0); obs_vector_free(obs_vector); + local_obsdata_node_free( local_node ); return true; } @@ -189,17 +206,20 @@ bool scale_std_gen_withdata_no_errors() { observations[i] = gen_obs; } - obs_vector_scale_std(obs_vector, multiplier); - - + { + local_obsdata_node_type * local_node = obs_vector_alloc_local_node( obs_vector ); + obs_vector_scale_std(obs_vector, local_node , multiplier); + local_obsdata_node_free( local_node ); + } for (int i = 0; i < num_observations; i++) { - char * index_key = util_alloc_sprintf("%d", i); + char * index_key = util_alloc_sprintf("%d", 0); double value_new, std_new; bool valid; gen_obs_user_get_with_data_index(observations[i], index_key, &value_new, &std_new, &valid); - test_assert_double_equal(std_dev * multiplier, std_new); + test_assert_double_equal(std_dev , std_new); test_assert_double_equal(value, value_new); + test_assert_double_equal(multiplier , gen_obs_iget_std_scaling( observations[i] , 0 )); free(index_key); } diff --git a/ThirdParty/Ert/devel/libert_util/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/CMakeLists.txt index 68ce6c9109..c53a529afb 100644 --- a/ThirdParty/Ert/devel/libert_util/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libert_util/CMakeLists.txt @@ -1,7 +1,7 @@ add_subdirectory( include/ert/util ) add_subdirectory( src ) -if (BUILD_APPLICATONS) +if (BUILD_APPLICATIONS) add_subdirectory( applications ) endif() diff --git a/ThirdParty/Ert/devel/libert_util/applications/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/applications/CMakeLists.txt index b16c480385..05138303fd 100644 --- a/ThirdParty/Ert/devel/libert_util/applications/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libert_util/applications/CMakeLists.txt @@ -5,3 +5,7 @@ target_link_libraries( matrix_test ert_util ) if (USE_RUNPATH) add_runpath( matrix_test ) endif() + +if (ERT_BUILD_BLOCK_FS) + add_subdirectory( block_fs ) +endif() diff --git a/ThirdParty/Ert/devel/libert_util/applications/block_fs/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/applications/block_fs/CMakeLists.txt new file mode 100644 index 0000000000..39b891f041 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/applications/block_fs/CMakeLists.txt @@ -0,0 +1,18 @@ +add_executable( bls bls.c ) + +target_link_libraries( bls ert_util ) + +if (USE_RUNPATH) + add_runpath( bls ) +endif() + + +set (destination ${CMAKE_INSTALL_PREFIX}/bin) +if (INSTALL_ERT) + install(TARGETS bls DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/bls)") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/bls)") + endif() +endif() + diff --git a/ThirdParty/Ert/devel/libert_util/applications/block_fs/bls.c b/ThirdParty/Ert/devel/libert_util/applications/block_fs/bls.c index 9ca7df8799..bd427d7c53 100644 --- a/ThirdParty/Ert/devel/libert_util/applications/block_fs/bls.c +++ b/ThirdParty/Ert/devel/libert_util/applications/block_fs/bls.c @@ -1,26 +1,27 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'bls.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'bls.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ -#include <util.h> -#include <block_fs.h> -#include <vector.h> #include <signal.h> +#include <ert/util/util.h> +#include <ert/util/block_fs.h> +#include <ert/util/vector.h> + void install_SIGNALS(void) { signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ @@ -32,7 +33,7 @@ void install_SIGNALS(void) { static int usage( void ) { fprintf(stderr,"\n"); fprintf(stderr,"Usage:\n\n"); - fprintf(stderr," bash%% block_fs BLOCK_FILE.mnt <pattern>\n\n"); + fprintf(stderr," bash%% bls BLOCK_FILE.mnt <pattern>\n\n"); fprintf(stderr,"Will list all elements in BLOCK_FILE matching pattern - remember to quote wildcards.\n"); exit(1); } @@ -49,17 +50,17 @@ int main(int argc , char ** argv) { block_fs_sort_type sort_mode = OFFSET_SORT; const char * pattern = NULL; int iarg; - + for (iarg = 2; iarg < argc; iarg++) { if (argv[iarg][0] == '-') { /** OK - this is an option .. */ } - else + else pattern = argv[iarg]; } - + { - block_fs_type * block_fs = block_fs_mount(mount_file , 1 , 0 , 1 , 0 , false , true ); + block_fs_type * block_fs = block_fs_mount(mount_file , 1 , 0 , 1 , 0 , false , true , false); vector_type * files = block_fs_alloc_filelist( block_fs , pattern , sort_mode , false ); { int i; @@ -71,7 +72,7 @@ int main(int argc , char ** argv) { vector_free( files ); block_fs_close( block_fs , false ); } - } else + } else fprintf(stderr,"The file:%s does not seem to be a block_fs mount file.\n" , mount_file); } } diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/arg_pack.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/arg_pack.h index 12ffd60e40..9c95f8cb48 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/arg_pack.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/arg_pack.h @@ -40,7 +40,7 @@ typedef void * (arg_node_copyc_ftype) (const void *); void arg_pack_free__(void *); void arg_pack_clear(arg_pack_type *); void arg_pack_lock(arg_pack_type *); - void arg_pack_fscanf(arg_pack_type * arg , FILE * stream); + void arg_pack_fscanf(arg_pack_type * arg , FILE * stream, const char * filename); void arg_pack_fprintf(const arg_pack_type * , FILE * ); void arg_pack_append_ptr(arg_pack_type * , void *); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix.h index 5cf59b4546..26e7b5b198 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'matrix.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __MATRIX_H__ @@ -24,11 +24,12 @@ #include <ert/util/rng.h> #include <ert/util/type_macros.h> +#include <ert/util/bool_vector.h> #ifdef HAVE_THREAD_POOL #include <ert/util/thread_pool.h> #endif -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -47,9 +48,11 @@ typedef struct matrix_struct matrix_type; bool matrix_resize(matrix_type * matrix , int rows , int columns , bool copy_content); bool matrix_safe_resize(matrix_type * matrix , int rows , int columns , bool copy_content); matrix_type * matrix_alloc_copy(const matrix_type * src); + matrix_type * matrix_alloc_column_compressed_copy(const matrix_type * src, const bool_vector_type * mask); + void matrix_column_compressed_memcpy(matrix_type * target, const matrix_type * src, const bool_vector_type * mask); matrix_type * matrix_safe_alloc_copy(const matrix_type * src); matrix_type * matrix_realloc_copy(matrix_type * T , const matrix_type * src); - + matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column , int rows , int columns); void matrix_free(matrix_type * matrix); void matrix_safe_free( matrix_type * matrix ); @@ -58,7 +61,7 @@ typedef struct matrix_struct matrix_type; void matrix_set_name( matrix_type * matrix , const char * name); void matrix_scale(matrix_type * matrix, double value); void matrix_shift(matrix_type * matrix, double value); - + void matrix_assign(matrix_type * A , const matrix_type * B); void matrix_inplace_add(matrix_type * A , const matrix_type * B); void matrix_inplace_sub(matrix_type * A , const matrix_type * B); @@ -67,7 +70,9 @@ typedef struct matrix_struct matrix_type; void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C); void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C); void matrix_transpose(const matrix_type * A , matrix_type * T); - + void matrix_inplace_sub_column(matrix_type * A , const matrix_type * B, int colA , int colB); + + void matrix_iset_safe(matrix_type * matrix , int i , int j, double value); void matrix_iset(matrix_type * matrix , int i , int j, double value); double matrix_iget(const matrix_type * matrix , int i , int j); @@ -75,14 +80,14 @@ typedef struct matrix_struct matrix_type; void matrix_iadd(matrix_type * matrix , int i , int j , double value); void matrix_isub(matrix_type * matrix , int i , int j , double value); void matrix_imul(matrix_type * matrix , int i , int j , double value); - - + + void matrix_inplace_matmul(matrix_type * A, const matrix_type * B); void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads); #ifdef HAVE_THREAD_POOL void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_pool_type * thread_pool); #endif - + void matrix_shift_column(matrix_type * matrix , int column, double shift); void matrix_shift_row(matrix_type * matrix , int row , double shift); double matrix_get_column_sum(const matrix_type * matrix , int column); @@ -98,10 +103,10 @@ typedef struct matrix_struct matrix_type; void matrix_set_const_column(matrix_type * matrix , const double value , int column); void matrix_copy_column(matrix_type * target_matrix, const matrix_type * src_matrix , int src_column, int target_column); void matrix_set_const_row(matrix_type * matrix , const double value , int row); - + double * matrix_get_data(const matrix_type * matrix); double matrix_orthonormality( const matrix_type * matrix ); - + matrix_type * matrix_alloc_steal_data(int rows , int columns , double * data , int data_size); void matrix_set_column(matrix_type * matrix , const double * data , int column); void matrix_set_many_on_column(matrix_type * matrix , int row_offset , int elements , const double * data , int column); @@ -116,12 +121,12 @@ typedef struct matrix_struct matrix_type; bool matrix_is_quadratic(const matrix_type * matrix); bool matrix_equal( const matrix_type * m1 , const matrix_type * m2); bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2); - + void matrix_diag_set_scalar(matrix_type * matrix , double value); void matrix_diag_set(matrix_type * matrix , const double * diag); void matrix_random_init(matrix_type * matrix , rng_type * rng); void matrix_matlab_dump(const matrix_type * matrix, const char * filename); - + void matrix_imul_col( matrix_type * matrix , int column , double factor); double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2); double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const matrix_type * m2 , int col2); @@ -130,7 +135,7 @@ typedef struct matrix_struct matrix_type; void matrix_copy_row(matrix_type * target_matrix, const matrix_type * src_matrix , int target_row, int src_row); void matrix_copy_block( matrix_type * target_matrix , int target_row , int target_column , int rows , int columns, const matrix_type * src_matrix , int src_row , int src_column); - + void matrix_scalar_set( matrix_type * matrix , double value); void matrix_inplace_diag_sqrt(matrix_type *Cd); void matrix_create_identiy(int n,matrix_type *Id); @@ -139,7 +144,7 @@ typedef struct matrix_struct matrix_type; double matrix_det2( const matrix_type * A); double matrix_det3( const matrix_type * A); double matrix_det4( const matrix_type * A); - + #ifdef HAVE_ISFINITE bool matrix_is_finite(const matrix_type * matrix); void matrix_assert_finite( const matrix_type * matrix ); @@ -147,7 +152,7 @@ typedef struct matrix_struct matrix_type; UTIL_SAFE_CAST_HEADER( matrix ); -#ifdef __cplusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_blas.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_blas.h index 2cfa755b47..2b8d36c8e9 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_blas.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_blas.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_blas.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'matrix_blas.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __MATRIX_BLAS__ @@ -23,7 +23,7 @@ #include <ert/util/matrix.h> -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_lapack.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_lapack.h index ceabd72556..9576acfcb7 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_lapack.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_lapack.h @@ -1,26 +1,26 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_lapack.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'matrix_lapack.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __MATRIX_LAPACK_H__ #define __MATRIX_LAPACK_H__ #include <ert/util/matrix.h> -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -35,7 +35,7 @@ extern "C" { - + typedef enum { /* A */ DGESVD_ALL, /* Returns all the singular vectors in U/VT. */ /* S */ DGESVD_MIN_RETURN, /* Return the first min(m,n) vectors in U/VT. */ @@ -48,44 +48,44 @@ extern "C" { /* A */ DSYEVX_ALL, /* Compute all the eigenvalues */ /* V */ DSYEVX_VALUE_INTERVAL, /* Computes eigenvalues in half open interval <VL , VU] */ /* I */ DSYEVX_INDEX_INTERVAL} /* The IL-th through IU'th eigenvalue will be found. */ - dsyevx_eig_enum; - - + dsyevx_eig_enum; + + typedef enum { /* U */ DSYEVX_AUPPER, /* The data is stored in the upper right part of the A matrix. */ /* L */ DSYEVX_ALOWER} /* The data is stored in the lower left part of the A matrix. */ - dsyevx_uplo_enum; - - + dsyevx_uplo_enum; + + + - void matrix_dgesv(matrix_type * A , matrix_type * B); void matrix_dgesvd(dgesvd_vector_enum jobv, dgesvd_vector_enum jobvt , matrix_type * A , double * S , matrix_type * U , matrix_type * VT); - - int matrix_dsyevx(bool compute_eig_vectors , - dsyevx_eig_enum which_values , - dsyevx_uplo_enum uplo, - matrix_type * A , - double VL , - double VU , - int IL , - int IU , - double *eig_values , + + int matrix_dsyevx(bool compute_eig_vectors , + dsyevx_eig_enum which_values , + dsyevx_uplo_enum uplo, + matrix_type * A , + double VL , + double VU , + int IL , + int IU , + double *eig_values , matrix_type * Z ) ; - - - int matrix_dsyevx_all(dsyevx_uplo_enum uplo , - matrix_type * A , - double *eig_values , + + + int matrix_dsyevx_all(dsyevx_uplo_enum uplo , + matrix_type * A , + double *eig_values , matrix_type * Z ); - + void matrix_dgeqrf(matrix_type * A , double * tau); void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors); double matrix_det( matrix_type *A ); int matrix_inv( matrix_type * A ); - + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_stat.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_stat.h new file mode 100644 index 0000000000..11062e710e --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/matrix_stat.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'matrix_stat.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#ifndef __MATRIX_STAT_H__ +#define __MATRIX_STAT_H__ + +#include <ert/util/matrix.h> + +typedef enum { + LLSQ_SUCCESS = 0, + LLSQ_INVALID_DIM = 1, + LLSQ_UNDETERMINED = 2 +} llsq_result_enum; + + +llsq_result_enum matrix_stat_llsq_estimate( matrix_type * beta , const matrix_type * X , const matrix_type * Y , const matrix_type * S); +llsq_result_enum matrix_stat_polyfit( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S); + + +#endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/parser.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/parser.h index 31e6704f2b..ff620543c4 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/parser.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/parser.h @@ -20,7 +20,7 @@ #define __PARSER_H__ #include <ert/util/stringlist.h> -typedef struct parser_struct parser_type; +typedef struct basic_parser_struct basic_parser_type; /** @@ -118,7 +118,7 @@ typedef struct parser_struct parser_type; */ -parser_type * parser_alloc( +basic_parser_type * basic_parser_alloc( const char * whitespace, /** Set to NULL if not interessting. */ const char * quoters, /** Set to NULL if not interessting. */ const char * specials, /** Set to NULL if not interessting. */ @@ -127,33 +127,33 @@ parser_type * parser_alloc( const char * comment_end); /** Set to NULL if not interessting. */ -void parser_set_splitters( parser_type * parser , const char * splitters ); -void parser_set_quoters( parser_type * parser , const char * quoters ); -void parser_set_specials( parser_type * parser , const char * specials ); -void parser_set_delete_set( parser_type * parser , const char * delete_set ); -void parser_set_comment_start( parser_type * parser , const char * comment_start ); -void parser_set_comment_end( parser_type * parser , const char * comment_end ); +void basic_parser_set_splitters( basic_parser_type * parser , const char * splitters ); +void basic_parser_set_quoters( basic_parser_type * parser , const char * quoters ); +void basic_parser_set_specials( basic_parser_type * parser , const char * specials ); +void basic_parser_set_delete_set( basic_parser_type * parser , const char * delete_set ); +void basic_parser_set_comment_start( basic_parser_type * parser , const char * comment_start ); +void basic_parser_set_comment_end( basic_parser_type * parser , const char * comment_end ); -void parser_free( - parser_type * parser); +void basic_parser_free( + basic_parser_type * parser); -stringlist_type * parser_tokenize_buffer( - const parser_type * parser, - const char * buffer, - bool strip_quote_marks); +stringlist_type * basic_parser_tokenize_buffer( + const basic_parser_type * parser, + const char * buffer, + bool strip_quote_marks); -stringlist_type * parser_tokenize_file( - const parser_type * parser, - const char * filename, - bool strip_quote_marks); +stringlist_type * basic_parser_tokenize_file( + const basic_parser_type * parser, + const char * filename, + bool strip_quote_marks); /* Pollution by Joakim: */ -void parser_strip_buffer(const parser_type * parser , char ** __buffer); -bool parser_fseek_string(const parser_type * parser , FILE * stream , const char * string , bool skip_string , bool case_sensitive); -char * parser_fread_alloc_file_content(const char * filename , const char * quote_set , const char * delete_set , const char * comment_start , const char * comment_end); +void basic_parser_strip_buffer(const basic_parser_type * parser , char ** __buffer); +bool basic_parser_fseek_string(const basic_parser_type * parser , FILE * stream , const char * string , bool skip_string , bool case_sensitive); +char * basic_parser_fread_alloc_file_content(const char * filename , const char * quote_set , const char * delete_set , const char * comment_start , const char * comment_end); #endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h index 9087c2e22a..f1a3078837 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h @@ -52,6 +52,7 @@ typedef int ( string_cmp_ftype) (const void * , const void *); bool stringlist_iequal( const stringlist_type * stringlist , int index, const char * s ); const char * stringlist_iget(const stringlist_type * , int); int stringlist_iget_as_int( const stringlist_type * stringlist , int index , bool * valid); + double stringlist_iget_as_double( const stringlist_type * stringlist , int index , bool * valid); bool stringlist_iget_as_bool( const stringlist_type * stringlist, int index, bool * valid); char * stringlist_iget_copy(const stringlist_type * stringlist , int ); char * stringlist_alloc_joined_string(const stringlist_type * , const char * ); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h index a8c6b292ee..c27610e30d 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'test_util.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'test_util.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -26,17 +26,17 @@ extern "C" { /* Included here to get the HAVE_UTIL_ABORT symbol.*/ -#include <ert/util/util.h> - +#include <ert/util/util.h> + void test_error_exit( const char * fmt , ...); #define test_exit( fmt, ...) test_exit__( __FILE__ , __LINE__ , fmt , __VA_ARGS__); void test_exit__(const char * file , int line , const char * fmt , ...); -#define test_assert_string_equal( s1 , s2 ) test_assert_string_equal__(s1 , s2 , __FILE__ , __LINE__) +#define test_assert_string_equal( s1 , s2 ) test_assert_string_equal__(s1 , s2 , __FILE__ , __LINE__) void test_assert_string_equal__( const char * s1 , const char * s2 , const char * file , int line); -#define test_assert_string_not_equal( s1 , s2 ) test_assert_string_not_equal__(s1 , s2 , __FILE__ , __LINE__) +#define test_assert_string_not_equal( s1 , s2 ) test_assert_string_not_equal__(s1 , s2 , __FILE__ , __LINE__) void test_assert_string_not_equal__( const char * s1 , const char * s2 , const char * file , int line); bool test_check_string_equal( const char *s1 , const char * s2); @@ -47,12 +47,24 @@ extern "C" { #define test_assert_int_not_equal( i1 , i2 ) test_assert_int_not_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) void test_assert_int_not_equal__( int i1 , int i2 , const char * file , int line ); +#define test_assert_long_equal( i1 , i2 ) test_assert_long_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) + void test_assert_long_equal__( long i1 , long i2 , const char * file , long line ); + +#define test_assert_long_not_equal( i1 , i2 ) test_assert_long_not_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) + void test_assert_long_not_equal__( long i1 , long i2 , const char * file , long line ); + #define test_assert_uint_equal( i1 , i2 ) test_assert_uint_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) void test_assert_uint_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line ); #define test_assert_uint_not_equal( i1 , i2 ) test_assert_uint_not_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) void test_assert_uint_not_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line ); +#define test_assert_size_t_equal( s1 , s2 ) test_assert_size_t_equal__( (s1) , (s2) , __FILE__ , __LINE__ ) + void test_assert_size_t_equal__( size_t s1 , size_t s2 , const char * file , int line ); + +#define test_assert_size_t_not_equal( s1 , s2 ) test_assert_size_t_not_equal__( (s1) , (s2) , __FILE__ , __LINE__ ) + void test_assert_size_t_not_equal__( size_t s1 , size_t s2 , const char * file , int line ); + #define test_assert_double_equal( d1 , d2 ) test_assert_double_equal__( (d1) , (d2) , __FILE__ , __LINE__ ) void test_assert_double_equal__( double d1 , double d2 , const char * file , int line ); @@ -73,7 +85,7 @@ extern "C" { #define test_assert_true( value ) test_assert_true__( (value) , __FILE__ , __LINE__) void test_assert_true__( bool value, const char * file , int line); - + #define test_assert_false( value ) test_assert_false__( (value) , __FILE__ , __LINE__) void test_assert_false__( bool value, const char * file , int line); @@ -94,7 +106,7 @@ extern "C" { #define test_assert_not_NULL( p ) test_assert_not_NULL__( (p) , __FILE__ , __LINE__) void test_assert_not_NULL__( const void * p , const char * file , int line); - + #define test_assert_mem_equal( p1 , p2 , byte_size ) test_assert_mem_equal__( (p1) , (p2) , (byte_size), __FILE__ , __LINE__) void test_assert_mem_equal__( const void * p1 , const void * p2 , size_t byte_size , const char * file , int line); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.hpp b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.hpp new file mode 100644 index 0000000000..262cc25e7c --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.hpp @@ -0,0 +1,41 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'test_util.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#ifndef __TEST_UTIL_HPP__ +#define __TEST_UTIL_HPP__ + +#include <ert/util/test_util.h> + +#define test_assert_throw(expr , exception_type ) \ +{ \ + bool throw_ok = false; \ + try { \ + expr; \ + } \ + catch (std::exception &e) { \ + if (dynamic_cast<exception_type *>(&e)) \ + throw_ok = true; \ + } \ + if (!throw_ok) \ + test_error_exit("Correct exception not thrown at %s:%d\n",__FILE__ , __LINE__); \ +} + + + +#endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/test_work_area.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_work_area.h index 0559e4cc7d..0d941f186f 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/test_work_area.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_work_area.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'test_work_area.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'test_work_area.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -36,7 +36,7 @@ extern "C" { void test_work_area_set_store( test_work_area_type * work_area , bool store); void test_work_area_free(test_work_area_type * work_area); - const char * test_work_area_get_cwd( const test_work_area_type * work_area ); + const char * test_work_area_get_cwd( const test_work_area_type * work_area ); const char * test_work_area_get_original_cwd( const test_work_area_type * work_area ); void test_work_area_install_file( test_work_area_type * work_area , const char * input_src_file ); void test_work_area_copy_directory( test_work_area_type * work_area , const char * input_directory); @@ -44,7 +44,7 @@ extern "C" { void test_work_area_copy_file( test_work_area_type * work_area , const char * input_file); bool test_work_area_copy_parent_directory( test_work_area_type * work_area , const char * input_path); bool test_work_area_copy_parent_content( test_work_area_type * work_area , const char * input_path); - + UTIL_IS_INSTANCE_HEADER( test_work_area ); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/type_vector_functions.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/type_vector_functions.h index 8e2cfcc9d2..06247a679c 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/type_vector_functions.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/type_vector_functions.h @@ -1,32 +1,34 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'type_vector_functions.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'type_vector_functions.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __TYPE_VECTOR_FUNCTIONS_H__ #define __TYPE_VECTOR_FUNCTIONS_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif #include <ert/util/int_vector.h> #include <ert/util/bool_vector.h> - - int_vector_type * bool_vector_alloc_active_list( const bool_vector_type * mask ); +#include <ert/util/double_vector.h> + + int_vector_type * bool_vector_alloc_active_list( const bool_vector_type * mask ); bool_vector_type * int_vector_alloc_mask( const int_vector_type * active_list ); - int_vector_type * bool_vector_alloc_active_index_list(const bool_vector_type * mask , int default_value); + int_vector_type * bool_vector_alloc_active_index_list(const bool_vector_type * mask , int default_value); + bool double_vector_approx_equal( const double_vector_type * v1 , const double_vector_type * v12 , double epsilon); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h index 7f903025e0..9097d87a03 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'util.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'util.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __UTIL_H__ @@ -47,7 +47,7 @@ #define UTIL_PATH_SEP_CHAR '/' /* A simple character used when we want an actual char instance (i.e. not a pointer). */ #endif -#define UTIL_NEWLINE_STRING " \n" +#define UTIL_NEWLINE_STRING " \n" #define UTIL_DEFAULT_MKDIR_MODE 0777 /* Directories are by default created with mode a+rwx - and then comes the umask ... */ @@ -81,7 +81,7 @@ typedef struct stat stat_type; /*****************************************************************/ /* - + */ @@ -110,6 +110,7 @@ typedef enum {left_pad = 0, time_t util_make_date(int , int , int); time_t util_make_pure_date(time_t t); void util_inplace_forward_days(time_t * , double); + void util_inplace_forward_seconds(time_t * t , double seconds); time_t util_file_mtime(const char * file); double util_difftime(time_t , time_t , int * , int * , int * , int *); double util_difftime_days(time_t , time_t ); @@ -149,6 +150,7 @@ typedef enum {left_pad = 0, double util_file_difftime(const char * , const char *); bool util_file_update_required(const char *, const char *); size_t util_file_size(const char *); + size_t util_fd_size(int fd); void util_clear_directory(const char *path, bool strict_uid , bool unlink_root); void util_unlink_existing(const char *filename); void util_strupr(char *); @@ -166,11 +168,12 @@ typedef enum {left_pad = 0, bool util_string_match(const char * string , const char * pattern); bool util_string_has_wildcard( const char * s); bool util_file_readable( const char * file ); - bool util_entry_readable( const char * entry ); + bool util_entry_readable( const char * entry ); bool util_entry_writable( const char * entry ); void util_ftruncate(FILE * stream , long size); - + void util_usleep( unsigned long micro_seconds ); + void util_yield(); char * util_blocking_alloc_stdin_line(unsigned long ); int util_roundf( float x ); @@ -201,12 +204,12 @@ typedef enum {left_pad = 0, bool util_addmode_if_owner( const char * filename , mode_t add_mode ); bool util_delmode_if_owner( const char * filename , mode_t del_mode); bool util_chmod_if_owner( const char * filename , mode_t new_mode); -#endif +#endif #ifdef HAVE_PROC bool util_proc_alive(pid_t pid); #endif - + int util_forward_line(FILE * , bool * ); void util_rewind_line(FILE *); int util_count_content_file_lines(FILE * ); @@ -285,12 +288,12 @@ typedef enum {left_pad = 0, void util_fread_from_buffer(void * , size_t , size_t , char ** ); - + unsigned int util_clock_seed( ); void util_fread_dev_random(int , char * ); void util_fread_dev_urandom(int , char * ); bool util_string_isspace(const char * s); - + char * util_alloc_dump_filename(); void util_exit(const char * fmt , ...); void util_abort__(const char * file , const char * function , int line , const char * fmt , ...); @@ -307,9 +310,9 @@ typedef enum {left_pad = 0, void * util_alloc_copy(const void * , size_t ); void util_double_to_float(float * , const double * , int ); void util_float_to_double(double * , const float * , int ); - + int util_get_month_nr(const char * ); - + char * util_fread_alloc_file_content(const char * , int *); void util_fwrite_string(const char * , FILE *); char * util_fread_realloc_string(char * , FILE *); @@ -317,8 +320,8 @@ typedef enum {left_pad = 0, void util_fskip_string(FILE *stream); void util_endian_flip_vector(void * data , int element_size , int elements); int util_proc_mem_free(void); - - + + void util_clamp_double(double * value , double limit1, double limit2); double util_double_vector_mean(int , const double * ); double util_double_vector_stddev(int , const double * ); @@ -359,12 +362,12 @@ typedef enum {left_pad = 0, void util_fread_char_vector(char * , int , FILE * , const char * ); int util_type_get_id( const void * data ); - + bool util_sscanf_bytesize(const char * , size_t *); int util_get_current_linenr(FILE * stream); const char * util_update_path_var(const char * , const char * , bool ); - - + + int util_get_type( void * data ); void util_fskip_int(FILE * stream); void util_fskip_long(FILE * stream); @@ -387,7 +390,7 @@ typedef enum {left_pad = 0, void util_unsetenv( const char * variable); char * util_alloc_envvar( const char * value ); bool util_is_link(const char * ); // Will always return false on windows - int util_chdir(const char * path); + int util_chdir(const char * path); #define UTIL_FWRITE_SCALAR(s,stream) { if (fwrite(&s , sizeof s , 1 , stream) != 1) util_abort("%s: write failed: %s\n",__func__ , strerror(errno)); } @@ -395,7 +398,7 @@ typedef enum {left_pad = 0, #define UTIL_FWRITE_VECTOR(s,n,stream) { if (fwrite(s , sizeof s , (n) , stream) != (n)) util_abort("%s: write failed: %s \n",__func__ , strerror(errno)); } #define UTIL_FREAD_VECTOR(s,n,stream) { if (fread(s , sizeof s , (n) , stream) != (n)) util_abort("%s: read failed: %s \n",__func__ , strerror(errno)); } - + #define CONTAINS_HEADER(TYPE) int util_sorted_contains_ ## TYPE(const TYPE * data , int size , TYPE value) CONTAINS_HEADER(int); CONTAINS_HEADER(time_t); @@ -418,7 +421,7 @@ typedef enum {left_pad = 0, const char * <enum>_iget(int index, int * value) { ... } - + which should take an enum element number as input argument and return a string representation of the corresponding enum element and also update the value reference to contain the corresponding enum @@ -428,7 +431,7 @@ typedef enum {left_pad = 0, The util_enum_element_type and the util_enum_iget() function are convenience functions which can be used to avoid indirectly - repeating the enum definition in the <enum>_iget() function. + repeating the enum definition in the <enum>_iget() function. In the example below we create the enum definition in normal way in the header file, and then in addition we repeat the defintion in a @@ -443,22 +446,22 @@ typedef enum {left_pad = 0, VALUE1 = 2, VALUE2 = 17 } - + // The enum definition is repeated; but at at least at the very same spot of the code. #define MY_ENUM_DEF { .value = INVALID, .name="INVALID"} , {.value = VALUE1 , .name="VALUE1"} , {.value = VALUE2 , .name="VALUE2"} #define MY_ENUM_SIZE 3 - + source file: ------------ - + const char * my_enum_iget(int index, int * value) { return util_enum_iget( index , MY_ENUM_SIZE , (const util_enum_element_type []) MY_ENUM_DEF , value); } -*/ - +*/ + typedef struct { int value; diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h index be2f724f31..1909d9cde0 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h @@ -1,25 +1,25 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'vector.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'vector.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __VECTOR_H__ #define __VECTOR_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif #include <ert/util/node_data.h> @@ -28,7 +28,7 @@ extern "C" { typedef void ( vector_func_type ) (void * , void *); typedef int ( vector_cmp_ftype) (const void * , const void *); - + typedef struct vector_struct vector_type; @@ -39,27 +39,27 @@ extern "C" { int vector_append_ref( vector_type * , const void *); int vector_append_owned_ref( vector_type * , const void * , free_ftype * del); int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - + void vector_iset_ref( vector_type * , int , const void *); void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del); void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); - + void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del); void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del); void vector_safe_iset_ref(vector_type * vector , int index , const void * data); - + void vector_insert_ref( vector_type * , int , const void *); void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del); void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *); void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - + void vector_push_front_ref( vector_type * , const void *); void vector_push_front_owned_ref( vector_type * , const void * , free_ftype * del); void vector_push_front_copy(vector_type * , const void *, copyc_ftype *, free_ftype *); - - + + void vector_clear(vector_type * vector); - void vector_free(vector_type * ); + void vector_free(vector_type * ); void vector_free__( void * arg ); void vector_append_buffer(vector_type * , const void * , int); void vector_push_buffer(vector_type * , const void * , int); @@ -79,9 +79,10 @@ extern "C" { int_vector_type * vector_alloc_sort_perm(const vector_type * vector , vector_cmp_ftype * cmp); void vector_inplace_reverse(vector_type * vector); vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); - + void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); - + int vector_find( const vector_type * vector , const void * ptr); + UTIL_IS_INSTANCE_HEADER( vector ); UTIL_SAFE_CAST_HEADER( vector ); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h index ea74fb5e8f..d4a11eddcc 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h @@ -84,7 +84,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); @TYPE@ * @TYPE@_vector_get_ptr(const @TYPE@_vector_type * ); @TYPE@ * @TYPE@_vector_alloc_data_copy( const @TYPE@_vector_type * vector ); const @TYPE@ * @TYPE@_vector_get_const_ptr(const @TYPE@_vector_type * ); - bool @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ min_value , @TYPE@ max_value , @TYPE@ delta); + void @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ value1 , @TYPE@ value2 , @TYPE@ delta); void @TYPE@_vector_set_many(@TYPE@_vector_type * , int , const @TYPE@ * , int ); void @TYPE@_vector_set_all(@TYPE@_vector_type * vector , @TYPE@ value); void @TYPE@_vector_append_many(@TYPE@_vector_type * vector , const @TYPE@ * data , int length); @@ -119,7 +119,8 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); int @TYPE@_vector_count_equal( const @TYPE@_vector_type * vector , @TYPE@ cmp_value); int @TYPE@_vector_element_size( const @TYPE@_vector_type * vector ); void @TYPE@_vector_range_fill(@TYPE@_vector_type * vector , @TYPE@ limit1 , @TYPE@ delta , @TYPE@ limit2); - + void @TYPE@_vector_shift(@TYPE@_vector_type * vector, @TYPE@ delta); + UTIL_SAFE_CAST_HEADER( @TYPE@_vector ); UTIL_IS_INSTANCE_HEADER( @TYPE@_vector ); diff --git a/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt index 38555eb0b9..a72e315e87 100644 --- a/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt @@ -102,7 +102,7 @@ else() message( WARNING "Git not found. Build will not contain git revision info." ) endif() -set_source_files_properties( version.c PROPERTIES COMPILE_DEFINITIONS "COMPILE_TIME_STAMP=\"${BUILD_TIME}\";GIT_COMMIT=\"${GIT_COMMIT}\";GIT_COMMIT_SHORT=\"${GIT_COMMIT_SHORT}\";ERT_VERSION_MAJOR=\"${ERT_VERSION_MAJOR}\";ERT_VERSION_MINOR=\"${ERT_VERSION_MINOR}\";ERT_VERSION_MICRO=\"${ERT_VERSION_MICRO}\"") +set_source_files_properties( version.c PROPERTIES COMPILE_DEFINITIONS "COMPILE_TIME_STAMP=\"${BUILD_TIME}\";GIT_COMMIT=\"${GIT_COMMIT}\";GIT_COMMIT_SHORT=\"${GIT_COMMIT_SHORT}\";ERT_VERSION_MAJOR=${ERT_VERSION_MAJOR};ERT_VERSION_MINOR=${ERT_VERSION_MINOR};ERT_VERSION_MICRO=\"${ERT_VERSION_MICRO}\"") if (CMAKE_COMPILER_IS_GNUCC) @@ -123,8 +123,8 @@ if (WITH_LATEX) endif() if (WITH_LAPACK) - list( APPEND source_files matrix_lapack.c matrix_blas.c regression.c lars.c stepwise.c) - list( APPEND header_files matrix_lapack.h matrix_blas.h regression.h lars.h stepwise.h) + list( APPEND source_files matrix_lapack.c matrix_blas.c matrix_stat.c regression.c lars.c stepwise.c) + list( APPEND header_files matrix_lapack.h matrix_blas.h matrix_stat.h regression.h lars.h stepwise.h) endif() if (UNISTD_HEADER) @@ -141,13 +141,14 @@ foreach (type int double bool long time_t size_t float) list( APPEND source_files ${src_target} ) endforeach( type ) +find_program (PING_PATH ping) if (PING_PATH) add_definitions( -DPING_CMD=\"${PING_PATH}\") endif() # The block_fs filesystem is so heavily dependant on pthreads that it is not # built if de not have pthreads. -if (WITH_PTHREAD) +if (ERT_BUILD_BLOCK_FS) list( APPEND source_files block_fs.c ) list( APPEND header_files block_fs.h ) @@ -160,6 +161,10 @@ if (HAVE_GETUID AND HAVE_OPENDIR) list( APPEND header_files test_work_area.h ) endif() +if (ERT_BUILD_CXX) + list( APPEND header_files test_util.hpp ) +endif() + add_library( ert_util ${LIBRARY_TYPE} ${source_files} ) if (BUILD_TESTS) add_library( test_util ${LIBRARY_TYPE} ${test_source} ) diff --git a/ThirdParty/Ert/devel/libert_util/src/arg_pack.c b/ThirdParty/Ert/devel/libert_util/src/arg_pack.c index c9484a501c..32789760e2 100644 --- a/ThirdParty/Ert/devel/libert_util/src/arg_pack.c +++ b/ThirdParty/Ert/devel/libert_util/src/arg_pack.c @@ -568,7 +568,8 @@ int arg_pack_size( const arg_pack_type * arg_pack ) { -void arg_pack_fscanf(arg_pack_type * arg , FILE * stream) { +void arg_pack_fscanf(arg_pack_type * arg , FILE * stream, const char * filename) { + int scan_count = 0; int iarg; char * fmt = NULL; @@ -631,11 +632,13 @@ void arg_pack_fscanf(arg_pack_type * arg , FILE * stream) { } default: - util_abort("%s: sorry %s not allocated for %d arguments - pathetic ehhh?? \n",__func__ , __func__ , arg->size); + util_abort("%s: sorry %s not allocated for %d arguments from file %s\n",__func__ , __func__ , arg->size, filename); + } - if (scan_count != arg->size) - util_abort("%s: wanted %d arguments - only found: %d \n", __func__ , arg->size , scan_count); + if (scan_count != arg->size) { + util_abort("%s: wanted %d arguments - only found: %d in file %s \n", __func__ , arg->size , scan_count, filename); + } free(fmt); } diff --git a/ThirdParty/Ert/devel/libert_util/src/block_fs.c b/ThirdParty/Ert/devel/libert_util/src/block_fs.c index 0d253e10fc..e2c7bb9555 100644 --- a/ThirdParty/Ert/devel/libert_util/src/block_fs.c +++ b/ThirdParty/Ert/devel/libert_util/src/block_fs.c @@ -1127,10 +1127,8 @@ static void block_fs_unlink_free_node( block_fs_type * block_fs , free_node_type static file_node_type * block_fs_get_new_node( block_fs_type * block_fs , const char * filename , size_t min_size) { free_node_type * current = block_fs->free_nodes; - free_node_type * prev = NULL; while (current != NULL && (current->file_node->node_size < min_size)) { - prev = current; current = current->next; } if (current != NULL) { @@ -1264,11 +1262,10 @@ bool block_fs_rotate( block_fs_type * block_fs , double fragmentation_limit) { void block_fs_fsync( block_fs_type * block_fs ) { if (block_fs->data_owner) { - long pos; //fdatasync( block_fs->data_fd ); fsync( block_fs->data_fd ); block_fs_fseek( block_fs , block_fs->data_file_size ); - pos = ftell( block_fs->data_stream ); + ftell( block_fs->data_stream ); } } diff --git a/ThirdParty/Ert/devel/libert_util/src/hash.c b/ThirdParty/Ert/devel/libert_util/src/hash.c index a30cd4e97b..1007e3d982 100644 --- a/ThirdParty/Ert/devel/libert_util/src/hash.c +++ b/ThirdParty/Ert/devel/libert_util/src/hash.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'hash.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'hash.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ @@ -34,7 +34,7 @@ #include <pthread.h> typedef pthread_rwlock_t lock_type; #else -typedef int lock_type; +typedef int lock_type; #endif #ifdef __cplusplus @@ -94,7 +94,7 @@ static void __hash_deadlock_abort(hash_type * hash) { static void __hash_rdlock(hash_type * hash) { int lock_error = pthread_rwlock_tryrdlock( &hash->rwlock ); - if (lock_error != 0) + if (lock_error != 0) util_abort("%s: did not get hash->read_lock - fix locking in calling scope\n",__func__); } @@ -140,11 +140,11 @@ static void * __hash_get_node_unlocked(const hash_type *__hash , const char *key { const uint32_t global_index = hash->hashf(key , strlen(key)); const uint32_t table_index = (global_index % hash->size); - + node = hash_sll_get(hash->table[table_index] , global_index , key); - if (node == NULL && abort_on_error) + if (node == NULL && abort_on_error) util_abort("%s: tried to get from key:%s which does not exist - aborting \n",__func__ , key); - + } return node; } @@ -179,7 +179,7 @@ static node_data_type * hash_get_node_data(hash_type *hash , const char *key) { /** This function resizes the hash table when it has become to full. The table only grows - this function is called from - __hash_insert_node(). + __hash_insert_node(). If you know in advance (roughly) how large the hash table will be it can be advantageous to call hash_resize() manually, to avoid @@ -190,7 +190,7 @@ void hash_resize(hash_type *hash, int new_size) { hash_sll_type ** new_table = hash_sll_alloc_table( new_size ); hash_node_type * node; uint32_t i; - + for (i=0; i < hash->size; i++) { node = hash_sll_get_head(hash->table[i]); while (node != NULL) { @@ -200,18 +200,18 @@ void hash_resize(hash_type *hash, int new_size) { node = next_node; } } - - /* + + /* Only freeing the table structure, *NOT* calling the node_free() functions, which happens when hash_sll_free() is called. */ - + { - for (i=0; i < hash->size; i++) + for (i=0; i < hash->size; i++) free( hash->table[i] ); free( hash->table ); } - + hash->size = new_size; hash->table = new_table; } @@ -222,7 +222,7 @@ void hash_resize(hash_type *hash, int new_size) { function takes a write-lock which is held during the execution of the function. */ - + static void __hash_insert_node(hash_type *hash , hash_node_type *node) { __hash_wrlock( hash ); { @@ -236,12 +236,12 @@ static void __hash_insert_node(hash_type *hash , hash_node_type *node) { if (existing_node != NULL) { hash_sll_del_node(hash->table[table_index] , existing_node); hash->elements--; - } + } } - - hash_sll_add_node(hash->table[table_index] , node); + + hash_sll_add_node(hash->table[table_index] , node); hash->elements++; - if ((1.0 * hash->elements / hash->size) > hash->resize_fill) + if ((1.0 * hash->elements / hash->size) > hash->resize_fill) hash_resize(hash , hash->size * 2); } __hash_unlock( hash ); @@ -261,12 +261,12 @@ static void hash_del_unlocked__(hash_type *hash , const char *key) { const uint32_t global_index = hash->hashf(key , strlen(key)); const uint32_t table_index = (global_index % hash->size); hash_node_type *node = hash_sll_get(hash->table[table_index] , global_index , key); - - if (node == NULL) + + if (node == NULL) util_abort("%s: hash does not contain key:%s - aborting \n",__func__ , key); else hash_sll_del_node(hash->table[table_index] , node); - + hash->elements--; } @@ -287,7 +287,7 @@ static hash_node_type * hash_internal_iter_next(const hash_type *hash , const ha while (i < hash->size && hash_sll_empty(hash->table[i])) i++; - if (i < hash->size) + if (i < hash->size) next_node = hash_sll_get_head(hash->table[i]); } } @@ -298,7 +298,7 @@ static hash_node_type * hash_internal_iter_next(const hash_type *hash , const ha /** This is the low level function which traverses a hash table and - allocates a char ** list of keys. + allocates a char ** list of keys. It takes a read-lock which is held during the execution of the function. The locking guarantees that the list of keys is valid @@ -320,13 +320,13 @@ static char ** hash_alloc_keylist__(hash_type *hash , bool lock) { uint32_t i = 0; while (i < hash->size && hash_sll_empty(hash->table[i])) i++; - - if (i < hash->size) + + if (i < hash->size) node = hash_sll_get_head(hash->table[i]); } - + while (node != NULL) { - const char *key = hash_node_get_key(node); + const char *key = hash_node_get_key(node); keylist[i] = util_alloc_string_copy(key); node = hash_internal_iter_next(hash , node); i++; @@ -343,7 +343,7 @@ static char ** hash_alloc_keylist__(hash_type *hash , bool lock) { /*****************************************************************/ -/** +/** The fundamental functions above relate the hash_node structure. Here comes a list of functions for inserting managed copies of various types. @@ -432,7 +432,7 @@ void hash_del(hash_type *hash , const char *key) { This function will delete the key if it exists in the hash, but it will NOT fail if the key is not already in the hash table. */ - + void hash_safe_del(hash_type * hash , const char * key) { __hash_wrlock( hash ); if (__hash_get_node_unlocked(hash , key , false)) @@ -462,7 +462,7 @@ void hash_clear(hash_type *hash) { void * hash_get(const hash_type *hash , const char *key) { hash_node_type * hash_node = __hash_get_node(hash , key , true); node_data_type * data_node = hash_node_get_data( hash_node ); - return node_data_get_ptr( data_node ); + return node_data_get_ptr( data_node ); } @@ -474,7 +474,7 @@ void * hash_safe_get( const hash_type * hash , const char * key ) { hash_node_type * hash_node = __hash_get_node(hash , key , false); if (hash_node != NULL) { node_data_type * data_node = hash_node_get_data( hash_node ); - return node_data_get_ptr( data_node ); + return node_data_get_ptr( data_node ); } else return NULL; } @@ -489,7 +489,7 @@ void * hash_safe_get( const hash_type * hash , const char * key ) { Observe that if the object has been installed with a destructor, the object will be destroyed by the hash_del() operation, and the return value is complete gibberish - i.e. this function can NOT be - used on hash-owned references. + used on hash-owned references. */ void * hash_pop( hash_type * hash , const char * key) { @@ -516,7 +516,7 @@ static hash_type * __hash_alloc(int size, double resize_fill , hashf_type *hashf hash->elements = 0; hash->resize_fill = resize_fill; LOCK_INIT( &hash->rwlock ); - + return hash; } @@ -527,7 +527,7 @@ hash_type * hash_alloc() { // Purely a helper in the process of removing the internal locking // in the hash implementation. -hash_type * hash_alloc_unlocked() { +hash_type * hash_alloc_unlocked() { return __hash_alloc(HASH_DEFAULT_SIZE , 0.50 , hash_index); } @@ -538,7 +538,7 @@ UTIL_IS_INSTANCE_FUNCTION(hash , HASH_TYPE_ID) void hash_free(hash_type *hash) { uint32_t i; - for (i=0; i < hash->size; i++) + for (i=0; i < hash->size; i++) hash_sll_free(hash->table[i]); free(hash->table); LOCK_DESTROY( &hash->rwlock ); @@ -561,7 +561,7 @@ stringlist_type * hash_alloc_stringlist(hash_type * hash) { int i; for (i = 0; i < hash_get_size( hash ); i++) stringlist_append_owned_ref( stringlist , keylist[i] ); - + free( keylist ); return stringlist; } @@ -569,7 +569,7 @@ stringlist_type * hash_alloc_stringlist(hash_type * hash) { /*****************************************************************/ -/** +/** The standard functions for inserting an entry in the hash table: hash_insert_copy(): The hash table uses copyc() to make a copy of @@ -591,7 +591,7 @@ stringlist_type * hash_alloc_stringlist(hash_type * hash) { void hash_insert_copy(hash_type *hash , const char *key , const void *value , copyc_ftype *copyc , free_ftype *del) { hash_node_type *hash_node; - if (copyc == NULL || del == NULL) + if (copyc == NULL || del == NULL) util_abort("%s: must provide copy constructer and delete operator for insert copy - aborting \n",__func__); { node_data_type * data_node = node_data_alloc_ptr( value , copyc , del ); @@ -614,7 +614,7 @@ void hash_insert_copy(hash_type *hash , const char *key , const void *value , co void hash_insert_hash_owned_ref(hash_type *hash , const char *key , const void *value , free_ftype *del) { hash_node_type *hash_node; - if (del == NULL) + if (del == NULL) util_abort("%s: must provide delete operator for insert hash_owned_ref - aborting \n",__func__); { node_data_type * data_node = node_data_alloc_ptr( value , NULL , del ); @@ -643,32 +643,32 @@ bool hash_has_key(const hash_type *hash , const char *key) { } -int hash_get_size(const hash_type *hash) { - return hash->elements; +int hash_get_size(const hash_type *hash) { + return hash->elements; } /******************************************************************/ -/** +/** Here comes a list of functions for allocating keylists which have been sorted in various ways. */ - + static hash_sort_type * hash_alloc_sort_list(const hash_type *hash , - const char **keylist) { + const char **keylist) { - int i; hash_sort_type * sort_list = calloc(hash_get_size(hash) , sizeof * sort_list); - for (i=0; i < hash_get_size(hash); i++) + int i; hash_sort_type * sort_list = calloc(hash_get_size(hash) , sizeof * sort_list); + for (i=0; i < hash_get_size(hash); i++) sort_list[i].key = util_alloc_string_copy(keylist[i]); - + return sort_list; } static void hash_free_sort_list(const hash_type *hash , hash_sort_type *sort_list) { int i; - for (i=0; i < hash_get_size(hash); i++) + for (i=0; i < hash_get_size(hash); i++) free(sort_list[i].key); free(sort_list); } @@ -687,15 +687,15 @@ static int hash_sortlist_cmp(const void *_p1 , const void *_p2) { } -static char ** __hash_alloc_ordered_keylist(hash_type *hash , int ( hash_get_cmp_value) (const void * )) { +static char ** __hash_alloc_ordered_keylist(hash_type *hash , int ( hash_get_cmp_value) (const void * )) { int i; char **sorted_keylist; char **tmp_keylist = hash_alloc_keylist(hash); hash_sort_type * sort_list = hash_alloc_sort_list(hash , (const char **) tmp_keylist); - for (i = 0; i < hash_get_size(hash); i++) + for (i = 0; i < hash_get_size(hash); i++) sort_list[i].cmp_value = hash_get_cmp_value( hash_get(hash , sort_list[i].key) ); - + qsort(sort_list , hash_get_size(hash) , sizeof *sort_list , &hash_sortlist_cmp); sorted_keylist = calloc(hash_get_size(hash) , sizeof *sorted_keylist); for (i = 0; i < hash_get_size(hash); i++) { @@ -720,14 +720,14 @@ char ** hash_alloc_sorted_keylist(hash_type *hash , int ( hash_get_cmp_value) (c static int key_cmp(const void *_s1 , const void *_s2) { const char * s1 = *((const char **) _s1); const char * s2 = *((const char **) _s2); - + return strcmp(s1 , s2); } -static char ** __hash_alloc_key_sorted_list(hash_type *hash, int (*cmp) (const void * , const void *)) { +static char ** __hash_alloc_key_sorted_list(hash_type *hash, int (*cmp) (const void * , const void *)) { char **keylist = hash_alloc_keylist(hash); - + qsort(keylist , hash_get_size(hash) , sizeof *keylist , cmp); return keylist; } @@ -749,7 +749,7 @@ bool hash_key_list_compare(hash_type * hash1, hash_type * hash2) { bool has_equal_keylist; int i,size1, size2; - char **keylist1, **keylist2; + char **keylist1, **keylist2; size1 = hash_get_size(hash1); size2 = hash_get_size(hash2); @@ -776,7 +776,7 @@ bool hash_key_list_compare(hash_type * hash1, hash_type * hash2) free( keylist1 ); free( keylist2 ); return has_equal_keylist; - + } @@ -784,7 +784,7 @@ bool hash_key_list_compare(hash_type * hash1, hash_type * hash2) /*****************************************************************/ /** - This function will take a list of strings of type: + This function will take a list of strings of type: ["OPT1:Value1" , "MIN:0.0001" , "MAX:1.00" , "FILE:XX"] @@ -806,17 +806,17 @@ hash_type * hash_alloc_from_options(const stringlist_type * options) { for (iopt = 0; iopt < num_options; iopt++) { char * option; char * value; - + util_binary_split_string( stringlist_iget(options , iopt) , ":" , true , &option , &value); - if ((option != NULL) && (value != NULL)) + if ((option != NULL) && (value != NULL)) hash_insert_hash_owned_ref( opt_hash , option , util_alloc_string_copy(value) , free); // Warning: could not interpret string as KEY:VALUE - ignored - - + + util_safe_free(option); util_safe_free(value); } - + return opt_hash; } @@ -832,7 +832,7 @@ hash_type * hash_alloc_from_options(const stringlist_type * options) { hash_insert_hash_owned_ref( hash , key , value , free ); addOK = true; } - + util_safe_free( key ); } return addOK; @@ -850,9 +850,9 @@ hash_type * hash_alloc_from_options(const stringlist_type * options) { */ struct hash_iter_struct { const hash_type * hash; /* The hash we are iterating over. */ - char ** keylist; /* The keys in the hash table - at the moment of hash_iter_alloc(). */ - int num_keys; - int current_key_num; /* This integer retains the state. */ + char ** keylist; /* The keys in the hash table - at the moment of hash_iter_alloc(). */ + int num_keys; + int current_key_num; /* This integer retains the state. */ }; @@ -864,7 +864,7 @@ void hash_iter_restart( hash_iter_type * iter ) { hash_iter_type * hash_iter_alloc(const hash_type * hash) { - hash_iter_type * iter = util_malloc(sizeof * iter ); + hash_iter_type * iter = util_malloc(sizeof * iter ); iter->hash = hash; iter->num_keys = hash_get_size(hash); @@ -931,9 +931,9 @@ void * hash_iter_get_next_value(hash_iter_type * iter) { .... value = hash_get( hash , key ); - func( value ); <-- The call is inplace - with no arguments, + func( value ); <-- The call is inplace - with no arguments, .... and no return value. The content of 'value' - can obviously change, but 'value' itself + can obviously change, but 'value' itself must still be a valid reference! */ @@ -943,7 +943,7 @@ void hash_apply( hash_type * hash , hash_apply_ftype * func) { while (!hash_iter_is_complete( iter )) { const char * key = hash_iter_get_next_key( iter ); void * value = hash_get( hash , key ); - + func( value ); } hash_iter_free( iter ); diff --git a/ThirdParty/Ert/devel/libert_util/src/matrix.c b/ThirdParty/Ert/devel/libert_util/src/matrix.c index 97356ee044..dc6f03d75a 100644 --- a/ThirdParty/Ert/devel/libert_util/src/matrix.c +++ b/ThirdParty/Ert/devel/libert_util/src/matrix.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'matrix.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -75,8 +75,8 @@ struct matrix_struct { int alloc_columns; int row_stride; /* The distance in data between two conscutive row values. */ int column_stride; /* The distance in data between to consecutive column values. */ - - /* + + /* Observe that the stride is considered an internal property - if the matrix is stored to disk and then recovered the strides might change, and also matrix_alloc_copy() will not respect strides. @@ -104,7 +104,7 @@ static void matrix_init_header(matrix_type * matrix , int rows , int columns , i if (!((column_stride * columns <= row_stride) || (row_stride * rows <= column_stride))) util_abort("%s: invalid stride combination \n",__func__); - + matrix->data_size = 0; matrix->alloc_rows = rows; matrix->alloc_columns = columns; @@ -127,7 +127,7 @@ static void matrix_init_header(matrix_type * matrix , int rows , int columns , i subsequently calling malloc() to get new storage. This is to avoid prohibitive temporary memory requirements during the realloc() call. - + 2. If the malloc() fails the function will return NULL, i.e. you will NOT keep the original data pointer. I.e. in this case the matrix will be invalid. It is the responsability of the calling @@ -145,9 +145,9 @@ static void matrix_realloc_data__( matrix_type * matrix , bool safe_mode ) { if (matrix->data_size == data_size) return; if (matrix->data != NULL) free(matrix->data); - + if (safe_mode) { - /* + /* If safe_mode == true it is 'OK' to fail in the allocation, otherwise we use util_malloc() which will abort if the memory is not available. @@ -155,14 +155,14 @@ static void matrix_realloc_data__( matrix_type * matrix , bool safe_mode ) { matrix->data = malloc( sizeof * matrix->data * data_size ); } else matrix->data = util_malloc( sizeof * matrix->data * data_size ); - + /* Initializing matrix content to zero. */ if (matrix->data != NULL) { size_t i; for (i = 0; i < data_size; i++) matrix->data[i] = 0; - } else + } else data_size = 0; /** @@ -170,7 +170,7 @@ static void matrix_realloc_data__( matrix_type * matrix , bool safe_mode ) { be returned with data == NULL, and data_size == 0. */ matrix->data_size = data_size; - } else + } else util_abort("%s: can not manipulate memory when is not data owner\n",__func__); } @@ -178,7 +178,7 @@ static void matrix_realloc_data__( matrix_type * matrix , bool safe_mode ) { UTIL_SAFE_CAST_FUNCTION( matrix , MATRIX_TYPE_ID ) /** - The matrix objecty is NOT ready for use after this function. + The matrix objecty is NOT ready for use after this function. */ static matrix_type * matrix_alloc_empty( ) { matrix_type * matrix = util_malloc( sizeof * matrix ); @@ -203,7 +203,7 @@ static matrix_type * matrix_alloc_with_stride(int rows , int columns , int row_s matrix->data_owner = true; matrix_realloc_data__( matrix , safe_mode ); if (safe_mode) { - if (matrix->data == NULL) { + if (matrix->data == NULL) { /* Allocation failed - we return NULL */ matrix_free(matrix); matrix = NULL; @@ -233,14 +233,14 @@ matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column src->rows , src->columns, row,column, rows,columns); - + { matrix_type * matrix = matrix_alloc_empty(); - + matrix_init_header( matrix , rows , columns , src->row_stride , src->column_stride); matrix->data = &src->data[ GET_INDEX(src , row , column) ]; matrix->data_owner = false; - + return matrix; } } @@ -248,11 +248,11 @@ matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column matrix_type * matrix_alloc_view(double * data , int rows , int columns) { matrix_type * matrix = matrix_alloc_empty(); - + matrix_init_header( matrix , rows , columns , 1 , rows); matrix->data = data; matrix->data_owner = false; - + return matrix; } @@ -265,17 +265,17 @@ matrix_type * matrix_alloc_view(double * data , int rows , int columns) { supplied pointer is too small it is immediately realloced ( in which case the pointer in the calling scope will be immediately invalid). -*/ +*/ matrix_type * matrix_alloc_steal_data(int rows , int columns , double * data , int data_size) { matrix_type * matrix = matrix_alloc_empty(); - matrix_init_header( matrix , rows , columns , 1 , rows ); + matrix_init_header( matrix , rows , columns , 1 , rows ); matrix->data_size = data_size; /* Can in general be different from rows * columns */ matrix->data_owner = true; matrix->data = data; - if (data_size < rows * columns) + if (data_size < rows * columns) matrix_realloc_data__(matrix , false); - + return matrix; } @@ -303,7 +303,7 @@ matrix_type * matrix_safe_alloc(int rows, int columns) { */ static matrix_type * matrix_alloc_copy__( const matrix_type * src , bool safe_mode) { matrix_type * copy = matrix_alloc__( matrix_get_rows( src ), matrix_get_columns( src ) , safe_mode); - if (copy != NULL) + if (copy != NULL) matrix_assign(copy , src); return copy; } @@ -313,6 +313,39 @@ matrix_type * matrix_alloc_copy(const matrix_type * src) { return matrix_alloc_copy__(src , false ); } +matrix_type * matrix_alloc_column_compressed_copy(const matrix_type * src, const bool_vector_type * mask) { + if (bool_vector_size( mask ) != matrix_get_columns( src )) + util_abort("%s: size mismatch. Src matrix has %d rows mask has:%d elements\n", __func__ , matrix_get_rows( src ) , bool_vector_size( mask )); + { + int target_columns = bool_vector_count_equal( mask , true ); + matrix_type * target = matrix_alloc( matrix_get_rows( src ) , target_columns ); + + matrix_column_compressed_memcpy( target , src , mask ); + return target; + } +} + + +void matrix_column_compressed_memcpy(matrix_type * target, const matrix_type * src, const bool_vector_type * mask) { + if (bool_vector_count_equal( mask , true ) != matrix_get_columns( target )) + util_abort("%s: size mismatch. \n",__func__); + + if (bool_vector_size( mask ) != matrix_get_columns( src)) + util_abort("%s: size mismatch. \n",__func__); + + { + int target_col = 0; + int src_col; + for (src_col = 0; src_col < bool_vector_size( mask ); src_col++) { + if (bool_vector_iget( mask , src_col)) { + matrix_copy_column( target , src , target_col , src_col); + target_col++; + } + } + } +} + + matrix_type * matrix_realloc_copy(matrix_type * T , const matrix_type * src) { if (T == NULL) @@ -328,7 +361,7 @@ matrix_type * matrix_realloc_copy(matrix_type * T , const matrix_type * src) { /** - Will return NULL if allocation of the copy failed. + Will return NULL if allocation of the copy failed. */ matrix_type * matrix_safe_alloc_copy(const matrix_type * src) { @@ -343,7 +376,7 @@ void matrix_copy_block( matrix_type * target_matrix , int target_row , int targe matrix_free( target_view ); matrix_free( src_view ); } - + /*****************************************************************/ @@ -353,21 +386,21 @@ static bool matrix_resize__(matrix_type * matrix , int rows , int columns , bool util_abort("%s: sorry - can not resize shared matrizes. \n",__func__); { bool resize_OK = true; - + if ((rows != matrix->rows) || (columns != matrix->columns)) { int copy_rows = util_int_min( rows , matrix->rows ); int copy_columns = util_int_min( columns , matrix->columns); matrix_type * copy_view = NULL; - matrix_type * copy = NULL; - + matrix_type * copy = NULL; + if (copy_content) { - copy_view = matrix_alloc_shared( matrix , 0 , 0 , copy_rows , copy_columns); /* This is the part of the old matrix which should be copied over to the new. */ + copy_view = matrix_alloc_shared( matrix , 0 , 0 , copy_rows , copy_columns); /* This is the part of the old matrix which should be copied over to the new. */ copy = matrix_alloc_copy__( copy_view , safe_mode ); /* Now copy contains the part of the old matrix which should be copied over - with private storage. */ } { int old_rows , old_columns, old_row_stride , old_column_stride; matrix_get_dims( matrix , &old_rows , &old_columns , &old_row_stride , &old_column_stride); /* Storing the old header information - in case the realloc() fails. */ - + matrix_init_header(matrix , rows , columns , 1 , rows); /* Resetting the header for the matrix */ matrix_realloc_data__(matrix , safe_mode); if (matrix->data != NULL) { /* Realloc succeeded */ @@ -376,13 +409,13 @@ static bool matrix_resize__(matrix_type * matrix , int rows , int columns , bool matrix_assign( target_view , copy); matrix_free( target_view ); } - } else { + } else { /* Failed to realloc new storage; RETURNING AN INVALID MATRIX */ matrix_init_header(matrix , old_rows , old_columns , old_row_stride , old_column_stride); resize_OK = false; } } - + if (copy_content) { matrix_free(copy_view); matrix_free(copy); @@ -393,11 +426,11 @@ static bool matrix_resize__(matrix_type * matrix , int rows , int columns , bool } -/** +/** If copy content is true the content of the old matrix is carried over to the new one, otherwise the new matrix is cleared. - - Will always return true (or abort). + + Will always return true (or abort). */ bool matrix_resize(matrix_type * matrix , int rows , int columns , bool copy_content) { return matrix_resize__(matrix , rows , columns , copy_content , false); @@ -420,10 +453,10 @@ bool matrix_safe_resize(matrix_type * matrix , int rows , int columns , bool cop -/** +/** This function will ensure that the matrix has at least 'rows' rows. If the present matrix already has >= rows it will return - immediately, otherwise the matrix will be resized. + immediately, otherwise the matrix will be resized. */ void matrix_ensure_rows(matrix_type * matrix, int rows, bool copy_content) { @@ -433,7 +466,7 @@ void matrix_ensure_rows(matrix_type * matrix, int rows, bool copy_content) { -/** +/** This function will reduce the size of the matrix. It will only affect the headers, and not touch the actual memory of the matrix. */ @@ -442,7 +475,7 @@ void matrix_shrink_header(matrix_type * matrix , int rows , int columns) { if (rows <= matrix->rows) matrix->rows = rows; - + if (columns <= matrix->columns) matrix->columns = columns; @@ -498,7 +531,7 @@ void matrix_pretty_fprint(const matrix_type * matrix , const char * name , const for (l = 0; l < strlen(name) + 2; l++) fprintf(stream , " "); } - + fprintf(stream , " ["); for (j=0; j < matrix->columns; j++) fprintf(stream , fmt , matrix_iget(matrix , i,j)); @@ -515,7 +548,7 @@ void matrix_pretty_print(const matrix_type * matrix , const char * name , const void matrix_fprintf( const matrix_type * matrix , const char * fmt , FILE * stream ) { int i,j; for (i=0; i < matrix->rows; i++) { - for (j=0; j < matrix->columns; j++) + for (j=0; j < matrix->columns; j++) fprintf(stream , fmt , matrix_iget( matrix , i , j)); fprintf(stream , "\n"); } @@ -526,7 +559,7 @@ void matrix_fprintf( const matrix_type * matrix , const char * fmt , FILE * stre void matrix_fwrite(const matrix_type * matrix , FILE * stream) { util_fwrite_int( matrix->rows , stream ); util_fwrite_int( matrix->columns , stream ); - + if (matrix->column_stride == matrix->rows) util_fwrite( matrix->data , sizeof * matrix->data , matrix->columns * matrix->rows , stream , __func__); else { @@ -548,7 +581,7 @@ void matrix_fwrite(const matrix_type * matrix , FILE * stream) { void matrix_fread(matrix_type * matrix , FILE * stream) { int rows = util_fread_int( stream ); int columns = util_fread_int( stream ); - + matrix_resize( matrix , rows , columns , false); if (matrix->column_stride == matrix->rows) util_fread( matrix->data , sizeof * matrix->data , matrix->columns * matrix->rows , stream , __func__); @@ -576,7 +609,7 @@ matrix_type * matrix_fread_alloc(FILE * stream) { /** [ a11 a12 ] - [ a21 a22 ] + [ a21 a22 ] @@ -595,7 +628,7 @@ matrix_type * matrix_fread_alloc(FILE * stream) { a_12 a_21 a_22 - + The @orw_major_order parameter ONLY affects the layout on the file, and NOT the memory layout of the matrix. @@ -606,7 +639,7 @@ static void __fscanf_and_set( matrix_type * matrix , int row , int col , FILE * double value; if (fscanf(stream , "%lg" , &value) == 1) matrix_iset( matrix , row , col , value ); - else + else util_abort("%s: reading of matrix failed at row:%d col:%d \n",__func__ , row , col); } @@ -617,13 +650,13 @@ void matrix_fscanf_data( matrix_type * matrix , bool row_major_order , FILE * st for (row = 0; row < matrix->columns; row++) { for (col = 0; col < matrix->columns; col++) { __fscanf_and_set( matrix , row , col ,stream); - } + } } } else { for (row = 0; row < matrix->columns; row++) { for (col = 0; col < matrix->columns; col++) { __fscanf_and_set( matrix , row , col , stream); - } + } } } } @@ -634,7 +667,7 @@ void matrix_fscanf_data( matrix_type * matrix , bool row_major_order , FILE * st /* Functions which manipulate one element in the matrix. */ static void matrix_assert_ij( const matrix_type * matrix , int i , int j) { - if ((i < 0) || (i >= matrix->rows) || (j < 0) || (j >= matrix->columns)) + if ((i < 0) || (i >= matrix->rows) || (j < 0) || (j >= matrix->columns)) util_abort("%s: (i,j) = (%d,%d) invalid. Matrix size: %d x %d \n",__func__ , i,j,matrix->rows , matrix->columns); } @@ -672,7 +705,7 @@ double matrix_iget_safe(const matrix_type * matrix , int i , int j) { matrix_assert_ij( matrix , i , j ); return matrix_iget( matrix , i , j ); } - + void matrix_iadd(matrix_type * matrix , int i , int j , double value) { matrix->data[ GET_INDEX(matrix , i,j) ] += value; @@ -695,7 +728,7 @@ void matrix_imul(matrix_type * matrix , int i , int j , double value) { void matrix_set(matrix_type * matrix, double value) { int i,j; for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) + for (i=0; i < matrix->rows; i++) matrix_iset(matrix , i , j , value); } @@ -703,7 +736,7 @@ void matrix_set(matrix_type * matrix, double value) { void matrix_shift(matrix_type * matrix, double value) { int i,j; for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) + for (i=0; i < matrix->rows; i++) matrix_iadd(matrix , i , j , value); } @@ -711,7 +744,7 @@ void matrix_shift(matrix_type * matrix, double value) { void matrix_scale(matrix_type * matrix, double value) { int i,j; for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) + for (i=0; i < matrix->rows; i++) matrix_imul(matrix , i , j , value); } @@ -752,16 +785,16 @@ void matrix_set_const_row(matrix_type * matrix , const double value , int row) { void matrix_copy_column(matrix_type * target_matrix, const matrix_type * src_matrix , int target_column, int src_column) { matrix_assert_equal_rows( target_matrix , src_matrix ); - { + { int row; for(row = 0; row < target_matrix->rows; row++) target_matrix->data[ GET_INDEX( target_matrix, row , target_column)] = src_matrix->data[ GET_INDEX( src_matrix, row, src_column)]; } -} +} void matrix_scale_column(matrix_type * matrix , int column , double scale_factor) { - int row; + int row; for (row = 0; row < matrix->rows; row++) matrix->data[ GET_INDEX( matrix , row , column) ] *= scale_factor; } @@ -779,7 +812,7 @@ void matrix_copy_row(matrix_type * target_matrix, const matrix_type * src_matrix for(col = 0; col < target_matrix->columns; col++) target_matrix->data[ GET_INDEX( target_matrix , target_row , col)] = src_matrix->data[ GET_INDEX( src_matrix, src_row, col)]; } -} +} /*****************************************************************/ @@ -794,9 +827,9 @@ double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , cons { int row; double sum = 0; - for( row = 0; row < m1->rows; row++) + for( row = 0; row < m1->rows; row++) sum += m1->data[ GET_INDEX(m1 , row , col1) ] * m2->data[ GET_INDEX(m2, row , col2) ]; - + return sum; } } @@ -809,9 +842,9 @@ double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const m { int k; double sum = 0; - for( k = 0; k < m1->columns; k++) + for( k = 0; k < m1->columns; k++) sum += m1->data[ GET_INDEX(m1 , row1 , k) ] * m2->data[ GET_INDEX(m2, k , col2) ]; - + return sum; } } @@ -827,7 +860,7 @@ double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const m void matrix_assign(matrix_type * A , const matrix_type * B) { if ((A->rows == B->rows) && (A->columns == B->columns)) { int i,j; - + if (A->row_stride == B->row_stride) { if (A->columns == A->row_stride) /** Memory is just one continous block */ memcpy( A->data , B->data , A->rows * A->columns * sizeof * A->data); @@ -835,29 +868,42 @@ void matrix_assign(matrix_type * A , const matrix_type * B) { /* Copying columns of data */ for (j = 0; j < A->columns; j++) memcpy( &A->data[ GET_INDEX(A , 0 , j)] , &B->data[ GET_INDEX(B , 0 , j) ] , A->rows * sizeof * A->data); - } + } } else { /* Copying element by element */ for (j = 0; j < A->columns; j++) for (i=0; i < A->rows; i++) A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ]; } - } else + } else util_abort("%s: size mismatch A:[%d,%d] B:[%d,%d] \n",__func__ , A->rows , A->columns , B->rows , B->columns); } +void matrix_inplace_sub_column(matrix_type * A , const matrix_type * B, int colA , int colB) { + if ((A->rows == B->rows) && + (colA < A->columns) && + (colB < B->columns)) { + int row; + + for (row = 0; row < A->rows; row++) + A->data[ GET_INDEX(A , row , colA)] -= B->data[ GET_INDEX(B , row , colB)]; + + } else + util_abort("%s: size mismatch \n",__func__); +} + /* Updates matrix A by adding in matrix B - elementwise. */ void matrix_inplace_add(matrix_type * A , const matrix_type * B) { if ((A->rows == B->rows) && (A->columns == B->columns)) { int i,j; - + for (j = 0; j < A->columns; j++) for (i=0; i < A->rows; i++) A->data[ GET_INDEX(A,i,j) ] += B->data[ GET_INDEX(B,i,j) ]; - - } else + + } else util_abort("%s: size mismatch \n",__func__); } @@ -866,12 +912,12 @@ void matrix_inplace_add(matrix_type * A , const matrix_type * B) { void matrix_inplace_mul(matrix_type * A , const matrix_type * B) { if ((A->rows == B->rows) && (A->columns == B->columns)) { int i,j; - + for (j = 0; j < A->columns; j++) for (i=0; i < A->rows; i++) A->data[ GET_INDEX(A,i,j) ] *= B->data[ GET_INDEX(B,i,j) ]; - - } else + + } else util_abort("%s: size mismatch \n",__func__); } @@ -883,12 +929,12 @@ void matrix_inplace_mul(matrix_type * A , const matrix_type * B) { void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C) { if ((A->rows == B->rows) && (A->columns == B->columns) && (A->rows == C->rows) && (A->columns == C->columns)) { int i,j; - + for (j = 0; j < A->columns; j++) for (i=0; i < A->rows; i++) A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ] * C->data[ GET_INDEX(B,i,j) ]; - - } else + + } else util_abort("%s: size mismatch \n",__func__); } @@ -898,13 +944,17 @@ void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C void matrix_inplace_sub(matrix_type * A , const matrix_type * B) { if ((A->rows == B->rows) && (A->columns == B->columns)) { int i,j; - + for (j = 0; j < A->columns; j++) for (i=0; i < A->rows; i++) A->data[ GET_INDEX(A,i,j) ] -= B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); + + } else + util_abort("%s: size mismatch A:[%d,%d] B:[%d,%d]\n",__func__ , + matrix_get_rows(A), + matrix_get_columns(A), + matrix_get_rows(B), + matrix_get_columns(B)); } @@ -917,12 +967,12 @@ void matrix_inplace_sub(matrix_type * A , const matrix_type * B) { void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C) { if ((A->rows == B->rows) && (A->columns == B->columns) && (A->rows == C->rows) && (A->columns == C->columns)) { int i,j; - + for (j = 0; j < A->columns; j++) for (i=0; i < A->rows; i++) A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ] - C->data[ GET_INDEX(B,i,j) ]; - - } else + + } else util_abort("%s: size mismatch \n",__func__); } @@ -933,24 +983,24 @@ void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C) void matrix_inplace_div(matrix_type * A , const matrix_type * B) { if ((A->rows == B->rows) && (A->columns == B->columns)) { int i,j; - + for (j = 0; j < A->columns; j++) for (i=0; i < A->rows; i++) A->data[ GET_INDEX(A,i,j) ] /= B->data[ GET_INDEX(B,i,j) ]; - - } else + + } else util_abort("%s: size mismatch \n",__func__); } /** Observe that A and T should not overlap, i.e. the call - + matrix_transpose(X , X) will fail in mysterious ways. */ - + void matrix_transpose(const matrix_type * A , matrix_type * T) { if ((A->columns == T->rows) && (A->rows == T->columns)) { int i,j; @@ -958,7 +1008,7 @@ void matrix_transpose(const matrix_type * A , matrix_type * T) { for (j=0; j < A->columns; j++) { size_t src_index = GET_INDEX(A , i , j ); size_t target_index = GET_INDEX(T , j , i ); - + T->data[ target_index ] = A->data[ src_index ]; } } @@ -978,8 +1028,8 @@ matrix_type * matrix_alloc_transpose( const matrix_type * A) { /** For this function to work the following must be satisfied: - columns in A == rows in B == columns in B - + columns in A == rows in B == columns in B + For general matrix multiplactions where A = B * C all have different dimensions you can use matrix_matmul() (which calls the BLAS routine dgemm()); @@ -990,18 +1040,18 @@ void matrix_inplace_matmul(matrix_type * A, const matrix_type * B) { if ((A->columns == B->rows) && (B->rows == B->columns)) { double * tmp = util_malloc( sizeof * A->data * A->columns ); int i,j,k; - + for (i=0; i < A->rows; i++) { - + /* Clearing the tmp vector */ for (k=0; k < B->rows; k++) tmp[k] = 0; for (j=0; j < B->rows; j++) { double scalar_product = 0; - for (k=0; k < A->columns; k++) + for (k=0; k < A->columns; k++) scalar_product += A->data[ GET_INDEX(A,i,k) ] * B->data[ GET_INDEX(B,k,j) ]; - + /* Assign first to tmp[j] */ tmp[j] = scalar_product; } @@ -1044,11 +1094,11 @@ static void * matrix_inplace_matmul_mt__(void * arg) { argument set to false. 2. The thread_pool has been joined __without__ an interevening - call to thread_pool_restart(). - + call to thread_pool_restart(). + If the thread_pool has not been correctly prepared, according to this specification, it will be crash and burn. -*/ +*/ void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_pool_type * thread_pool){ int num_threads = thread_pool_get_max_running( thread_pool ); @@ -1059,31 +1109,31 @@ void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_p int rows = matrix_get_rows( A ) / num_threads; int rows_mod = matrix_get_rows( A ) % num_threads; int row_offset = 0; - + for (it = 0; it < num_threads; it++) { int row_size; arglist[it] = arg_pack_alloc(); row_size = rows; if (it < rows_mod) row_size += 1; - + arg_pack_append_int(arglist[it] , row_offset ); arg_pack_append_int(arglist[it] , row_size ); arg_pack_append_ptr(arglist[it] , A ); arg_pack_append_const_ptr(arglist[it] , B ); - + thread_pool_add_job( thread_pool , matrix_inplace_matmul_mt__ , arglist[it]); row_offset += row_size; } } thread_pool_join( thread_pool ); - - for (it = 0; it < num_threads; it++) + + for (it = 0; it < num_threads; it++) arg_pack_free( arglist[it] ); free( arglist ); -} +} -void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ +void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ thread_pool_type * thread_pool = thread_pool_alloc( num_threads , false ); matrix_inplace_matmul_mt2( A , B , thread_pool ); thread_pool_free( thread_pool ); @@ -1091,7 +1141,7 @@ void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_ #else -void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ +void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ matrix_inplace_matmul( A , B ); } @@ -1168,14 +1218,14 @@ double matrix_get_column_sum2(const matrix_type * matrix , int column) { void matrix_shift_column(matrix_type * matrix , int column, double shift) { int i; - for ( i=0; i < matrix->rows; i++) + for ( i=0; i < matrix->rows; i++) matrix->data[ GET_INDEX( matrix , i , column) ] += shift; } void matrix_shift_row(matrix_type * matrix , int row , double shift) { int j; - for ( j=0; j < matrix->columns; j++) + for ( j=0; j < matrix->columns; j++) matrix->data[ GET_INDEX( matrix , row , j ) ] += shift; } @@ -1188,7 +1238,7 @@ void matrix_shift_row(matrix_type * matrix , int row , double shift) { */ void matrix_subtract_row_mean(matrix_type * matrix) { - int i; + int i; for ( i=0; i < matrix->rows; i++) { double row_mean = matrix_get_row_sum(matrix , i) / matrix->columns; matrix_shift_row( matrix , i , -row_mean); @@ -1212,9 +1262,9 @@ void matrix_imul_col( matrix_type * matrix , int column , double factor) { /*****************************************************************/ -/** +/** This function will return the double data pointer of the matrix, - when you use this explicitly you ARE ON YOUR OWN. + when you use this explicitly you ARE ON YOUR OWN. */ double * matrix_get_data(const matrix_type * matrix) { @@ -1249,7 +1299,7 @@ void matrix_get_dims(const matrix_type * matrix , int * rows , int * columns , *columns = matrix->columns; *row_stride = matrix->row_stride; *column_stride = matrix->column_stride; - + } @@ -1282,8 +1332,8 @@ void matrix_assert_finite( const matrix_type * matrix ) { if (!matrix_is_finite( matrix )) { if ((matrix->rows * matrix->columns) < 400) matrix_pretty_fprint( matrix , matrix->name , " %6.3f" , stdout); - - util_abort("%s: matrix:%s is not finite. \n",__func__ , matrix->name); + + util_abort("%s: matrix:%s is not finite. \n",__func__ , matrix->name); } } @@ -1296,7 +1346,7 @@ void matrix_assert_finite( const matrix_type * matrix ) { conditions for the matrix - i.e. when this function returns 0.000000 the matrix is perfectly orthonormal; otherwise it is the responsability of the calling scope to evaluate. -*/ +*/ double matrix_orthonormality( const matrix_type * matrix ) { double max_dev = 0.0; @@ -1310,7 +1360,7 @@ double matrix_orthonormality( const matrix_type * matrix ) { dev = fabs( dot_product - 1.0 ); else dev = fabs( dot_product ); - + if (dev > max_dev) max_dev = dev; } @@ -1326,14 +1376,14 @@ double matrix_orthonormality( const matrix_type * matrix ) { Return true if the two matrices m1 and m2 are equal. The equality test is based on element-by-element memcmp() comparison, i.e. the there is ZERO numerical tolerance in the comparison. - - If the two matrices do not have equal dimension false is returned. + + If the two matrices do not have equal dimension false is returned. */ bool matrix_equal( const matrix_type * m1 , const matrix_type * m2) { if (! ((m1->rows == m2->rows) && (m1->columns == m2->columns))) return false; - { + { int i,j; for (i=0; i < m1->rows; i++) { for (j=0; j < m1->columns; j++) { @@ -1341,8 +1391,8 @@ bool matrix_equal( const matrix_type * m1 , const matrix_type * m2) { int index2 = GET_INDEX(m2 , i , j); double d1 = m1->data[ index1 ]; double d2 = m2->data[ index2 ]; - - if (d1 != d2) + + if (d1 != d2) return false; } } @@ -1357,7 +1407,7 @@ bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type if (m1->rows != m2->rows) return false; - { + { int row; for (row=0; row < m1->rows; row++) { if (memcmp( &m1->data[ GET_INDEX(m1 , row , col1)] , &m2->data[ GET_INDEX(m2 , row , col2)] , sizeof * m1->data) != 0) @@ -1373,7 +1423,7 @@ bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type /* Various special matrices */ -/** +/** Will set the diagonal elements in matrix to the values in diag, and all remaining elements to zero. Assumes that matrix is rectangular. @@ -1392,7 +1442,7 @@ void matrix_diag_set(matrix_type * matrix , const double * diag) { /** Will set the scalar @value on all the diagonal elements of the - matrix; all off-diagonal elements are explicitly set to zero. + matrix; all off-diagonal elements are explicitly set to zero. */ void matrix_diag_set_scalar(matrix_type * matrix , double value) { @@ -1459,8 +1509,8 @@ void matrix_clear( matrix_type * matrix ) { m = fread(fid , [dims(1) , dims(2)] , 'double'); fclose(fid); - - >> A = load_matrix( 'filename' ); + + >> A = load_matrix( 'filename' ); */ @@ -1480,9 +1530,9 @@ void matrix_matlab_dump(const matrix_type * matrix, const char * filename) { // Comment void matrix_inplace_diag_sqrt(matrix_type *Cd) -{ +{ int nrows = Cd->rows; - + if (Cd->rows != Cd->columns) { util_abort("%s: size mismatch \n",__func__); } @@ -1490,10 +1540,10 @@ void matrix_inplace_diag_sqrt(matrix_type *Cd) int i; for ( i=0; i<nrows; i++) { - Cd->data[GET_INDEX(Cd , i , i)] = sqrt(Cd->data[GET_INDEX(Cd , i , i)]); + Cd->data[GET_INDEX(Cd , i , i)] = sqrt(Cd->data[GET_INDEX(Cd , i , i)]); } } -} +} @@ -1501,7 +1551,7 @@ double matrix_trace(const matrix_type *matrix) { int nrows = matrix->rows; double sum = 0; - + if (matrix->rows != matrix->columns) { util_abort("%s: matrix is not square \n",__func__); } @@ -1509,7 +1559,7 @@ double matrix_trace(const matrix_type *matrix) { int i; for ( i=0; i<nrows; i++) { - sum = sum + matrix->data[GET_INDEX(matrix , i , i)]; + sum = sum + matrix->data[GET_INDEX(matrix , i , i)]; } } return sum; @@ -1535,13 +1585,13 @@ double matrix_diag_std(const matrix_type * Sk,double mean) int nrows = Sk->rows; double std = 0; int i; - + for ( i=0; i<nrows; i++) { double d = Sk->data[GET_INDEX(Sk , i , i)] - mean; std += d*d; } - + std = sqrt(std / nrows); return std; } @@ -1564,7 +1614,7 @@ double matrix_det2( const matrix_type * A) { return a00 * a11 - a10 * a01; } else { - util_abort("%s: hardcoded for 2x2 matrices A is: %d x %d \n",__func__, A->rows , A->columns); + util_abort("%s: hardcoded for 2x2 matrices A is: %d x %d \n",__func__, A->rows , A->columns); return 0; } } @@ -1582,10 +1632,10 @@ double matrix_det3( const matrix_type * A) { double g = A->data[GET_INDEX(A,2,0)]; double h = A->data[GET_INDEX(A,2,1)]; double i = A->data[GET_INDEX(A,2,2)]; - + return a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h; } else { - util_abort("%s: hardcoded for 3x3 matrices A is: %d x %d \n",__func__, A->rows , A->columns); + util_abort("%s: hardcoded for 3x3 matrices A is: %d x %d \n",__func__, A->rows , A->columns); return 0; } } @@ -1609,11 +1659,11 @@ double matrix_det4( const matrix_type * A) { double a31 = A->data[GET_INDEX(A,3,1)]; double a32 = A->data[GET_INDEX(A,3,2)]; double a33 = A->data[GET_INDEX(A,3,3)]; - + /* double det = (a00*(a11*(a22*a33 - a23*a32)-a12*(a21*a33 - a23*a31)+a13*(a21*a32 - a22*a31)) - - a01*(a10*(a22*a33 - a23*a32)-a12*(a20*a33 - a23*a30)+a13*(a20*a32 - a22*a30)) + - a02*(a10*(a21*a33 - a23*a31)-a11*(a20*a33 - a23*a30)+a13*(a20*a31 - a21*a30)) - + a01*(a10*(a22*a33 - a23*a32)-a12*(a20*a33 - a23*a30)+a13*(a20*a32 - a22*a30)) + + a02*(a10*(a21*a33 - a23*a31)-a11*(a20*a33 - a23*a30)+a13*(a20*a31 - a21*a30)) - a03*(a10*(a21*a32 - a22*a31)-a11*(a20*a32 - a22*a30)+a12*(a20*a31 - a21*a30))); */ double det = 0; @@ -1630,28 +1680,28 @@ double matrix_det4( const matrix_type * A) { a02*a13*a20*a31, a03*a10*a22*a31, a03*a11*a20*a32, - a03*a12*a21*a30 + a03*a12*a21*a30 -a02*a13*a21*a30, - -a03*a10*a21*a32, - -a03*a11*a22*a30, - -a03*a12*a20*a31, + -a03*a10*a21*a32, + -a03*a11*a22*a30, + -a03*a12*a20*a31, -a00*a11*a23*a32, -a00*a12*a21*a33, -a00*a13*a22*a31, - -a01*a10*a22*a33, - -a01*a12*a23*a30, - -a01*a13*a20*a32, - -a02*a10*a23*a31, + -a01*a10*a22*a33, + -a01*a12*a23*a30, + -a01*a13*a20*a32, + -a02*a10*a23*a31, -a02*a11*a20*a33}; int i; - for (i = 0; i < 12; i++) + for (i = 0; i < 12; i++) det += (factors[i] + factors[i + 12]); } - + return det; } else { - util_abort("%s: hardcoded for 4x4 matrices A is: %d x %d \n",__func__, A->rows , A->columns); + util_abort("%s: hardcoded for 4x4 matrices A is: %d x %d \n",__func__, A->rows , A->columns); return 0; } } diff --git a/ThirdParty/Ert/devel/libert_util/src/matrix_blas.c b/ThirdParty/Ert/devel/libert_util/src/matrix_blas.c index d860151bde..d4d2d6c37b 100644 --- a/ThirdParty/Ert/devel/libert_util/src/matrix_blas.c +++ b/ThirdParty/Ert/devel/libert_util/src/matrix_blas.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_blas.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'matrix_blas.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -40,7 +40,7 @@ void dgemv_(char * , int * , int * , double * , double * , int * , const double x,y : vectors A : matrix - + x and y are entered as (double * ). */ @@ -53,11 +53,11 @@ void matrix_dgemv(const matrix_type * A , const double *x , double * y, bool tra int incy = 1; char transA_c; - if (transA) + if (transA) transA_c = 'T'; else transA_c = 'N'; - + dgemv_(&transA_c , &m , &n , &alpha , matrix_get_data( A ) , &lda , x , &incx , &beta , y , &incy); } @@ -74,7 +74,7 @@ void matrix_mul_vector(const matrix_type * A , const double * x , double * y) { static void dgemm_debug(const matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB) { printf("\nC = [%d , %d]\n",matrix_get_rows( C ) , matrix_get_columns(C)); - + printf("A: [%d , %d]", matrix_get_rows( A ) , matrix_get_columns(A)); if (transA) printf("^T"); @@ -89,13 +89,13 @@ static void dgemm_debug(const matrix_type *C , const matrix_type *A , const matr printf("[%d ,%d] x ",matrix_get_rows( A ) , matrix_get_columns(A)); else printf("[%d ,%d] x ",matrix_get_columns( A ) , matrix_get_rows(A)); - - + + if (transB) printf("[%d ,%d]\n",matrix_get_rows( B ) , matrix_get_columns(B)); else printf("[%d ,%d]\n",matrix_get_columns( B ) , matrix_get_rows(B)); - + } @@ -116,13 +116,13 @@ void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B char transA_c; char transB_c; int k , innerA, innerB , outerA , outerB; - - if (transA) + + if (transA) k = matrix_get_rows( A ); else k = matrix_get_columns( A ); - - + + if (transA) { innerA = matrix_get_rows(A); outerA = matrix_get_columns(A); @@ -133,17 +133,17 @@ void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B transA_c = 'N'; } - + if (transB) { - innerB = matrix_get_columns( B ); - outerB = matrix_get_rows( B ); + innerB = matrix_get_columns( B ); + outerB = matrix_get_rows( B ); transB_c = 'T'; } else { transB_c = 'N'; innerB = matrix_get_rows( B ); - outerB = matrix_get_columns( B ); + outerB = matrix_get_columns( B ); } - + /* This is the dimension check which must pass: @@ -151,7 +151,7 @@ void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B A | B | Columns(A) = Rows(B) Trans(A) | Trans(B) | Rows(A) = Columns(B) A | Trans(B) | Columns(A) = Columns(B) - Trans(A) | B | Rows(A) = Rows(B) + Trans(A) | B | Rows(A) = Rows(B) -------------------------------------------------- -------------------------------------------------- @@ -160,22 +160,22 @@ void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B B | Columns(B) = Columns(C) Trans(B) | Rows(B) = Columns(B) -------------------------------------------------- - + */ - + if (innerA != innerB) { dgemm_debug(C,A,B,transA , transB); util_abort("%s: matrix size mismatch between A and B \n", __func__); } - - + + if (outerA != matrix_get_rows( C )) { dgemm_debug(C,A,B,transA , transB); printf("outerA:%d rows(C):%d \n",outerA , matrix_get_rows( C )); util_abort("%s: matrix size mismatch between A and C \n",__func__); } - + if (outerB != matrix_get_columns( C )) { dgemm_debug(C,A,B,transA , transB); util_abort("%s: matrix size mismatch between B and C \n",__func__); @@ -199,8 +199,8 @@ void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B &lda , // 8 matrix_get_data( B ) , // 9 &ldb , // 10 - &beta , // 11 - matrix_get_data( C ) , // 12 + &beta , // 11 + matrix_get_data( C ) , // 12 &ldc); // 13 } @@ -211,7 +211,7 @@ void matrix_matmul_with_transpose(matrix_type * C, const matrix_type * A , const } -/* +/* This function does a general matrix multiply of A * B, and stores the result in C. */ @@ -247,13 +247,13 @@ void matrix_gram_set( const matrix_type * X , matrix_type * G, bool col) { int X_cols = matrix_get_columns( X ); if (col) { // Calculate X' · X - if ((G_rows == G_cols) && (X_cols == G_rows)) + if ((G_rows == G_cols) && (X_cols == G_rows)) matrix_dgemm( G , X , X , true , false , 1 , 0); - else + else util_abort("%s: dimension mismatch \n",__func__); } else { // Calculate X · X' - if ((G_rows == G_cols) && (X_rows == G_rows)) + if ((G_rows == G_cols) && (X_rows == G_rows)) matrix_dgemm( G , X , X , false , true , 1 , 0); else util_abort("%s: dimension mismatch \n",__func__); @@ -263,7 +263,7 @@ void matrix_gram_set( const matrix_type * X , matrix_type * G, bool col) { /** If col == true: G = X' · X - col == false: G = X · X' + col == false: G = X · X' */ @@ -272,8 +272,8 @@ matrix_type * matrix_alloc_gram( const matrix_type * X , bool col) { int X_columns = matrix_get_columns( X ); matrix_type * G; - if (col) - G = matrix_alloc( X_columns , X_columns ); + if (col) + G = matrix_alloc( X_columns , X_columns ); else G = matrix_alloc( X_rows , X_rows ); diff --git a/ThirdParty/Ert/devel/libert_util/src/matrix_lapack.c b/ThirdParty/Ert/devel/libert_util/src/matrix_lapack.c index 3f8bb0ec9a..7c3f3afb42 100644 --- a/ThirdParty/Ert/devel/libert_util/src/matrix_lapack.c +++ b/ThirdParty/Ert/devel/libert_util/src/matrix_lapack.c @@ -1,22 +1,22 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_lapack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'matrix_lapack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ -#include <math.h> +#include <math.h> #include <ert/util/util.h> #include <ert/util/matrix.h> @@ -26,13 +26,13 @@ extern "C" { #endif -/** - The external lapack routines +/** + The external lapack routines */ /*****************************************************************/ void dgesv_(int * n, int * nrhs , double * A , int * lda , long int * ipivot , double * B , int * ldb , int * info); void dgesvd_(char * jobu , char * jobvt , int * m , int * n , double * A, int * lda , double * S , double * U , int * ldu , double * VT , int * ldvt, double * work , int * worksize , int * info); -void dsyevx_(char * jobz, char * range , char * uplo , int *n , double * A , int * lda , double * vl , double * vu , int * il , int * iu , double * abstol , int * m , double * w , double *z , int * ldz , double * work, int * lwork , int * iwork , int * ifail , int * info); +void dsyevx_(char * jobz, char * range , char * uplo , int *n , double * A , int * lda , double * vl , double * vu , int * il , int * iu , double * abstol , int * m , double * w , double *z , int * ldz , double * work, int * lwork , int * iwork , int * ifail , int * info); void dgeqrf_(int * m , int * n , double * A , int * lda , double * tau , double * work , int * lwork, int * info); void dorgqr_(int * m, int * n , int * k , double * A , int * lda , double * tau , double * work , int * lwork, int * info); void dgetrf_(int * M , int * n , double * A , int * lda , int * ipiv, int * info); @@ -83,13 +83,13 @@ void matrix_dgesv(matrix_type * A , matrix_type * B) { matrix_lapack_assert_square( A ); matrix_lapack_assert_fortran_layout( B ); { - int n = matrix_get_rows( A ); + int n = matrix_get_rows( A ); int lda = matrix_get_column_stride( A ); int ldb = matrix_get_column_stride( B ); int nrhs = matrix_get_columns( B ); long int * ipivot = util_calloc( n , sizeof * ipivot ); int info; - + dgesv_(&n , &nrhs , matrix_get_data( A ) , &lda , ipivot , matrix_get_data( B ), &ldb , &info); if (info != 0) util_abort("%s: low level lapack routine: dgesv() failed with info:%d \n",__func__ , info); @@ -108,8 +108,8 @@ void matrix_dgesv(matrix_type * A , matrix_type * B) { This little function translates between an integer identifier (i.e. and enum instance) to one of the characters used by the low level lapack routine to indicate how the singular vectors should be - returned to the calling scope. - + returned to the calling scope. + The meaning of the different enum values is documented in the enum definition in the header file matrix_lapack.h. */ @@ -143,7 +143,7 @@ static char dgesvd_get_vector_job( dgesvd_vector_enum vector_job) { void matrix_dgesvd(dgesvd_vector_enum jobu , dgesvd_vector_enum jobvt , matrix_type * A , double * S , matrix_type * U , matrix_type * VT) { char _jobu = dgesvd_get_vector_job( jobu ); - char _jobvt = dgesvd_get_vector_job( jobvt ); + char _jobvt = dgesvd_get_vector_job( jobvt ); int m = matrix_get_rows( A ); int n = matrix_get_columns( A ); int lda = matrix_get_column_stride( A ); @@ -162,7 +162,7 @@ void matrix_dgesvd(dgesvd_vector_enum jobu , dgesvd_vector_enum jobvt , matrix_ util_abort("%s: internal error \n",__func__); } else { ldu = matrix_get_column_stride( U ); - U_data = matrix_get_data( U ); + U_data = matrix_get_data( U ); if (jobu == DGESVD_NONE) util_abort("%s: internal error \n",__func__); } @@ -174,21 +174,21 @@ void matrix_dgesvd(dgesvd_vector_enum jobu , dgesvd_vector_enum jobvt , matrix_ util_abort("%s: internal error \n",__func__); } else { ldvt = matrix_get_column_stride( VT ); - VT_data = matrix_get_data( VT ); + VT_data = matrix_get_data( VT ); if (jobvt == DGESVD_NONE) util_abort("%s: internal error \n",__func__); } - /* - Query the routine for optimal worksize. + /* + Query the routine for optimal worksize. */ - + work = util_calloc( 1 , sizeof * work ); worksize = -1; dgesvd_(&_jobu , /* 1 */ &_jobvt , /* 2 */ &m , /* 3 */ - &n , /* 4 */ + &n , /* 4 */ matrix_get_data( A ) , /* 5 */ &lda , /* 6 */ S , /* 7 */ @@ -199,8 +199,8 @@ void matrix_dgesvd(dgesvd_vector_enum jobu , dgesvd_vector_enum jobvt , matrix_ work , /* 12 */ &worksize , /* 13 */ &info); /* 14 */ - - + + /* Try to allocate optimal worksize. */ worksize = (int) work[0]; work = realloc( work , sizeof * work * worksize ); @@ -221,28 +221,28 @@ void matrix_dgesvd(dgesvd_vector_enum jobu , dgesvd_vector_enum jobvt , matrix_ /* Return value is the number of eigenvalues found. */ /******************************************************************/ -int matrix_dsyevx(bool compute_eig_vectors , - dsyevx_eig_enum which_values , /* DSYEVX | DSYEVX_VALUE_INTERVAL | DSYEVX_INDEX_INTERVAL */ - dsyevx_uplo_enum uplo, - matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ +int matrix_dsyevx(bool compute_eig_vectors , + dsyevx_eig_enum which_values , /* DSYEVX | DSYEVX_VALUE_INTERVAL | DSYEVX_INDEX_INTERVAL */ + dsyevx_uplo_enum uplo, + matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ double VL , /* Lower limit when using DSYEVX_VALUE_INTERVAL */ double VU , /* Upper limit when using DSYEVX_VALUE_INTERVAL */ - int IL , /* Lower index when using DSYEVX_INDEX_INTERVAL */ + int IL , /* Lower index when using DSYEVX_INDEX_INTERVAL */ int IU , /* Upper index when using DSYEVX_INDEX_INTERVAL */ double *eig_values , /* The calcualated eigenvalues */ - matrix_type * Z ) { /* The eigenvectors as columns vectors */ + matrix_type * Z ) { /* The eigenvectors as columns vectors */ int lda = matrix_get_column_stride( A ); int n = matrix_get_rows( A ); char jobz; char range; char uplo_c; - + if (compute_eig_vectors) jobz = 'V'; else jobz = 'N'; - + switch(which_values) { case(DSYEVX_ALL): range = 'A'; @@ -263,11 +263,11 @@ int matrix_dsyevx(bool compute_eig_vectors , uplo_c = 'L'; else util_abort("%s: internal error \n",__func__); - - + + if (!matrix_is_quadratic( A )) util_abort("%s: matrix A must be quadratic \n",__func__); - + { int num_eigenvalues , ldz, info , worksize; int * ifail = util_calloc( n , sizeof * ifail ); @@ -285,20 +285,20 @@ int matrix_dsyevx(bool compute_eig_vectors , ldz = 1; z_data = NULL; } - + /* First call to determine optimal worksize. */ worksize = -1; info = 0; dsyevx_( &jobz, /* 1 */ &range, /* 2 */ &uplo_c, /* 3 */ - &n, /* 4 */ + &n, /* 4 */ matrix_get_data( A ), /* 5 */ &lda , /* 6 */ &VL , /* 7 */ &VU , /* 8 */ &IL , /* 9 */ - &IU , /* 10 */ + &IU , /* 10 */ &abstol , /* 11 */ &num_eigenvalues , /* 12 */ eig_values , /* 13 */ @@ -309,14 +309,14 @@ int matrix_dsyevx(bool compute_eig_vectors , iwork , /* 18 */ ifail , /* 19 */ &info); /* 20 */ - - + + worksize = (int) work[0]; { double * tmp = realloc(work , sizeof * work * worksize ); if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, + /* + OK - we could not get the optimal worksize, try again with the minimum. */ worksize = 8 * n; @@ -331,20 +331,20 @@ int matrix_dsyevx(bool compute_eig_vectors , &uplo_c, &n, matrix_get_data( A ), - &lda , + &lda , &VL , - &VU , - &IL , - &IU , - &abstol , - &num_eigenvalues , - eig_values , - z_data , - &ldz , - work , - &worksize , - iwork , - ifail , + &VU , + &IL , + &IU , + &abstol , + &num_eigenvalues , + eig_values , + z_data , + &ldz , + work , + &worksize , + iwork , + ifail , &info); free( ifail ); @@ -360,10 +360,10 @@ int matrix_dsyevx(bool compute_eig_vectors , matrix_dsyevx() function. */ -int matrix_dsyevx_all(dsyevx_uplo_enum uplo, - matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ +int matrix_dsyevx_all(dsyevx_uplo_enum uplo, + matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ double *eig_values , /* The calcualated eigenvalues */ - matrix_type * Z ) { /* The eigenvectors as columns vectors */ + matrix_type * Z ) { /* The eigenvectors as columns vectors */ int num_eigenvalues; num_eigenvalues = matrix_dsyevx(true , DSYEVX_ALL , uplo , A , 0,0,0,0, eig_values , Z); return num_eigenvalues; @@ -378,7 +378,7 @@ int matrix_dsyevx_all(dsyevx_uplo_enum uplo, void matrix_dgeqrf(matrix_type * A , double * tau) { int lda = matrix_get_column_stride( A ); int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); + int n = matrix_get_columns( A ); double * work = util_calloc(1 , sizeof * work ); int worksize; int info; @@ -393,8 +393,8 @@ void matrix_dgeqrf(matrix_type * A , double * tau) { { double * tmp = realloc(work , sizeof * work * worksize ); if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, + /* + OK - we could not get the optimal worksize, try again with the minimum. */ worksize = n; @@ -402,8 +402,8 @@ void matrix_dgeqrf(matrix_type * A , double * tau) { } else work = tmp; /* The request for optimal worksize succeeded */ } - - + + /* Second call - do the actual computation. */ dgeqrf_(&m , &n , matrix_get_data( A ), &lda , tau , work , &worksize , &info); if (info != 0) @@ -412,14 +412,14 @@ void matrix_dgeqrf(matrix_type * A , double * tau) { } -/** - Typically to be used after the matrix_dgeqrf() function to construct a orthormal matrix. +/** + Typically to be used after the matrix_dgeqrf() function to construct a orthormal matrix. */ void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors) { /* num_reflectors == length of tau. */ int lda = matrix_get_column_stride( A ); int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); + int n = matrix_get_columns( A ); double * work = util_malloc(sizeof * work ); int worksize; int info; @@ -434,8 +434,8 @@ void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors) { /* num { double * tmp = realloc(work , sizeof * work * worksize ); if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, + /* + OK - we could not get the optimal worksize, try again with the minimum. */ worksize = n; @@ -443,8 +443,8 @@ void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors) { /* num } else work = tmp; /* The request for optimal worksize succeeded */ } - - + + /* Second call - do the actual computation. */ dorgqr_(&m , &n , &num_reflectors , matrix_get_data( A ), &lda , tau , work , &worksize , &info); if (info != 0) @@ -461,19 +461,19 @@ void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors) { /* num static void matrix_dgetrf__( matrix_type * A, int * ipiv, int * info) { int lda = matrix_get_column_stride( A ); int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); + int n = matrix_get_columns( A ); dgetrf_( &m , &n , matrix_get_data( A ) , &lda , ipiv , info); } -/** +/** Calculated the determinant of A. The matrix content will be destroyed. */ double matrix_det( matrix_type *A ) { - matrix_lapack_assert_square( A ); + matrix_lapack_assert_square( A ); { int dgetrf_info; @@ -504,7 +504,7 @@ double matrix_det( matrix_type *A ) { } } } - + free( ipiv ); return det * pow(10 , det_scale ); } @@ -524,7 +524,7 @@ double matrix_det( matrix_type *A ) { >0 : Singular matrix <0 : Invalid input */ - + @@ -550,8 +550,8 @@ int matrix_inv( matrix_type * A ) { work = util_realloc( work , sizeof * work * work_size ); dgetri_( &n , matrix_get_data( A ), &lda , ipiv , work , &work_size , &info); } else - util_abort("%s: dgetri_ returned info:%d \n",__func__ , info); - + util_abort("%s: dgetri_ returned info:%d \n",__func__ , info); + free( work ); } free( ipiv ); diff --git a/ThirdParty/Ert/devel/libert_util/src/matrix_stat.c b/ThirdParty/Ert/devel/libert_util/src/matrix_stat.c new file mode 100644 index 0000000000..d8b47300f5 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/src/matrix_stat.c @@ -0,0 +1,114 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'matrix_stat.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#include <stdbool.h> +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <math.h> + +#include <ert/util/thread_pool.h> +#include <ert/util/util.h> +#include <ert/util/matrix.h> +#include <ert/util/matrix_blas.h> +#include <ert/util/matrix_lapack.h> +#include <ert/util/matrix_stat.h> + + +llsq_result_enum matrix_stat_llsq_estimate( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S) { + if (matrix_get_rows( beta ) != matrix_get_columns( X0 )) + return LLSQ_INVALID_DIM; + + if (matrix_get_rows( X0 ) != matrix_get_rows( Y0 )) + return LLSQ_INVALID_DIM; + + if (S && matrix_get_rows( S ) != matrix_get_rows( Y0 )) + return LLSQ_INVALID_DIM; + + if (matrix_get_rows(beta) > matrix_get_rows( X0 )) + return LLSQ_UNDETERMINED; + + { + int num_data = matrix_get_rows( X0 ); + int num_var = matrix_get_columns( X0 ); + matrix_type * XX = matrix_alloc( num_var , num_var ); + matrix_type * A = matrix_alloc( num_var , num_data ); + + matrix_type * X,*Y; + + if (S == NULL) { + X = (matrix_type *) X0; + Y = (matrix_type *) Y0; + } else { + X = matrix_alloc_copy( X0 ); + Y = matrix_alloc_copy( Y0 ); + + { + int row,col; + for (row = 0; row < matrix_get_rows( X0 ); row++) { + double sigma = matrix_iget(S , row , 0); + double weigth = 1.0 / (sigma * sigma ); + + for (col = 0; col < matrix_get_columns( X0 ); col++) + matrix_imul( X , row , col , weigth ); + + matrix_imul( Y , row , col , weigth ); + } + } + } + + matrix_matmul_with_transpose( XX , X , X , true , false ); + matrix_inv( XX ); + matrix_matmul_with_transpose( A , XX , X , false , true ); + matrix_matmul(beta , A , Y); + + matrix_free( XX ); + matrix_free( A ); + if (S) { + matrix_free( X ); + matrix_free( Y ); + } + } + + return LLSQ_SUCCESS; +} + + + + +llsq_result_enum matrix_stat_polyfit( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S) { + int num_data = matrix_get_rows( X0 ); + int num_var = matrix_get_rows( beta ); + llsq_result_enum result; + matrix_type * X = matrix_alloc( num_data , num_var ); + int row,col; + + for (row = 0; row < matrix_get_rows( X0 ); row++) { + double x1 = matrix_iget( X0 , row , 0 ); + double xp = 1; + for (col = 0; col < num_var; col++) { + matrix_iset(X , row , col , xp); + xp *= x1; + } + } + + result = matrix_stat_llsq_estimate( beta , X , Y0 , S); + matrix_free( X ); + return result; +} + diff --git a/ThirdParty/Ert/devel/libert_util/src/mzran.c b/ThirdParty/Ert/devel/libert_util/src/mzran.c index 32d83c22ed..2dbcc0903d 100644 --- a/ThirdParty/Ert/devel/libert_util/src/mzran.c +++ b/ThirdParty/Ert/devel/libert_util/src/mzran.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'mzran.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'mzran.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -71,18 +71,18 @@ unsigned int mzran_forward(void * __rng) { mzran_type * rng = (mzran_type *) __rng; { unsigned int s; - - if (rng->y > (rng->x + rng->c)) { - s = rng->y - rng->x - rng->c; - rng->c=0; - } else { - s = rng->y - rng->x - rng->c - 18; - rng->c=1; + + if (rng->y > (rng->x + rng->c)) { + s = rng->y - rng->x - rng->c; + rng->c=0; + } else { + s = rng->y - rng->x - rng->c - 18; + rng->c=1; } - - rng->x = rng->y; - rng->y = rng->z; - rng->z = s; + + rng->x = rng->y; + rng->y = rng->z; + rng->z = s; rng->n = 69069*rng->n + 1013904243; return rng->z + rng->n; } @@ -96,17 +96,17 @@ unsigned int mzran_forward(void * __rng) { /** This function will set the state of the rng, based on four input seeds. -*/ -static void mzran_set_state4(mzran_type * rng , +*/ +static void mzran_set_state4(mzran_type * rng , unsigned int s0 , unsigned int s1, unsigned int s2 , unsigned int s3) { - + rng->x = s0; rng->y = s1; rng->z = s2; rng->n = s3; - rng->c = 1; - + rng->c = 1; + } @@ -122,7 +122,7 @@ static unsigned int fscanf_4bytes( FILE * stream ) { char * filename = "<file>"; #ifdef HAVE_FORK filename = util_alloc_filename_from_stream( stream ); -#endif +#endif util_abort("%s: reading byte from: %s failed \n",__func__ , filename); } } @@ -173,7 +173,7 @@ void mzran_fprintf_state( const void * __rng , FILE * stream) { static void mzran_set_default_state( mzran_type * rng ) { mzran_set_state4( rng , DEFAULT_S0 , DEFAULT_S1 , DEFAULT_S2 , DEFAULT_S3); } - + /** @@ -206,12 +206,12 @@ void mzran_get_state(void * __rng , char * state_buffer) { /** Creates a new rng instance, the instance is initialized with the - default seed given by: + default seed given by: - {DEFAULT_S0, DEFAULT_S1, DEFAULT_S2,DEFAULT_S3}. + {DEFAULT_S0, DEFAULT_S1, DEFAULT_S2,DEFAULT_S3}. To recover a known state you must subsequently call one of the - mzran_set_state() functions. + mzran_set_state() functions. */ diff --git a/ThirdParty/Ert/devel/libert_util/src/parser.c b/ThirdParty/Ert/devel/libert_util/src/parser.c index 0640dbcbe4..711f892279 100644 --- a/ThirdParty/Ert/devel/libert_util/src/parser.c +++ b/ThirdParty/Ert/devel/libert_util/src/parser.c @@ -28,7 +28,7 @@ -struct parser_struct +struct basic_parser_struct { char * splitters; /* The string is split into tokens on the occurence of one of these characters - and they are removed. */ char * specials; /* This exactly like the splitters - but these characters are retained as tokens. */ @@ -46,41 +46,41 @@ static void __verify_string_length( const char * s) { } -void parser_set_splitters( parser_type * parser , const char * splitters ) { +void basic_parser_set_splitters( basic_parser_type * parser , const char * splitters ) { __verify_string_length( splitters ); parser->splitters = util_realloc_string_copy( parser->splitters , splitters ); } -void parser_set_quoters( parser_type * parser , const char * quoters ) { +void basic_parser_set_quoters( basic_parser_type * parser , const char * quoters ) { __verify_string_length( quoters ); parser->quoters = util_realloc_string_copy( parser->quoters , quoters ); } -void parser_set_specials( parser_type * parser , const char * specials ) { +void basic_parser_set_specials( basic_parser_type * parser , const char * specials ) { __verify_string_length( specials ); parser->specials = util_realloc_string_copy( parser->specials , specials ); } -void parser_set_delete_set( parser_type * parser , const char * delete_set ) { +void basic_parser_set_delete_set( basic_parser_type * parser , const char * delete_set ) { __verify_string_length( delete_set ); parser->delete_set = util_realloc_string_copy( parser->delete_set , delete_set ); } -void parser_set_comment_start( parser_type * parser , const char * comment_start ) { +void basic_parser_set_comment_start( basic_parser_type * parser , const char * comment_start ) { __verify_string_length( comment_start ); parser->comment_start = util_realloc_string_copy( parser->comment_start , comment_start ); } -void parser_set_comment_end( parser_type * parser , const char * comment_end ) { +void basic_parser_set_comment_end( basic_parser_type * parser , const char * comment_end ) { __verify_string_length( comment_end ); parser->comment_end = util_realloc_string_copy( parser->comment_end , comment_end ); } -parser_type * parser_alloc( +basic_parser_type * basic_parser_alloc( const char * splitters, /** Set to NULL if not interessting. */ const char * quoters, /** Set to NULL if not interessting. */ const char * specials, /** Set to NULL if not interessting. */ @@ -88,7 +88,7 @@ parser_type * parser_alloc( const char * comment_start, /** Set to NULL if not interessting. */ const char * comment_end) /** Set to NULL if not interessting. */ { - parser_type * parser = util_malloc(sizeof * parser); + basic_parser_type * parser = util_malloc(sizeof * parser); parser->splitters = NULL; parser->delete_set = NULL; parser->quoters = NULL; @@ -96,12 +96,12 @@ parser_type * parser_alloc( parser->comment_start = NULL; parser->comment_end = NULL; - parser_set_splitters( parser , splitters ); - parser_set_quoters( parser , quoters ); - parser_set_specials( parser , specials ); - parser_set_delete_set( parser , delete_set ); - parser_set_comment_start( parser , comment_start ); - parser_set_comment_end( parser , comment_end ); + basic_parser_set_splitters( parser , splitters ); + basic_parser_set_quoters( parser , quoters ); + basic_parser_set_specials( parser , specials ); + basic_parser_set_delete_set( parser , delete_set ); + basic_parser_set_comment_start( parser , comment_start ); + basic_parser_set_comment_end( parser , comment_end ); if(comment_start == NULL && comment_end != NULL) util_abort("%s: Need to have comment_start when comment_end is set.\n", __func__); @@ -113,9 +113,7 @@ parser_type * parser_alloc( -void parser_free( - parser_type * parser) -{ +void basic_parser_free(basic_parser_type * parser) { util_safe_free( parser->splitters ); util_safe_free( parser->quoters ); @@ -129,10 +127,7 @@ void parser_free( -static -bool is_escape( - const char c) -{ +static bool is_escape(const char c) { if( c == PARSER_ESCAPE_CHAR ) return true; else @@ -142,11 +137,7 @@ bool is_escape( -static -int length_of_initial_splitters( - const char * buffer_position, - const parser_type * parser) -{ +static int length_of_initial_splitters(const char * buffer_position, const basic_parser_type * parser) { assert( buffer_position != NULL ); assert( parser != NULL ); @@ -168,34 +159,20 @@ static bool in_set(char c , const char * set) { } -static -bool is_splitters( - const char c, - const parser_type * parser) -{ +static bool is_splitters( const char c, const basic_parser_type * parser) { return in_set(c , parser->splitters); } -static -bool is_special( - const char c, - const parser_type * parser) -{ +static bool is_special( const char c, const basic_parser_type * parser) { return in_set(c , parser->specials); } -static -bool is_in_quoters( - const char c, - const parser_type * parser) -{ +static bool is_in_quoters( const char c, const basic_parser_type * parser) { return in_set(c , parser->quoters); } - - -static bool is_in_delete_set(const char c , const parser_type * parser) { +static bool is_in_delete_set(const char c , const basic_parser_type * parser) { return in_set(c , parser->delete_set); } @@ -223,10 +200,7 @@ static bool is_in_delete_set(const char c , const parser_type * parser) { character, this is *NOT* regarded as the end. */ -static -int length_of_quotation( - const char * buffer) -{ +static int length_of_quotation( const char * buffer) { assert( buffer != NULL ); { int length = 1; @@ -252,41 +226,30 @@ int length_of_quotation( -static -int length_of_comment( - const char * buffer_position, - const parser_type * parser) -{ +static int length_of_comment( const char * buffer_position, const basic_parser_type * parser) { bool in_comment = false; int length = 0; if(parser->comment_start == NULL || parser->comment_end == NULL) length = 0; - else - { + else { const char * comment_start = parser->comment_start; int len_comment_start = strlen( comment_start ); - if( strncmp( buffer_position, comment_start, len_comment_start) == 0) - { + if( strncmp( buffer_position, comment_start, len_comment_start) == 0) { in_comment = true; length = len_comment_start; - } - else + } else length = 0; } - if( in_comment ) - { + if( in_comment ) { const char * comment_end = parser->comment_end; int len_comment_end = strlen( comment_end ); - while(buffer_position[length] != '\0' && in_comment) - { - if( strncmp( &buffer_position[length], comment_end, len_comment_end) == 0) - { + while(buffer_position[length] != '\0' && in_comment) { + if( strncmp( &buffer_position[length], comment_end, len_comment_end) == 0) { in_comment = false; length += len_comment_end; - } - else + } else length += 1; } } @@ -295,21 +258,13 @@ int length_of_comment( -static -char * alloc_quoted_token( - const char * buffer, - int length, - bool strip_quote_marks) -{ +static char * alloc_quoted_token( const char * buffer, int length, bool strip_quote_marks) { char * token; - if(!strip_quote_marks) - { + if(!strip_quote_marks) { token = util_calloc( (length + 1) , sizeof * token ); memmove(token, &buffer[0], length * sizeof * token ); token[length] = '\0'; - } - else - { + } else { token = util_calloc( (length - 1) , sizeof * token); memmove(token, &buffer[1], (length -1) * sizeof * token); token[length-2] = '\0'; @@ -339,37 +294,28 @@ char * alloc_quoted_token( token list. */ -static -int length_of_normal_non_splitters( - const char * buffer, - const parser_type * parser) -{ +static int length_of_normal_non_splitters( const char * buffer, const basic_parser_type * parser) { bool at_end = false; int length = 0; char current = buffer[0]; - while(current != '\0' && !at_end) - { + while(current != '\0' && !at_end) { length += 1; current = buffer[length]; - if( is_splitters( current, parser ) ) - { + if( is_splitters( current, parser ) ) { at_end = true; continue; } - if( is_special( current, parser ) ) - { + if( is_special( current, parser ) ) { at_end = true; continue; } - if( is_in_quoters( current, parser ) ) - { + if( is_in_quoters( current, parser ) ) { at_end = true; continue; } - if( length_of_comment(&buffer[length], parser) > 0) - { + if( length_of_comment(&buffer[length], parser) > 0) { at_end = true; continue; } @@ -380,7 +326,7 @@ int length_of_normal_non_splitters( -static int length_of_delete( const char * buffer , const parser_type * parser) { +static int length_of_delete( const char * buffer , const basic_parser_type * parser) { int length = 0; char current = buffer[0]; @@ -395,8 +341,8 @@ static int length_of_delete( const char * buffer , const parser_type * parser) { /** Allocates a new stringlist. */ -stringlist_type * parser_tokenize_buffer( - const parser_type * parser, +stringlist_type * basic_parser_tokenize_buffer( + const basic_parser_type * parser, const char * buffer, bool strip_quote_marks) { @@ -408,14 +354,12 @@ stringlist_type * parser_tokenize_buffer( stringlist_type * tokens = stringlist_alloc_new(); - while( position < buffer_size ) - { + while( position < buffer_size ) { /** Skip initial splitters. */ splitters_length = length_of_initial_splitters( &buffer[position], parser ); - if(splitters_length > 0) - { + if(splitters_length > 0) { position += splitters_length; continue; } @@ -425,8 +369,7 @@ stringlist_type * parser_tokenize_buffer( Skip comments. */ comment_length = length_of_comment( &buffer[position], parser); - if(comment_length > 0) - { + if(comment_length > 0) { position += comment_length; continue; } @@ -447,8 +390,7 @@ stringlist_type * parser_tokenize_buffer( /** Copy the character if it is in the special set, */ - if( is_special( buffer[position], parser ) ) - { + if( is_special( buffer[position], parser ) ) { char key[2]; key[0] = buffer[position]; key[1] = '\0'; @@ -460,8 +402,7 @@ stringlist_type * parser_tokenize_buffer( /** If the character is a quotation start, we copy the whole quotation. */ - if( is_in_quoters( buffer[position], parser ) ) - { + if( is_in_quoters( buffer[position], parser ) ) { int length = length_of_quotation( &buffer[position] ); char * token = alloc_quoted_token( &buffer[position], length, strip_quote_marks ); stringlist_append_owned_ref( tokens, token ); @@ -525,14 +466,10 @@ stringlist_type * parser_tokenize_buffer( -stringlist_type * parser_tokenize_file( - const parser_type * parser, - const char * filename, - bool strip_quote_marks) -{ +stringlist_type * basic_parser_tokenize_file(const basic_parser_type * parser, const char * filename, bool strip_quote_marks) { stringlist_type * tokens; char * buffer = util_fread_alloc_file_content( filename, NULL ); - tokens = parser_tokenize_buffer( parser, buffer, strip_quote_marks ); + tokens = basic_parser_tokenize_buffer( parser, buffer, strip_quote_marks ); free(buffer); return tokens; } @@ -592,7 +529,7 @@ static bool fgetc_while_equal( FILE * stream , const char * string , bool case_s unterminated comments and unterminated quotations. */ -bool parser_fseek_string(const parser_type * parser , FILE * stream , const char * __string , bool skip_string, bool case_sensitive) { +bool basic_parser_fseek_string(const basic_parser_type * parser , FILE * stream , const char * __string , bool skip_string, bool case_sensitive) { bool string_found = false; char * string = util_alloc_string_copy( __string ); if (!case_sensitive) @@ -684,7 +621,7 @@ bool parser_fseek_string(const parser_type * parser , FILE * stream , const char */ -void parser_strip_buffer(const parser_type * parser , char ** __buffer) { +void basic_parser_strip_buffer(const basic_parser_type * parser , char ** __buffer) { char * src = *__buffer; char * target = util_calloc( ( strlen( *__buffer ) + 1) , sizeof * target ); @@ -717,8 +654,7 @@ void parser_strip_buffer(const parser_type * parser , char ** __buffer) { /* Quotations. */ - if( is_in_quoters( src[src_position], parser ) ) - { + if( is_in_quoters( src[src_position], parser ) ) { int length = length_of_quotation( &src[src_position] ); char * token = alloc_quoted_token( &src[src_position], length, false ); memcpy( &target[target_position] , &src[src_position] , length); @@ -755,11 +691,11 @@ void parser_strip_buffer(const parser_type * parser , char ** __buffer) { comment string. */ -char * parser_fread_alloc_file_content(const char * filename , const char * quote_set , const char * delete_set , const char * comment_start , const char * comment_end) { - parser_type * parser = parser_alloc( NULL , quote_set , NULL , delete_set , comment_start , comment_end); +char * basic_parser_fread_alloc_file_content(const char * filename , const char * quote_set , const char * delete_set , const char * comment_start , const char * comment_end) { + basic_parser_type * parser = basic_parser_alloc( NULL , quote_set , NULL , delete_set , comment_start , comment_end); char * buffer = util_fread_alloc_file_content( filename , NULL); - parser_strip_buffer( parser , &buffer ); - parser_free( parser ); + basic_parser_strip_buffer( parser , &buffer ); + basic_parser_free( parser ); return buffer; } diff --git a/ThirdParty/Ert/devel/libert_util/src/rng.c b/ThirdParty/Ert/devel/libert_util/src/rng.c index 1c5e733e98..037c7ab50f 100644 --- a/ThirdParty/Ert/devel/libert_util/src/rng.c +++ b/ThirdParty/Ert/devel/libert_util/src/rng.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'rng.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'rng.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <math.h> #include <stdint.h> @@ -34,7 +34,7 @@ extern "C" { The rng structure is a thin structure which wraps a specific Random Number Generator (rng) implementation. The rng_struct structure is essentially container with function pointers to functions - manipulating the underlying state. + manipulating the underlying state. */ struct rng_struct { @@ -43,19 +43,19 @@ struct rng_struct { source of random numbers, and all other random numbers are derived from this through scaling/shifting/type conversion/... */ rng_set_state_ftype * set_state; /* Takes a char * buffer as input and sets the state of the rng; should set the rng into a default state if arg == NULL. */ - rng_get_state_ftype * get_state; + rng_get_state_ftype * get_state; rng_alloc_ftype * alloc_state; /* Creates a new instance of this rng. */ - rng_free_ftype * free_state; + rng_free_ftype * free_state; rng_fscanf_ftype * fscanf_state; /* Loads the state from a formatted file with (integer representation of) bytes. */ rng_fprintf_ftype * fprintf_state; /* Writes the state as a formatted series of bytes. */ /******************************************************************/ - rng_alg_type type; + rng_alg_type type; void * state; /* The current state - the return value from alloc_state() - passed as parameter to all the function pointers. */ int state_size; /* How many bytes needed to specify the state of the rng. */ uint64_t max_value; /* The maximum value this rng can return. */ double inv_max; }; - + UTIL_SAFE_CAST_FUNCTION( rng , RNG_TYPE_ID) UTIL_IS_INSTANCE_FUNCTION( rng , RNG_TYPE_ID) @@ -63,31 +63,31 @@ UTIL_IS_INSTANCE_FUNCTION( rng , RNG_TYPE_ID) rng_type * rng_alloc__(rng_alloc_ftype * alloc_state, rng_free_ftype * free_state , - rng_forward_ftype * forward , - rng_set_state_ftype * set_state , - rng_get_state_ftype * get_state , + rng_forward_ftype * forward , + rng_set_state_ftype * set_state , + rng_get_state_ftype * get_state , rng_fscanf_ftype * fscanf_state , rng_fprintf_ftype * fprintf_state , - rng_alg_type type , - int state_size , + rng_alg_type type , + int state_size , uint64_t max_value) { rng_type * rng = (rng_type *) util_malloc( sizeof * rng ); UTIL_TYPE_ID_INIT( rng , RNG_TYPE_ID ); rng->alloc_state = alloc_state; - rng->free_state = free_state; + rng->free_state = free_state; rng->forward = forward; - rng->set_state = set_state; - rng->get_state = get_state; - rng->fscanf_state = fscanf_state; - rng->fprintf_state = fprintf_state; + rng->set_state = set_state; + rng->get_state = get_state; + rng->fscanf_state = fscanf_state; + rng->fprintf_state = fprintf_state; rng->state_size = state_size; rng->max_value = max_value; rng->inv_max = 1.0 / max_value; rng->type = type; rng->state = NULL; - + rng->state = rng->alloc_state( ); rng_forward( rng ); @@ -97,7 +97,7 @@ rng_type * rng_alloc__(rng_alloc_ftype * alloc_state, /** Will initialize the rng with 'random content', using the method - specified by the @init_mode variable. + specified by the @init_mode variable. If you have a state which you want to reproduce deterministically you should use one of the mzran_set_state() functions. @@ -105,11 +105,11 @@ rng_type * rng_alloc__(rng_alloc_ftype * alloc_state, void rng_init( rng_type * rng , rng_init_mode init_mode ) { - if (init_mode == INIT_DEFAULT) + if (init_mode == INIT_DEFAULT) rng_set_state( rng , NULL ); else { char * seed_buffer = (char *) util_calloc( rng->state_size , sizeof * seed_buffer ); - + switch (init_mode) { case(INIT_CLOCK): { @@ -127,7 +127,7 @@ void rng_init( rng_type * rng , rng_init_mode init_mode ) { default: util_abort("%s: unrecognized init_code:%d \n",__func__ , init_mode); } - + rng_set_state( rng , seed_buffer ); free( seed_buffer ); } @@ -146,11 +146,11 @@ void rng_rng_init( rng_type * rng , rng_type * seed_src) { seed_buffer = (unsigned int *) util_calloc( int_size , sizeof * seed_buffer ); { int i; - for (i =0; i < int_size; i++) + for (i =0; i < int_size; i++) seed_buffer[i] = rng_forward( seed_src ); - } + } rng->set_state( rng->state , (char *) seed_buffer ); - + free( seed_buffer ); } } @@ -164,22 +164,22 @@ rng_type * rng_alloc( rng_alg_type type , rng_init_mode init_mode ) { rng_type * rng; switch (type) { case(MZRAN): - rng = rng_alloc__( mzran_alloc , - mzran_free , - mzran_forward , - mzran_set_state , - mzran_get_state , - mzran_fscanf_state , - mzran_fprintf_state , - type , - MZRAN_STATE_SIZE , + rng = rng_alloc__( mzran_alloc , + mzran_free , + mzran_forward , + mzran_set_state , + mzran_get_state , + mzran_fscanf_state , + mzran_fprintf_state , + type , + MZRAN_STATE_SIZE , MZRAN_MAX_VALUE ); break; default: util_abort("%s: rng type:%d not recognized \n",__func__ , type); rng = NULL; } - + rng_init( rng , init_mode ); return rng; } @@ -240,7 +240,7 @@ void rng_shuffle( rng_type * rng , char * data , size_t element_size , size_t nu size_t offset1 = index1 * element_size; size_t offset2 = index2 * element_size; - + memcpy( tmp , &data[ offset1 ] , element_size ); memcpy( &data[ offset1 ] , &data[ offset2 ] , element_size ); memcpy( &data[ offset2 ] , tmp , element_size ); @@ -259,7 +259,7 @@ double rng_std_normal( rng_type * rng ) { const double pi = 3.141592653589; double R1 = rng_get_double( rng ); double R2 = rng_get_double( rng ); - + return sqrt(-2.0 * log(R1)) * cos(2.0 * pi * R2); } diff --git a/ThirdParty/Ert/devel/libert_util/src/string_util.c b/ThirdParty/Ert/devel/libert_util/src/string_util.c index ed0b2fd60a..53a788564b 100644 --- a/ThirdParty/Ert/devel/libert_util/src/string_util.c +++ b/ThirdParty/Ert/devel/libert_util/src/string_util.c @@ -80,7 +80,7 @@ static int_vector_type * string_util_sscanf_alloc_active_list(const char * range if (valid) { - parser_type * parser = parser_alloc( "," , /* No ordinary split characters. */ + basic_parser_type * parser = basic_parser_alloc( "," , /* No ordinary split characters. */ NULL , /* No quoters. */ NULL , /* No special split */ " \t" , /* Removing ' ' and '\t' */ @@ -89,7 +89,7 @@ static int_vector_type * string_util_sscanf_alloc_active_list(const char * range stringlist_type * tokens; int item; active_list = int_vector_alloc(0,0); - tokens = parser_tokenize_buffer( parser , range_string , true); + tokens = basic_parser_tokenize_buffer( parser , range_string , true); for (item = 0; item < stringlist_get_size( tokens ); item++) { const char * string_item = stringlist_iget( tokens , item ); @@ -116,7 +116,7 @@ static int_vector_type * string_util_sscanf_alloc_active_list(const char * range stringlist_free( tokens ); - parser_free( parser ); + basic_parser_free( parser ); } return active_list; diff --git a/ThirdParty/Ert/devel/libert_util/src/stringlist.c b/ThirdParty/Ert/devel/libert_util/src/stringlist.c index 7712a18179..5e9cab85e4 100644 --- a/ThirdParty/Ert/devel/libert_util/src/stringlist.c +++ b/ThirdParty/Ert/devel/libert_util/src/stringlist.c @@ -363,6 +363,22 @@ int stringlist_iget_as_int( const stringlist_type * stringlist , int index , boo return value; } + +double stringlist_iget_as_double( const stringlist_type * stringlist , int index , bool * valid) { + const char * string_value = stringlist_iget( stringlist , index ); + double value = -1.0; + + if (valid != NULL) + *valid = false; + + if (util_sscanf_double(string_value , &value)) + if (valid != NULL) + *valid = true; + + return value; +} + + bool stringlist_iget_as_bool( const stringlist_type * stringlist, int index, bool * valid) { const char * string_value = stringlist_iget( stringlist, index); bool value = false; diff --git a/ThirdParty/Ert/devel/libert_util/src/subst_list.c b/ThirdParty/Ert/devel/libert_util/src/subst_list.c index 3aa0d3538d..ec51b8fb76 100644 --- a/ThirdParty/Ert/devel/libert_util/src/subst_list.c +++ b/ThirdParty/Ert/devel/libert_util/src/subst_list.c @@ -480,7 +480,7 @@ static bool subst_list_replace_strings__(const subst_list_type * subst_list , bu */ -static bool subst_list_eval_funcs____(const subst_list_type * subst_list , const parser_type * parser , buffer_type * buffer) { +static bool subst_list_eval_funcs____(const subst_list_type * subst_list , const basic_parser_type * parser , buffer_type * buffer) { bool global_match = false; int index; for (index = 0; index < vector_get_size( subst_list->func_data); index++) { @@ -504,7 +504,7 @@ static bool subst_list_eval_funcs____(const subst_list_type * subst_list , const if (arg_end != NULL) { /* OK - we found an enclosing () pair. */ char * arg_content = util_alloc_substring_copy( arg_start, 1 , arg_end - arg_start - 1); - stringlist_type * arg_list = parser_tokenize_buffer( parser , arg_content , true); + stringlist_type * arg_list = basic_parser_tokenize_buffer( parser , arg_content , true); char * func_eval = subst_list_func_eval( subst_func , arg_list ); int old_len = strlen(func_name) + strlen( arg_content) + 2; @@ -532,10 +532,10 @@ static bool subst_list_eval_funcs____(const subst_list_type * subst_list , const static bool subst_list_eval_funcs__(const subst_list_type * subst_list , buffer_type * buffer) { - parser_type * parser = parser_alloc( "," , "\"\'" , NULL , " \t" , NULL , NULL ); + basic_parser_type * parser = basic_parser_alloc( "," , "\"\'" , NULL , " \t" , NULL , NULL ); bool match = subst_list_eval_funcs____( subst_list , parser , buffer ); - parser_free( parser ); + basic_parser_free( parser ); return match; } diff --git a/ThirdParty/Ert/devel/libert_util/src/template_loop.c b/ThirdParty/Ert/devel/libert_util/src/template_loop.c index 4a43b42227..9bd37d2ed8 100644 --- a/ThirdParty/Ert/devel/libert_util/src/template_loop.c +++ b/ThirdParty/Ert/devel/libert_util/src/template_loop.c @@ -84,11 +84,11 @@ static loop_type * loop_alloc( const char * buffer , int global_offset , regmatc int items_offset = global_offset + __items_offset.rm_so; int items_length = __items_offset.rm_eo - __items_offset.rm_so; char * items_string = util_alloc_substring_copy( buffer , items_offset , items_length ); - parser_type * parser = parser_alloc("," , NULL , NULL , NULL , NULL , NULL); // Does not tolerate spaces around the splitting "," + basic_parser_type * parser = basic_parser_alloc("," , NULL , NULL , NULL , NULL , NULL); // Does not tolerate spaces around the splitting "," - loop->items = parser_tokenize_buffer( parser , items_string , false); + loop->items = basic_parser_tokenize_buffer( parser , items_string , false); - parser_free( parser ); + basic_parser_free( parser ); free( items_string ); } return loop; diff --git a/ThirdParty/Ert/devel/libert_util/src/test_util.c b/ThirdParty/Ert/devel/libert_util/src/test_util.c index 197c588fb9..b7569c57a2 100644 --- a/ThirdParty/Ert/devel/libert_util/src/test_util.c +++ b/ThirdParty/Ert/devel/libert_util/src/test_util.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'test_util.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'test_util.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -73,66 +73,90 @@ bool test_check_string_equal( const char * s1 , const char * s2 ) { void test_assert_string_equal__( const char * s1 , const char * s2 , const char * file, int line) { bool equal = test_check_string_equal( s1 , s2 ); - if (!equal) + if (!equal) test_error_exit( "%s:%d => String are different s1:[%s] s2:[%s]\n" , file , line , s1 , s2 ); } void test_assert_string_not_equal__( const char * s1 , const char * s2 , const char * file, int line) { bool equal = test_check_string_equal( s1 , s2 ); - if (equal) + if (equal) test_error_exit( "%s:%d => String are equal s1:[%s] s2:[%s]\n" , file , line , s1 , s2 ); } +void test_assert_long_equal__( long i1 , long i2 , const char * file , long line) { + if (i1 != i2) + test_error_exit( "%s:%d => Long values are different i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); +} + + +void test_assert_long_not_equal__( long i1 , long i2 , const char * file , long line) { + if (i1 == i2) + test_error_exit( "%s:%d => Long values are equal i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); +} + void test_assert_int_equal__( int i1 , int i2 , const char * file , int line) { - if (i1 != i2) + if (i1 != i2) test_error_exit( "%s:%d => Integers are different i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); } void test_assert_int_not_equal__( int i1 , int i2 , const char * file , int line) { - if (i1 == i2) + if (i1 == i2) test_error_exit( "%s:%d => Integers are equal i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); } void test_assert_uint_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line) { - if (i1 != i2) + if (i1 != i2) test_error_exit( "%s:%d => Integers are different i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); } void test_assert_uint_not_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line) { - if (i1 == i2) + if (i1 == i2) test_error_exit( "%s:%d => Integers are equal i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); } void test_assert_bool_equal__( bool b1 , bool b2 , const char * file , int line) { - if (b1 != b2) + if (b1 != b2) test_error_exit( "%s:%d => Booleans are different b1:[%d] b2:[%d]\n" , file , line , b1 , b2 ); } void test_assert_bool_not_equal__( bool b1 , bool b2 , const char * file , int line) { - if (b1 == b2) + if (b1 == b2) test_error_exit( "%s:%d => Booleans are equal b1:[%d] b2:[%d]\n" , file , line , b1 , b2 ); } +/*****************************************************************/ + +void test_assert_size_t_equal__( size_t s1 , size_t s2 , const char * file , int line) { + if (s1 != s2) + test_error_exit("%s:%d => size_t values are different s1:%d s2:[%d]\n" , file , line , s1 , s2); +} + + +void test_assert_size_t_not_equal__( size_t s1 , size_t s2 , const char * file , int line) { + if (s1 == s2) + test_error_exit("%s:%d => size_t values are different s1:%d s2:[%d]\n" , file , line , s1 , s2); +} + /*****************************************************************/ void test_assert_time_t_equal__( time_t t1 , time_t t2 , const char * file , int line) { - if (t1 != t2) + if (t1 != t2) test_error_exit("%s:%d => time_t values are different t1:%d t2:[%d]\n" , file , line , t1 , t2); } void test_assert_time_t_not_equal__( time_t t1 , time_t t2 , const char * file , int line) { - if (t1 == t2) + if (t1 == t2) test_error_exit("%s:%d => time_t values are different t1:%d t2:[%d]\n" , file , line , t1 , t2); } @@ -141,13 +165,13 @@ void test_assert_time_t_not_equal__( time_t t1 , time_t t2 , const char * file , /*****************************************************************/ void test_assert_true__( bool value, const char * file , int line) { - if (!value) + if (!value) test_error_exit("%s:%d => assert( true ) failed\n" , file , line); } void test_assert_false__( bool value, const char * file , int line) { - if (value) + if (value) test_error_exit("%s:%d => assert( false ) failed" , file , line); } @@ -156,26 +180,26 @@ void test_assert_false__( bool value, const char * file , int line) { void test_assert_ptr_equal__( const void * p1 , const void * p2 , const char * file , int line) { bool equal = (p1 == p2); - if (!equal) + if (!equal) test_error_exit( "%s:%d => Pointers are different p1:[%p] p2:[%p]\n" , file , line , p1 , p2 ); } void test_assert_ptr_not_equal__( const void * p1 , const void * p2 , const char * file , int line) { bool equal = (p1 == p2); - if (equal) + if (equal) test_error_exit( "%s:%d => Pointers are equal p1:[%p] p2:[%p]\n" , file , line , p1 , p2 ); } void test_assert_NULL__( const void * p , const char * file , int line) { - if (p != NULL) + if (p != NULL) test_error_exit( "%s:%d => Pointer is != NULL \n" , file , line , p); } void test_assert_not_NULL__( const void * p , const char * file , int line) { - if (p == NULL) + if (p == NULL) test_error_exit( "%s:%d => Pointer is NULL \n" , file , line , p); } @@ -188,7 +212,7 @@ void test_assert_mem_equal__( const void * p1 , const void * p2 , size_t byte_si while( char_ptr1[offset] == char_ptr2[offset]) offset++; - + test_error_exit( "%s:%d => Memory regions have different content. First difference at offset:%ld\n" , file , line , offset); } } @@ -240,7 +264,7 @@ void test_assert_float_not_equal__( float d1 , float d2, const char * file , int void test_install_SIGNALS(void) { signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ signal(SIGINT , util_abort_signal); /* Control C */ - signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. + signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ } @@ -255,13 +279,13 @@ void test_util_addr2line() { const char * func = __func__; int line; const int max_bt = 50; - void *bt_addr[max_bt]; + void *bt_addr[max_bt]; int size; char * func_name , * file_name; int line_nr; - + line = __LINE__ + 2; - size = backtrace(bt_addr , max_bt); + size = backtrace(bt_addr , max_bt); test_assert_int_equal( size , 4 ); test_assert_true( util_addr2line_lookup( bt_addr[0] , &func_name , &file_name , &line_nr)); test_assert_string_equal( func_name , func ); @@ -276,12 +300,12 @@ void test_assert_util_abort(const char * function_name , void call_func (void *) { jmp_buf * context = util_abort_test_jump_buffer(); util_abort_test_set_intercept_function( function_name ); - - if (setjmp(*context) == 0) + + if (setjmp(*context) == 0) call_func( arg ); - else + else util_abort_intercepted = true; - + util_abort_test_set_intercept_function( NULL ); } diff --git a/ThirdParty/Ert/devel/libert_util/src/test_work_area.c b/ThirdParty/Ert/devel/libert_util/src/test_work_area.c index bf9dd8203a..37deb24c3e 100644 --- a/ThirdParty/Ert/devel/libert_util/src/test_work_area.c +++ b/ThirdParty/Ert/devel/libert_util/src/test_work_area.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'test_work_area.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'test_work_area.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifdef HAVE_GETUID @@ -58,17 +58,17 @@ -------------------- - -- Create directory /tmp/$USER/ert-test/my/funn/test and call - -- chdir() to the newly created directory. - test_work_area_type * work_area = test_work_area_alloc("my/funny/test" , true); + -- Create directory /tmp/$USER/ert-test/my/funn/test and call + -- chdir() to the newly created directory. + test_work_area_type * work_area = test_work_area_alloc("my/funny/test" , true); - -- Make files available from the test directory. + -- Make files available from the test directory. test_work_area_install_file(work_area , "/home/user/build/test-data/file1"); test_work_area_install_file(work_area , "relative/path/file2"); -- Recursively copy directory and directory content into test area: - test_work_area_copy_directory(work_area , "/home/user/build/test-data/case1"); - + test_work_area_copy_directory(work_area , "/home/user/build/test-data/case1"); + ... -- Do normal test operations ... @@ -80,7 +80,7 @@ test_work_area_free( work_area ); */ - + #define DEFAULT_STORE false #define DEFAULT_PREFIX "/tmp" @@ -99,7 +99,7 @@ struct test_work_area_struct { test_work_area_type * test_work_area_alloc__(const char * prefix , const char * test_path) { test_work_area_type * work_area = NULL; - + if (util_is_directory( prefix )) { char * test_cwd = util_alloc_sprintf(FULL_PATH_FMT , prefix , test_path ); util_make_path( test_cwd ); @@ -109,11 +109,11 @@ test_work_area_type * test_work_area_alloc__(const char * prefix , const char * UTIL_TYPE_ID_INIT( work_area , TEST_WORK_AREA_TYPE_ID ); work_area->original_cwd = util_alloc_cwd(); work_area->cwd = test_cwd; - util_chdir( work_area->cwd ); + util_chdir( work_area->cwd ); test_work_area_set_store( work_area , DEFAULT_STORE); - } else + } else free( test_cwd ); - } + } return work_area; } @@ -136,7 +136,7 @@ test_work_area_type * test_work_area_alloc_with_prefix(const char * prefix , con rng_free( rng ); free( user_name ); return work_area; - } else + } else return NULL; } @@ -151,10 +151,10 @@ void test_work_area_set_store( test_work_area_type * work_area , bool store) { } -void test_work_area_free(test_work_area_type * work_area) { +void test_work_area_free(test_work_area_type * work_area) { if (!work_area->store) util_clear_directory( work_area->cwd , true , true ); - + util_chdir( work_area->original_cwd ); free( work_area->original_cwd ); free( work_area->cwd ); @@ -188,7 +188,7 @@ void test_work_area_install_file( test_work_area_type * work_area , const char * else { char * src_file = util_alloc_filename( work_area->original_cwd , input_src_file , NULL ); char * src_path; - + util_alloc_file_components( input_src_file , &src_path , NULL , NULL); if (!util_entry_exists( src_path )) util_make_path( src_path ); @@ -234,11 +234,11 @@ void test_work_area_copy_file( test_work_area_type * work_area , const char * in if (input_file) { char * src_file; - if (util_is_abs_path( input_file )) + if (util_is_abs_path( input_file )) src_file = util_alloc_string_copy( input_file ); else src_file = util_alloc_filename( work_area->original_cwd , input_file , NULL); - + if (util_file_exists( src_file )) { char * target_file = util_split_alloc_filename( input_file ); util_copy_file( src_file , target_file ); @@ -251,22 +251,22 @@ void test_work_area_copy_file( test_work_area_type * work_area , const char * in static bool test_work_area_copy_parent__( test_work_area_type * work_area , const char * input_path, bool copy_content) { char * full_path; - + if (util_is_abs_path( input_path )) full_path = util_alloc_string_copy( input_path ); - else + else full_path = util_alloc_filename( work_area->original_cwd , input_path , NULL); - + if (util_entry_exists( full_path)) { char * parent_path = NULL; parent_path = util_alloc_parent_path( full_path ); - + if (copy_content) test_work_area_copy_directory_content( work_area , parent_path ); else test_work_area_copy_directory( work_area , parent_path ); - + free( full_path ); free( parent_path ); return true; diff --git a/ThirdParty/Ert/devel/libert_util/src/thread_pool_posix.c b/ThirdParty/Ert/devel/libert_util/src/thread_pool_posix.c index fd7cdca194..1439d9ac08 100644 --- a/ThirdParty/Ert/devel/libert_util/src/thread_pool_posix.c +++ b/ThirdParty/Ert/devel/libert_util/src/thread_pool_posix.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'thread_pool_posix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'thread_pool_posix.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ @@ -45,7 +45,7 @@ threads and a boolean flag of whether the queue should start immediately (that is in general the case). - thread_pool_type * tp = thread_pool_alloc( NUM_THREADS , immediate_start); + thread_pool_type * tp = thread_pool_alloc( NUM_THREADS , immediate_start); 2. Add the jobs you want to run: @@ -77,13 +77,13 @@ To get the return value from function nr index. - + 5. Optional: The thread pool will probably mainly be used only once, but after a join it is possible to reuse a thread pool, but then you MUST call thread_pool_restart() before adding jobs again. - 6. When you are really finished: thread_pool_free( tp ); + 6. When you are really finished: thread_pool_free( tp ); */ @@ -98,19 +98,19 @@ typedef struct { thread_pool_type * pool; /* A back-reference to the thread_pool holding the queue. */ int slot_index; /* The index in the space [0,max_running) of the job slot where this job is running. */ int queue_index; /* The index of the current tp_arg in the queue. */ - void * func_arg; /* The arguments to this job - supplied by the calling scope. */ + void * func_arg; /* The arguments to this job - supplied by the calling scope. */ start_func_ftype * func; /* The function to call - supplied by the calling scope. */ - void * return_value; + void * return_value; } thread_pool_arg_type; /** - Internal struct used to keep track of the job slots. + Internal struct used to keep track of the job slots. */ typedef struct { pthread_t thread; /* The thread variable currently (or more correct:last) running. */ - int run_count; /* The number of times this slot has been used - just to check whether the slot has been used AT ALL when/if joining. */ + int run_count; /* The number of times this slot has been used - just to check whether the slot has been used AT ALL when/if joining. */ bool running; /* Is the job_slot running now?? */ } thread_pool_job_slot_type; @@ -123,11 +123,11 @@ struct thread_pool_struct { int queue_index; /* The index of the next job to run. */ int queue_size; /* The number of jobs in the queue - including those which are complete. [Should be protected / atomic / ... ] */ int queue_alloc_size; /* The allocated size of the queue. */ - + int max_running; /* The max number of concurrently running jobs. */ bool join; /* Flag set by the main thread to inform the dispatch thread that joining should start. */ bool accepting_jobs; /* True|False whether the dispatch thread is running. */ - + thread_pool_job_slot_type * job_slots; /* A vector to @max_running job slots, each slot can be reused several times.*/ pthread_t dispatch_thread; pthread_rwlock_t queue_lock; @@ -190,17 +190,17 @@ static void * thread_pool_start_job( void * arg ) { int slot_index = tp_arg->slot_index; void * func_arg = tp_arg->func_arg; start_func_ftype * func = tp_arg->func; - void * return_value; + void * return_value; + - return_value = func( func_arg ); /* Starting the real external function */ tp->job_slots[ slot_index ].running = false; /* We mark the job as completed. */ free( arg ); - if (return_value != NULL) + if (return_value != NULL) thread_pool_iset_return_value( tp , tp_arg->queue_index , return_value); - return NULL; + return NULL; } @@ -214,13 +214,12 @@ static void * thread_pool_start_job( void * arg ) { static void * thread_pool_main_loop( void * arg ) { thread_pool_type * tp = (thread_pool_type *) arg; { - const int usleep_busy = 1000; /* The sleep time when all job slots are occupied. */ const int usleep_init = 1000; /* The sleep time when there are free slots available - but no jobs wanting to run. */ int internal_offset = 0; /* Keep track of the (index of) the last job slot fired off - minor time saving. */ while (true) { if (tp->queue_size > tp->queue_index) { - /* - There are jobs in the queue which would like to run - + /* + There are jobs in the queue which would like to run - let us see if we can find a slot for them. */ int counter = 0; @@ -231,26 +230,26 @@ static void * thread_pool_main_loop( void * arg ) { if (!job_slot->running) { /* OK thread[slot_index] is ready to take this job.*/ thread_pool_arg_type * tp_arg; - - /* + + /* The queue might be updated by the main thread - we must take a copy of the node we are interested in. */ pthread_rwlock_rdlock( &tp->queue_lock ); tp_arg = util_alloc_copy( &tp->queue[ tp->queue_index ] , sizeof * tp_arg ); - pthread_rwlock_unlock( &tp->queue_lock ); + pthread_rwlock_unlock( &tp->queue_lock ); tp_arg->slot_index = slot_index; job_slot->running = true; - /* + /* Here is the actual pthread_create() call creating an additional running thread. */ - + /*Cleanup of previous run threads. Needed to avoid memory leak*/ if (job_slot->run_count > 0) - pthread_join(job_slot->thread, NULL); - + pthread_join(job_slot->thread, NULL); + pthread_create( &job_slot->thread , NULL , thread_pool_start_job , tp_arg ); job_slot->run_count += 1; tp->queue_index++; @@ -259,26 +258,27 @@ static void * thread_pool_main_loop( void * arg ) { } else counter++; } while (!slot_found && (counter < tp->max_running)); - - if (!slot_found) - util_usleep( usleep_busy ); /* There are no available job slots. */ - } else - util_usleep( usleep_init ); /* There are no jobs wanting to run. */ + + if (!slot_found) { + util_yield(); + } + } else { + util_usleep(usleep_init); /* There are no jobs wanting to run. */ + } /*****************************************************************/ /* We exit explicitly from this loop when both conditions apply: - 1. tp->join == true : The calling scope has signaled that it will not submit more jobs. + 1. tp->join == true : The calling scope has signaled that it will not submit more jobs. 2. tp->queue_size == tp->queue_index : This function has submitted all the jobs in the queue. */ - if ((tp->join) && - (tp->queue_size == tp->queue_index)) + if ((tp->join) && (tp->queue_size == tp->queue_index)) break; } /* End of while() loop */ } - /* + /* There are no more jobs in the queue, and the main scope has signaled that join should start. Observe that we join only the jobs corresponding to explicitly running job_slots; when a job @@ -310,7 +310,7 @@ static void * thread_pool_main_loop( void * arg ) { */ void thread_pool_restart( thread_pool_type * tp ) { - if (tp->accepting_jobs) + if (tp->accepting_jobs) util_abort("%s: fatal error - tried restart already running thread pool\n",__func__); { tp->join = false; @@ -323,7 +323,7 @@ void thread_pool_restart( thread_pool_type * tp ) { tp->job_slots[i].running = false; } } - + /* Starting the dispatch thread. */ pthread_create( &tp->dispatch_thread , NULL , thread_pool_main_loop , tp ); tp->accepting_jobs = true; @@ -365,8 +365,8 @@ thread_pool_type * thread_pool_alloc(int max_running , bool start_queue) { pool->queue = NULL; pool->accepting_jobs = false; pthread_rwlock_init( &pool->queue_lock , NULL); - thread_pool_resize_queue( pool , 32 ); - if (start_queue) + thread_pool_resize_queue( pool , 32 ); + if (start_queue) thread_pool_restart( pool ); return pool; } @@ -381,7 +381,7 @@ void thread_pool_add_job(thread_pool_type * pool , start_func_ftype * start_func if (pool->queue_size == pool->queue_alloc_size) thread_pool_resize_queue( pool , pool->queue_alloc_size * 2); - /* + /* The new job is added to the queue - the main thread is watching the queue and will pick up the new job. */ @@ -399,9 +399,9 @@ void thread_pool_add_job(thread_pool_type * pool , start_func_ftype * start_func util_abort("%s: thread_pool is not running - restart with thread_pool_restart()?? \n",__func__); } } - - + + /* Observe that this function does not join the worker threads, i.e. you should call thread_pool_join() first (otherwise the thing diff --git a/ThirdParty/Ert/devel/libert_util/src/type_vector_functions.c b/ThirdParty/Ert/devel/libert_util/src/type_vector_functions.c index b3f19370f3..b7f0c60c21 100644 --- a/ThirdParty/Ert/devel/libert_util/src/type_vector_functions.c +++ b/ThirdParty/Ert/devel/libert_util/src/type_vector_functions.c @@ -1,25 +1,28 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ert_util_vector_function.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ert_util_vector_function.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ +#include <stdbool.h> #include <ert/util/int_vector.h> #include <ert/util/bool_vector.h> +#include <ert/util/double_vector.h> +#include <ert/util/type_vector_functions.h> int_vector_type * bool_vector_alloc_active_list( const bool_vector_type * mask ) { @@ -29,7 +32,7 @@ int_vector_type * bool_vector_alloc_active_list( const bool_vector_type * mask ) for (i =0; i < bool_vector_size( mask ); i++) if (bool_vector_iget( mask , i )) int_vector_append( active_list , i ); - + return active_list; } @@ -51,11 +54,30 @@ int_vector_type * bool_vector_alloc_active_index_list(const bool_vector_type * m bool_vector_type * int_vector_alloc_mask( const int_vector_type * active_list ) { bool_vector_type * mask = bool_vector_alloc( 0 , false ); int i; - for (i=0; i < int_vector_size( active_list ); i++) + for (i=0; i < int_vector_size( active_list ); i++) bool_vector_iset( mask , int_vector_iget( active_list , i) , true ); return mask; } +bool double_vector_approx_equal( const double_vector_type * v1 , const double_vector_type * v2 , double epsilon) { + bool equal = true; + if (double_vector_size( v1 ) == double_vector_size( v2 )) { + int i; + + for (i=0; i < double_vector_size( v1 ); i++) { + double d1 = double_vector_iget( v1 , i ); + double d2 = double_vector_iget( v2 , i ); + + if (!util_double_approx_equal__(d1 , d2 , epsilon)) + equal = false; + } + } else + equal = false; + + return equal; +} + + diff --git a/ThirdParty/Ert/devel/libert_util/src/util.c b/ThirdParty/Ert/devel/libert_util/src/util.c index 4a20f675a2..3d071d4da8 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util.c +++ b/ThirdParty/Ert/devel/libert_util/src/util.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'util.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'util.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -21,7 +21,7 @@ handling, string handling and file handling. Observe that all these functions are just that - functions - there is no associated state with any of these functions. - + The file util_path.c is included in this, and contains path manipulation functions which explicitly use the PATH_SEP variable. */ @@ -49,7 +49,7 @@ #ifdef HAVE_UTIL_ABORT #define __USE_GNU // Must be defined to get access to the dladdr() function; Man page says the symbol should be: _GNU_SOURCE but that does not seem to work? -#define _GNU_SOURCE // Must be defined _before_ #include <errno.h> to get the symbol 'program_invocation_name'. +#define _GNU_SOURCE // Must be defined _before_ #include <errno.h> to get the symbol 'program_invocation_name'. #include <dlfcn.h> #endif #include <errno.h> @@ -112,12 +112,12 @@ /* Macros for endian flipping. The macros create a new endian-flipped - value, and should be used as: + value, and should be used as: flipped_value = FLIP32( value ) - + The macros are not exported and only available through the function - util_endian_flip_vector(). + util_endian_flip_vector(). */ @@ -148,7 +148,7 @@ static uint16_t util_endian_convert16( uint16_t u ) { static uint32_t util_endian_convert32( uint32_t u ) { const uint32_t m8 = (uint32_t) 0x00FF00FFUL; const uint32_t m16 = (uint32_t) 0x0000FFFFUL; - + u = (( u >> 8U ) & m8) | ((u & m8) << 8U); u = (( u >> 16U ) & m16) | ((u & m16) << 16U); return u; @@ -160,7 +160,7 @@ static uint64_t util_endian_convert64( uint64_t u ) { const uint64_t m16 = (uint64_t) 0x0000FFFF0000FFFFULL; const uint64_t m32 = (uint64_t) 0x00000000FFFFFFFFULL; - + u = (( u >> 8U ) & m8) | ((u & m8) << 8U); u = (( u >> 16U ) & m16) | ((u & m16) << 16U); u = (( u >> 32U ) & m32) | ((u & m32) << 32U); @@ -172,7 +172,7 @@ static uint64_t util_endian_convert32_64( uint64_t u ) { const uint64_t m8 = (uint64_t) 0x00FF00FF00FF00FFULL; const uint64_t m16 = (uint64_t) 0x0000FFFF0000FFFFULL; - + u = (( u >> 8U ) & m8) | ((u & m8) << 8U); u = (( u >> 16U ) & m16) | ((u & m16) << 16U); return u; @@ -185,7 +185,7 @@ void util_endian_flip_vector(void *data, int element_size , int elements) { switch (element_size) { case(1): break; - case(2): + case(2): { uint16_t *tmp16 = (uint16_t *) data; @@ -201,7 +201,7 @@ void util_endian_flip_vector(void *data, int element_size , int elements) { variables will be by swapping two elements in one operation; this is provided by the util_endian_convert32_64() function. In the case of binary ECLIPSE files this case is quite common, and - therefor worth supporting as a special case. + therefor worth supporting as a special case. */ uint64_t *tmp64 = (uint64_t *) data; @@ -216,10 +216,10 @@ void util_endian_flip_vector(void *data, int element_size , int elements) { break; #else uint32_t *tmp32 = (uint32_t *) data; - + for (i = 0; i <elements; i++) tmp32[i] = util_endian_convert32(tmp32[i]); - + break; #endif } @@ -242,7 +242,7 @@ void util_endian_flip_vector_old(void *data, int element_size , int elements) { switch (element_size) { case(1): break; - case(2): + case(2): { uint16_t *tmp_int = (uint16_t *) data; @@ -256,7 +256,7 @@ void util_endian_flip_vector_old(void *data, int element_size , int elements) { for (i = 0; i <elements; i++) tmp_int[i] = FLIP32(tmp_int[i]); - + break; } case(8): @@ -305,7 +305,7 @@ void util_fread_dev_random(int buffer_size , char * buffer) { FILE * stream = util_fopen("/dev/random" , "r"); if (fread(buffer , 1 , buffer_size , stream) != buffer_size) util_abort("%s: failed to read:%d bytes from /dev/random \n",__func__ , buffer_size); - + fclose(stream); } @@ -314,7 +314,7 @@ void util_fread_dev_urandom(int buffer_size , char * buffer) { FILE * stream = util_fopen("/dev/urandom" , "r"); if (fread(buffer , 1 , buffer_size , stream) != buffer_size) util_abort("%s: failed to read:%d bytes from /dev/random \n",__func__ , buffer_size); - + fclose(stream); } @@ -323,8 +323,8 @@ unsigned int util_clock_seed( ) { int sec,min,hour; int mday,year,month; time_t now = time( NULL ); - - + + util_set_datetime_values(now , &sec , &min , &hour , &mday , &month , &year); { unsigned int seed = clock( ); @@ -344,7 +344,7 @@ unsigned int util_clock_seed( ) { /** Kahan summation is a technique to retain numerical precision when summing a long vector of values. See: - http://en.wikipedia.org/wiki/Kahan_summation_algorithm + http://en.wikipedia.org/wiki/Kahan_summation_algorithm */ double util_kahan_sum(const double *data, size_t N) { @@ -352,7 +352,7 @@ double util_kahan_sum(const double *data, size_t N) { double C = 0; double Y,T; size_t i; - + for (i=1; i < N; i++) { Y = data[i] - C; T = S + Y; @@ -369,7 +369,7 @@ bool util_float_approx_equal__( float d1 , float d2, float epsilon) { else { float diff = fabs(d1 - d2); float sum = fabs(d1) + fabs(d2); - + if ((diff / sum) < epsilon) return true; else @@ -384,7 +384,7 @@ bool util_double_approx_equal__( double d1 , double d2, double epsilon) { else { double diff = fabs(d1 - d2); double sum = fabs(d1) + fabs(d2); - + if ((diff / sum) < epsilon) return true; else @@ -405,7 +405,7 @@ char * util_alloc_substring_copy(const char *src , int offset , int N) { copy = util_calloc(N + 1 , sizeof * copy ); strncpy(copy , &src[offset] , N); copy[N] = '\0'; - } else + } else copy = util_alloc_string_copy(&src[offset]); return copy; } @@ -416,17 +416,17 @@ char * util_alloc_dequoted_copy(const char *s) { char last_char = s[strlen(s) - 1]; char *new; int offset , len; - + if ((first_char == '\'') || (first_char == '\"')) offset = 1; - else + else offset = 0; - + if ((last_char == '\'') || (last_char == '\"')) len = strlen(s) - offset - 1; - else + else len = strlen(s) - offset; - + new = util_alloc_substring_copy(s , offset , len); return new; } @@ -435,7 +435,7 @@ char * util_alloc_dequoted_copy(const char *s) { /** The input string is freed, and a new storage - without quotes is returned. + without quotes is returned. */ char * util_realloc_dequoted_string(char *s) { char first_char = s[0]; @@ -445,14 +445,14 @@ char * util_realloc_dequoted_string(char *s) { if ((first_char == '\'') || (first_char == '\"')) offset = 1; - else + else offset = 0; - + if ((last_char == '\'') || (last_char == '\"')) len = strlen(s) - offset - 1; - else + else len = strlen(s) - offset; - + new = util_alloc_substring_copy(s , offset , len); free(s); return new; @@ -472,7 +472,7 @@ char * util_alloc_strupr_copy(const char * s) { } -/** +/** Replaces all occurences of c1 in s with c2. */ void util_string_tr(char * s, char c1, char c2) { @@ -529,7 +529,7 @@ bool util_fseek_string(FILE * stream , const char * __string , bool skip_string int c = fgetc( stream ); if (!case_sensitive) c = toupper( c ); - + if (c == string[0]) { /* OK - we got the first character right - lets try in more detail: */ long int current_pos = util_ftell(stream); bool equal = true; @@ -538,25 +538,25 @@ bool util_fseek_string(FILE * stream , const char * __string , bool skip_string c = fgetc( stream ); if (!case_sensitive) c = toupper( c ); - + if (c != string[string_index]) { equal = false; break; } } - + if (equal) { string_found = true; cont = false; } else /* Go back to current pos and continue searching. */ util_fseek(stream , current_pos , SEEK_SET); - + } - if (c == EOF) + if (c == EOF) cont = false; } while (cont); - - + + if (string_found) { if (!skip_string) { offset_type offset = (offset_type) strlen(string); @@ -564,7 +564,7 @@ bool util_fseek_string(FILE * stream , const char * __string , bool skip_string } } else util_fseek(stream , initial_pos , SEEK_SET); /* Could not find the string reposition at initial position. */ - + } free( string ); return string_found; @@ -596,7 +596,7 @@ char * util_fscanf_alloc_upto(FILE * stream , const char * stop_string, bool inc util_fseek(stream , start_pos , SEEK_SET); util_fread( buffer , 1 , len , stream , __func__); buffer[len] = '\0'; - + return buffer; } else return NULL; /* stop_string not found */ @@ -611,14 +611,14 @@ static char * util_fscanf_alloc_line__(FILE *stream , bool *at_eof , char * line char end_char; bool cont; bool dos_newline; - + len = 0; cont = true; { char c; do { c = fgetc(stream); - if (c == EOF) + if (c == EOF) cont = false; else { if (EOL_CHAR(c)) @@ -633,14 +633,14 @@ static char * util_fscanf_alloc_line__(FILE *stream , bool *at_eof , char * line dos_newline = false; end_char = c; } - - if (util_fseek(stream , init_pos , SEEK_SET) != 0) + + if (util_fseek(stream , init_pos , SEEK_SET) != 0) util_abort("%s: fseek failed: %d/%s \n",__func__ , errno , strerror(errno)); new_line = util_realloc(line , len + 1 ); util_fread(new_line , sizeof * new_line , len , stream , __func__); new_line[len] = '\0'; - + /* Skipping the end of line marker(s). @@ -648,19 +648,19 @@ static char * util_fscanf_alloc_line__(FILE *stream , bool *at_eof , char * line fgetc(stream); if (dos_newline) - fgetc(stream); - + fgetc(stream); + if (at_eof != NULL) { if (end_char == EOF) *at_eof = true; else *at_eof = false; } - + if (new_line != NULL) { char * strip_line = util_alloc_strip_copy(new_line); free(new_line); - + return strip_line; } else return NULL; @@ -709,14 +709,14 @@ char * util_alloc_stdin_line(void) { } } else end = true; } while (!end); - if (index == 0) { + if (index == 0) { free(input); input = NULL; } else { - input[index] = '\0'; + input[index] = '\0'; input = util_realloc(input , strlen(input) + 1 ); } - + return input; } @@ -738,7 +738,7 @@ char * util_realloc_stdin_line(char * p) { void util_usleep( unsigned long micro_seconds ) { #ifdef HAVE__USLEEP usleep( micro_seconds ); -#else +#else #ifdef ERT_WINDOWS { int milli_seconds = micro_seconds / 1000; @@ -748,6 +748,17 @@ void util_usleep( unsigned long micro_seconds ) { #endif } +void util_yield() { +#if defined(WITH_PTHREAD) && (defined(HAVE_YIELD_NP) || defined(HAVE_YIELD)) + #ifdef HAVE_YIELD_NP + pthread_yield_np(); + #elif HAVE_YIELD + pthread_yield(); + #endif +#else + util_usleep(1000); +#endif +} /** This function will allocate and read a line from stdin. If there is @@ -760,7 +771,7 @@ char * util_blocking_alloc_stdin_line(unsigned long usec) { char * line; do { line = util_alloc_stdin_line(); - if (line == NULL) + if (line == NULL) util_usleep(usec); } while (line == NULL); return line; @@ -815,9 +826,9 @@ bool util_is_cwd( const char * path ) { -/* +/* Homemade realpath() for not existing path or platforms without - realpath(). + realpath(). */ @@ -849,7 +860,7 @@ char * util_alloc_realpath__(const char * input_path) { char * abs_path = util_alloc_cwd_abs_path( input_path ); char * real_path = util_malloc( strlen(abs_path) + 1 ); real_path[0] = '\0'; - + { bool * mask; char ** path_list; @@ -862,7 +873,7 @@ char * util_alloc_realpath__(const char * input_path) { for (i=0; i < path_len; i++) mask[i] = true; } - + { int path_index = 1; // Path can not start with .. int prev_index = 0; @@ -896,24 +907,24 @@ char * util_alloc_realpath__(const char * input_path) { } } } - } + } free(mask); util_free_stringlist( path_list , path_len ); } - free(abs_path); + free(abs_path); return real_path; } -#undef BACKREF -#undef CURRENT +#undef BACKREF +#undef CURRENT /** The util_alloc_realpath() will fail hard if the @input_path does not exist. If the path might-not-exist you should use - util_alloc_abs_path() instead. + util_alloc_abs_path() instead. */ @@ -921,13 +932,13 @@ char * util_alloc_realpath(const char * input_path) { #ifdef HAVE_REALPATH char * buffer = util_calloc(PATH_MAX + 1 , sizeof * buffer ); char * new_path = NULL; - + new_path = realpath( input_path , buffer); - if (new_path == NULL) + if (new_path == NULL) util_abort("%s: input_path:%s - failed: %s(%d) \n",__func__ , input_path , strerror(errno) , errno); - else + else new_path = util_realloc(new_path , strlen(new_path) + 1); - + return new_path; #else /* We do not have the realpath() implementation. Must first check if @@ -936,11 +947,11 @@ char * util_alloc_realpath(const char * input_path) { #ifdef HAVE_SYMLINK ERROR - What the fuck; have symlinks and not realpath()?! #endif - if (!util_entry_exists( input_path )) + if (!util_entry_exists( input_path )) util_abort("%s: input_path:%s does not exist - failed.\n",__func__ , input_path); - + return util_alloc_realpath__( input_path ); -#endif +#endif } @@ -953,7 +964,7 @@ char * util_alloc_realpath(const char * input_path) { 1. If @path starts with '/' the path is assumed to be absolute, and just returned. - + 2. Else cwd is prepended to the path. In the manual realpath() neither "/../" nor symlinks are resolved. If path == NULL the function will return cwd(). @@ -963,7 +974,7 @@ char * util_alloc_abs_path( const char * path ) { if (path == NULL) return util_alloc_cwd(); else { - if (util_entry_exists( path )) + if (util_entry_exists( path )) return util_alloc_realpath( path ); else return util_alloc_cwd_abs_path( path ); @@ -997,7 +1008,7 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { /* 1. Split both input paths into list of path elements. */ util_path_split( root_path, &root_path_length , &root_path_list ); util_path_split( path , &path_length , &path_list ); - + { /* 2: Determine the number of common leading path elements. */ int common_length = 0; @@ -1006,19 +1017,19 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { common_length++; else break; - + if (common_length == util_int_min( root_path_length , path_length)) break; } - + /* 3: Start building up the relative path with leading ../ elements. */ back_length = root_path_length - common_length; if (back_length > 0) { - int i; + int i; for (i=0; i < back_length; i++) { rel_path = util_strcat_realloc( rel_path , back_path ); rel_path = util_strcat_realloc( rel_path , UTIL_PATH_SEP_STRING ); - } + } } /* 4: Add the remaining elements from the input path. */ @@ -1031,7 +1042,7 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { } } } - + util_free_stringlist( root_path_list , root_path_length ); util_free_stringlist( path_list , path_length ); free( root_path ); @@ -1041,7 +1052,7 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { rel_path = NULL; } return rel_path; } else { - /* + /* One or both the input arguments do not correspond to an absolute path; just return a copy of the input back. */ @@ -1056,7 +1067,7 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { /** This function will allocate a string copy of the env_index'th occurence of an embedded environment variable from the input - string. + string. An environment variable is defined as follows: @@ -1065,14 +1076,14 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { The function will return environment variable number 'env_index'. If no such environment variable can be found in the string the - function will return NULL. + function will return NULL. Observe that the returned string will start with '$'. This is to simplify subsequent calls to util_string_replace_XXX() functions, however &ret_value[1] must be used in the subsequent getenv() call: - { - char * env_var = util_isscanf_alloc_envvar( s , 0 ); + { + char * env_var = util_isscanf_alloc_envvar( s , 0 ); if (env_var != NULL) { const char * env_value = getenv( &env_var[1] ); // Skip the leading '$'. if (env_value != NULL) @@ -1097,14 +1108,14 @@ char * util_isscanf_alloc_envvar( const char * string , int env_index ) { } while ((env_count <= env_index) && (env_ptr != NULL)); if (env_ptr != NULL) { - /* + /* We found an environment variable we are interested in. Find the end of this variable and return a copy. - */ + */ int length = 1; bool cont = true; do { - + if ( !( isalnum(env_ptr[length]) || env_ptr[length] == '_' )) cont = false; else @@ -1112,7 +1123,7 @@ char * util_isscanf_alloc_envvar( const char * string , int env_index ) { if (length == strlen( env_ptr )) cont = false; } while (cont); - + return util_alloc_substring_copy( env_ptr , 0 , length ); } else return NULL; /* Could not find any env variable occurences. */ @@ -1136,7 +1147,7 @@ void util_fskip_lines(FILE * stream , int lines) { at_eof = true; } while (c != '\r' && c != '\n' && !at_eof); - /* + /* If we have read a \r this is quite probably a DOS formatted file, and we read another character in the anticipation that it is a \n character. @@ -1150,12 +1161,12 @@ void util_fskip_lines(FILE * stream , int lines) { util_fseek( stream , -1 , SEEK_CUR ); } } - + line_nr++; if (line_nr == lines || at_eof) cont = false; } while (cont); } - + /* The last line(s) without content are not counted, i.e. @@ -1172,12 +1183,12 @@ void util_fskip_lines(FILE * stream , int lines) { will return a value of four. */ - + int util_forward_line(FILE * stream , bool * at_eof) { bool at_eol = false; int col = 0; *at_eof = false; - + do { char c = fgetc(stream); if (c == EOF) { @@ -1187,10 +1198,10 @@ int util_forward_line(FILE * stream , bool * at_eof) { if (EOL_CHAR(c)) { at_eol = true; c = fgetc(stream); - if (c == EOF) + if (c == EOF) *at_eof = true; else { - if (!EOL_CHAR(c)) + if (!EOL_CHAR(c)) util_fseek(stream , -1 , SEEK_CUR); } } else @@ -1208,12 +1219,12 @@ bool util_char_in(char c , int set_size , const char * set) { for (i=0; i < set_size; i++) if (set[i] == c) in = true; - + return in; } -/** +/** Returns true if ALL the characters in 's' return true from isspace(). */ @@ -1300,7 +1311,7 @@ void util_fskip_space(FILE * stream , bool *at_eof) { -/** +/** This functions reads a token[1] from stream, allocates storage for the it, and returns the newly allocated storage. Observe that the function does *NOT* read past end of line. If no token can be the @@ -1323,7 +1334,7 @@ void util_fskip_space(FILE * stream , bool *at_eof) { while (!at_eof) { token = util_fscanf_alloc_token(stream); if (token != NULL) { - printf("Have read token:%s \n",token); + printf("Have read token:%s \n",token); free(token); } else { printf("Have reached EOL/EOF \n"); @@ -1334,7 +1345,7 @@ void util_fskip_space(FILE * stream , bool *at_eof) { This will produce the output: Have read token: This Have read token: is - Have read token: a + Have read token: a Have read token: file Have reached EOL/EOF Have read token: Line2 @@ -1346,7 +1357,7 @@ void util_fskip_space(FILE * stream , bool *at_eof) { [1]: A token is defined as a sequence of characters separated by white-space or tab. */ - + @@ -1356,7 +1367,7 @@ char * util_fscanf_alloc_token(FILE * stream) { char * token = NULL; char c; - + cont = true; /* Skipping initial whitespace */ @@ -1367,7 +1378,7 @@ char * util_fscanf_alloc_token(FILE * stream) { /* Going back to position at newline */ util_fseek(stream , pos , SEEK_SET); cont = false; - } else if (c == EOF) + } else if (c == EOF) cont = false; else if (!util_char_in(c , 2 , space_set)) { util_fseek(stream , pos , SEEK_SET); @@ -1377,7 +1388,7 @@ char * util_fscanf_alloc_token(FILE * stream) { if (EOL_CHAR(c)) return NULL; if (c == EOF) return NULL; - + /* At this point we are guranteed to return something != NULL */ cont = true; @@ -1397,10 +1408,10 @@ char * util_fscanf_alloc_token(FILE * stream) { length++; } while (cont); if (EOL_CHAR(c)) util_fseek(stream , -1 , SEEK_CUR); - + token = util_calloc(length + 1 , sizeof * token ); util_fseek(stream , token_start , SEEK_SET); - { + { int i; for (i = 0; i < length; i++) token[i] = fgetc(stream); @@ -1423,16 +1434,16 @@ char * util_fscanf_alloc_token(FILE * stream) { -------- const char * s = "78.92" double value; - - if (util_sscanf_double(s , &value)) + + if (util_sscanf_double(s , &value)) printf("%s is a valid double\n"); else printf("%s is NOT a valid double\n"); */ - -bool util_sscanf_double(const char * buffer , double * value) { - bool value_OK = false; + +bool util_sscanf_double(const char * buffer , double * value) { + bool value_OK = false; char * error_ptr; double tmp_value = strtod(buffer , &error_ptr); @@ -1441,12 +1452,12 @@ bool util_sscanf_double(const char * buffer , double * value) { */ while (error_ptr[0] != '\0' && isspace(error_ptr[0])) error_ptr++; - + if (error_ptr[0] == '\0') { - value_OK = true; + value_OK = true; if (value != NULL) *value = tmp_value; - } + } return value_OK; } @@ -1460,7 +1471,7 @@ bool util_sscanf_octal_int(const char * buffer , unsigned int * value) { char * error_ptr; int tmp_value = strtol(buffer , &error_ptr , 8); - + /* Skip trailing white-space */ @@ -1469,10 +1480,10 @@ bool util_sscanf_octal_int(const char * buffer , unsigned int * value) { error_ptr++; if (error_ptr[0] == '\0') { - value_OK = true; + value_OK = true; if (value != NULL) *value = tmp_value; - } + } return value_OK; } @@ -1498,10 +1509,10 @@ bool util_sscanf_int(const char * buffer , int * value) { error_ptr++; if (error_ptr[0] == '\0') { - value_OK = true; + value_OK = true; if (value != NULL) *value = tmp_value; - } + } return value_OK; } @@ -1511,9 +1522,9 @@ bool util_sscanf_int(const char * buffer , int * value) { */ bool util_string_equal(const char * s1 , const char * s2 ) { - if (s1 == NULL || s2 == NULL) + if (s1 == NULL || s2 == NULL) return false; - + /* Now we know that BOTH s1 and s2 are != NULL */ if (strcmp(s1,s2) == 0) return true; @@ -1542,12 +1553,12 @@ bool util_string_equal(const char * s1 , const char * s2 ) { s = "1, 10, 78, 67"; | | | NULL 1 2 3 3 - - The vertical bars indicate the return values. + + The vertical bars indicate the return values. */ - + const char * util_parse_int(const char * s , int * value, bool *OK) { if (*OK) { char * error_ptr; @@ -1578,12 +1589,12 @@ const char * util_parse_int(const char * s , int * value, bool *OK) { while (OK) { int value; current_ptr = util_parse_int(current_ptr , &value , &OK); - if (OK) + if (OK) printf("Found:%d \n",value); current_ptr = util_skip_sep(current_ptr , " ," , &OK); } - + */ const char * util_skip_sep(const char * s, const char * sep_set, bool *OK) { @@ -1592,7 +1603,7 @@ const char * util_skip_sep(const char * s, const char * sep_set, bool *OK) { if (sep_length == 0) *OK = false; return &s[sep_length]; - } else + } else return NULL; } @@ -1605,7 +1616,7 @@ const char * util_skip_sep(const char * s, const char * sep_set, bool *OK) { optional suffix. The valid suffizes are KB,MB and GB (any case is allowed); if no suffix is appended the buffer is assumed to contain a memory size already specified in bytes. - + Observe that __this_function__ allows an arbitrary number of spaces between between the integer literal and the suffix string; however @@ -1619,7 +1630,7 @@ const char * util_skip_sep(const char * s, const char * sep_set, bool *OK) { KB => *= 1024 MB => *= 1024 * 1024; GB => *= 1024 * 1024 * 1024; - + Observe that if the functions fails to parse/interpret the string it will return false, and set the reference value to 0. However it will not fail with an abort. Overflows are *NOT* checked for. @@ -1637,7 +1648,7 @@ bool util_sscanf_bytesize(const char * buffer, size_t *size) { value = strtol(buffer , &suffix_ptr , 10); if (suffix_ptr[0] != '\0') { - while (isspace(suffix_ptr[0])) + while (isspace(suffix_ptr[0])) suffix_ptr++; { char * upper = util_alloc_string_copy(suffix_ptr); @@ -1652,7 +1663,7 @@ bool util_sscanf_bytesize(const char * buffer, size_t *size) { /* else - failed to parse - returning false. */ free(upper); } - } + } if (size != NULL) { if (parse_OK) @@ -1660,7 +1671,7 @@ bool util_sscanf_bytesize(const char * buffer, size_t *size) { else *size = 0; } - + return parse_OK; } @@ -1699,29 +1710,29 @@ static int isnumeric( int c , bool float_mode) { function. } - Caveats: - + Caveats: + o Algorithm will not interpret "-" as a minus sign, only as a character. This might lead to unexpected results if you want to compare strings with embedded signed numeric literals, see example three below. - + Examples: - + S1 S2 util_strcmp_numeric() strcmp() ------------------------------------------------------------ "001" "1" 0 -1 - "String-10" "String-3" 1 -1 + "String-10" "String-3" 1 -1 "String-8" "String1" -1 -1 ------------------------------------------------------------ */ - + static int util_strcmp_numeric__( const char * s1 , const char * s2, bool float_mode) { - /* + /* Special case to handle e.g. - util_strcmp_numeric("100.00000" , "100") + util_strcmp_numeric("100.00000" , "100") which should compare as equal. The normal algorithm will compare equal characterwise all the way until one string ends, and the @@ -1732,7 +1743,7 @@ static int util_strcmp_numeric__( const char * s1 , const char * s2, bool float_ double num1 , num2; char * end1; char * end2; - + if (float_mode) { num1 = strtod( s1 , &end1 ); num2 = strtod( s2 , &end2 ); @@ -1740,38 +1751,38 @@ static int util_strcmp_numeric__( const char * s1 , const char * s2, bool float_ num1 = 1.0 * strtol( s1 , &end1 , 10); num2 = 1.0 * strtol( s2 , &end2 , 10); } - - if ( (*end2 == '\0') && (*end1 == '\0')) { + + if ( (*end2 == '\0') && (*end1 == '\0')) { /* The whole string has been read and converted to a number - for both strings. */ if (num1 < num2) return -1; - else if (num1 > num2) + else if (num1 > num2) return 1; else return 0; - } - } - - - /* + } + } + + + /* At least one of the strings is not a pure numerical literal and - we start on a normal comparison. + we start on a normal comparison. */ { int cmp = 0; - bool complete = false; + bool complete = false; int len1 = strlen( s1 ); int len2 = strlen( s2 ); int offset1 = 0; int offset2 = 0; - - + + while (!complete) { while( true ) { if ((offset1 == len1) || (offset2 == len2)) { /* OK - at least one of the strings is at the end; we set the cmp value and return. */ - + if ((offset1 == len1) && (offset2 == len2)) /* We are the the end of both strings - they compare as equal. */ cmp = 0; @@ -1782,38 +1793,38 @@ static int util_strcmp_numeric__( const char * s1 , const char * s2, bool float_ complete = true; break; } - + if (s1[offset1] != s2[offset2]) /* We have reached a point of difference, jump out of this loop and continue with more detailed comparison further down. */ break; - + // Strings are still equal - proceed one character further. offset1++; offset2++; } - + if (!complete) { - /* + /* Both offset values point to a valid character value, but the two character values are different: - + 1. Both characters are numeric - we use strtol() to read the two integers and perform a numeric comparison. - + 2. One or none of the characters are numeric, we just use ordinary strcmp() on the substrings starting at the current offset. */ - + if (isnumeric( s1[ offset1 ] , float_mode) && isnumeric( s2[ offset2 ] , float_mode)) { char * end1; char * end2; double num1,num2; - /* + /* The numerical comparison is based on double variables - irrespective of the value of @float_mode. + irrespective of the value of @float_mode. */ if (float_mode) { num1 = strtod( &s1[ offset1 ] , &end1 ); @@ -1822,7 +1833,7 @@ static int util_strcmp_numeric__( const char * s1 , const char * s2, bool float_ num1 = 1.0 * strtol( &s1[ offset1 ] , &end1 , 10); num2 = 1.0 * strtol( &s2[ offset2 ] , &end2 , 10); } - + if (num1 != num2) { if (num1 < num2) cmp = -1; @@ -1847,13 +1858,13 @@ static int util_strcmp_numeric__( const char * s1 , const char * s2, bool float_ offset2 = end2 - s2; } } else { - /* + /* We have arrived at a point of difference in the string, and perform 100% standard strcmp(). */ cmp = strcmp( &s1[offset1] , &s2[offset2] ); complete = true; - } + } } } return cmp; @@ -1878,12 +1889,12 @@ int util_strcmp_int( const char * s1 , const char * s2) { -/** +/** Succesfully parses: 1 , T (not 't') , True (with any case) => true 0 , F (not 'f') , False(with any case) => false - + Else the parsing fails. */ @@ -1907,14 +1918,14 @@ bool util_sscanf_bool(const char * buffer , bool * _value) { } else { char * local_buffer = util_alloc_string_copy(buffer); util_strupr(local_buffer); - + if (strcmp(local_buffer , "TRUE") == 0) { parse_OK = true; value = true; } else if (strcmp(local_buffer , "FALSE") == 0) { parse_OK = true; value = false; - } + } free(local_buffer); } @@ -1941,12 +1952,12 @@ bool util_fscanf_bool(FILE * stream , bool * value) { If the parsing fails the stream is repositioned at the location it had on entry to the function. */ - + bool util_fscanf_int(FILE * stream , int * value) { long int start_pos = util_ftell(stream); char * token = util_fscanf_alloc_token(stream); - + bool value_OK = false; if (token != NULL) { value_OK = util_sscanf_int(token , value); @@ -1955,12 +1966,12 @@ bool util_fscanf_int(FILE * stream , int * value) { free(token); } return value_OK; -} +} /** Prompt .........====> - <-------1------><-2-> + <-------1------><-2-> The section marked with 1 above is the prompt length, i.e. the input prompt is padded wth one blank, and then padded with @@ -1980,8 +1991,8 @@ bool util_fscanf_int(FILE * stream , int * value) { void util_printf_prompt(const char * prompt , int prompt_len, char fill_char , const char * termination) { int current_len = strlen(prompt) + 1; - printf("%s ",prompt); /* Observe that one ' ' is forced in here. */ - + printf("%s ",prompt); /* Observe that one ' ' is forced in here. */ + while (current_len < prompt_len) { fputc(fill_char , stdout); current_len++; @@ -2059,7 +2070,7 @@ double util_scanf_double(const char * prompt , int prompt_len) { -/** +/** The limits are inclusive. */ int util_scanf_int_with_limits(const char * prompt , int prompt_len , int min_value , int max_value) { @@ -2072,7 +2083,7 @@ int util_scanf_int_with_limits(const char * prompt , int prompt_len , int min_va return value; } -/** +/** The limits are inclusive, yet the function returns the input char and stops on empty string. */ char * util_scanf_int_with_limits_return_char(const char * prompt , int prompt_len , int min_value , int max_value) { @@ -2126,7 +2137,7 @@ int util_count_content_file_lines(FILE * stream) { int empty_lines = 0; int col = 0; char c; - + do { c = fgetc(stream); if (EOL_CHAR(c)) { @@ -2145,7 +2156,7 @@ int util_count_content_file_lines(FILE * stream) { }else if (c == EOF){ lines++; } - + } else if (c == EOF){ lines++; } @@ -2154,7 +2165,7 @@ int util_count_content_file_lines(FILE * stream) { col++; } } while (! feof(stream) ); - if (col == 0) + if (col == 0) /* Not counting empty last line. */ @@ -2166,7 +2177,7 @@ int util_count_content_file_lines(FILE * stream) { /******************************************************************/ -/** +/** buffer_size is _only_ for a return (by reference) of the size of the allocation. Can pass in NULL if that size is not interesting. */ @@ -2180,7 +2191,7 @@ char * util_fread_alloc_file_content(const char * filename , int * buffer_size) fclose(stream); } if (buffer_size != NULL) *buffer_size = file_size; - + buffer[file_size] = '\0'; return buffer; } @@ -2193,14 +2204,14 @@ char * util_fread_alloc_file_content(const char * filename , int * buffer_size) write fails, in this case the calling scope must do the right thing. */ - + bool util_copy_stream(FILE *src_stream , FILE *target_stream , size_t buffer_size , void * buffer , bool abort_on_error) { while ( ! feof(src_stream)) { int bytes_read; int bytes_written; bytes_read = fread (buffer , 1 , buffer_size , src_stream); - + if (bytes_read < buffer_size && !feof(src_stream)) { if (abort_on_error) util_abort("%s: error when reading from src_stream - aborting \n",__func__); @@ -2212,11 +2223,11 @@ bool util_copy_stream(FILE *src_stream , FILE *target_stream , size_t buffer_siz util_fwrite( buffer , 1 , bytes_read , target_stream , __func__); else { bytes_written = fwrite(buffer , 1 , bytes_read , target_stream); - if (bytes_written < bytes_read) + if (bytes_written < bytes_read) return false; } } - + return true; } @@ -2230,7 +2241,7 @@ static bool util_copy_file__(const char * src_file , const char * target_file, s FILE * src_stream = util_fopen(src_file , "r"); FILE * target_stream = util_fopen(target_file , "w"); bool result = util_copy_stream(src_stream , target_stream , buffer_size , buffer , abort_on_error); - + fclose(src_stream); fclose(target_stream); @@ -2260,10 +2271,10 @@ bool util_copy_file(const char * src_file , const char * target_file) { buffer = malloc(buffer_size); if (buffer == NULL) buffer_size /= 2; } while ((buffer == NULL) && (buffer_size > 0)); - + if (buffer_size == 0) util_abort("%s: failed to allocate any memory ?? \n",__func__); - + { bool result = util_copy_file__(src_file , target_file , buffer_size , buffer , abort_on_error); free(buffer); @@ -2293,7 +2304,7 @@ void util_move_file4( const char * src_name , const char * target_name , const c if (target_path == NULL) target_path = src_path; - + if (target_path != NULL) target = util_alloc_filename( target_path , target_name , NULL); else @@ -2301,7 +2312,7 @@ void util_move_file4( const char * src_name , const char * target_name , const c util_move_file( src , target ); - + free( target ); free( src ); } @@ -2317,7 +2328,7 @@ bool util_files_equal( const char * file1 , const char * file2 ) { const int buffer_size = 4096; char * buffer1 = util_calloc( buffer_size , sizeof * buffer1 ); char * buffer2 = util_calloc( buffer_size , sizeof * buffer2 ); - + FILE * stream1 = util_fopen( file1 , "r" ); FILE * stream2 = util_fopen( file2 , "r" ); @@ -2325,7 +2336,7 @@ bool util_files_equal( const char * file1 , const char * file2 ) { int count1 = fread( buffer1 , 1 , buffer_size , stream1 ); int count2 = fread( buffer2 , 1 , buffer_size , stream2 ); - if (count1 != count2) + if (count1 != count2) equal = false; else { if (memcmp( buffer1 , buffer2 , count1 ) != 0) @@ -2350,7 +2361,7 @@ bool util_files_equal( const char * file1 , const char * file2 ) { static void util_fclear_region( FILE * stream , long offset , long region_size) { util_fseek( stream , offset , SEEK_SET ); - { + { int i; for ( i=0; i < region_size; i++) fputc( 0 , stream ); @@ -2375,7 +2386,7 @@ static void util_fmove_block(FILE * stream , long offset , long shift , char * b negative a part of the file will be overwritten: Original : "ABCDEFGHIJKILMNOPQ" - fmove( 10 , 5 ) : "ABCDEFGHIJ KILMNOPQ" + fmove( 10 , 5 ) : "ABCDEFGHIJ KILMNOPQ" fmove( 10 , -5) : "ABCDEKILMNOPQ" If offset is positioned at the end of the file a section initialized @@ -2383,7 +2394,7 @@ static void util_fmove_block(FILE * stream , long offset , long shift , char * b of the file the function will return EINVAL. For this function to work the file must be opened in read-write mode - (i.e. r+). + (i.e. r+). */ int util_fmove( FILE * stream , long offset , long shift) { @@ -2395,44 +2406,44 @@ int util_fmove( FILE * stream , long offset , long shift) { file_size = util_ftell( stream ); util_fseek( stream , init_pos , SEEK_SET ); } - + // Validate offset and shift input values. if ((offset > file_size) || (offset < 0)) return EINVAL; - + if (offset + shift < 0) return EINVAL; - + if (shift != 0) { int buffer_size = 1024 * 1024 * 4; /* 4MB buffer size. */ char * buffer = util_calloc( buffer_size , sizeof * buffer ); - + /* Shift > 0: We are opening up a hole in the file. */ if (shift > 0) { long pos = offset; while (( pos + buffer_size ) < file_size) pos += buffer_size; - + while (pos >= offset) { util_fmove_block( stream , pos , shift , buffer , buffer_size ); pos -= buffer_size; } util_fclear_region( stream , offset , shift ); } else { - /* Shift < 0: We are overwriting a part of the file internally. */ + /* Shift < 0: We are overwriting a part of the file internally. */ long pos = offset; while (pos <= file_size) { util_fmove_block( stream , pos , shift , buffer , buffer_size ); pos += buffer_size; } - + // Make sure the file actually shrinks. util_ftruncate( stream , file_size + shift ); } free( buffer ); } - return 0; -} + return 0; +} @@ -2459,7 +2470,7 @@ bool util_file_exists(const char *filename) { bool util_entry_exists( const char * entry ) { stat_type stat_buffer; int stat_return = util_stat(entry, &stat_buffer); - if (stat_return == 0) + if (stat_return == 0) return true; else { if (errno == ENOENT) @@ -2483,8 +2494,8 @@ bool util_entry_exists( const char * entry ) { 2. If stat() has succeeded check the type of the entry, and return true|false if it is of the wanted type. - - 3. If stat() fails with error != ENOENT => util_abort(). + + 3. If stat() fails with error != ENOENT => util_abort(). */ @@ -2538,11 +2549,11 @@ bool util_is_executable(const char * path) { else return false; /* It is not a file. */ } else /* Entry does not exist - return false. */ - return false; + return false; } -/* +/* Will not differtiate between files and directories. */ bool util_entry_readable( const char * entry ) { @@ -2580,7 +2591,7 @@ bool util_is_executable(const char * path) { if (ext != NULL) if (strcmp(ext , "exe") == 0) return true; - + return false; } @@ -2604,18 +2615,18 @@ bool util_entry_writable( const char * entry ) { -#endif +#endif static int util_get_path_length(const char * file) { - if (util_is_directory(file)) + if (util_is_directory(file)) return strlen(file); else { const char * last_slash = strrchr(file , UTIL_PATH_SEP_CHAR); if (last_slash == NULL) return 0; - else + else return last_slash - file; } } @@ -2631,9 +2642,9 @@ static int util_get_base_length(const char * file) { return 0; else if (path_length == 0) base_start = file; - else + else base_start = &file[path_length + 1]; - + last_point = strrchr(base_start , '.'); if (last_point == NULL) return strlen(base_start); @@ -2662,7 +2673,7 @@ static int util_get_base_length(const char * file) { char * ext; util_alloc_file_components("/path/to/some/file.txt" , &path , &base , &ext); - util_alloc_file_components("/path/to/some/file.txt" , &path , &base , NULL); + util_alloc_file_components("/path/to/some/file.txt" , &path , &base , NULL); In the second example we were not interested in the extension, and just passed in NULL. Before use in the calling scope it is @@ -2675,9 +2686,9 @@ static int util_get_base_length(const char * file) { printf("File does *not* have an extension \n"); The memory allocated in util_alloc_file_components must be freed by - the calling unit. + the calling unit. - Observe the following: + Observe the following: * It is easy to be fooled by the optional existence of an extension (badly desgined API). @@ -2695,30 +2706,30 @@ static int util_get_base_length(const char * file) { path -> "/some/existing/path" base -> NULL ext -> NULL - - + + Ex2: input is NOT an existing directory: ------------------------------------ util_alloc_file_components("/some/random/not_existing/path" , &path , &base , &ext) - + path -> "/some/random/not_existing" base -> "path" ext -> NULL - + */ void util_alloc_file_components(const char * file, char **_path , char **_basename , char **_extension) { char *path = NULL; char *basename = NULL; char *extension = NULL; - + int path_length = util_get_path_length(file); int base_length = util_get_base_length(file); int ext_length ; int slash_length = 1; - - if (path_length > 0) + + if (path_length > 0) path = util_alloc_substring_copy(file , 0 , path_length); else slash_length = 0; @@ -2727,28 +2738,28 @@ void util_alloc_file_components(const char * file, char **_path , char **_basena if (base_length > 0) basename = util_alloc_substring_copy(file , path_length + slash_length , base_length); - + ext_length = strlen(file) - (path_length + base_length + 1); if (ext_length > 0) extension = util_alloc_substring_copy(file , (path_length + slash_length + base_length + 1) , ext_length); - if (_extension != NULL) + if (_extension != NULL) *_extension = extension; - else + else if (extension != NULL) free(extension); - - if (_basename != NULL) + + if (_basename != NULL) *_basename = basename; - else + else if (basename != NULL) free(basename); - - - if (_path != NULL) + + + if (_path != NULL) *_path = path; - else + else if (path != NULL) free(path); - + } @@ -2758,16 +2769,27 @@ void util_alloc_file_components(const char * file, char **_path , char **_basena size_t util_file_size(const char *file) { + size_t file_size; + + { + int fildes = open(file , O_RDONLY); + if (fildes == -1) + util_abort("%s: failed to open:%s - %s \n",__func__ , file , strerror(errno)); + + file_size = util_fd_size( fildes ); + close(fildes); + } + + return file_size; +} + + + +size_t util_fd_size(int fd) { stat_type buffer; - int fildes; - - fildes = open(file , O_RDONLY); - if (fildes == -1) - util_abort("%s: failed to open:%s - %s \n",__func__ , file , strerror(errno)); - - util_fstat(fildes, &buffer); - close(fildes); - + + util_fstat(fd, &buffer); + return buffer.st_size; } @@ -2796,10 +2818,10 @@ void util_ftruncate(FILE * stream , long size) { The windows stat structure has the inode element, but it is not set. Actually - this is a property of the filesystem, and not the operating system - this check is probably broken on two levels: - + 1. One should really check the filesystem involved - whether it supports inodes. - + 2. The code below will compile on windows, but for a windows filesystem it will yield rubbish. */ @@ -2810,9 +2832,9 @@ bool util_same_file(const char * file1 , const char * file2) { stat1 = util_stat(file1, &buffer1); // In the case of symlinks the stat call will stat the target file and not the link. stat2 = util_stat(file2, &buffer2); - + if ((stat1 == 0) && (stat1 == stat2)) { - if (buffer1.st_ino == buffer2.st_ino) + if (buffer1.st_ino == buffer2.st_ino) return true; else return false; @@ -2845,24 +2867,24 @@ bool util_fmt_bit8_stream(FILE * stream ) { char *buffer = util_calloc(buffer_size , sizeof * buffer ); elm_read = fread(buffer , 1 , buffer_size , stream); - if (elm_read < min_read) + if (elm_read < min_read) util_abort("%s: file is too small to automatically determine formatted/unformatted status \n",__func__); - + for (i=0; i < elm_read; i++) N_bit8set += (buffer[i] & (1 << 7)) >> 7; - - + + free(buffer); - + bit8set_fraction = 1.0 * N_bit8set / elm_read; - if (bit8set_fraction < bit8set_limit) + if (bit8set_fraction < bit8set_limit) fmt_file = true; - else + else fmt_file = false; } util_fseek(stream , start_pos , SEEK_SET); return fmt_file; -} +} @@ -2874,7 +2896,7 @@ bool util_fmt_bit8(const char *filename ) { stream = fopen(filename , "r"); fmt_file = util_fmt_bit8_stream(stream); fclose(stream); - } else + } else util_abort("%s: could not find file: %s - aborting \n",__func__ , filename); return fmt_file; @@ -2883,15 +2905,15 @@ bool util_fmt_bit8(const char *filename ) { /* - time_t st_atime; time of last access - time_t st_mtime; time of last modification - time_t st_ctime; time of last status change + time_t st_atime; time of last access + time_t st_mtime; time of last modification + time_t st_ctime; time of last status change */ /* The returned value is the difference in file mtime from the file2 to file1 (what a mess). I.e. if file1 is newer than file2 the returned - value will be positive. + value will be positive. */ @@ -2924,7 +2946,7 @@ time_t util_file_mtime(const char * file) { util_fstat(fd , &f_stat ); mtime = f_stat.st_mtime; close( fd ); - } + } return mtime; } @@ -2933,7 +2955,7 @@ time_t util_file_mtime(const char * file) { /** Will check if the st_mtime (i.e. last modification) of the file is - after the time given by @t0. + after the time given by @t0. */ bool util_file_newer( const char * file , time_t t0) { @@ -2946,7 +2968,7 @@ bool util_file_newer( const char * file , time_t t0) { /** Will check if the st_mtime (i.e. last modification) of the file is - before the time given by @t0. + before the time given by @t0. */ @@ -2976,7 +2998,7 @@ bool util_after( time_t t , time_t limit) { -/** +/** This function will return a pointer to the newest of the two files. If one of the files does not exist - the other is returned. If none of the files exist - NULL is returned. @@ -3025,7 +3047,7 @@ static void __util_set_timevalues(time_t t , int * sec , int * min , int * hour /* - This function takes a time_t instance as input, and + This function takes a time_t instance as input, and returns the the time broken down in sec:min:hour mday:month:year. The return values are by pointers - you can pass in NULL to any of @@ -3057,9 +3079,9 @@ bool util_is_first_day_in_month( time_t t) { bool util_sscanf_date(const char * date_token , time_t * t) { int day , month , year; char sep1 , sep2; - + if (sscanf(date_token , "%d%c%d%c%d" , &day , &sep1 , &month , &sep2 , &year) == 5) { - *t = util_make_date(day , month , year ); + *t = util_make_date(day , month , year ); return true; } else { *t = -1; @@ -3090,7 +3112,7 @@ bool util_fscanf_date(FILE *stream , time_t *t) { return return_value; } -/* +/* The date format is HARD assumed to be dd/mm/yyyy @@ -3104,7 +3126,7 @@ bool util_fscanf_date(FILE *stream , time_t *t) { void util_fprintf_datetime(time_t t , FILE * stream) { int sec,min,hour; int mday,year,month; - + util_set_datetime_values(t , &sec , &min , &hour , &mday , &month , &year); fprintf(stream , "%02d/%02d/%4d %02d:%02d:%02d", mday,month,year,hour,min,sec); } @@ -3112,7 +3134,7 @@ void util_fprintf_datetime(time_t t , FILE * stream) { void util_fprintf_date(time_t t , FILE * stream) { int mday,year,month; - + util_set_datetime_values(t , NULL , NULL , NULL , &mday , &month , &year); fprintf(stream , "%02d/%02d/%4d", mday,month,year); } @@ -3120,7 +3142,7 @@ void util_fprintf_date(time_t t , FILE * stream) { char * util_alloc_date_string( time_t t ) { int mday,year,month; - + util_set_datetime_values(t , NULL , NULL , NULL , &mday , &month , &year); return util_alloc_sprintf("%02d/%02d/%4d", mday,month,year); } @@ -3131,7 +3153,17 @@ char * util_alloc_date_stamp( ) { } -/* +void util_inplace_forward_seconds(time_t * t , double seconds) { + struct tm ts; + int isdst; + + util_localtime(t , &ts); + isdst = ts.tm_isdst; + (*t) += ( time_t ) (seconds); + util_localtime(t , &ts); + (*t) += 3600 * (isdst - ts.tm_isdst); /* Extra adjustment of +/- one hour if we have crossed exactly one daylight savings border. */ +} +/* This function takes a pointer to a time_t instance, and shifts the value days forward. Observe the calls to localtime_r() which give rise to +/- one extra hour of adjustment if we have crossed exactly @@ -3143,14 +3175,7 @@ char * util_alloc_date_stamp( ) { */ void util_inplace_forward_days(time_t * t , double days) { - struct tm ts; - int isdst; - - util_localtime(t , &ts); - isdst = ts.tm_isdst; - (*t) += ( time_t ) (days * 3600 * 24); - util_localtime(t , &ts); - (*t) += 3600 * (isdst - ts.tm_isdst); /* Extra adjustment of +/- one hour if we have crossed exactly one daylight savings border. */ + util_inplace_forward_seconds( t , days * 3600 * 24 ); } @@ -3160,12 +3185,12 @@ void util_inplace_forward_days(time_t * t , double days) { seconds (straight difftime output). Observe that the ordering of time_t arguments is switched with respect to the difftime arguments. - + In addition the difference can be broken down in days, hours, minutes and seconds if the appropriate pointers are passed in. */ - + double util_difftime(time_t start_time , time_t end_time , int * _days , int * _hours , int * _minutes , int *_seconds) { int sec_min = 60; int sec_hour = 3600; @@ -3176,10 +3201,10 @@ double util_difftime(time_t start_time , time_t end_time , int * _days , int * _ days = (int) floor(dt / sec_day ); dt -= days * sec_day; - + hours = (int) floor(dt / sec_hour); dt -= hours * sec_hour; - + minutes = (int) floor(dt / sec_min); dt -= minutes * sec_min; @@ -3189,7 +3214,7 @@ double util_difftime(time_t start_time , time_t end_time , int * _days , int * _ if (_minutes != NULL) *_minutes = minutes; if (_hours != NULL) *_hours = hours; if (_days != NULL) *_days = days; - + return dt0; } @@ -3229,9 +3254,9 @@ time_t util_make_datetime(int sec, int min, int hour , int mday , int month , in ts.tm_isdst = -1; /* Negative value means mktime tries to determine automagically whether Daylight Saving Time is in effect. */ { time_t t = mktime( &ts ); - if (t == -1) + if (t == -1) util_abort("%s: failed to make a time_t instance of %02d/%02d/%4d %02d:%02d:%02d - aborting \n",__func__ , mday,month,year,hour,min,sec); - + return t; } } @@ -3298,7 +3323,7 @@ char * util_alloc_strip_copy(const char *src) { strip_length = end_index - start_index + 1; target = util_calloc(strip_length + 1 , sizeof * target ); memcpy(target , &src[start_index] , strip_length); - } else + } else /* A blank string */ target = util_calloc(strip_length + 1 , sizeof * target ); @@ -3326,7 +3351,7 @@ char ** util_alloc_stringlist_copy(const char **src, int len) { for (i=0; i < len; i++) copy[i] = util_alloc_string_copy(src[i]); return copy; - } else + } else return NULL; } @@ -3341,7 +3366,7 @@ char ** util_alloc_stringlist_copy(const char **src, int len) { -------- char ** stringlist = (char *[2]) {"One" , "Two"}; char * three_string = "Three"; - + stringlist = util_stringlist_append_copy(stringlist , 2 , three_string); This function does allocate memory - but does not have *alloc* in @@ -3377,7 +3402,7 @@ char * util_alloc_string_copy(const char *src ) { char * copy = util_calloc( byte_size , sizeof * copy ); memcpy( copy , src , byte_size ); return copy; - } else + } else return NULL; } @@ -3410,19 +3435,19 @@ char * util_realloc_substring_copy(char * old_string , const char *src , int len copy[str_len] = '\0'; return copy; - } else + } else return NULL; } /** This function check that a pointer is different from NULL, and - frees the memory if that is the case. + frees the memory if that is the case. */ - -void util_safe_free(void *ptr) { - if (ptr != NULL) free(ptr); + +void util_safe_free(void *ptr) { + if (ptr != NULL) free(ptr); } @@ -3433,18 +3458,18 @@ void util_safe_free(void *ptr) { wildcard(s). The pattern can consist of plain string parts (which must match verbatim), and an arbitrary number of '*' which will match an arbitrary number (including zero) of arbitrary characters. - + Examples: --------- util_string_match("Bjarne" , "Bjarne") ==> True - util_string_match("Bjarne" , "jarn") ==> False + util_string_match("Bjarne" , "jarn") ==> False util_string_match("Bjarne" , "*jarn*") ==> True util_string_match("Bjarne" , "B*e") ==> True - + util_string_match("Bjarne" , "B*n") ==> False util_string_match("Bjarne" , "*") ==> True @@ -3461,7 +3486,7 @@ bool util_string_match(const char * string , const char * pattern) { const char wildcard = '*'; const char *wildcard_st = "*"; - if (strcmp(wildcard_st , pattern) == 0) + if (strcmp(wildcard_st , pattern) == 0) return true; else { bool match = true; @@ -3469,33 +3494,33 @@ bool util_string_match(const char * string , const char * pattern) { int num_patterns; char * string_ptr; util_split_string( pattern , wildcard_st , &num_patterns , &sub_pattern ); - + if (pattern[0] == '*') string_ptr = strstr(string , sub_pattern[0]); else string_ptr = (strncmp(string , sub_pattern[0] , strlen(sub_pattern[0])) == 0) ? (char * ) string : NULL; - + if (string_ptr != NULL) { /* Inital part matched */ int i; string_ptr += strlen( sub_pattern[0] ); for (i=1; i < num_patterns; i++) { char * match_ptr = strstr(string_ptr , sub_pattern[i]); - if (match_ptr != NULL) + if (match_ptr != NULL) string_ptr = match_ptr + strlen( sub_pattern[i] ); else { match = false; break; } } - - /* + + /* We have exhausted the complete pattern - matching all the way. Does it match at the end? */ if (match) { if (strlen(string_ptr) > 0) { - /* + /* There is more left at the end of the string; if the pattern ends with '*' that is OK, otherwise the match result is FALSE. @@ -3504,10 +3529,10 @@ bool util_string_match(const char * string , const char * pattern) { match = false; } } - - } else + + } else match = false; - + util_free_stringlist( sub_pattern , num_patterns); return match; } @@ -3551,7 +3576,7 @@ char * util_strstr_int_format(const char * string ) { else { if (percent_ptr[0] == '0') { - while (isdigit(percent_ptr[0])) + while (isdigit(percent_ptr[0])) percent_ptr++; if (percent_ptr[0] == 'd') @@ -3559,7 +3584,7 @@ char * util_strstr_int_format(const char * string ) { else return NULL; - } + } return NULL; } } @@ -3603,7 +3628,7 @@ void util_free_NULL_terminated_stringlist(char ** string_list) { /** This function will reallocate the string s1 to become the sum of s1 - and s2. If s1 == NULL it will just return a copy of s2. + and s2. If s1 == NULL it will just return a copy of s2. Observe that due to the use realloc() the s1 input argument MUST BE the return value from a malloc() call; this is not intuitive and @@ -3611,14 +3636,14 @@ void util_free_NULL_terminated_stringlist(char ** string_list) { */ char * util_strcat_realloc(char *s1 , const char * s2) { - if (s1 == NULL) + if (s1 == NULL) s1 = util_alloc_string_copy(s2); else { if (s2 != NULL) { int new_length = strlen(s1) + strlen(s2) + 1; s1 = util_realloc( s1 , new_length ); strcat(s1 , s2); - } + } } return s1; } @@ -3661,7 +3686,7 @@ char * util_alloc_joined_string(const char ** item_list , int len , const char * int total_length = 0; int eff_len = 0; int i; - for (i=0; i < len; i++) + for (i=0; i < len; i++) if (item_list[i] != NULL) { total_length += strlen(item_list[i]); eff_len++; @@ -3707,7 +3732,7 @@ void util_split_string(const char *line , const char *sep_set, int *_tokens, cha int tokens , token , token_length; char **token_list; - offset = strspn(line , sep_set); + offset = strspn(line , sep_set); tokens = 0; do { /* @@ -3718,7 +3743,7 @@ void util_split_string(const char *line , const char *sep_set, int *_tokens, cha token_length = strcspn(&line[offset] , sep_set); if (token_length > 0) tokens++; - + offset += token_length; offset += strspn(&line[offset] , sep_set); } while (line[offset] != '\0'); @@ -3734,13 +3759,13 @@ void util_split_string(const char *line , const char *sep_set, int *_tokens, cha token++; } else token_list[token] = NULL; - + offset += token_length; offset += strspn(&line[offset] , sep_set); } while (line[offset] != '\0'); } else token_list = NULL; - + *_tokens = tokens; *_token_list = token_list; } @@ -3749,7 +3774,7 @@ void util_split_string(const char *line , const char *sep_set, int *_tokens, cha /** This function will split the input string in two parts, it will split on occurence of one or several of the characters in - sep_set. + sep_set. o If split_on_first is true it will split on the first occurence of @@ -3772,7 +3797,7 @@ void util_split_string(const char *line , const char *sep_set, int *_tokens, cha characters are removed before the splitting starts: util_binary_split_string(":ABCD" , ":" , true , ) => "ABCD" & NULL - + */ @@ -3791,15 +3816,15 @@ void util_binary_split_string(const char * __src , const char * sep_set, bool sp if (len > 0) { int tail_pos = strlen( __src ) - 1; /* 2: Remove trailing split characters. */ - while (strchr(sep_set , __src[tail_pos]) != NULL) + while (strchr(sep_set , __src[tail_pos]) != NULL) tail_pos--; len = 1 + tail_pos - offset; - + src = util_alloc_substring_copy(__src , offset , len); } else src = NULL; - /* + /* OK - we have removed all leading (or trailing) separators, and we have a valid string which we can continue with. */ @@ -3817,11 +3842,11 @@ void util_binary_split_string(const char * __src , const char * sep_set, bool sp } pos = start_pos; - while ((pos != end_pos) && (strchr(sep_set , src[pos]) == NULL)) + while ((pos != end_pos) && (strchr(sep_set , src[pos]) == NULL)) pos += delta; - /* + /* OK - now we have either iterated through the whole string - or - we hav found a character in the sep_set. + we hav found a character in the sep_set. */ if (pos == end_pos) { /* There was no split. */ @@ -3841,7 +3866,7 @@ void util_binary_split_string(const char * __src , const char * sep_set, bool sp if (split_on_first) { sep_end = pos; first_part = util_alloc_substring_copy(src , 0 , sep_start); - + if (sep_end == end_pos) second_part = NULL; else @@ -3880,7 +3905,7 @@ void util_binary_split_string_from_max_length(const char * __src , const char * src = NULL; else src = util_alloc_string_copy(&__src[pos]); - + /*Remove trailing separators. */ pos = strlen(__src) - 1; while ((pos >= 0) && (strchr(sep_set , __src[pos]) != NULL)) @@ -3889,9 +3914,9 @@ void util_binary_split_string_from_max_length(const char * __src , const char * src = NULL; else src = util_alloc_substring_copy(__src , 0 , pos + 1); - - - /* + + + /* OK - we have removed all leading (or trailing) separators, and we have a valid string which we can continue with. */ @@ -3902,11 +3927,11 @@ void util_binary_split_string_from_max_length(const char * __src , const char * delta = -1; end_pos = -1; pos = start_pos; - while ((pos != end_pos) && (strchr(sep_set , src[pos]) == NULL)) + while ((pos != end_pos) && (strchr(sep_set , src[pos]) == NULL)) pos += delta; - /* + /* OK - now we have either iterated through the whole string - or - we hav found a character in the sep_set. + we hav found a character in the sep_set. */ if (pos == end_pos) { /* There was no split. */ @@ -3919,8 +3944,8 @@ void util_binary_split_string_from_max_length(const char * __src , const char * /* Iterate through the separation string - can be e.g. many " " */ while ((pos != end_pos) && (strchr(sep_set , src[pos]) != NULL)) pos += delta; - - + + sep_start = pos; if (sep_start == end_pos) { // ":String" => (NULL , "String") @@ -3953,15 +3978,15 @@ int static util_string_replace_inplace__(char ** _buffer , const char * expr , c int len_expr = strlen( expr ); int len_subs = strlen( subs ); int size = strlen(buffer); - int offset = 0; + int offset = 0; int match_count = 0; char * match = NULL; do { match = strstr(&buffer[offset] , expr); - + if (match != NULL) { - /* + /* Can not use pointer arithmetic here - because the underlying buffer pointer might be realloced. */ @@ -3979,7 +4004,7 @@ int static util_string_replace_inplace__(char ** _buffer , const char * expr , c char * match_end = &buffer[end_offset]; memmove(target , match_end , 1 + size - end_offset); } - + memcpy(&buffer[start_offset] , subs , len_subs); offset = start_offset + len_subs; size = new_size; @@ -3987,8 +4012,8 @@ int static util_string_replace_inplace__(char ** _buffer , const char * expr , c } } } while (match != NULL && offset < strlen(buffer)); - - + + *_buffer = buffer; return match_count; } @@ -4011,7 +4036,7 @@ char * util_string_replace_alloc(const char * buff_org, const char * expr, const char * new_buffer = util_calloc(buffer_size , sizeof * new_buffer ); memcpy(new_buffer , buff_org , strlen(buff_org) + 1); util_string_replace_inplace__( &new_buffer , expr , subs); - + { int size = strlen(new_buffer); new_buffer = util_realloc(new_buffer, (size + 1) * sizeof * new_buffer); @@ -4035,12 +4060,12 @@ char * util_string_replacen_alloc(const char * buff_org, int num_expr, const cha for( i=0; i<num_expr; i++) util_string_replace_inplace__( &new_buffer , expr[i] , subs[i]); } - + { int size = strlen(new_buffer); new_buffer = util_realloc(new_buffer, (size + 1) * sizeof * new_buffer); } - + return new_buffer; } @@ -4062,7 +4087,7 @@ char * util_string_strip_chars_alloc(const char * buff_org, const char * chars) int pos_off = strcspn(buff_org + pos_org, chars); if(pos_off > 0) { - memmove(buff_new + pos_new, buff_org + pos_org, pos_off * sizeof * buff_new); + memmove(buff_new + pos_new, buff_org + pos_org, pos_off * sizeof * buff_new); pos_org += pos_off; pos_new += pos_off; } @@ -4087,7 +4112,7 @@ char * util_string_strip_chars_alloc(const char * buff_org, const char * chars) void util_float_to_double(double *double_ptr , const float *float_ptr , int size) { int i; - for (i=0; i < size; i++) + for (i=0; i < size; i++) double_ptr[i] = float_ptr[i]; } @@ -4101,7 +4126,7 @@ void util_double_to_float(float *float_ptr , const double *double_ptr , int size /*****************************************************************/ -/* +/* The util_fwrite_string / util_fread_string are BROKEN when it comes to NULL / versus an empty string "": @@ -4115,7 +4140,7 @@ void util_double_to_float(float *float_ptr , const double *double_ptr , int size as follows: 1. Nothing is changed when writing NULL => '0' to disk. - + 2. When writing "" => '-1\0' to disk. The -1 is the magic length signifying that the following string is "". */ @@ -4126,7 +4151,7 @@ void util_fwrite_string(const char * s, FILE *stream) { int len = 0; if (s != NULL) { len = strlen(s); - if (len == 0) + if (len == 0) util_fwrite_int(-1 , stream); /* Writing magic string for "" */ else util_fwrite(&len , sizeof len , 1 , stream , __func__); @@ -4162,7 +4187,7 @@ char * util_fread_realloc_string(char * old_s , FILE *stream) { } else if (len == -1) /* Magic length for "" */ { s = util_realloc(s , 1 ); util_fread(s , 1 , 1 , stream , __func__); - } + } return s; } @@ -4170,9 +4195,9 @@ char * util_fread_realloc_string(char * old_s , FILE *stream) { void util_fskip_string(FILE *stream) { int len; util_fread(&len , sizeof len , 1 , stream , __func__); - if (len == 0) - return; /* The user has written NULL with util_fwrite_string(). */ - else if (len == -1) + if (len == 0) + return; /* The user has written NULL with util_fwrite_string(). */ + else if (len == -1) util_fseek( stream , 1 , SEEK_CUR); /* Magic length for "" - skip the '\0' */ else util_fseek(stream , len + 1 , SEEK_CUR); /* Skip the data in a normal string. */ @@ -4301,11 +4326,11 @@ void util_update_double_max_min(double value , double * max , double * min) { *min = util_double_min(value , *min); *max = util_double_max(value , *max); } - + void util_clamp_double(double * value , double limit1 , double limit2) { double min = util_double_min( limit1 , limit2 ); double max = util_double_max( limit1 , limit2 ); - + *value = util_double_max( *value , min ); *value = util_double_min( *value , max ); } @@ -4316,7 +4341,7 @@ void util_clamp_double(double * value , double limit1 , double limit2) { Scans through a vector of doubles, and finds min and max values. They are returned by reference. */ - + void util_double_vector_max_min(int N , const double *vector, double *_max , double *_min) { double min = 1e100; /* How should this be done ??? */ double max = -1e100; @@ -4326,7 +4351,7 @@ void util_double_vector_max_min(int N , const double *vector, double *_max , dou max = vector[i]; /* Can not have else here - because same item might succed on both tests. */ - + if (vector[i] < min) min = vector[i]; } @@ -4354,7 +4379,7 @@ double util_double_vector_stddev(int N, const double * vector) { double stddev = 0.0; double mean = util_double_vector_mean(N, vector); double * vector_shifted = util_calloc(N , sizeof *vector_shifted); - + { int i; for(i=0; i<N; i++) @@ -4376,7 +4401,7 @@ double util_double_vector_stddev(int N, const double * vector) { - + /** This function will update *value so that on return ALL bits which are set in bitmask, are also set in value. No other bits in *value @@ -4396,9 +4421,9 @@ FILE * util_fopen__(const char * filename , const char * mode) { FILE * util_fopen(const char * filename , const char * mode) { FILE * stream = util_fopen__(filename , mode); - if (stream == NULL) + if (stream == NULL) util_abort("%s: failed to open:%s with mode:\'%s\' - error:%s(%d) \n",__func__ , filename , mode , strerror(errno) , errno); - + return stream; } @@ -4425,7 +4450,7 @@ void util_fclose( FILE * stream ) { should be possible to safely call: util_mkdir_fopen("/some/path/to/file.txt" , "w"); - + without first enusring that /some/path/to exists. */ @@ -4452,14 +4477,14 @@ FILE * util_mkdir_fopen( const char * filename , const char * mode ) { void util_fwrite(const void *ptr , size_t element_size , size_t items, FILE * stream , const char * caller) { int items_written = fwrite(ptr , element_size , items , stream); - if (items_written != items) + if (items_written != items) util_abort("%s/%s: only wrote %d/%d items to disk - aborting: %s(%d) .\n",caller , __func__ , items_written , items , strerror(errno) , errno); } void util_fread(void *ptr , size_t element_size , size_t items, FILE * stream , const char * caller) { int items_read = fread(ptr , element_size , items , stream); - if (items_read != items) + if (items_read != items) util_abort("%s/%s: only read %d/%d items from disk - aborting.\n %s(%d) \n",caller , __func__ , items_read , items , strerror(errno) , errno); } @@ -4481,7 +4506,7 @@ void util_fread_from_buffer(void * ptr , size_t element_size , size_t items , ch void * util_realloc(void * old_ptr , size_t new_size ) { /* The realloc documentation as ambigous regarding realloc() with size 0 - WE return NULL. */ - if (new_size == 0) { + if (new_size == 0) { if (old_ptr != NULL) free(old_ptr); return NULL; @@ -4507,18 +4532,18 @@ void * util_realloc(void * old_ptr , size_t new_size ) { static void * util_malloc__(size_t size) { void * data; - if (size == 0) - /* + if (size == 0) + /* Not entirely clear from documentation what you get when you call malloc( 0 ); this code will return NULL in that case. */ data = NULL; else { data = malloc( size ); - if (data == NULL) + if (data == NULL) util_abort("%s: failed to allocate %zu bytes - aborting \n",__func__ , size); - /* + /* Initializing with something different from zero - hopefully errors will pop up more easily this way? */ @@ -4555,7 +4580,7 @@ void * util_alloc_copy(const void * src , size_t byte_size ) { void * util_realloc_copy(void * org_ptr , const void * src , size_t byte_size ) { - if (byte_size == 0 && src == NULL) + if (byte_size == 0 && src == NULL) return util_realloc( org_ptr , 0 ); { void * new = util_realloc(org_ptr , byte_size ); @@ -4592,14 +4617,14 @@ void util_read_path(const char * prompt , int prompt_len , bool must_exist , cha ok = util_is_directory(path); else ok = true; - if (!ok) + if (!ok) fprintf(stderr,"Path: %s does not exist - try again.\n",path); } } /* exist_status == 0: Just read a string; do not check if it exist or not. - exist_status == 1: Must be existing file. + exist_status == 1: Must be existing file. exist_status == 2: Must NOT exist as entry. */ @@ -4615,7 +4640,7 @@ char * util_fscanf_alloc_filename(const char * prompt , int prompt_len , int exi fprintf(stderr,"Sorry: %s does not exist. \n",filename); free( filename ); filename = NULL; - } + } } else if (exist_status == 2) { if (util_entry_exists( filename )) { fprintf(stderr,"Sorry: entry %s already exists. \n",filename); @@ -4660,10 +4685,10 @@ void util_fprintf_string(const char * s , int width , string_alignement_type ali if (alignement == left_pad) { i = 0; if (width > strlen(s)) { - for (i=0; i < (width - strlen(s)); i++) + for (i=0; i < (width - strlen(s)); i++) fputc(' ' , stream); } - fprintf(stream , s); + fprintf(stream , "%s", s); } else if (alignement == right_pad) { sprintf(fmt , "%%-%ds" , width); fprintf(stream , fmt , s); @@ -4687,13 +4712,13 @@ void util_fprintf_string(const char * s , int width , string_alignement_type ali specification, and arguments. The arguments (except the format) are entered as a variable length argument list, and the function is basically a thin wrapper around vsnprintf(). - + Example of usage: - + char * s = util_alloc_sprintf("/%s/File:%04d/%s" , "prefix" , 67 , "Suffix"); - + => s = /prefix/File:0067/Suffix - + Observe that when it is based in vsnprintf() essentially no error-checking is performed. */ @@ -4723,10 +4748,10 @@ char * util_alloc_sprintf(const char * fmt , ...) { char * util_alloc_sprintf_escape(const char * src , int max_escape) { if (src == NULL) return NULL; - + if (max_escape == 0) max_escape = strlen( src ); - + { const int src_len = strlen( src ); char * target = util_calloc( max_escape + strlen(src) + 1 , sizeof * target); @@ -4734,7 +4759,7 @@ char * util_alloc_sprintf_escape(const char * src , int max_escape) { int escape_count = 0; int src_offset = 0; int target_offset = 0; - + while (true) { if (src[src_offset] == '%') { if (escape_count < max_escape) { @@ -4746,7 +4771,7 @@ char * util_alloc_sprintf_escape(const char * src , int max_escape) { target[target_offset] = src[src_offset]; target_offset++; src_offset++; - if (src_offset == src_len) + if (src_offset == src_len) break; } target[target_offset] = '\0'; @@ -4779,10 +4804,10 @@ char * util_realloc_sprintf(char * s , const char * fmt , ...) { char * new_s; va_list ap; va_start(ap , fmt); - + new_s = util_alloc_sprintf_va( fmt , ap ); util_safe_free(s); - + va_end(ap); return new_s; } @@ -4796,7 +4821,7 @@ char * util_realloc_sprintf(char * s , const char * fmt , ...) { /** This function is intended to be installed as a signal handler, so we can get a traceback from signals like SIGSEGV. - + To install the signal handler: #include <signal.h> @@ -4807,7 +4832,7 @@ char * util_realloc_sprintf(char * s , const char * fmt , ...) { The various signals can be found in: /usr/include/bits/signum.h */ - + void util_abort_signal(int signal) { util_abort("Program received signal:%d\n" , signal); @@ -4815,10 +4840,14 @@ void util_abort_signal(int signal) { void util_install_signals(void) { +#ifdef HAVE_SIGBUS + signal(SIGBUS , util_abort_signal); +#endif + signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ - signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace. + signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ - signal(SIGABRT , util_abort_signal); /* Signal abort. */ + signal(SIGABRT , util_abort_signal); /* Signal abort. */ signal(SIGILL , util_abort_signal); /* Signal illegal instruction. */ } @@ -4835,12 +4864,12 @@ void util_exit(const char * fmt , ...) { - - + + /** This function is quite dangerous - it will always return something; it is the responsability of the calling scope to check that it - makes sense. Will return 0 on input NULL. + makes sense. Will return 0 on input NULL. */ int util_get_type( void * data ) { @@ -4901,7 +4930,7 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type } -static char * __abort_program_message = NULL; /* Can use util_abort_append_version_info() to fill this with +static char * __abort_program_message = NULL; /* Can use util_abort_append_version_info() to fill this with version info+++ wich will be printed when util_abort() is called. */ static char * __current_executable = NULL; @@ -4921,11 +4950,11 @@ void util_abort_free_version_info() { void util_abort_set_executable( const char * argv0 ) { - if (util_is_abs_path(argv0)) + if (util_is_abs_path(argv0)) __current_executable = util_realloc_string_copy( __current_executable , argv0 ); else { char * executable; - if (util_is_executable( argv0 )) + if (util_is_executable( argv0 )) executable = util_alloc_realpath(argv0); else executable = util_alloc_PATH_executable( argv0 ); @@ -4974,12 +5003,12 @@ void util_abort_set_executable( const char * argv0 ) { } \ } \ } \ -} +} CONTAINS(int) CONTAINS(time_t) CONTAINS(size_t) -#undef CONTAINS +#undef CONTAINS /*****************************************************************/ @@ -4996,7 +5025,7 @@ int util_fnmatch( const char * pattern , const char * string ) { return 0; else return 1; - + #endif } @@ -5078,7 +5107,7 @@ int util_round( double x ) { return (int) (x + 0.5); } int util_type_get_id( const void * data ) { int type_id = ((const int*) data)[0]; return type_id; -} +} #include "util_chdir.c" diff --git a/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c b/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c index 014869060a..ca3b8d2825 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c @@ -227,7 +227,8 @@ void util_abort__(const char * file , const char * function , int line , const c va_start(ap , fmt); fprintf(abort_dump , "\n\n"); - fprintf(abort_dump , "Abort called from: %s (%s:%d) \n",function , file , line); + fprintf(abort_dump , "Abort called from: %s (%s:%d) \n\n",function , file , line); + fprintf(abort_dump , "Error message: "); vfprintf(abort_dump , fmt , ap); fprintf(abort_dump , "\n\n"); va_end(ap); @@ -262,7 +263,14 @@ void util_abort__(const char * file , const char * function , int line , const c if (abort_dump != stderr) { util_fclose(abort_dump); - fprintf(stderr, "\n\nA fatal error occured, see file: %s for details.\nSetting the environment variable \"ERT_SHOW_BACKTRACE\" will show the backtrace on stderr.\n", filename); + fprintf(stderr, "\nError message: "); + { + va_list args; + va_start(args , fmt); + vfprintf(stderr , fmt , args); + va_end(args); + } + fprintf(stderr, "\nSee file: %s for more details of the crash.\nSetting the environment variable \"ERT_SHOW_BACKTRACE\" will show the backtrace on stderr.\n", filename); } free(filename); diff --git a/ThirdParty/Ert/devel/libert_util/src/util_fork.c b/ThirdParty/Ert/devel/libert_util/src/util_fork.c index 209cd844ef..2f0a242f73 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_fork.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_fork.c @@ -1,8 +1,8 @@ -/** +/** A small function used to redirect a file descriptior, only used as a helper utility for util_fork_exec(). */ - + static void __util_redirect(int src_fd , const char * target_file , int open_flags) { int new_fd = open(target_file , open_flags , 0644); dup2(new_fd , src_fd); @@ -44,7 +44,7 @@ static void __util_redirect(int src_fd , const char * target_file , int open_fla util_fork_exec("/local/gnu/bin/ls" , 1 , (const char *[1]) {"-l"} , true , NULL , NULL , NULL , "listing" , NULL); - + This program will run the command 'ls', with the argument '-l'. The main process will block, i.e. wait until the 'ls' process is complete, and the results of the 'ls' operation will be stored in @@ -54,13 +54,13 @@ static void __util_redirect(int src_fd , const char * target_file , int open_fla */ -pid_t util_fork_exec(const char * executable , int argc , const char ** argv , - bool blocking , const char * target_file , const char * run_path , +pid_t util_fork_exec(const char * executable , int argc , const char ** argv , + bool blocking , const char * target_file , const char * run_path , const char * stdin_file , const char * stdout_file , const char * stderr_file) { const char ** __argv = NULL; pid_t child_pid; - - if (target_file != NULL && blocking == false) + + if (target_file != NULL && blocking == false) util_abort("%s: When giving a target_file != NULL - you must use the blocking semantics. \n",__func__); child_pid = fork(); @@ -68,56 +68,56 @@ pid_t util_fork_exec(const char * executable , int argc , const char ** argv , fprintf(stderr,"Error: %s(%d) \n",strerror(errno) , errno); util_abort("%s: fork() failed when trying to run external command:%s \n",__func__ , executable); } - + if (child_pid == 0) { /* This is the child */ int iarg; nice(19); /* Remote process is run with nice(19). */ if (run_path != NULL) { - if (util_chdir(run_path) != 0) + if (util_chdir(run_path) != 0) util_abort("%s: failed to change to directory:%s %s \n",__func__ , run_path , strerror(errno)); } - if (stdout_file != NULL) + if (stdout_file != NULL) __util_redirect(1 , stdout_file , O_WRONLY | O_TRUNC | O_CREAT); - - if (stderr_file != NULL) + + if (stderr_file != NULL) __util_redirect(2 , stderr_file , O_WRONLY | O_TRUNC | O_CREAT); - - if (stdin_file != NULL) + + if (stdin_file != NULL) __util_redirect(0 , stdin_file , O_RDONLY); - - __argv = util_malloc((argc + 2) * sizeof * __argv ); + + __argv = util_malloc((argc + 2) * sizeof * __argv ); __argv[0] = executable; for (iarg = 0; iarg < argc; iarg++) __argv[iarg+1] = argv[iarg]; __argv[argc + 1] = NULL; - /* - If executable is an absolute path, it is invoked directly, + /* + If executable is an absolute path, it is invoked directly, otherwise PATH is used to locate the executable. */ execvp( executable , (char **) __argv); - /* + /* Exec should *NOT* return - if this code is executed the exec??? function has indeed returned, and this is an error. */ util_abort("%s: failed to execute external command: \'%s\': %s \n",__func__ , executable , strerror(errno)); - + } else { /* Parent */ - + if (blocking) { waitpid(child_pid , NULL , 0); - + if (target_file != NULL) if (!util_file_exists(target_file)) util_abort("%s: %s failed to produce target_file:%s aborting \n",__func__ , executable , target_file); } } - + util_safe_free( __argv ); return child_pid; } @@ -134,7 +134,7 @@ pid_t util_fork_exec(const char * executable , int argc , const char ** argv , * In the current implementation a user can occur several times if the user has the file open in several processes. - + * If a NFS mounted file is opened on a remote machine it will not appear in this listing. I.e. to check that an executable file can be safely modified you must iterate through the relevant @@ -161,7 +161,7 @@ uid_t * util_alloc_file_users( const char * filename , int * __num_users) { } users[ num_users ] = uid; num_users++; - } else + } else break; /* have reached the end of file - seems like we will not find the file descriptor we are looking for. */ } fclose( stream ); @@ -178,7 +178,7 @@ uid_t * util_alloc_file_users( const char * filename , int * __num_users) { /** This function uses the external program lsof to (try) to associate an open FILE * instance with a filename in the filesystem. - + If it succeds in finding the filename the function will allocate storage and return a (char *) pointer with the filename. If the filename can not be found, the function will return NULL. @@ -187,14 +187,14 @@ uid_t * util_alloc_file_users( const char * filename , int * __num_users) { +++), and also quite fragile, it should therefor not be used in routine FILE -> name lookups, rather in situations where a FILE * operation has failed extraordinary, and we want to provide as much - information as possible before going down in flames. + information as possible before going down in flames. */ - + char * util_alloc_filename_from_stream( FILE * input_stream ) { char * filename = NULL; const char * lsof_executable = "/usr/sbin/lsof"; int fd = fileno( input_stream ); - + if (util_is_executable( lsof_executable ) && (fd != -1)) { char * fd_string = util_alloc_sprintf("f%d" , fd); char line_fd[32]; @@ -202,7 +202,7 @@ char * util_alloc_filename_from_stream( FILE * input_stream ) { char * pid_string = util_alloc_sprintf("%d" , getpid()); char * tmp_file = util_alloc_tmp_file("/tmp" , "lsof" , false); - /* + /* The lsof executable is run as: bash% lsof -p pid -Ffn @@ -219,7 +219,7 @@ char * util_alloc_filename_from_stream( FILE * input_stream ) { filename = util_alloc_string_copy( &line_file[1] ); break; } - } else + } else break; /* have reached the end of file - seems like we will not find the file descriptor we are looking for. */ } fclose( stream ); @@ -238,7 +238,8 @@ char * util_alloc_filename_from_stream( FILE * input_stream ) { The PING_CMD is passed as -D from the build system. */ -bool util_ping(const char *hostname) { +#ifdef PING_CMD +bool util_ping(const char *hostname) { pid_t ping_pid = util_fork_exec(PING_CMD , 4 , (const char *[4]) {"-c" , "3" , "-q", hostname} , false , NULL , NULL , NULL , "/dev/null" , "/dev/null"); int wait_status; pid_t wait_pid = waitpid(ping_pid , &wait_status , 0); @@ -256,7 +257,7 @@ bool util_ping(const char *hostname) { return false; } } - +#endif diff --git a/ThirdParty/Ert/devel/libert_util/src/util_lfs.c b/ThirdParty/Ert/devel/libert_util/src/util_lfs.c index fb1413843a..900a856109 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_lfs.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_lfs.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'util_win64.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'util_win64.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /* @@ -36,17 +36,17 @@ windows apply even on a 64 bit platform. To provide large file support windows has the functions _ftelli64() and _fseeki64() and the struct _stat64. Here we provide small wrapper functions - util_ftell(), util_fseek() and typedef struct stat_info. + util_ftell(), util_fseek() and typedef struct stat_info. The final challenge is that the types 'long' and 'off_t == long' have different size on windows and linux: Windows(64 bit): sizeof(long) = 4 - sizeof(off_t) = 4 + sizeof(off_t) = 4 Linux(64 bit): sizeof(long) = 8 - sizeof(off_t) = 8 + sizeof(off_t) = 8 To protect against this confusion we have typedefed a type @@ -63,20 +63,32 @@ offset_type util_ftell(FILE * stream) { return ftell(stream); #endif #endif -} +} + +/* + The return value of fseeko() and fseek() is different. The first + returns current offset on success, whereas the latter returns 0 on + success. +*/ int util_fseek(FILE * stream, offset_type offset, int whence) { #ifdef WINDOWS_LFS return _fseeki64(stream , offset , whence); #else #ifdef HAVE_FSEEKO - return fseeko( stream , offset , whence ); + { + offset_type offset = fseeko( stream , offset , whence ); + if (offset != -1) + return 0; + else + return -1; + } #else return fseek( stream , offset , whence ); #endif #endif -} +} diff --git a/ThirdParty/Ert/devel/libert_util/src/util_lockf.c b/ThirdParty/Ert/devel/libert_util/src/util_lockf.c index c2ab45524e..ed67a7436d 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_lockf.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_lockf.c @@ -70,7 +70,7 @@ FILE * util_fopen_lockf(const char * filename, const char * mode) { if (strcmp(mode , "w") == 0) flags += O_CREAT; - fd = open(filename , flags); + fd = open(filename , flags, S_IRUSR|S_IWUSR); if (fd == -1) util_abort("%s: failed to open:%s with flags:%d \n",__func__ , filename , flags); diff --git a/ThirdParty/Ert/devel/libert_util/src/util_path.c b/ThirdParty/Ert/devel/libert_util/src/util_path.c index 3ca5b285d0..7ef6870fae 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_path.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_path.c @@ -1,26 +1,26 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'util_path.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'util_path.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> /** This little function checks if the supplied path is an abolute path, or a relative path. The check is extremely simple - if the first - character equals "/" (on Unix) it is interpreted as an abolute path, + character equals "/" (on Unix) it is interpreted as an abolute path, otherwise not. */ @@ -45,7 +45,7 @@ void util_make_path(const char *_path) { char *active_path; char *path = (char *) _path; int current_pos = 0; - + if (!util_is_directory(path)) { int i = 0; active_path = util_calloc(strlen(path) + 1 , sizeof * active_path ); @@ -55,12 +55,12 @@ void util_make_path(const char *_path) { n += 1; path += n; i++; - strncpy(active_path , _path , n + current_pos); + strncpy(active_path , _path , n + current_pos); active_path[n+current_pos] = '\0'; - current_pos += n; - + current_pos += n; + if (!util_is_directory(active_path)) { - if (util_mkdir(active_path) != 0) { + if (util_mkdir(active_path) != 0) { bool fail = false; switch (errno) { case(EEXIST): @@ -75,7 +75,7 @@ void util_make_path(const char *_path) { util_abort("%s: failed to make directory:%s - aborting\n: %s(%d) \n",__func__ , active_path , strerror(errno), errno); } } - + } while (strlen(active_path) < strlen(_path)); free(active_path); } @@ -103,12 +103,12 @@ void util_make_path(const char *_path) { char * util_alloc_tmp_file(const char * path, const char * prefix , bool include_pid ) { - // Should be reimplemented to use mkstemp() + // Should be reimplemented to use mkstemp() const int pid_digits = 6; const int random_digits = 6; const int random_max = 1000000; -#ifdef HAVE_PID_T +#ifdef HAVE_PID_T const int pid_max = 1000000; pid_t pid = getpid() % pid_max; #else @@ -117,18 +117,18 @@ char * util_alloc_tmp_file(const char * path, const char * prefix , bool include char * file = util_calloc(strlen(path) + 1 + strlen(prefix) + 1 + pid_digits + 1 + random_digits + 1 , sizeof * file ); char * tmp_prefix = util_alloc_string_copy( prefix ); - + if (!util_is_directory(path)) util_make_path(path); util_string_tr( tmp_prefix , UTIL_PATH_SEP_CHAR , '_'); /* removing path seps. */ - + do { long int rand_int = rand() % random_max; if (include_pid) sprintf(file , "%s%c%s-%d-%ld" , path , UTIL_PATH_SEP_CHAR , tmp_prefix , pid , rand_int); else sprintf(file , "%s%c%s-%ld" , path , UTIL_PATH_SEP_CHAR , tmp_prefix , rand_int); - } while (util_file_exists(file)); + } while (util_file_exists(file)); free( tmp_prefix ); return file; @@ -137,8 +137,8 @@ char * util_alloc_tmp_file(const char * path, const char * prefix , bool include /** This file allocates a filename consisting of a leading path, a basename and an extension. Both the path and the extension can be - NULL, but not the basename. - + NULL, but not the basename. + Observe that this function does pure string manipulation; there is no input check on whether path exists, if baseneme contains "." (or even a '/') and so on. @@ -146,9 +146,9 @@ char * util_alloc_tmp_file(const char * path, const char * prefix , bool include char * util_alloc_filename(const char * path , const char * basename , const char * extension) { char * file; - int length = strlen(basename) + 1; - - if (path != NULL) + int length = strlen(basename) + 1; + + if (path != NULL) length += strlen(path) + 1; if (extension != NULL) @@ -213,16 +213,16 @@ char * util_split_alloc_filename( const char * input_path ) { { char * basename; char * extension; - + util_alloc_file_components( input_path , NULL , &basename , &extension); - - if (basename) + + if (basename) filename = util_alloc_filename( NULL , basename , extension ); - + util_safe_free( basename ); util_safe_free( extension ); } - + return filename; } @@ -233,7 +233,7 @@ void util_path_split(const char *line , int *_tokens, char ***_token_list) { } /** - Observe that + Observe that */ char * util_alloc_parent_path( const char * path) { @@ -244,9 +244,9 @@ char * util_alloc_parent_path( const char * path) { if (path) { bool is_abs = util_is_abs_path( path ); char * work_path; - + if (strstr(path , "..")) { - if (is_abs) + if (is_abs) work_path = util_alloc_realpath__( path ); else { char * abs_path = util_alloc_realpath__( path ); @@ -257,7 +257,7 @@ char * util_alloc_parent_path( const char * path) { } } else work_path = util_alloc_string_copy( path ); - + util_path_split( work_path , &path_ncomp , &path_component_list ); if (path_ncomp > 0) { int current_length = 4; @@ -265,11 +265,11 @@ char * util_alloc_parent_path( const char * path) { parent_path = util_realloc( parent_path , current_length * sizeof * parent_path); parent_path[0] = '\0'; - + for (ip=0; ip < path_ncomp - 1; ip++) { const char * ipath = path_component_list[ip]; int min_length = strlen(parent_path) + strlen(ipath) + 1; - + if (min_length >= current_length) { current_length = 2 * min_length; parent_path = util_realloc( parent_path , current_length * sizeof * parent_path); diff --git a/ThirdParty/Ert/devel/libert_util/src/vector.c b/ThirdParty/Ert/devel/libert_util/src/vector.c index 66e0032151..cc75d7c115 100644 --- a/ThirdParty/Ert/devel/libert_util/src/vector.c +++ b/ThirdParty/Ert/devel/libert_util/src/vector.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'vector.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'vector.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -36,7 +36,7 @@ struct vector_struct { node_data_type **data; /* node_data instances - which again contain user data. */ }; - + /* Small datastructure PURELY used for sorting the vector. */ @@ -45,7 +45,7 @@ typedef struct { node_data_type * data; int index; } vector_sort_node_type; - + UTIL_SAFE_CAST_FUNCTION(vector , VECTOR_TYPE_ID) UTIL_IS_INSTANCE_FUNCTION(vector , VECTOR_TYPE_ID) @@ -57,9 +57,9 @@ static void vector_resize__(vector_type * vector, int new_alloc_size) { /* The vector is shrinking. */ for (i=new_alloc_size; i < vector->alloc_size; i++) node_data_free( vector->data[i] ); - } - - vector->data = util_realloc( vector->data , new_alloc_size * sizeof * vector->data ); + } + + vector->data = util_realloc( vector->data , new_alloc_size * sizeof * vector->data ); for (i = vector->alloc_size; i < new_alloc_size; i++) vector->data[i] = NULL; /* Initialising new nodes to NULL */ @@ -90,7 +90,7 @@ void vector_grow_NULL( vector_type * vector , int new_size ) { elements is initialized with NULL pointers. */ -vector_type * vector_alloc_NULL_initialized( int size ) { +vector_type * vector_alloc_NULL_initialized( int size ) { vector_type * vector = vector_alloc_new(); vector_grow_NULL( vector , size ); return vector; @@ -100,21 +100,21 @@ vector_type * vector_alloc_NULL_initialized( int size ) { static int vector_append_node(vector_type * vector , node_data_type * node); -/** +/** If the index is beyond the length of the vector the hole in the - vector will be filled with NULL nodes. + vector will be filled with NULL nodes. */ static void vector_iset__(vector_type * vector , int index , node_data_type * node) { if (index > vector->size) vector_grow_NULL( vector , index ); - if (index == vector->size) + if (index == vector->size) vector_append_node( vector , node ); else { - if (vector->data[index] != NULL) + if (vector->data[index] != NULL) node_data_free( vector->data[index] ); - + vector->data[index] = node; } } @@ -148,7 +148,7 @@ static void vector_insert__(vector_type * vector , int index , node_data_type * static int vector_append_node(vector_type * vector , node_data_type * node) { if (vector->size == vector->alloc_size) vector_resize__(vector , 2*(vector->alloc_size + 1)); - + vector->size++; vector_iset__(vector , vector->size - 1 , node); return vector->size - 1; @@ -180,11 +180,11 @@ static void vector_push_node(vector_type * vector , node_data_type * node) { /** Will append NULL pointers until the vectors length is equal to - @min_size. + @min_size. */ static void vector_assert_size( vector_type * vector , int min_size) { - while (vector->size < min_size) + while (vector->size < min_size) vector_append_ref( vector , NULL ); } @@ -305,7 +305,7 @@ void vector_insert_copy(vector_type * vector , int index , const void * data , c with free, and copied with malloc + memcpy. The vector takes a copy of the buffer which is inserted (and freed on vector destruction). */ - + void vector_append_buffer(vector_type * vector , const void * buffer, int buffer_size) { node_data_type * node = node_data_alloc_buffer( buffer , buffer_size ); @@ -357,14 +357,14 @@ void * vector_iget(const vector_type * vector, int index) { /** The safe_iget() functions will return NULL if index is greater than - the length of the vector. + the length of the vector. */ const void * vector_safe_iget_const(const vector_type * vector, int index) { if ((index >= 0) && (index < vector->size)) { const node_data_type * node = vector->data[index]; return node_data_get_ptr( node ); - } else + } else return NULL; } @@ -373,17 +373,17 @@ void * vector_safe_iget(const vector_type * vector, int index) { if ((index >= 0) && (index < vector->size)) { const node_data_type * node = vector->data[index]; return node_data_get_ptr( node ); - } else + } else return NULL; } -/* +/* Removes element nr index from the vector, if a destructor is associated with element 'index' it is called, and the memory freed. Afterwards all elements at positions (index +1) and onwards - are shifted one element to the left. + are shifted one element to the left. */ void vector_idel(vector_type * vector , int index) { @@ -396,7 +396,7 @@ void vector_idel(vector_type * vector , int index) { vector->data[vector->size - 1] = NULL; /* Clear the last element - which is no longer valid. */ vector->size--; } - } else + } else util_abort("%s: Invalid index:%d Valid range: [0,%d> \n",__func__ , index , vector->size); } @@ -420,8 +420,8 @@ void vector_shrink( vector_type * vector , int new_size ) { -/** - Will abort if the vector is empty. +/** + Will abort if the vector is empty. */ void * vector_get_last(const vector_type * vector) { if (vector->size == 0) @@ -433,8 +433,8 @@ void * vector_get_last(const vector_type * vector) { } -/** - Will abort if the vector is empty. +/** + Will abort if the vector is empty. */ const void * vector_get_last_const(const vector_type * vector) { if (vector->size == 0) @@ -461,16 +461,16 @@ void * vector_pop_back(vector_type * vector) { { node_data_type * node = vector->data[vector->size - 1]; void * data = node_data_get_ptr( node ); - + node_data_free_container( node ); /* Free the container holding data. */ - vector->data[ vector->size -1 ] = NULL; + vector->data[ vector->size -1 ] = NULL; vector->size--; /* Shrink the vector */ return data; } } -/* +/* Removes the first element from the vector and returns it - similar to vector_pop(): */ @@ -481,7 +481,7 @@ void * vector_pop_front(vector_type * vector ) { { node_data_type * node = vector->data[0]; void * data = node_data_get_ptr( node ); - + node_data_free_container( node ); /* Free the container holding data. */ { int bytes = (vector->size - 1) * sizeof * vector->data; /* Move the storage one element to the left (could als be implemented with an offset??). */ @@ -529,7 +529,7 @@ void vector_free__( void * arg ) { static int vector_cmp(const void * s1 , const void * s2) { const vector_sort_node_type * node1 = (const vector_sort_node_type *) s1; const vector_sort_node_type * node2 = (const vector_sort_node_type *) s2; - + return node1->user_cmp(node_data_get_ptr(node1->data) , node_data_get_ptr(node2->data)); } @@ -559,17 +559,17 @@ static int vector_cmp(const void * s1 , const void * s2) { static vector_sort_node_type * vector_alloc_sort_data( const vector_type * vector , vector_cmp_ftype * cmp) { vector_sort_node_type * sort_data = util_calloc( vector->size , sizeof * sort_data ); int i; - + /* Fill up the temporary storage used for sorting */ for (i = 0; i < vector->size; i++) { sort_data[i].data = vector->data[i]; sort_data[i].user_cmp = cmp; sort_data[i].index = i; } - + /* Sort the temporary vector */ qsort(sort_data , vector->size , sizeof * sort_data , vector_cmp); - + return sort_data; } @@ -578,7 +578,7 @@ void vector_sort(vector_type * vector , vector_cmp_ftype * cmp) { vector_sort_node_type * sort_data = vector_alloc_sort_data( vector , cmp ); int i; /* Recover the sorted vector */ - for (i = 0; i < vector->size; i++) + for (i = 0; i < vector->size; i++) vector->data[i] = sort_data[i].data; free( sort_data ); @@ -589,7 +589,7 @@ int_vector_type * vector_alloc_sort_perm(const vector_type * vector , vector_cmp vector_sort_node_type * sort_data = vector_alloc_sort_data( vector , cmp ); int_vector_type * sort_perm = int_vector_alloc(0,0); int i; - for (i = 0; i < vector->size; i++) + for (i = 0; i < vector->size; i++) int_vector_iset( sort_perm , i , sort_data[i].index); free( sort_data ); @@ -614,6 +614,25 @@ void vector_inplace_reverse(vector_type * vector) { } +int vector_find( const vector_type * vector , const void * ptr) { + int location_index = -1; + int index = 0; + + while (true) { + if (index < vector_get_size( vector )) { + const void * element = vector_iget( vector , index ); + if (element == ptr) { + location_index = index; + break; + } else + index++; + } else + break; + } + + return location_index; +} + /*****************************************************************/ diff --git a/ThirdParty/Ert/devel/libert_util/src/vector_template.c b/ThirdParty/Ert/devel/libert_util/src/vector_template.c index 9f6faf5b8a..749e4fb2be 100644 --- a/ThirdParty/Ert/devel/libert_util/src/vector_template.c +++ b/ThirdParty/Ert/devel/libert_util/src/vector_template.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'vector_template.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'vector_template.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ /** @@ -30,7 +30,7 @@ o The implementation is in terms of a @TYPE@, the following sed one-liners will then produce proper source and header files: - + sed -e's/@TYPE@/int/g' vector_template.c > int_vector.c sed -e's/@TYPE@/int/g' vector_template.h > int_vector.h @@ -47,39 +47,39 @@ ------------------------------------ - ·-----·-----· + ·-----·-----· 1. | 77 | 77 | size = 0, alloc_size = 2 ·-----·-----· - ·-----·-----· + ·-----·-----· 2. | 1 | 77 | size = 1, alloc_size = 2 ·-----·-----· - ·-----·-----· + ·-----·-----· 3. | 1 | 0 | size = 2, alloc_size = 2 ·-----·-----· - ·-----·-----·-----·-----· -4. | 1 | 0 | 12 | 77 | size = 3, alloc_size = 4 + ·-----·-----·-----·-----· +4. | 1 | 0 | 12 | 77 | size = 3, alloc_size = 4 ·-----·-----·-----·-----· - ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· + ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· 5. | 1 | 0 | 12 | 77 | 77 | 77 | 78 | 77 | 77 | 77 | 77 | 77 | 77 | 77 | 77 | 77 | size = 7, alloc_size = 12, default = 77 ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· - ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· + ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· 6. | 1 | 0 | 12 | 77 | 77 | 77 | 78 | 99 | 99 | 99 | 99 | 99 | 99 | 99 | 99 | 99 | size = 7, alloc_size = 12, default = 99 ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· - + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1. In point 4. above - if you ask the vector for it's size you will get 3, and int_vector_iget(vector, 3) will fail because - that is beyound the end of the vector. + that is beyound the end of the vector. 2. The size of the vector is the index (+1) of the last validly - set element in the vector. + set element in the vector. 3. In point 5 above we have grown the vector quite a lot to be able to write in index 6, as a results there are now many slots @@ -114,9 +114,9 @@ struct @TYPE@_vector_struct { int size; /* The index of the last valid - i.e. actively set - element in the vector. */ @TYPE@ default_value; /* The data vector is initialized with this value. */ @TYPE@ * data; /* The actual data. */ - bool data_owner; /* Is the vector owner of the the actual storage data? + bool data_owner; /* Is the vector owner of the the actual storage data? If this is false the vector can not be resized. */ - bool read_only; + bool read_only; }; @@ -160,16 +160,16 @@ static void @TYPE@_vector_realloc_data__(@TYPE@_vector_type * vector , int new_a static void @TYPE@_vector_memmove(@TYPE@_vector_type * vector , int offset , int shift) { if ((shift + offset) < 0) util_abort("%s: offset:%d left_shift:%d - invalid \n",__func__ , offset , -shift); - + if ((shift + vector->size > vector->alloc_size)) @TYPE@_vector_realloc_data__( vector , util_int_min( 2*vector->alloc_size , shift + vector->size )); - + { size_t move_size = (vector->size - offset) * sizeof(@TYPE@); @TYPE@ * target = &vector->data[offset + shift]; const @TYPE@ * src = &vector->data[offset]; memmove( target , src , move_size ); - + vector->size += shift; } } @@ -177,7 +177,7 @@ static void @TYPE@_vector_memmove(@TYPE@_vector_type * vector , int offset , int static void @TYPE@_vector_assert_index(const @TYPE@_vector_type * vector , int index) { - if ((index < 0) || (index >= vector->size)) + if ((index < 0) || (index >= vector->size)) util_abort("%s: index:%d invalid. Valid interval: [0,%d>.\n",__func__ , index , vector->size); } @@ -200,8 +200,8 @@ static @TYPE@_vector_type * @TYPE@_vector_alloc__(int init_size , @TYPE@ default data_owner == true - 2. Creating a shared wrapper from the @TYPE@_vector_alloc_shared_wrapper(): - + 2. Creating a shared wrapper from the @TYPE@_vector_alloc_shared_wrapper(): + data != NULL data_size > 0 data_owner == false @@ -213,24 +213,24 @@ static @TYPE@_vector_type * @TYPE@_vector_alloc__(int init_size , @TYPE@ default data != NULL data_size > 0 data_owner == true - + */ - + if (data == NULL) { /* Case 1: */ vector->data = NULL; vector->data_owner = true; /* The input values alloc_size and */ vector->alloc_size = 0; /* data_owner are not even consulted. */ - } else { /* Case 2 & 3 */ + } else { /* Case 2 & 3 */ vector->data = data; vector->data_owner = data_owner; vector->alloc_size = alloc_size; } - vector->size = 0; - + vector->size = 0; + @TYPE@_vector_set_read_only( vector , false ); if (init_size > 0) @TYPE@_vector_iset( vector , init_size - 1 , default_value ); /* Filling up the init size elements with the default value */ - + return vector; } @@ -239,7 +239,7 @@ static @TYPE@_vector_type * @TYPE@_vector_alloc__(int init_size , @TYPE@ default The alloc_size argument is just a hint - the vector will grow as needed. */ - + @TYPE@_vector_type * @TYPE@_vector_alloc(int init_size , @TYPE@ default_value) { @TYPE@_vector_type * vector = @TYPE@_vector_alloc__( init_size , default_value , NULL , 0 , true ); return vector; @@ -255,7 +255,7 @@ static @TYPE@_vector_type * @TYPE@_vector_alloc__(int init_size , @TYPE@ default void @TYPE@_vector_resize( @TYPE@_vector_type * vector , int new_size ) { if (new_size <= vector->size) vector->size = new_size; - else + else @TYPE@_vector_iset( vector , new_size - 1 , vector->default_value); } @@ -270,7 +270,7 @@ bool @TYPE@_vector_get_read_only( const @TYPE@_vector_type * vector ) { static void @TYPE@_vector_assert_writable( const @TYPE@_vector_type * vector ) { - if (vector->read_only) + if (vector->read_only) util_abort("%s: Sorry - tried to modify a read_only vector instance.\n",__func__); } @@ -316,7 +316,7 @@ static void @TYPE@_vector_assert_writable( const @TYPE@_vector_type * vector ) { the src vector to a block starting at @target_offset in the target vector. The target vector will be resized and initialized with default values as required. - + If len goes beyond the length of the src vector the function will fail hard. */ @@ -327,10 +327,10 @@ void @TYPE@_vector_memcpy_data_block( @TYPE@_vector_type * target , const @TYPE@ /* Force a resize + default initialisation of the target. */ if (target->alloc_size < (target_offset + len)) @TYPE@_vector_iset( target , target_offset + len - 1 , target->default_value) ; - + /* Copy the content. */ memcpy( &target->data[target_offset] , &src->data[src_offset] , len * sizeof * src->data ); - + /* Update size of target. */ if (target->size < (target_offset + len)) target->size = target_offset + len; @@ -379,10 +379,10 @@ void @TYPE@_vector_memcpy( @TYPE@_vector_type * target, const @TYPE@_vector_type @TYPE@_vector_type * copy = @TYPE@_vector_alloc( 0 , src->default_value ); if (start < 0) start = src->size - start; - + if (stop < 0) stop = src->size - stop; - + { int src_index = start; while (src_index < stop) { @@ -421,7 +421,7 @@ bool @TYPE@_vector_growable( const @TYPE@_vector_type * vector) { void @TYPE@_vector_set_default(@TYPE@_vector_type * vector, @TYPE@ default_value) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { int i; vector->default_value = default_value; @@ -435,22 +435,22 @@ void @TYPE@_vector_set_default(@TYPE@_vector_type * vector, @TYPE@ default_value and then subsequently set this value as the new default. */ -void @TYPE@_vector_append_default(@TYPE@_vector_type * vector , @TYPE@ default_value) { +void @TYPE@_vector_append_default(@TYPE@_vector_type * vector , @TYPE@ default_value) { @TYPE@_vector_append( vector , default_value ); - @TYPE@_vector_set_default( vector , default_value ); + @TYPE@_vector_set_default( vector , default_value ); } /** This function will iset the value @default_value into the vector, - and then subsequently set this value as the new default. + and then subsequently set this value as the new default. 1. V = [1 , 2 , 3 , 4 ], default = 77 2. _iset_default(v , 10 , 66) - V = [1 ,2 , 3 , 4 , 77, 77, 77, 77, 77, 77, 66] + V = [1 ,2 , 3 , 4 , 77, 77, 77, 77, 77, 77, 66] I.e. before setting the 66 value all values up to @index are filled with the current default. @@ -458,15 +458,15 @@ void @TYPE@_vector_append_default(@TYPE@_vector_type * vector , @TYPE@ default_v 3. If @index is inside the current data region, there will be no effect of the current default, i.e. _iset_default(v , 2 , 66) will just give: - + V = [1 ,2 , 66 , 4 ] and 66 as the new default value. */ -void @TYPE@_vector_iset_default(@TYPE@_vector_type * vector , int index , @TYPE@ default_value) { +void @TYPE@_vector_iset_default(@TYPE@_vector_type * vector , int index , @TYPE@ default_value) { @TYPE@_vector_iset( vector , index , default_value ); - @TYPE@_vector_set_default( vector , default_value ); + @TYPE@_vector_set_default( vector , default_value ); } @@ -478,7 +478,7 @@ void @TYPE@_vector_iset_default(@TYPE@_vector_type * vector , int index , @TYPE@ } /* Will start counting from the reverse end, as negative indexing in python: - + vector_reverse_iget( v , -1 ) => The last element vector_reverse_iget( v , -2 ) => The second to last element @@ -490,7 +490,7 @@ void @TYPE@_vector_iset_default(@TYPE@_vector_type * vector , int index , @TYPE@ /** - This might very well operate on a default value. + This might very well operate on a default value. */ void @TYPE@_vector_imul(@TYPE@_vector_type * vector, int index, @TYPE@ factor) { @TYPE@_vector_assert_index(vector , index); @@ -526,22 +526,22 @@ void @TYPE@_vector_shift(@TYPE@_vector_type * vector, @TYPE@ delta) { /* vector + vector */ void @TYPE@_vector_inplace_add( @TYPE@_vector_type * vector , const @TYPE@_vector_type * delta) { - if (vector->size != delta->size) + if (vector->size != delta->size) util_abort("%s: combining vectors with different size: %d and %d \n",__func__ , vector->size , delta->size); { int i; - for (i=0; i < vector->size; i++) + for (i=0; i < vector->size; i++) vector->data[i] += delta->data[i]; } } /* vector - vector */ void @TYPE@_vector_inplace_sub( @TYPE@_vector_type * vector , const @TYPE@_vector_type * delta) { - if (vector->size != delta->size) + if (vector->size != delta->size) util_abort("%s: combining vectors with different size: %d and %d \n",__func__ , vector->size , delta->size); { int i; - for (i=0; i < vector->size; i++) + for (i=0; i < vector->size; i++) vector->data[i] -= delta->data[i]; } } @@ -549,11 +549,11 @@ void @TYPE@_vector_inplace_sub( @TYPE@_vector_type * vector , const @TYPE@_vecto /* vector * vector (elementwise) */ void @TYPE@_vector_inplace_mul( @TYPE@_vector_type * vector , const @TYPE@_vector_type * factor) { - if (vector->size != factor->size) + if (vector->size != factor->size) util_abort("%s: combining vectors with different size: %d and %d \n",__func__ , vector->size , factor->size); { int i; - for (i=0; i < vector->size; i++) + for (i=0; i < vector->size; i++) vector->data[i] *= factor->data[i]; } } @@ -561,11 +561,11 @@ void @TYPE@_vector_inplace_mul( @TYPE@_vector_type * vector , const @TYPE@_vecto /* vector / vector (elementwise) */ void @TYPE@_vector_inplace_div( @TYPE@_vector_type * vector , const @TYPE@_vector_type * inv_factor) { - if (vector->size != inv_factor->size) + if (vector->size != inv_factor->size) util_abort("%s: combining vectors with different size: %d and %d \n",__func__ , vector->size , inv_factor->size); { int i; - for (i=0; i < vector->size; i++) + for (i=0; i < vector->size; i++) vector->data[i] /= inv_factor->data[i]; } } @@ -609,9 +609,9 @@ void @TYPE@_vector_inplace_div( @TYPE@_vector_type * vector , const @TYPE@_vecto */ void @TYPE@_vector_iset(@TYPE@_vector_type * vector , int index , @TYPE@ value) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { - if (index < 0) + if (index < 0) util_abort("%s: Sorry - can NOT set negative indices. called with index:%d \n",__func__ , index); { if (vector->alloc_size <= index) @@ -635,7 +635,7 @@ void @TYPE@_vector_iset(@TYPE@_vector_type * vector , int index , @TYPE@ value) void @TYPE@_vector_iset_block(@TYPE@_vector_type * vector , int index , int block_size , @TYPE@ value) { int sign = (block_size > 0) ? 1 : -1 ; int c; - for (c=0; c < abs(block_size); c++) + for (c=0; c < abs(block_size); c++) @TYPE@_vector_iset( vector , index + c * sign , value); } @@ -654,24 +654,24 @@ void @TYPE@_vector_iset_block(@TYPE@_vector_type * vector , int index , int bloc /** Will remove a block of length @block_size elements, starting at @index from the vector. The @block_size might very well extend beyond - the length of the vector. + the length of the vector. V = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9] vector_idel_block( vector , 4 , 2 ) => V = [ 0 , 1 , 2 , 3 , 6 , 7 , 8 , 9] The function is based on memmove() and probably not a high - performance player.... + performance player.... */ void @TYPE@_vector_idel_block( @TYPE@_vector_type * vector , int index , int block_size) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { if ((index >= 0) && (index < vector->size) && (block_size >= 0)) { if (index + block_size > vector->size) block_size = vector->size - index; - + index += block_size; @TYPE@_vector_memmove( vector , index , -block_size ); } else @@ -682,7 +682,7 @@ void @TYPE@_vector_idel_block( @TYPE@_vector_type * vector , int index , int blo /** Removes element @index from the vector, shifting all elements to the right of @index one element to the left and shrinking the total - vector. The return value is the value which is removed. + vector. The return value is the value which is removed. */ @@ -733,7 +733,7 @@ void @TYPE@_vector_append(@TYPE@_vector_type * vector , @TYPE@ value) { void @TYPE@_vector_reset(@TYPE@_vector_type * vector) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); vector->size = 0; } @@ -779,7 +779,7 @@ int @TYPE@_vector_size(const @TYPE@_vector_type * vector) { */ @TYPE@ @TYPE@_vector_pop(@TYPE@_vector_type * vector) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { if (vector->size > 0) { @TYPE@ value = vector->data[vector->size - 1]; @@ -794,7 +794,7 @@ int @TYPE@_vector_size(const @TYPE@_vector_type * vector) { void @TYPE@_vector_rshift(@TYPE@_vector_type * vector , int shift) { - if (shift < 0) + if (shift < 0) @TYPE@_vector_memmove( vector , -shift , shift); else { int i; @@ -810,7 +810,7 @@ void @TYPE@_vector_lshift(@TYPE@_vector_type * vector , int shift) { @TYPE@ * @TYPE@_vector_get_ptr(const @TYPE@_vector_type * vector) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); return vector->data; } @@ -831,7 +831,7 @@ const @TYPE@ * @TYPE@_vector_get_const_ptr(const @TYPE@_vector_type * vector) { */ @TYPE@ * @TYPE@_vector_alloc_data_copy( const @TYPE@_vector_type * vector ) { - int size = vector->size * sizeof ( @TYPE@ ); + int size = vector->size * sizeof ( @TYPE@ ); @TYPE@ * copy = util_calloc(vector->size , sizeof * copy ); if (copy != NULL) memcpy( copy , vector->data , size); @@ -843,7 +843,7 @@ int @TYPE@_vector_element_size( const @TYPE@_vector_type * vector ) { } void @TYPE@_vector_set_many(@TYPE@_vector_type * vector , int index , const @TYPE@ * data , int length) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { int min_size = index + length; if (min_size > vector->alloc_size) @@ -855,7 +855,7 @@ void @TYPE@_vector_set_many(@TYPE@_vector_type * vector , int index , const @TYP } void @TYPE@_vector_set_all(@TYPE@_vector_type * vector , @TYPE@ value) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { int i; for (i=0; i< vector->size; i++) @@ -863,18 +863,25 @@ void @TYPE@_vector_set_all(@TYPE@_vector_type * vector , @TYPE@ value) { } } -bool @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ min_value , @TYPE@ max_value , @TYPE@ delta) { - if (max_value >= min_value) { - @TYPE@ current_value = min_value; - @TYPE@_vector_reset( vector ); - while (current_value < max_value) { - @TYPE@_vector_append( vector , current_value ); - current_value += delta; + +/** + The bahviour of this function should closely follow the semantics + of the Python range() function. +*/ +void @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ value1 , @TYPE@ value2 , @TYPE@ delta) { + @TYPE@_vector_reset( vector ); + if (delta != 0) { + if (((delta > 0) && (value2 > value1)) || ((delta < 0) && (value2 < value1))) { + @TYPE@ current_value = value1; + while (true) { + @TYPE@_vector_append( vector , current_value ); + current_value += delta; + + if (((delta > 0) && (current_value >= value2)) || ((delta < 0) && (current_value <= value2))) + break; + } } - @TYPE@_vector_append( vector , max_value ); - return true; - } else - return false; + } } @@ -913,7 +920,7 @@ int @TYPE@_vector_get_max_index(const @TYPE@_vector_type * vector, bool reverse) max_value = vector->data[i]; max_index = i; } - } + } } else { @TYPE@ max_value; max_index = 0; @@ -933,7 +940,7 @@ int @TYPE@_vector_get_max_index(const @TYPE@_vector_type * vector, bool reverse) @TYPE@ @TYPE@_vector_get_max(const @TYPE@_vector_type * vector) { int max_index = @TYPE@_vector_get_max_index( vector , false ); - return vector->data[ max_index ]; + return vector->data[ max_index ]; } @@ -953,7 +960,7 @@ int @TYPE@_vector_get_min_index(const @TYPE@_vector_type * vector, bool reverse) min_value = vector->data[i]; min_index = i; } - } + } } else { @TYPE@ min_value; min_index = 0; @@ -975,7 +982,7 @@ int @TYPE@_vector_get_min_index(const @TYPE@_vector_type * vector, bool reverse) @TYPE@ @TYPE@_vector_get_min(const @TYPE@_vector_type * vector) { int min_index = @TYPE@_vector_get_min_index( vector , false ); - return vector->data[ min_index ]; + return vector->data[ min_index ]; } @@ -1007,14 +1014,14 @@ int @TYPE@_vector_index(const @TYPE@_vector_type * vector , @TYPE@ value) { while (true) { if (vector->data[index] == value) break; - + index++; if (index == vector->size) { index = -1; /* Not found */ break; } } - + return index; } else return -1; @@ -1042,12 +1049,12 @@ bool @TYPE@_vector_contains_sorted(const @TYPE@_vector_type * vector , @TYPE@ va int @TYPE@_vector_index_sorted(const @TYPE@_vector_type * vector , @TYPE@ value) { if (vector->size) { - + if (value < vector->data[0]) return -1; if (value == vector->data[ 0 ]) return 0; - + { int last_index = vector->size - 1; if (value > vector->data[ last_index ]) @@ -1055,21 +1062,21 @@ int @TYPE@_vector_index_sorted(const @TYPE@_vector_type * vector , @TYPE@ value) if (value == vector->data[ last_index]) return last_index; } - - + + { int lower_index = 0; int upper_index = vector->size - 1; - + while (true) { if ((upper_index - lower_index) <= 1) /* Not found */ return -1; - + { int center_index = (lower_index + upper_index) / 2; @TYPE@ center_value = vector->data[ center_index ]; - + if (center_value == value) /* Found it */ return center_index; @@ -1095,7 +1102,7 @@ static int @TYPE@_vector_cmp(const void *_a, const void *_b) { if (a > b) return 1; - + if (a < b) return -1; @@ -1118,8 +1125,8 @@ static int @TYPE@_vector_rcmp(const void *a, const void *b) { */ void @TYPE@_vector_select_unique(@TYPE@_vector_type * vector) { - @TYPE@_vector_assert_writable( vector ); - { + @TYPE@_vector_assert_writable( vector ); + if (vector->size > 0) { @TYPE@_vector_type * copy = @TYPE@_vector_alloc_copy( vector ); @TYPE@_vector_sort( copy ); @TYPE@_vector_reset( vector ); @@ -1127,7 +1134,7 @@ void @TYPE@_vector_select_unique(@TYPE@_vector_type * vector) { int i; @TYPE@ previous_value = @TYPE@_vector_iget( copy , 0); @TYPE@_vector_append( vector , previous_value); - + for (i=1; i < copy->size; i++) { @TYPE@ value = @TYPE@_vector_iget( copy , i ); if (value != previous_value) @@ -1143,13 +1150,13 @@ void @TYPE@_vector_select_unique(@TYPE@_vector_type * vector) { Inplace numerical sort of the vector; sorted in increasing order. */ void @TYPE@_vector_sort(@TYPE@_vector_type * vector) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); qsort(vector->data , vector->size , sizeof * vector->data , @TYPE@_vector_cmp); } void @TYPE@_vector_rsort(@TYPE@_vector_type * vector) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); qsort(vector->data , vector->size , sizeof * vector->data , @TYPE@_vector_rcmp); } @@ -1161,10 +1168,10 @@ static int @TYPE@_vector_cmp_node(const void *_a, const void *_b) { if (a.value < b.value) return -1; - + if (a.value > b.value) return 1; - + return 0; } @@ -1192,12 +1199,12 @@ static int @TYPE@_vector_rcmp_node(const void *a, const void *b) { double_vector_permute( v3 , sort_perm ); free(sort_perm); } - + */ - + static int * @TYPE@_vector_alloc_sort_perm__(const @TYPE@_vector_type * vector, bool reverse) { int * sort_perm = util_calloc( vector->size , sizeof * sort_perm ); sort_node_type * sort_nodes = util_calloc( vector->size , sizeof * sort_nodes ); @@ -1210,10 +1217,10 @@ static int * @TYPE@_vector_alloc_sort_perm__(const @TYPE@_vector_type * vector, qsort(sort_nodes , vector->size , sizeof * sort_nodes , @TYPE@_vector_rcmp_node); else qsort(sort_nodes , vector->size , sizeof * sort_nodes , @TYPE@_vector_cmp_node); - - for (i=0; i < vector->size; i++) + + for (i=0; i < vector->size; i++) sort_perm[i] = sort_nodes[i].index; - + free( sort_nodes ); return sort_perm; } @@ -1230,11 +1237,11 @@ int * @TYPE@_vector_alloc_rsort_perm(const @TYPE@_vector_type * vector) { void @TYPE@_vector_permute(@TYPE@_vector_type * vector , const int * perm) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { int i; @TYPE@ * tmp = util_alloc_copy( vector->data , sizeof * tmp * vector->size ); - for (i=0; i < vector->size; i++) + for (i=0; i < vector->size; i++) vector->data[i] = tmp[perm[i]]; free( tmp ); } @@ -1249,7 +1256,7 @@ void @TYPE@_vector_permute(@TYPE@_vector_type * vector , const int * perm) { bool @TYPE@_vector_is_sorted( const @TYPE@_vector_type * vector , bool reverse) { bool sorted = true; int start_index, delta,stop_index; - + if (reverse) { start_index = vector->size - 1; stop_index = 0; @@ -1271,7 +1278,7 @@ bool @TYPE@_vector_is_sorted( const @TYPE@_vector_type * vector , bool reverse) if (index == stop_index) break; } - + return sorted; } } @@ -1290,7 +1297,7 @@ bool @TYPE@_vector_is_sorted( const @TYPE@_vector_type * vector , bool reverse) in which bin @value fits and return the bin index. If the test limit[i] <= value < limit[i+1] - + succeeds the function will return i. If value is less than limits[0] the function will return -1, if value is greater than max( limit ) the function will return -1 * limit->size. @@ -1299,16 +1306,16 @@ bool @TYPE@_vector_is_sorted( const @TYPE@_vector_type * vector , bool reverse) of @guess < 0 is interpreted as "no guess". When all input has been validated the final search will be binary search. */ - + int @TYPE@_vector_lookup_bin( const @TYPE@_vector_type * limits , @TYPE@ value , int guess) { - if (value < limits->data[0]) + if (value < limits->data[0]) return -1; if (value > limits->data[ limits->size - 1]) return -1 * limits->size; - + if (guess >= limits->size) guess = -1; /* No guess */ @@ -1320,7 +1327,7 @@ int @TYPE@_vector_lookup_bin( const @TYPE@_vector_type * limits , @TYPE@ value , /* This is the fast path and assumes that @value is within the limits, and that guess < limits->size. See @TYPE@_vector_lookup_bin() for - further documentation.x + further documentation.x */ int @TYPE@_vector_lookup_bin__( const @TYPE@_vector_type * limits , @TYPE@ value , int guess) { @@ -1344,8 +1351,8 @@ int @TYPE@_vector_lookup_bin__( const @TYPE@_vector_type * limits , @TYPE@ value { int central_index = (lower_index + upper_index) / 2; @TYPE@ central_value = limits->data[ central_index ]; - - if (central_value > value) + + if (central_value > value) upper_index = central_index; else lower_index = central_index; @@ -1397,7 +1404,7 @@ void @TYPE@_vector_fwrite_data( const @TYPE@_vector_type * vector , FILE * strea /** Writing: - 1. Size + 1. Size 2. default value 3. Values */ @@ -1411,7 +1418,7 @@ void @TYPE@_vector_fwrite(const @TYPE@_vector_type * vector , FILE * stream) { /* - Observe that this function will reset the default value. + Observe that this function will reset the default value. */ void @TYPE@_vector_fread( @TYPE@_vector_type * vector , FILE * stream ) { @TYPE@ default_value; @@ -1444,7 +1451,7 @@ void @TYPE@_vector_buffer_fread(@TYPE@_vector_type * vector , buffer_type * buff @TYPE@ default_value; int size = buffer_fread_int( buffer ); buffer_fread( buffer , &default_value , sizeof default_value , 1 ); - + @TYPE@_vector_set_default( vector , default_value ); @TYPE@_vector_realloc_data__( vector , size ); buffer_fread( buffer , vector->data , sizeof * vector->data , size ); @@ -1465,7 +1472,7 @@ bool @TYPE@_vector_equal(const @TYPE@_vector_type * vector1 , const @TYPE@_vecto if (vector1->size == vector2->size) { if (memcmp(vector1->data , vector2->data , sizeof * vector1->data * vector1->size) == 0) return true; - else + else return false; } else return false; @@ -1474,14 +1481,14 @@ bool @TYPE@_vector_equal(const @TYPE@_vector_type * vector1 , const @TYPE@_vecto void @TYPE@_vector_apply(@TYPE@_vector_type * vector , @TYPE@_ftype * func) { - @TYPE@_vector_assert_writable( vector ); + @TYPE@_vector_assert_writable( vector ); { int i; for (i=0; i < vector->size; i++) vector->data[i] = func( vector->data[i] ); } } - + int @TYPE@_vector_count_equal( const @TYPE@_vector_type * vector , @TYPE@ cmp_value) { int count = 0; int i; @@ -1492,7 +1499,7 @@ int @TYPE@_vector_count_equal( const @TYPE@_vector_type * vector , @TYPE@ cmp_va return count; } - + /* The upper limit is inclusive - if it is commensurable with the delta. @@ -1503,19 +1510,19 @@ void @TYPE@_vector_range_fill(@TYPE@_vector_type * vector , @TYPE@ limit1 , @TYP if (delta == 0) util_abort("%s: sorry can not have delta == 0 \n",__func__); - + @TYPE@_vector_reset( vector ); while (true) { @TYPE@_vector_append( vector , current_value ); current_value += delta; if (delta > 0 && current_value > limit2) break; - + if (delta < 0 && current_value < limit2) break; } } - + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libert_util/src/version.c b/ThirdParty/Ert/devel/libert_util/src/version.c index c17675eb97..b1f7c045a5 100644 --- a/ThirdParty/Ert/devel/libert_util/src/version.c +++ b/ThirdParty/Ert/devel/libert_util/src/version.c @@ -1,13 +1,4 @@ -#define DOT "." - -#ifdef ERT_VERSION_MAJOR -#ifdef ERT_VERSION_MINOR -#ifdef ERT_VERSION_MICRO - #define ERT_VERSION ERT_VERSION_MAJOR DOT ERT_VERSION_MINOR DOT ERT_VERSION_MICRO -#endif -#endif -#endif - +#include <ert/util/util.h> char* version_get_git_commit() { #ifdef GIT_COMMIT @@ -25,13 +16,6 @@ char* version_get_git_commit_short() { #endif } -char* version_get_ert_version() { - #ifdef ERT_VERSION - return ERT_VERSION; - #else - return "Unknown version"; - #endif -} char* version_get_build_time() { #ifdef COMPILE_TIME_STAMP @@ -40,3 +24,22 @@ char* version_get_build_time() { return "Unknown build time"; #endif } + +int version_get_major_ert_version() { + return ERT_VERSION_MAJOR; +} + + +int version_get_minor_ert_version() { + return ERT_VERSION_MINOR; +} + + +const char * version_get_micro_ert_version() { + return ERT_VERSION_MICRO; +} + + +bool version_is_ert_devel_version() { + return util_sscanf_int( ERT_VERSION_MICRO , NULL); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt index 96076ad251..996618d796 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt @@ -18,6 +18,10 @@ add_executable( ert_util_matrix ert_util_matrix.c ) target_link_libraries( ert_util_matrix ert_util test_util ) add_test( ert_util_matrix ${EXECUTABLE_OUTPUT_PATH}/ert_util_matrix ) +add_executable( ert_util_matrix_stat ert_util_matrix_stat.c ) +target_link_libraries( ert_util_matrix_stat ert_util test_util ) +add_test( ert_util_matrix_stat ${EXECUTABLE_OUTPUT_PATH}/ert_util_matrix_stat ) + add_executable( ert_util_statistics ert_util_statistics.c ) target_link_libraries( ert_util_statistics ert_util test_util ) add_test( ert_util_statistics ${EXECUTABLE_OUTPUT_PATH}/ert_util_statistics ) @@ -107,9 +111,11 @@ add_executable( ert_util_approx_equal ert_util_approx_equal.c ) target_link_libraries( ert_util_approx_equal ert_util test_util ) add_test( ert_util_approx_equal ${EXECUTABLE_OUTPUT_PATH}/ert_util_approx_equal ) -add_executable( ert_util_ping ert_util_ping.c ) -target_link_libraries( ert_util_ping ert_util test_util ) -add_test( ert_util_ping ${EXECUTABLE_OUTPUT_PATH}/ert_util_ping ${PING_SERVERS}) +if (PING_PATH) + add_executable( ert_util_ping ert_util_ping.c ) + target_link_libraries( ert_util_ping ert_util test_util ) + add_test( ert_util_ping ${EXECUTABLE_OUTPUT_PATH}/ert_util_ping ${PING_SERVERS}) +endif() add_executable( ert_util_file_readable ert_util_file_readable.c ) target_link_libraries( ert_util_file_readable ert_util test_util ) @@ -164,7 +170,7 @@ add_executable( ert_util_abort_gnu_tests ert_util_abort_gnu_tests.c) target_link_libraries( ert_util_abort_gnu_tests ert_util test_util) add_test( ert_util_abort_gnu_tests ${EXECUTABLE_OUTPUT_PATH}/ert_util_abort_gnu_tests) -if (WITH_PTHREAD) +if (ERT_BUILD_BLOCK_FS) add_executable( ert_util_block_fs ert_util_block_fs.c) target_link_libraries( ert_util_block_fs ert_util test_util) add_test( ert_util_block_fs ${EXECUTABLE_OUTPUT_PATH}/ert_util_block_fs) diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_matrix.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_matrix.c index 9bf1c1e0af..ac6492f36c 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_matrix.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_matrix.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ert_util_matrix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ert_util_matrix.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ @@ -21,6 +21,7 @@ #include <stdlib.h> #include <math.h> +#include <ert/util/bool_vector.h> #include <ert/util/test_util.h> #include <ert/util/statistics.h> #include <ert/util/test_work_area.h> @@ -34,17 +35,17 @@ void test_resize() { matrix_type * m1 = matrix_alloc(5,5); matrix_type * m2 = matrix_alloc(5,5); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); + rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); matrix_random_init( m1 , rng ); matrix_assign( m2 , m1 ); - + test_assert_true( matrix_equal( m1 , m2 )); matrix_resize( m1 , 5 , 5 , false ); test_assert_true( matrix_equal( m1 , m2 )); matrix_resize( m1 , 5 , 5 , true ); test_assert_true( matrix_equal( m1 , m2 )); - + rng_free( rng ); matrix_free( m1 ); matrix_free( m2 ); @@ -55,7 +56,7 @@ void test_column_equal() { matrix_type * m1 = matrix_alloc(5,5); matrix_type * m2 = matrix_alloc(5,5); matrix_type * m3 = matrix_alloc(6,5); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); + rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); matrix_random_init( m1 , rng ); matrix_assign( m2 , m1 ); @@ -63,7 +64,7 @@ void test_column_equal() { test_assert_true( matrix_columns_equal( m1 , 2 , m2 , 2 )); test_assert_false( matrix_columns_equal( m1 , 2 , m2 , 3 )); test_assert_false( matrix_columns_equal( m1 , 2 , m3 , 3 )); - + rng_free( rng ); matrix_free( m1 ); matrix_free( m2 ); @@ -97,13 +98,13 @@ void test_dims() { void test_det4() { matrix_type * m = matrix_alloc(4 , 4 ); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); for (int i=0; i < 10; i++) { matrix_random_init( m , rng ); { double det4 = matrix_det4( m ); double det = matrix_det( m ); - + test_assert_double_equal( det , det4 ); } } @@ -115,7 +116,7 @@ void test_det4() { void test_det3() { matrix_type * m = matrix_alloc(3 , 3 ); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); matrix_random_init( m , rng ); { @@ -132,7 +133,7 @@ void test_det3() { void test_det2() { matrix_type * m = matrix_alloc(2,2); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); matrix_random_init( m , rng ); { double det2 = matrix_det2( m ); @@ -148,7 +149,7 @@ void test_det2() { void test_readwrite() { test_work_area_type * test_area = test_work_area_alloc("matrix-test"); { - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); matrix_type * m1 = matrix_alloc(3 , 3); matrix_type * m2 = matrix_alloc(3 , 3); matrix_random_init( m1 , rng ); @@ -191,17 +192,17 @@ void test_readwrite() { void test_diag_std() { const int N = 25; double_vector_type * data = double_vector_alloc( 0,0); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); matrix_type * m = matrix_alloc( N , N ); double sum1 = 0; double sum2 = 0; int i; for (i=0; i < N; i++) { - double R = rng_get_double( rng ); + double R = rng_get_double( rng ); matrix_iset(m , i , i , R); double_vector_iset( data , i , R ); - + sum1 += R; sum2 += R*R; } @@ -219,6 +220,64 @@ void test_diag_std() { +void test_masked_copy() { + const int N = 25; + bool_vector_type * mask = bool_vector_alloc(N , true); + rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + matrix_type * m1 = matrix_alloc( N , N ); + matrix_random_init( m1 , rng ); + + bool_vector_iset( mask , 0 , false ); + bool_vector_iset( mask , 10 , false ); + + { + matrix_type * m2 = matrix_alloc_column_compressed_copy( m1 , mask ); + matrix_type * m3 = matrix_alloc( N , N - 2 ); + + test_assert_int_equal( matrix_get_rows( m1 ) , matrix_get_rows( m2 )); + test_assert_int_equal( matrix_get_columns( m1 ) , matrix_get_columns( m2 ) + 2); + + matrix_column_compressed_memcpy( m3 , m1 , mask ); + { + int src_col; + int target_col = 0; + for (src_col = 0; src_col < N; src_col++) { + if (bool_vector_iget( mask , src_col)) { + test_assert_true( matrix_columns_equal( m1 , src_col , m3 , target_col )); + target_col++; + } + } + } + + test_assert_true( matrix_equal( m2 , m3 )); + matrix_free( m3 ); + matrix_free( m2 ); + } + + matrix_free( m1 ); + rng_free( rng ); +} + + +void test_inplace_sub_column() { + const int N = 25; + rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + matrix_type * m1 = matrix_alloc( N , N ); + matrix_type * m2 = matrix_alloc( N , N ); + + matrix_random_init( m1 , rng ); + matrix_assign( m2 , m1 ); + matrix_inplace_sub_column( m1 , m2 , 0 , 0 ); + { + int row; + for (row = 0; row < N; row++) { + double diff = matrix_iget( m1 , row , 0); + test_assert_true( fabs( diff ) < 1e-6); + } + } +} + + int main( int argc , char ** argv) { test_create_invalid(); test_resize(); @@ -229,5 +288,7 @@ int main( int argc , char ** argv) { test_det4(); test_readwrite(); test_diag_std(); + test_masked_copy(); + test_inplace_sub_column(); exit(0); } diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_matrix_stat.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_matrix_stat.c new file mode 100644 index 0000000000..6e2ce86bf5 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_matrix_stat.c @@ -0,0 +1,169 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'ert_util_matrix_stat.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#include <ert/util/matrix.h> +#include <ert/util/matrix_stat.h> +#include <ert/util/test_util.h> +#include <ert/util/util.h> + + + +void test_invalid_dimensions() { + matrix_type * X = matrix_alloc(10,2); + matrix_type * Y = matrix_alloc(11,1); + matrix_type * S = matrix_alloc(10,1); + matrix_type * beta = matrix_alloc(2,1); + + test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , S ) == LLSQ_INVALID_DIM ); + test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_INVALID_DIM ); + + matrix_resize(beta , 4 , 1 , false ); + matrix_resize(Y , 3 , 1 , false ); + matrix_resize(X , 3 , 4 , false ); + test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_UNDETERMINED ); + + matrix_free( Y ); + matrix_free( S ); + matrix_free( beta ); + matrix_free( X ); +} + + +void test_no_sigma() { + const double A = 4.00; + const double B = -2; + const double C = 0.25; + + const double xmin = 0; + const double xmax = 1; + int size = 20; + int P = 3; + matrix_type * X = matrix_alloc(size,P); + matrix_type * Y = matrix_alloc(size,1); + matrix_type * beta = matrix_alloc(P,1); + + int i; + for (i = 0; i < size; i++) { + double x = xmin + i * (xmax - xmin) / (size - 1); + + double y = A + B*x + C*x*x; + matrix_iset( X , i , 0 , 1 ); + matrix_iset( X , i , 1 , x ); + matrix_iset( X , i , 2 , x*x ); + + matrix_iset( Y , i , 0 , y); + } + + test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_SUCCESS ); + + test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); + test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); + test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); + + + matrix_free( Y ); + matrix_free( beta ); + matrix_free( X ); +} + + +void test_with_sigma() { + const double A = 4.00; + const double B = -2; + const double C = 0.25; + + const double xmin = 0; + const double xmax = 1; + int size = 20; + int P = 3; + matrix_type * X = matrix_alloc(size,P); + matrix_type * Y = matrix_alloc(size,1); + matrix_type * beta = matrix_alloc(P,1); + matrix_type * S = matrix_alloc(size,1); + + int i; + for (i = 0; i < size; i++) { + double x = xmin + i * (xmax - xmin) / (size - 1); + + double y = A + B*x + C*x*x; + matrix_iset( X , i , 0 , 1 ); + matrix_iset( X , i , 1 , x ); + matrix_iset( X , i , 2 , x*x ); + + matrix_iset( Y , i , 0 , y); + matrix_iset( S , i , 0 , 1); + } + + test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , S ) == LLSQ_SUCCESS ); + + test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); + test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); + test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); + + matrix_free( S ); + matrix_free( Y ); + matrix_free( beta ); + matrix_free( X ); +} + + +void test_polyfit() { + const double A = 4.00; + const double B = -2; + const double C = 0.25; + + const double xmin = 0; + const double xmax = 1; + int size = 20; + int P = 3; + matrix_type * X = matrix_alloc(size,1); + matrix_type * Y = matrix_alloc(size,1); + matrix_type * beta = matrix_alloc(P,1); + + int i; + for (i = 0; i < size; i++) { + double x = xmin + i * (xmax - xmin) / (size - 1); + + double y = A + B*x + C*x*x; + matrix_iset( X , i , 0 , x ); + matrix_iset( Y , i , 0 , y); + } + + test_assert_true( matrix_stat_polyfit( beta , X , Y , NULL) == LLSQ_SUCCESS ); + + test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); + test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); + test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); + + matrix_free( Y ); + matrix_free( beta ); + matrix_free( X ); +} + + + + + +int main() { + util_install_signals(); + test_invalid_dimensions(); + test_no_sigma(); + test_with_sigma(); + test_polyfit(); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c index db66f36439..6b479ca64c 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c @@ -89,6 +89,32 @@ void test_iget_as_int() { } } + +void test_iget_as_double() { + stringlist_type * s = stringlist_alloc_new(); + stringlist_append_ref(s , "1000.90" ); + stringlist_append_ref(s , "1000" ); + stringlist_append_ref(s , "XXXX" ); + + { + double value; + bool valid; + + value = stringlist_iget_as_double( s , 0 , &valid); + test_assert_double_equal( value , 1000.90); + test_assert_true( valid ); + + value = stringlist_iget_as_double( s , 1 , &valid); + test_assert_double_equal( value , 1000.0); + test_assert_true( valid ); + + value = stringlist_iget_as_double( s , 2 , &valid); + test_assert_double_equal( value , -1); + test_assert_false( valid ); + } +} + + void test_iget_as_bool() { stringlist_type * s = stringlist_alloc_new(); stringlist_append_ref(s , "TRUE" ); @@ -268,6 +294,7 @@ int main( int argc , char ** argv) { test_reverse(); test_iget_as_int(); test_iget_as_bool(); + test_iget_as_double(); test_split(); test_matching(); exit(0); diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_functions.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_functions.c index dc67cfa2b3..07d126a4ce 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_functions.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_functions.c @@ -98,9 +98,44 @@ void test_active_index_list() { } +void test_approx_equal() { + double_vector_type * d1 = double_vector_alloc(0,0); + double_vector_type * d2 = double_vector_alloc(0,0); + double_vector_type * d3 = double_vector_alloc(0,0); + + double_vector_append( d1 , 1.0 ); + double_vector_append( d1 , 2.0 ); + double_vector_append( d1 , 3.0 ); + + + double_vector_append( d2 , 1.0 ); + double_vector_append( d2 , 2.0 ); + + test_assert_false( double_vector_approx_equal( d1 , d2 ,1e-6)); + + double_vector_append( d2 , 3.0 ); + test_assert_true( double_vector_approx_equal( d1 , d2 ,1e-6)); + + double_vector_append( d3 , 1.0 ); + double_vector_append( d3 , 2.0 ); + double_vector_append( d3 , 3.0 ); + + double_vector_scale( d3 , 1 + 1e-6 ); + test_assert_true( double_vector_approx_equal( d1 , d3 ,1e-4)); + test_assert_false( double_vector_approx_equal( d1 , d3 ,1e-8)); + + + double_vector_free(d1); + double_vector_free(d2); + double_vector_free(d3); +} + + + int main( int argc , char ** argv) { test_index_list(); test_mask(); test_active_index_list(); + test_approx_equal(); exit(0); } diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c index 5d522a9e2b..e5bc248634 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c @@ -1,19 +1,19 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_type_vector_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_type_vector_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -37,7 +37,7 @@ void test_range_fill_int() { test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 20 ); test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 30 ); test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 40 ); - + int_vector_range_fill( int_vector , 10 , 10 , 44 ); /* 10,20,30,40 */ test_assert_int_equal( int_vector_size( int_vector ), 4); test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 10 ); @@ -66,14 +66,14 @@ void test_range_fill_int() { void test_range_fill_double() { double_vector_type * double_vector = double_vector_alloc(0,0); double_vector_range_fill( double_vector , 1,2,10 ); /* 1 , 3 , 5 , 7 , 9 */ - + test_assert_double_equal( double_vector_size( double_vector ), 5); test_assert_double_equal( double_vector_iget( double_vector , 0 ) , 1 ); test_assert_double_equal( double_vector_iget( double_vector , 1 ) , 3 ); test_assert_double_equal( double_vector_iget( double_vector , 2 ) , 5 ); test_assert_double_equal( double_vector_iget( double_vector , 3 ) , 7 ); test_assert_double_equal( double_vector_iget( double_vector , 4 ) , 9 ); - + double_vector_range_fill( double_vector , 3,3,9 ); /* 3,6,9 */ test_assert_double_equal( double_vector_size( double_vector ), 3); test_assert_double_equal( double_vector_iget( double_vector , 0 ) , 3 ); @@ -92,7 +92,7 @@ void test_range_fill() { void test_contains() { int_vector_type * int_vector = int_vector_alloc( 0 , 100); - + test_assert_false( int_vector_contains( int_vector , 100 )); int_vector_iset( int_vector , 0 , 77 ); test_assert_false( int_vector_contains( int_vector , 100 )); @@ -108,7 +108,7 @@ void test_contains() { void test_contains_sorted() { int_vector_type * int_vector = int_vector_alloc( 0 , 100); - + int_vector_append( int_vector , 99 ); int_vector_append( int_vector , 89 ); int_vector_append( int_vector , 79 ); @@ -130,7 +130,7 @@ void test_div() { int_vector_div( int_vector , 10 ); { int i; - for (i=0; i < int_vector_size( int_vector ); i++) + for (i=0; i < int_vector_size( int_vector ); i++) test_assert_int_equal( 10 , int_vector_iget( int_vector , i )); } } @@ -142,9 +142,9 @@ void test_memcpy_from_data() { int_vector_memcpy_from_data( int_vector , data , 5 ); test_assert_int_equal( 5 , int_vector_size( int_vector )); - for (int i=0; i < int_vector_size( int_vector ); i++) + for (int i=0; i < int_vector_size( int_vector ); i++) test_assert_int_equal( i + 1 , int_vector_iget( int_vector , i )); - + int_vector_free( int_vector ); } @@ -201,7 +201,7 @@ void test_shift() { test_assert_int_equal( 2 , int_vector_size( v )); test_assert_int_equal( 2 , int_vector_iget( v , 0 )); test_assert_int_equal( 3 , int_vector_iget( v , 1 )); - + int_vector_free( v ); } @@ -242,7 +242,7 @@ void test_iset_block() { int_vector_iset_block( vec , 10 , 10 , 77 ); test_assert_int_equal( int_vector_size( vec ) , 20 ); { - int i; + int i; for (i=10; i < 20; i++) test_assert_int_equal( int_vector_iget( vec , i ) , 77 ); } @@ -251,7 +251,7 @@ void test_iset_block() { int_vector_iset_block( vec , 10 , -11 , 66 ); { - int i; + int i; for (i=0; i <= 10; i++) test_assert_int_equal( int_vector_iget( vec , i ) , 66 ); } @@ -267,7 +267,7 @@ void test_resize() { test_assert_int_equal( int_vector_size( vec ) , 10 ); for (i=0; i < 10; i++) test_assert_int_equal( int_vector_iget( vec , i ) , def ); - + int_vector_iset_block( vec , 5 , 5 , 5 ); for (i=5; i < 10; i++) test_assert_int_equal( int_vector_iget( vec , i ) , 5 ); @@ -288,7 +288,7 @@ void test_resize() { void test_del() { int_vector_type * vec = int_vector_alloc(0,0); - + test_assert_int_equal( int_vector_del_value( vec , 77) , 0 ); int_vector_append(vec , 1); @@ -314,7 +314,7 @@ void test_del() { test_assert_int_equal( 3 , int_vector_iget(vec , 3)); test_assert_int_equal( 1 , int_vector_iget(vec , 4)); test_assert_int_equal( 1 , int_vector_iget(vec , 5)); - + test_assert_int_equal( 4 , int_vector_del_value( vec , 1 )); test_assert_int_equal( 2 , int_vector_size( vec )); @@ -323,27 +323,47 @@ void test_del() { int_vector_free( vec ); } + +void test_insert_double() { + double_vector_type * vec = double_vector_alloc(0,0); + double_vector_append( vec , 1 ); + double_vector_insert( vec , 0 , 0 ); + + test_assert_double_equal( 0 , double_vector_iget( vec , 0 )); + test_assert_double_equal( 1 , double_vector_iget( vec , 1 )); + + double_vector_free( vec ); +} + + +void test_empty() { + int_vector_type * vec = int_vector_alloc(0,0); + int_vector_sort( vec ); + int_vector_select_unique( vec ); + int_vector_free( vec ); +} + int main(int argc , char ** argv) { - + int_vector_type * int_vector = int_vector_alloc( 0 , 99); - + test_abort(); test_assert_int_equal( -1 , int_vector_index(int_vector , 100)); test_assert_int_equal( -1 , int_vector_index_sorted(int_vector , 100)); test_assert_true( int_vector_is_instance( int_vector )); test_assert_false( double_vector_is_instance( int_vector )); - int_vector_iset( int_vector , 2 , 0); - int_vector_insert( int_vector , 2 , 77 ); - int_vector_iset( int_vector , 5 , -10); - + int_vector_iset( int_vector , 2 , 0); + int_vector_insert( int_vector , 2 , 77 ); + int_vector_iset( int_vector , 5 , -10); + assert_equal( int_vector_iget(int_vector , 0 ) == 99 ); assert_equal( int_vector_iget(int_vector , 1 ) == 99 ); assert_equal( int_vector_iget(int_vector , 2 ) == 77 ); assert_equal( int_vector_iget(int_vector , 3 ) == 00 ); assert_equal( int_vector_iget(int_vector , 4 ) == 99 ); assert_equal( int_vector_iget(int_vector , 5 ) == -10 ); - + { int N1 = 100000; int N2 = 10*N1; @@ -355,26 +375,26 @@ int main(int argc , char ** argv) { int_vector_free_container( v1 ); v2 = int_vector_alloc( N2 , 0 ); int_vector_iset(v2 , N2 - 1, 77 ); - + test_assert_int_equal( data1[N1-1] , 99); int_vector_free( v2 ); free( data1 ); - } - - - test_assert_true( int_vector_init_range( int_vector , 100 , 1000 , 115 ) ); + } + + + int_vector_init_range( int_vector , 100 , 1000 , 115 ); test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); - test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); - - test_assert_false( int_vector_init_range( int_vector , 100 , -1000 , 115 ) ); + test_assert_int_equal( int_vector_get_last( int_vector ) , 905); + + int_vector_init_range( int_vector , 100 , -1000 , -115 ); test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); - test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); - test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); - test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); - test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); + test_assert_int_equal( int_vector_iget( int_vector , 1 ) , -15); + test_assert_int_equal( int_vector_iget( int_vector , 2 ) , -130); + test_assert_int_equal( int_vector_iget( int_vector , 3 ) , -245); + test_assert_int_equal( int_vector_get_last( int_vector ) , -935); { int_vector_type * v1 = int_vector_alloc(0,0); @@ -392,7 +412,7 @@ int main(int argc , char ** argv) { test_assert_int_equal( int_vector_iget (v1 , 0 ), 10 ); test_assert_int_equal( int_vector_iget (v1 , 1 ), 15 ); test_assert_int_equal( int_vector_iget (v1 , 2 ), 20 ); - + test_assert_int_equal( int_vector_iget (v1 , 3 ), 1 ); test_assert_int_equal( int_vector_iget (v1 , 4 ), 2 ); test_assert_int_equal( int_vector_iget (v1 , 5 ), 3 ); @@ -411,5 +431,7 @@ int main(int argc , char ** argv) { test_range_fill(); test_iset_block(); test_resize(); + test_empty(); + test_insert_double(); exit(0); } diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c index 3ee8d0146a..66fe83cbca 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_vector_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_vector_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -28,7 +28,7 @@ int test_iset( ) { vector_type * vector = vector_alloc_new( ); vector_iset_ref( vector , 2 , vector ); - + test_assert_true( vector_get_size( vector ) == 3 ); test_assert_true( vector_iget( vector , 0 ) == NULL ); test_assert_true( vector_iget( vector , 1 ) == NULL ); @@ -43,7 +43,7 @@ void test_reverse() { const char * val2 = "value2"; const char * val3 = "value3"; const char * val4 = "value4"; - + vector_type * vector1 = vector_alloc_new( ); vector_type * vector2 = vector_alloc_new( ); @@ -111,11 +111,29 @@ void test_sort() { } } +void test_find( ) { + vector_type * vector = vector_alloc_new(); + const char * p1 = "AAA"; + const char * p2 = "BBB"; + const char * p3 = "CCC"; + test_assert_int_equal( -1 , vector_find( vector , NULL )); + test_assert_int_equal( -1 , vector_find( vector , vector)); + + vector_append_ref(vector , p1 ); + vector_append_ref(vector , p2 ); + + test_assert_int_equal( 0 , vector_find( vector , p1 )); + test_assert_int_equal( 1 , vector_find( vector , p2 )); + test_assert_int_equal( -1 , vector_find( vector , p3 )); + + vector_free( vector ); +} int main(int argc , char ** argv) { test_iset( ); test_reverse( ); test_sort( ); + test_find( ); exit(0); } diff --git a/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_polygon.h b/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_polygon.h index c1a35683a0..0f8b4b53d3 100644 --- a/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_polygon.h +++ b/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_polygon.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'geo_polygon.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'geo_polygon.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __GEO_POLYGON_H__ @@ -25,14 +25,31 @@ extern "C" { #include <stdbool.h> +#include <ert/util/type_macros.h> + typedef struct geo_polygon_struct geo_polygon_type; - - geo_polygon_type * geo_polygon_alloc( ); + + geo_polygon_type * geo_polygon_alloc( const char * name ); void geo_polygon_free( geo_polygon_type * polygon ); void geo_polygon_free__( void * arg ); void geo_polygon_add_point( geo_polygon_type * polygon , double x , double y ); + void geo_polygon_add_point_front( geo_polygon_type * polygon , double x , double y); geo_polygon_type * geo_polygon_fload_alloc_irap( const char * filename ); bool geo_polygon_contains_point( const geo_polygon_type * polygon , double x , double y); + bool geo_polygon_contains_point__( const geo_polygon_type * polygon , double x , double y, bool force_edge_inside); + void geo_polygon_reset(geo_polygon_type * polygon ); + void geo_polygon_fprintf(const geo_polygon_type * polygon , FILE * stream); + void geo_polygon_shift(geo_polygon_type * polygon , double x0 , double y0); + void geo_polygon_close( geo_polygon_type * polygoon); + int geo_polygon_get_size(const geo_polygon_type * polygon ); + void geo_polygon_iget_xy(const geo_polygon_type * polygon , int index , double *x , double *y); + bool geo_polygon_segment_intersects(const geo_polygon_type * polygon , double x1 , double y1 , double x2 , double y2); + const char * geo_polygon_get_name( const geo_polygon_type * polygon ); + void geo_polygon_set_name( geo_polygon_type * polygon , const char * name); + double geo_polygon_get_length( geo_polygon_type * polygon ); + double geo_polygon_equal( const geo_polygon_type * polygon1 , const geo_polygon_type * polygon2 ); + + UTIL_IS_INSTANCE_HEADER( geo_polygon ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_polygon_collection.h b/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_polygon_collection.h new file mode 100644 index 0000000000..c7116c6d22 --- /dev/null +++ b/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_polygon_collection.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'geo_polygon_collection.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#ifndef __GEO_POLYGON_COLLECTION_H__ +#define __GEO_POLYGON_COLLECTION_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdbool.h> + +#include <ert/util/type_macros.h> + +#include <ert/geometry/geo_polygon.h> + + + + typedef struct geo_polygon_collection_struct geo_polygon_collection_type; + + geo_polygon_collection_type * geo_polygon_collection_alloc( ); + void geo_polygon_collection_free( geo_polygon_collection_type * polygons ); + int geo_polygon_collection_size( const geo_polygon_collection_type * polygons ); + geo_polygon_type * geo_polygon_collection_create_polygon( geo_polygon_collection_type * polygons , const char * name ); + bool geo_polygon_collection_has_polygon( const geo_polygon_collection_type * polygons , const char * name); + bool geo_polygon_collection_add_polygon( geo_polygon_collection_type * polygons , geo_polygon_type * polygon , bool polygon_owner ); + geo_polygon_type * geo_polygon_collection_iget_polygon(const geo_polygon_collection_type * polygons , int index); + geo_polygon_type * geo_polygon_collection_get_polygon(const geo_polygon_collection_type * polygons , const char * polygon_name); + + UTIL_IS_INSTANCE_HEADER( geo_polygon_collection ); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_util.h b/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_util.h index d1dc4b1079..b661f56afe 100644 --- a/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_util.h +++ b/ThirdParty/Ert/devel/libgeometry/include/ert/geometry/geo_util.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'geo_util.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'geo_util.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __GEO_UTIL_H__ @@ -29,12 +29,14 @@ extern "C" { GEO_UTIL_LINES_CROSSING = 0, GEO_UTIL_LINES_PARALLELL = 1, GEO_UTIL_LINES_OVERLAPPING = 2, - GEO_UTIL_LINES_DEGENERATE = 3 + GEO_UTIL_LINES_DEGENERATE = 3, + GEO_UTIL_NOT_CROSSING = 4 } geo_util_xlines_status_enum; - + bool geo_util_inside_polygon__(const double * xlist , const double * ylist , int num_points , double x0 , double y0 , bool force_edge_inside); bool geo_util_inside_polygon(const double * xlist , const double * ylist , int num_points , double x0 , double y0); geo_util_xlines_status_enum geo_util_xlines( const double ** points , double * x0, double * y0 ); + geo_util_xlines_status_enum geo_util_xsegments( const double ** points , double * x0, double * y0 ); #ifdef __cplusplus diff --git a/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt b/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt index 8dc42c6d20..4c00002ed8 100644 --- a/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt @@ -1,5 +1,5 @@ -set( source_files geo_surface.c geo_util.c geo_pointset.c geo_region.c geo_polygon.c) -set( header_files geo_surface.h geo_util.h geo_pointset.h geo_region.h geo_polygon.h) +set( source_files geo_surface.c geo_util.c geo_pointset.c geo_region.c geo_polygon.c geo_polygon_collection.c) +set( header_files geo_surface.h geo_util.h geo_pointset.h geo_region.h geo_polygon.h geo_polygon_collection.h) add_library( ert_geometry ${LIBRARY_TYPE} ${source_files} ) set_target_properties( ert_geometry PROPERTIES VERSION 1.0 SOVERSION 1.0 ) diff --git a/ThirdParty/Ert/devel/libgeometry/src/geo_polygon.c b/ThirdParty/Ert/devel/libgeometry/src/geo_polygon.c index 7e619276de..d98cfefdca 100644 --- a/ThirdParty/Ert/devel/libgeometry/src/geo_polygon.c +++ b/ThirdParty/Ert/devel/libgeometry/src/geo_polygon.c @@ -1,30 +1,32 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'geo_polygon.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'geo_polygon.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> +#include <math.h> #include <ert/util/util.h> #include <ert/util/double_vector.h> +#include <ert/util/type_vector_functions.h> #include <ert/geometry/geo_util.h> -#include <ert/geometry/geo_polygon.h> +#include <ert/geometry/geo_polygon.h> @@ -34,24 +36,28 @@ struct geo_polygon_struct { UTIL_TYPE_ID_DECLARATION; double_vector_type * xcoord; double_vector_type * ycoord; + char * name; }; static UTIL_SAFE_CAST_FUNCTION( geo_polygon , GEO_POLYGON_TYPE_ID ); +UTIL_IS_INSTANCE_FUNCTION( geo_polygon , GEO_POLYGON_TYPE_ID); + -geo_polygon_type * geo_polygon_alloc() { +geo_polygon_type * geo_polygon_alloc(const char * name) { geo_polygon_type * polygon = util_malloc( sizeof * polygon ); - + UTIL_TYPE_ID_INIT( polygon , GEO_POLYGON_TYPE_ID ); polygon->xcoord = double_vector_alloc( 0 , 0 ); polygon->ycoord = double_vector_alloc( 0 , 0 ); - + polygon->name = util_alloc_string_copy( name ); return polygon; } void geo_polygon_free( geo_polygon_type * polygon ) { double_vector_free( polygon->xcoord ); double_vector_free( polygon->ycoord ); + util_safe_free( polygon->name ); free( polygon ); } @@ -68,38 +74,221 @@ void geo_polygon_add_point( geo_polygon_type * polygon , double x , double y) { double_vector_append( polygon->ycoord , y ); } +void geo_polygon_add_point_front( geo_polygon_type * polygon , double x , double y) { + double_vector_insert( polygon->xcoord , 0 , x ); + double_vector_insert( polygon->ycoord , 0 , y ); +} + + +void geo_polygon_close( geo_polygon_type * polygon) { + double x = double_vector_get_first( polygon->xcoord ); + double y = double_vector_get_first( polygon->ycoord ); + geo_polygon_add_point( polygon , x , y ); +} + + + + +bool geo_polygon_contains_point__( const geo_polygon_type * polygon , double x , double y, bool force_edge_inside) { + return geo_util_inside_polygon__( double_vector_get_const_ptr( polygon->xcoord ) , + double_vector_get_const_ptr( polygon->ycoord ) , + double_vector_size( polygon->xcoord ) , + x , y , force_edge_inside); +} + bool geo_polygon_contains_point( const geo_polygon_type * polygon , double x , double y) { - return geo_util_inside_polygon( double_vector_get_const_ptr( polygon->xcoord ) , - double_vector_get_const_ptr( polygon->ycoord ) , - double_vector_size( polygon->xcoord ) , - x , y ); + return geo_polygon_contains_point__(polygon , x, y , false ); } -geo_polygon_type * geo_polygon_fload_alloc_irap( const char * filename ) { - geo_polygon_type * polygon = geo_polygon_alloc(); +static geo_polygon_type * geo_polygon_fload_alloc_xyz( const char * filename , bool irap_format) { + bool stop_on_999 = irap_format; + bool skip_last_point = irap_format; + + geo_polygon_type * polygon = geo_polygon_alloc( filename ); { FILE * stream = util_fopen( filename , "r"); double x , y , z; while (true) { - if (fscanf(stream , "%lg %lg %lg" , &x, &y , &z) == 3) + if (fscanf(stream , "%lg %lg %lg" , &x, &y , &z) == 3) { + if (stop_on_999 && (x == 999) && (y == 999) && (z == 999)) + break; + geo_polygon_add_point( polygon , x , y ); - else + } else break; - } + } + fclose( stream ); - /* - The irap format is a polygon which closes on itself by - construction; i.e. the last point from file is not added to the - polygon data structure. In addition the final '999' termination - is not included. - */ - double_vector_pop( polygon->xcoord ); - double_vector_pop( polygon->xcoord ); - double_vector_pop( polygon->ycoord ); - double_vector_pop( polygon->ycoord ); + + if ((double_vector_size( polygon->xcoord ) > 1) && (skip_last_point)) { + if ((double_vector_get_last(polygon->xcoord) == double_vector_get_first(polygon->xcoord)) && + (double_vector_get_last(polygon->ycoord) == double_vector_get_first(polygon->ycoord))) { + + double_vector_pop( polygon->xcoord ); + double_vector_pop( polygon->ycoord ); + } + } } return polygon; } + + +/* + The irap format is a polygon which closes on itself by construction, + and the list of numbers is terminated with (999,999,999). This is + supported as follows: + + - Reading will stop at (999,999,999) - all points after this + triplet will be ignored. + + - The polyline will by construction close on itself, i.e. P0 == + PN. Iff the last point is identical to the first it will not be + included. +*/ + +geo_polygon_type * geo_polygon_fload_alloc_irap( const char * filename ) { + geo_polygon_type * polygon = geo_polygon_fload_alloc_xyz( filename , true ); + return polygon; +} + + + +void geo_polygon_reset(geo_polygon_type * polygon ) { + double_vector_reset( polygon->xcoord ); + double_vector_reset( polygon->ycoord ); +} + + + +void geo_polygon_shift(geo_polygon_type * polygon , double x0 , double y0) { + double_vector_shift( polygon->xcoord , x0 ); + double_vector_shift( polygon->ycoord , y0 ); +} + + +int geo_polygon_get_size(const geo_polygon_type * polygon ) { + return double_vector_size( polygon->xcoord ); +} + + +void geo_polygon_fprintf(const geo_polygon_type * polygon , FILE * stream) { + int i; + for (i=0; i < double_vector_size( polygon->xcoord ); i++) + fprintf(stream , "%10.3f %10.3f \n", double_vector_iget( polygon->xcoord , i ) , double_vector_iget( polygon->ycoord , i)); +} + + +void geo_polygon_iget_xy(const geo_polygon_type * polygon , int index , double *x , double *y) { + *x = double_vector_iget( polygon->xcoord , index ); + *y = double_vector_iget( polygon->ycoord , index ); +} + + +bool geo_polygon_segment_intersects(const geo_polygon_type * polygon , double x1 , double y1 , double x2 , double y2) { + bool intersects = false; + double ** points = util_malloc( 4 * sizeof * points); + { + int i; + for (i = 0; i < 4; i++) + points[i] = util_malloc( 2 * sizeof * points[i]); + } + + points[0][0] = x1; + points[1][0] = x2; + points[0][1] = y1; + points[1][1] = y2; + + { + int index = 0; + while (true) { + + if (index >= (geo_polygon_get_size( polygon ) - 1)) + break; + + { + double xc,yc; + + points[2][0] = double_vector_iget( polygon->xcoord , index ); + points[3][0] = double_vector_iget( polygon->xcoord , index + 1); + points[2][1] = double_vector_iget( polygon->ycoord , index ); + points[3][1] = double_vector_iget( polygon->ycoord , index + 1); + + { + geo_util_xlines_status_enum xline_status = geo_util_xsegments(( const double **) points , &xc , &yc); + if ((xline_status == GEO_UTIL_LINES_CROSSING) || + (xline_status == GEO_UTIL_LINES_OVERLAPPING)) + intersects = true; + } + + if (intersects) + break; + + } + + index++; + } + } + + { + int i; + for (i = 0; i < 4; i++) + free(points[i]); + + free( points ); + } + + return intersects; +} + + +const char* geo_polygon_get_name( const geo_polygon_type * polygon ) { + return polygon->name; +} + +void geo_polygon_set_name( geo_polygon_type * polygon , const char * name) { + polygon->name = util_realloc_string_copy( polygon->name , name ); +} + + +double geo_polygon_get_length( geo_polygon_type * polygon ) { + if (double_vector_size( polygon->xcoord) == 1) + return 0; + else { + double length = 0; + double x0 = double_vector_iget( polygon->xcoord , 0 ); + double y0 = double_vector_iget( polygon->ycoord , 0 ); + int i; + + for (i = 1; i < double_vector_size( polygon->xcoord ); i++) { + double x1 = double_vector_iget( polygon->xcoord , i ); + double y1 = double_vector_iget( polygon->ycoord , i ); + + length += sqrt( (x1 - x0)*(x1 - x0) + (y1 - y0)*(y1 - y0)); + x0 = x1; + y0 = y1; + } + return length; + } +} + + +/* + Name is ignored in the comparison. +*/ +double geo_polygon_equal( const geo_polygon_type * polygon1 , const geo_polygon_type * polygon2 ) { + bool equal = + double_vector_equal( polygon1->xcoord , polygon2->xcoord) && + double_vector_equal( polygon1->ycoord , polygon2->ycoord); + + + if (!equal) { + equal = + double_vector_approx_equal( polygon1->xcoord , polygon2->xcoord , 1e-8) && + double_vector_approx_equal( polygon1->ycoord , polygon2->ycoord , 1e-8); + } + + return equal; +} diff --git a/ThirdParty/Ert/devel/libgeometry/src/geo_polygon_collection.c b/ThirdParty/Ert/devel/libgeometry/src/geo_polygon_collection.c new file mode 100644 index 0000000000..269a9032fa --- /dev/null +++ b/ThirdParty/Ert/devel/libgeometry/src/geo_polygon_collection.c @@ -0,0 +1,115 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'geo_polygon_collection.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + + +#include <stdlib.h> +#include <stdbool.h> + +#include <ert/util/util.h> +#include <ert/util/type_macros.h> +#include <ert/util/vector.h> +#include <ert/util/hash.h> + +#include <ert/geometry/geo_polygon.h> +#include <ert/geometry/geo_polygon_collection.h> + + + +#define GEO_POLYGON_COLLECTION_TYPE_ID 95721327 + +struct geo_polygon_collection_struct { + UTIL_TYPE_ID_DECLARATION; + vector_type * polygon_list; + hash_type * polygon_map; +}; + + +UTIL_IS_INSTANCE_FUNCTION( geo_polygon_collection , GEO_POLYGON_COLLECTION_TYPE_ID) + +geo_polygon_collection_type * geo_polygon_collection_alloc( ) { + geo_polygon_collection_type * polygons = util_malloc( sizeof * polygons ); + UTIL_TYPE_ID_INIT( polygons , GEO_POLYGON_COLLECTION_TYPE_ID ); + polygons->polygon_list = vector_alloc_new(); + polygons->polygon_map = hash_alloc(); + return polygons; +} + + +int geo_polygon_collection_size( const geo_polygon_collection_type * polygons ) { + return vector_get_size( polygons->polygon_list ); +} + + +geo_polygon_type * geo_polygon_collection_create_polygon( geo_polygon_collection_type * polygons , const char * name ) { + geo_polygon_type * polygon = NULL; + bool create_polygon = true; + + if (name && geo_polygon_collection_has_polygon( polygons , name )) + create_polygon = false; + + if (create_polygon) { + polygon = geo_polygon_alloc( name ); + geo_polygon_collection_add_polygon( polygons , polygon , true ); + } + + return polygon; +} + + +bool geo_polygon_collection_add_polygon( geo_polygon_collection_type * polygons , geo_polygon_type * polygon , bool polygon_owner ) { + const char * name = geo_polygon_get_name( polygon ); + if (geo_polygon_collection_has_polygon( polygons , name )) + return false; + else { + if (polygon_owner) + vector_append_owned_ref( polygons->polygon_list , polygon , geo_polygon_free__); + else + vector_append_ref( polygons->polygon_list , polygon ); + + if (name) + hash_insert_ref( polygons->polygon_map , name , polygon ); + + return true; + } +} + + +bool geo_polygon_collection_has_polygon( const geo_polygon_collection_type * polygons , const char * name) { + if (name) + return hash_has_key( polygons->polygon_map , name ); + else + return false; +} + + +void geo_polygon_collection_free( geo_polygon_collection_type * polygons ) { + vector_free( polygons->polygon_list ); + hash_free( polygons->polygon_map ); + free( polygons ); +} + + + +geo_polygon_type * geo_polygon_collection_iget_polygon(const geo_polygon_collection_type * polygons , int index) { + return vector_iget( polygons->polygon_list , index ); +} + + +geo_polygon_type * geo_polygon_collection_get_polygon(const geo_polygon_collection_type * polygons , const char * polygon_name) { + return hash_get( polygons->polygon_map , polygon_name ); +} diff --git a/ThirdParty/Ert/devel/libgeometry/src/geo_util.c b/ThirdParty/Ert/devel/libgeometry/src/geo_util.c index 6b89b77347..a0a7a1d077 100644 --- a/ThirdParty/Ert/devel/libgeometry/src/geo_util.c +++ b/ThirdParty/Ert/devel/libgeometry/src/geo_util.c @@ -1,30 +1,31 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'geo_util.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'geo_util.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> +#include <math.h> #include <ert/util/util.h> #include <ert/geometry/geo_util.h> - +#define EPSILON 0.000001 static bool between(double v1, double v2 , double v) { @@ -32,28 +33,107 @@ static bool between(double v1, double v2 , double v) { } -bool geo_util_inside_polygon(const double * xlist , const double * ylist , int num_points , double x0 , double y0) { +static bool interval_overlap(double a1,double a2, double b1, double b2) { + if (between(a1,a2,b1) || between(a1,a2,b2)) + return true; + + if ((a1 == b1) && (a2 == b2)) + return true; + + return false; +} + + +static bool on_edge(double _x1 , double _y1 , double _x2 , double _y2 , double x0 , double y0) { + double x1 = util_double_min( _x1 , _x2 ); + double x2 = util_double_max( _x1 , _x2 ); + double y1 = util_double_min( _y1 , _y2 ); + double y2 = util_double_max( _y1 , _y2 ); + + { + /* Vertical line */ + if (((x1 == x2) && (x0 == x1)) && ((y1 <= y0) && (y0 <= y2))) + return true; + + /* Horizontal line */ + if (((x1 <= x0) && (x0 <= x2)) && ((y1 == y2) && (y0 == y1))) + return true; + + /* General slope */ + { + double a = (y2 - y1) / (x2 - x1); + double yc = a*(x0 - x1) + y1; + + if (yc == y0) { + if ((x1 <= x0) && (x0 <= x2)) + return true; + } + } + return false; + } +} + + + +/* + If the bool force_edge_inside is set to true, points exactly on the + edge will be identified as inside. If the force_edge_inside variable + is set to false the behaviour on the edges is undefined. +*/ + + +bool geo_util_inside_polygon__(const double * xlist , const double * ylist , int num_points , double x0 , double y0 , bool force_edge_inside) { bool inside = false; int point_num; double y = y0; - + double xc = 0; + for (point_num = 0; point_num < num_points; point_num++) { int next_point = ((point_num + 1) % num_points); double x1 = xlist[point_num]; double y1 = ylist[point_num]; double x2 = xlist[next_point]; double y2 = ylist[next_point]; - - if (between(x1,x2,x0)) { - double yc = (y2 - y1)/(x2 - x1) * (x0 - x1) + y1; - if (y < yc) { - y = yc; - inside = !inside; + + double ymin = util_double_min(y1,y2); + double ymax = util_double_max(y1,y2); + double xmax = util_double_max(x1,x2); + + if (force_edge_inside) { + if (on_edge(x1,y1,x2,y2,x0,y0)) { + inside = true; + break; + } + } + + if ((x1 == x2) && (y1 == y2)) + continue; + + if ((y0 > ymin) && (y <= ymax)) { + + if (x0 <= xmax) { + if (y1 != y2) + xc = (y0 - y1) * (x2 - x1) / (y2 - y1) + x1; + + if ((x1 == x2) || (x0 <= xc)) + inside = !inside; + } } } + return inside; } +bool geo_util_inside_polygon(const double * xlist , const double * ylist , int num_points , double x0 , double y0) { + return geo_util_inside_polygon__(xlist , ylist , num_points , x0 , y0 , false ); +} + +/* + This function will cross to infinitely long lines which go through + the points given by the points pointer; this function does not + consider line segments of finite length. +*/ + geo_util_xlines_status_enum geo_util_xlines( const double ** points , double * x0, double * y0 ) { double x1 = points[0][0]; double x2 = points[1][0]; @@ -64,7 +144,7 @@ geo_util_xlines_status_enum geo_util_xlines( const double ** points , double * x double y2 = points[1][1]; double y3 = points[2][1]; double y4 = points[3][1]; - + double dx1 = (x2 - x1); double dx2 = (x4 - x3); double dy1 = (y2 - y1); @@ -73,7 +153,7 @@ geo_util_xlines_status_enum geo_util_xlines( const double ** points , double * x if ((dx1 == 0 && dy1 == 0) || (dx2 == 0 && dy2 == 0)) return GEO_UTIL_LINES_DEGENERATE; - + if ((dx1 != 0) && (dx2 != 0)) { // Both lines have a finite slope. double a1 = dy1 / dx1; @@ -86,7 +166,7 @@ geo_util_xlines_status_enum geo_util_xlines( const double ** points , double * x *x0 = x; *y0 = y; - + return GEO_UTIL_LINES_CROSSING; } else { // The two lines are parallell - potentially overlapping. @@ -122,3 +202,50 @@ geo_util_xlines_status_enum geo_util_xlines( const double ** points , double * x } } + +geo_util_xlines_status_enum geo_util_xsegments( const double ** points , double * x0, double * y0 ) { + double x1 = points[0][0]; + double x2 = points[1][0]; + double x3 = points[2][0]; + double x4 = points[3][0]; + + double y1 = points[0][1]; + double y2 = points[1][1]; + double y3 = points[2][1]; + double y4 = points[3][1]; + + double denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + double numerator_a = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + double numerator_b = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + + // coincident? + if ((fabs(numerator_a) < EPSILON) && + (fabs(numerator_b) < EPSILON) && + (fabs(denominator) < EPSILON)) { + + if (interval_overlap( x1,x2,x3,x4) && interval_overlap(y1,y2,y3,y4)) + return GEO_UTIL_LINES_OVERLAPPING; + else + return GEO_UTIL_NOT_CROSSING; + } + + + // Parallell + if (fabs(denominator) < EPSILON) + return GEO_UTIL_NOT_CROSSING; + + + // Normal intersection + { + double mua = numerator_a / denominator; + double mub = numerator_b / denominator; + + if ((mua < 0.0) || (mua > 1.0) || (mub < 0.0) || (mub > 1.0)) + return GEO_UTIL_NOT_CROSSING; + + *x0 = x1 + mua * (x2 - x1); + *y0 = y1 + mua * (y2 - y1 ); + + return GEO_UTIL_LINES_CROSSING; + } +} diff --git a/ThirdParty/Ert/devel/libgeometry/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libgeometry/tests/CMakeLists.txt index 1c6b037df5..07c6672b4a 100644 --- a/ThirdParty/Ert/devel/libgeometry/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libgeometry/tests/CMakeLists.txt @@ -10,6 +10,13 @@ add_executable( geo_util_xlines geo_util_xlines.c ) target_link_libraries( geo_util_xlines ert_geometry test_util ) add_test( geo_util_xlines ${EXECUTABLE_OUTPUT_PATH}/geo_util_xlines ) +add_executable( geo_polygon geo_polygon.c ) +target_link_libraries( geo_polygon ert_geometry test_util ) +add_test( geo_polygon ${EXECUTABLE_OUTPUT_PATH}/geo_polygon ) + +add_executable( geo_polygon_collection geo_polygon_collection.c ) +target_link_libraries( geo_polygon_collection ert_geometry test_util ) +add_test( geo_polygon_collection ${EXECUTABLE_OUTPUT_PATH}/geo_polygon_collection ) set_property( TEST geo_surface PROPERTY LABELS StatoilData ) diff --git a/ThirdParty/Ert/devel/libgeometry/tests/geo_polygon.c b/ThirdParty/Ert/devel/libgeometry/tests/geo_polygon.c new file mode 100644 index 0000000000..d6c9110f56 --- /dev/null +++ b/ThirdParty/Ert/devel/libgeometry/tests/geo_polygon.c @@ -0,0 +1,106 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'geo_surface.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include <ert/util/test_util.h> +#include <ert/util/util.h> +#include <ert/util/test_work_area.h> + +#include <ert/geometry/geo_polygon.h> + + + + +void test_create() { + geo_polygon_type * polygon = geo_polygon_alloc( "Name" ); + test_assert_true( geo_polygon_is_instance( polygon )); + test_assert_string_equal( "Name" , geo_polygon_get_name( polygon )); + geo_polygon_free( polygon ); +} + + +void test_contains__( double x , double y , int length , const double * data, bool expected) { + geo_polygon_type * polygon = geo_polygon_alloc( NULL ); + int i; + for (i=0; i < length; i++) + geo_polygon_add_point( polygon , data[2*i] , data[2*i + 1]); + + test_assert_bool_equal( expected , geo_polygon_contains_point( polygon ,x , y)); + geo_polygon_free( polygon ); +} + + + +void test_contains_polygon1( int length , const double * data) { + test_contains__(0.50 , 0.50 , length , data , true); + test_contains__(2.00 , 2.00 , length , data , false); + test_contains__(1.00 , 0.50 , length , data , true); +} + + +void test_contains_polygon2( int length , const double * data) { + test_contains__(0.50 , 0.50 , length , data , true); + test_contains__(2.00 , 2.00 , length , data , false); + test_contains__(1.00 , 0.50 , length , data , true); +} + + +void test_contains_polygon3( int length , const double * data) { + test_contains__(0.50 , 0.51 , length , data , false); + test_contains__(0.50 , 0.49 , length , data , true); +} + + + +void test_contains() { + test_contains_polygon1( 4 , (const double[8]) {0,0,1,0,1,1,0,1}); + test_contains_polygon2( 5 , (const double[10]) {0,0,1,0,1,1,0,1,0,0}); + test_contains_polygon3( 6 , (const double[12]) {0,0 , 0,1 , 0.6,0.5 , 0.4,0.5 , 1,1 , 1,0}); +} + + +void test_prepend() { + geo_polygon_type * polygon = geo_polygon_alloc( NULL ); + geo_polygon_add_point(polygon , 1 , 1); + geo_polygon_add_point_front( polygon , 0,0); + test_assert_int_equal( 2 , geo_polygon_get_size( polygon )); + { + double x,y; + + geo_polygon_iget_xy(polygon , 0 , &x , &y); + test_assert_double_equal( x , 0 ); + test_assert_double_equal( x , 0 ); + + geo_polygon_iget_xy(polygon , 1 , &x , &y); + test_assert_double_equal( x , 1 ); + test_assert_double_equal( x , 1 ); + } + geo_polygon_free( polygon ); +} + + + +int main(int argc , char ** argv) { + test_create(); + test_contains(); + test_prepend(); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libgeometry/tests/geo_polygon_collection.c b/ThirdParty/Ert/devel/libgeometry/tests/geo_polygon_collection.c new file mode 100644 index 0000000000..1c803aeb66 --- /dev/null +++ b/ThirdParty/Ert/devel/libgeometry/tests/geo_polygon_collection.c @@ -0,0 +1,45 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'geo_polygon_collection.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ + +#include <stdlib.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include <ert/util/test_util.h> +#include <ert/util/util.h> + +#include <ert/geometry/geo_polygon.h> +#include <ert/geometry/geo_polygon_collection.h> + + + + +void test_create() { + geo_polygon_collection_type * pc = geo_polygon_collection_alloc(); + test_assert_true( geo_polygon_collection_is_instance( pc )); + test_assert_int_equal( 0 , geo_polygon_collection_size( pc )); + geo_polygon_collection_free( pc ); +} + + + +int main(int argc , char ** argv) { + test_create(); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libgeometry/tests/geo_util_xlines.c b/ThirdParty/Ert/devel/libgeometry/tests/geo_util_xlines.c index 4cad82bee9..388ec16740 100644 --- a/ThirdParty/Ert/devel/libgeometry/tests/geo_util_xlines.c +++ b/ThirdParty/Ert/devel/libgeometry/tests/geo_util_xlines.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'geo_util_xlines.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'geo_util_xlines.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -30,7 +30,7 @@ void test_parallell_lines(double ** points) { double x0 = -100; double y0 = -100; - + points[0][0] = 0; points[1][0] = 10; @@ -51,10 +51,10 @@ void test_parallell_lines(double ** points) { } -void test_overlapping_lines(double ** points) { +void test_overlapping_lines_in_contact(double ** points) { double x0 = -100; double y0 = -100; - + points[0][0] = 0; points[1][0] = 1; @@ -75,12 +75,90 @@ void test_overlapping_lines(double ** points) { } +void test_overlapping_lines_not_in_contact(double ** points) { + double x0 = -100; + double y0 = -100; + + points[0][0] = 0; + points[1][0] = 1; + + points[0][1] = 0; + points[1][1] = 1; + + + points[2][0] = 2; + points[3][0] = 3; + + points[2][1] = 2; + points[3][1] = 3; + + + test_assert_int_equal(GEO_UTIL_NOT_CROSSING , geo_util_xsegments( (const double **) points , &x0 , &y0 )); + test_assert_double_equal( x0 , -100 ); + test_assert_double_equal( y0 , -100 ); +} + + +void test_overlapping_lines_not_in_contact_horizontal(double ** points) { + double x0 = -100; + double y0 = -100; + + points[0][0] = 0; + points[1][0] = 1; + + points[0][1] = 0; + points[1][1] = 0; + + + points[2][0] = 2; + points[3][0] = 3; + + points[2][1] = 0; + points[3][1] = 0; + + + test_assert_int_equal(GEO_UTIL_NOT_CROSSING , geo_util_xsegments( (const double **) points , &x0 , &y0 )); + test_assert_double_equal( x0 , -100 ); + test_assert_double_equal( y0 , -100 ); +} + + +void test_overlapping_lines_not_in_contact_vertical(double ** points) { + double x0 = -100; + double y0 = -100; + + points[0][0] = 0; + points[1][0] = 0; + + points[0][1] = 0; + points[1][1] = 1; + + + points[2][0] = 0; + points[3][0] = 0; + + points[2][1] = 2; + points[3][1] = 3; + + test_assert_int_equal(GEO_UTIL_NOT_CROSSING , geo_util_xsegments( (const double **) points , &x0 , &y0 )); + test_assert_double_equal( x0 , -100 ); + test_assert_double_equal( y0 , -100 ); +} + + + +void test_overlapping_lines(double ** points) { + test_overlapping_lines_in_contact( points ); + test_overlapping_lines_not_in_contact( points ); + test_overlapping_lines_not_in_contact_horizontal( points ); + test_overlapping_lines_not_in_contact_vertical( points ); +} void test_crossing_lines(double ** points) { double x0 = -100; double y0 = -100; - + points[0][0] = 0; points[1][0] = 1; @@ -106,7 +184,7 @@ void test_crossing_lines(double ** points) { void test_vertical_line(double ** points) { double x0 = -100; double y0 = -100; - + points[0][0] = -1; points[1][0] = 1; @@ -131,7 +209,7 @@ void test_vertical_line(double ** points) { void test_degenerate_line(double ** points) { double x0 = -100; double y0 = -100; - + points[0][0] = -1; points[1][0] = -1; diff --git a/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt b/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt index 39eb770c76..9ea4540853 100644 --- a/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt @@ -8,6 +8,8 @@ find_path( LSF_HEADER_PATH lsf/lsf.h find_library( LSF_LIBRARY NAMES lsf PATHS ${ERT_LSF_LIB_PATH}) + + if (LSF_HEADER_PATH) if (LSF_LIBRARY) set( HAVE_LSF_LIBRARY ON ) diff --git a/ThirdParty/Ert/devel/libjob_queue/applications/block_node.c b/ThirdParty/Ert/devel/libjob_queue/applications/block_node.c index 32b26ab595..21e5ebbb85 100644 --- a/ThirdParty/Ert/devel/libjob_queue/applications/block_node.c +++ b/ThirdParty/Ert/devel/libjob_queue/applications/block_node.c @@ -207,14 +207,14 @@ int main( int argc, char ** argv) { util_exit("block_node node1 node2 node3:2 \n"); /* Initialize lsf environment */ - util_setenv( "LSF_BINDIR" , "/prog/LSF/8.0/linux2.6-glibc2.3-x86_64/bin" ); - util_setenv( "LSF_LINDIR" , "/prog/LSF/8.0/linux2.6-glibc2.3-x86_64/lib" ); - util_setenv( "XLSF_UIDDIR" , "/prog/LSF/8.0/linux2.6-glibc2.3-x86_64/lib/uid" ); - util_setenv( "LSF_SERVERDIR" , "/prog/LSF/8.0/linux2.6-glibc2.3-x86_64/etc"); + util_setenv( "LSF_BINDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/bin" ); + util_setenv( "LSF_LINDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/lib" ); + util_setenv( "XLSF_UIDDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/lib/uid" ); + util_setenv( "LSF_SERVERDIR" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/etc"); util_setenv( "LSF_ENVDIR" , "/prog/LSF/conf"); - util_update_path_var( "PATH" , "/prog/LSF/8.0/linux2.6-glibc2.3-x86_64/bin" , false); - util_update_path_var( "LD_LIBRARY_PATH" , "/prog/LSF/8.0/linux2.6-glibc2.3-x86_64/lib" , false); + util_update_path_var( "PATH" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/bin" , false); + util_update_path_var( "LD_LIBRARY_PATH" , "/prog/LSF/9.1/linux2.6-glibc2.3-x86_64/lib" , false); lsf_driver = lsf_driver_alloc(); diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_job.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_job.h index 5e5aa0ad9b..4a40d5780f 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_job.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_job.h @@ -46,12 +46,12 @@ void ext_job_set_private_arg(ext_job_type * , const char * , void ext_job_set_argc(ext_job_type * , const char ** , int); void ext_job_python_fprintf(const ext_job_type * , FILE * , const subst_list_type *); -ext_job_type * ext_job_fscanf_alloc(const char * , const char * , bool private_job , const char *); +ext_job_type * ext_job_fscanf_alloc(const char * , const char * , bool private_job , const char *, bool search_path); const stringlist_type * ext_job_get_arglist( const ext_job_type * ext_job ); bool ext_job_is_shared( const ext_job_type * ext_job ); bool ext_job_is_private( const ext_job_type * ext_job ); -void ext_job_set_executable(ext_job_type * ext_job, const char * executable, const char * execuatble_raw); +void ext_job_set_executable(ext_job_type * ext_job, const char * executable_abs, const char * executable_input, bool search_path); const char * ext_job_get_executable(const ext_job_type * ext_job); diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_joblist.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_joblist.h index 4f279755da..71f16ed6aa 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_joblist.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_joblist.h @@ -41,7 +41,7 @@ ext_job_type * ext_joblist_get_job_copy(const ext_joblist_type * , const ch bool ext_joblist_has_job(const ext_joblist_type * , const char * ); stringlist_type * ext_joblist_alloc_list( const ext_joblist_type * joblist); bool ext_joblist_del_job( ext_joblist_type * joblist , const char * job_name ); -void ext_joblist_add_jobs_in_directory(ext_joblist_type * joblist , const char * path, const char * license_root_path, bool user_mode ); +void ext_joblist_add_jobs_in_directory(ext_joblist_type * joblist , const char * path, const char * license_root_path, bool user_mode, bool search_path ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue.h index 0c4e3ed66c..e74eaa770b 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'job_queue.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'job_queue.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __JOB_QUEUE_H__ @@ -41,29 +41,29 @@ extern "C" { void job_queue_set_runpath_fmt(job_queue_type * , const path_fmt_type * ); job_queue_type * job_queue_alloc( int , const char * ok_file , const char * exit_file); void job_queue_free(job_queue_type *); - - int job_queue_add_job_mt(job_queue_type * , - const char * run_cmd , - job_callback_ftype * done_callback, + + int job_queue_add_job_mt(job_queue_type * , + const char * run_cmd , + job_callback_ftype * done_callback, job_callback_ftype * retry_callback, job_callback_ftype * exit_callback, - void * callback_arg , - int num_cpu , - const char * , - const char * , - int argc , + void * callback_arg , + int num_cpu , + const char * , + const char * , + int argc , const char ** argv ); - int job_queue_add_job_st(job_queue_type * , - const char * run_cmd , - job_callback_ftype * done_callback, + int job_queue_add_job_st(job_queue_type * , + const char * run_cmd , + job_callback_ftype * done_callback, job_callback_ftype * retry_callback, job_callback_ftype * exit_callback, - void * callback_arg , - int num_cpu , - const char * , - const char * , - int argc , + void * callback_arg , + int num_cpu , + const char * , + const char * , + int argc , const char ** argv ); void job_queue_reset(job_queue_type * queue); @@ -74,17 +74,17 @@ extern "C" { job_status_type job_queue_iget_job_status(const job_queue_type * , int ); const char * job_queue_status_name( job_status_type status ); - + int job_queue_iget_status_summary( const job_queue_type * queue , job_status_type status); time_t job_queue_iget_sim_start( job_queue_type * queue, int job_index); - time_t job_queue_iget_sim_end( job_queue_type * queue, int job_index); + time_t job_queue_iget_sim_end( job_queue_type * queue, int job_index); time_t job_queue_iget_submit_time( job_queue_type * queue, int job_index); job_driver_type job_queue_lookup_driver_name( const char * driver_name ); - - void job_queue_set_max_job_duration(job_queue_type * queue, int max_duration_seconds); - int job_queue_get_max_job_duration(const job_queue_type * queue); - void job_queue_set_job_stop_time(job_queue_type * queue, time_t time); - time_t job_queue_get_job_stop_time(const job_queue_type * queue); + + void job_queue_set_max_job_duration(job_queue_type * queue, int max_duration_seconds); + int job_queue_get_max_job_duration(const job_queue_type * queue); + void job_queue_set_job_stop_time(job_queue_type * queue, time_t time); + time_t job_queue_get_job_stop_time(const job_queue_type * queue); void job_queue_set_auto_job_stop_time(job_queue_type * queue); bool job_queue_kill_job( job_queue_type * queue , int job_index); bool job_queue_is_running( const job_queue_type * queue ); diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue_manager.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue_manager.h index fa77457df0..e4bbf8554d 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue_manager.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue_manager.h @@ -32,6 +32,10 @@ typedef struct job_queue_manager_struct job_queue_manager_type; void job_queue_manager_free( job_queue_manager_type * manager ); void job_queue_manager_start_queue( job_queue_manager_type * manager , int num_total_run , bool verbose); void job_queue_manager_wait( job_queue_manager_type * manager); + int job_queue_manager_get_num_running( const job_queue_manager_type * manager); + int job_queue_manager_get_num_complete( const job_queue_manager_type * manager); + bool job_queue_manager_is_running( const job_queue_manager_type * manager); + bool job_queue_manager_job_complete( const job_queue_manager_type * manager , int job_index); UTIL_IS_INSTANCE_HEADER( job_queue_manager ); diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h index 69f9fd7ac5..6e5e711aba 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'lsf_driver.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'lsf_driver.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __LSF_DRIVER_H__ @@ -37,10 +37,12 @@ extern "C" { #define LSF_BSUB_CMD "BSUB_CMD" #define LSF_BJOBS_CMD "BJOBS_CMD" #define LSF_BKILL_CMD "BKILL_CMD" +#define LSF_DEBUG_OUTPUT "DEBUG_OUTPUT" +#define LSF_SUBMIT_SLEEP "SUBMIT_SLEEP" #define LOCAL_LSF_SERVER "LOCAL" #define NULL_LSF_SERVER "NULL" - +#define DEFAULT_SUBMIT_SLEEP "0" typedef enum { LSF_SUBMIT_INVALID = 0, @@ -49,7 +51,7 @@ extern "C" { LSF_SUBMIT_REMOTE_SHELL = 3 } lsf_submit_method_enum; - + typedef struct lsf_driver_struct lsf_driver_type; typedef struct lsf_job_struct lsf_job_type; @@ -58,20 +60,20 @@ typedef struct lsf_job_struct lsf_job_type; long lsf_job_get_jobnr( const lsf_job_type * job ); void * lsf_driver_alloc( ); - stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , - const char * run_path , - const char * job_name , + stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , + const char * run_path , + const char * job_name , const char * submit_cmd , - int num_cpu , + int num_cpu , int job_argc, const char ** job_argv); - - void * lsf_driver_submit_job(void * __driver , - const char * submit_cmd , - int num_cpu , - const char * run_path , + + void * lsf_driver_submit_job(void * __driver , + const char * submit_cmd , + int num_cpu , + const char * run_path , const char * job_name , - int argc, + int argc, const char ** argv ); job_status_type lsf_driver_convert_status( int lsf_status ); void lsf_driver_kill_job(void * __driver , void * __job); @@ -82,21 +84,18 @@ typedef struct lsf_job_struct lsf_job_type; void lsf_driver_free_job(void * __job); void lsf_driver_display_info( void * __driver , void * __job); void lsf_driver_set_bjobs_refresh_interval( lsf_driver_type * driver , int refresh_interval); - - lsf_submit_method_enum lsf_driver_get_submit_method( const lsf_driver_type * driver ); - + + lsf_submit_method_enum lsf_driver_get_submit_method( const lsf_driver_type * driver ); + bool lsf_driver_has_option( const void * __driver , const char * option_key); const void * lsf_driver_get_option( const void * __driver , const char * option_key); bool lsf_driver_set_option( void * __driver , const char * option_key , const void * value); void lsf_driver_init_option_list(stringlist_type * option_list); - - - - + int lsf_job_parse_bsub_stdout(const char * bsub_cmd, const char * stdout_file); UTIL_SAFE_CAST_HEADER( lsf_driver ); - - + + #ifdef __cplusplus } #endif -#endif +#endif diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/queue_driver.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/queue_driver.h index 63efc4bd27..d30a917122 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/queue_driver.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/queue_driver.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'queue_driver.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'queue_driver.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef __QUEUE_DRIVER_H__ @@ -37,15 +37,15 @@ extern "C" { {.value = 1 , .name = "LSF_DRIVER"}, \ {.value = 2 , .name = "LOCAL_DRIVER"}, \ {.value = 3 , .name = "RSH_DRIVER"}, \ -{.value = 4 , .name = "TORQUE_DRIVER"} - +{.value = 4 , .name = "TORQUE_DRIVER"} + #define JOB_DRIVER_ENUM_SIZE 5 - + /* The options supported by the base queue_driver. */ #define MAX_RUNNING "MAX_RUNNING" - + typedef enum { JOB_QUEUE_NOT_ACTIVE = 1, /* This value is used in external query routines - for jobs which are (currently) not active. */ //JOB_QUEUE_LOADING = 2 , /* This value is used by external routines. Not used in the libjob_queue implementation. */ @@ -109,6 +109,9 @@ extern "C" { #define JOB_QUEUE_CAN_UPDATE_STATUS (JOB_QUEUE_RUNNING + JOB_QUEUE_PENDING + JOB_QUEUE_SUBMITTED) +#define JOB_QUEUE_COMPLETE_STATUS (JOB_QUEUE_USER_EXIT + JOB_QUEUE_SUCCESS + JOB_QUEUE_FAILED) + + typedef struct queue_driver_struct queue_driver_type; typedef void * (submit_job_ftype) (void * data, const char * cmd, int num_cpu, const char * run_path, const char * job_name, int argc, const char ** argv); @@ -120,7 +123,7 @@ extern "C" { typedef const void * (get_option_ftype) (const void *, const char *); typedef bool (has_option_ftype) (const void *, const char *); typedef void (init_option_list_ftype) (stringlist_type *); - + queue_driver_type * queue_driver_alloc_RSH(const char * rsh_cmd, const hash_type * rsh_hostlist); queue_driver_type * queue_driver_alloc_LSF(const char * queue_name, const char * resource_request, const char * remote_lsf_server); @@ -132,7 +135,7 @@ extern "C" { void queue_driver_free_job(queue_driver_type * driver, void * job_data); void queue_driver_kill_job(queue_driver_type * driver, void * job_data); job_status_type queue_driver_get_status(queue_driver_type * driver, void * job_data); - + const char * queue_driver_get_name(const queue_driver_type * driver); bool queue_driver_set_option(queue_driver_type * driver, const char * option_key, const void * value); diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/torque_driver.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/torque_driver.h index 3a89abfd4b..e18c7df8e5 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/torque_driver.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/torque_driver.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'torque_driver.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'torque_driver.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #ifndef TORQUE_DRIVER_H #define TORQUE_DRIVER_H @@ -21,6 +21,7 @@ #ifdef __cplusplus extern "C" { #endif +#include <stdio.h> #include <ert/util/type_macros.h> #include <ert/job_queue/queue_driver.h> @@ -37,10 +38,13 @@ extern "C" { #define TORQUE_KEEP_QSUB_OUTPUT "KEEP_QSUB_OUTPUT" #define TORQUE_CLUSTER_LABEL "CLUSTER_LABEL" #define TORQUE_JOB_PREFIX_KEY "JOB_PREFIX" +#define TORQUE_SUBMIT_SLEEP "SUBMIT_SLEEP" +#define TORQUE_DEBUG_OUTPUT "DEBUG_OUTPUT" -#define TORQUE_DEFAULT_QSUB_CMD "qsub" -#define TORQUE_DEFAULT_QSTAT_CMD "qstat" -#define TORQUE_DEFAULT_QDEL_CMD "qdel" +#define TORQUE_DEFAULT_QSUB_CMD "qsub" +#define TORQUE_DEFAULT_QSTAT_CMD "qstat" +#define TORQUE_DEFAULT_QDEL_CMD "qdel" +#define TORQUE_DEFAULT_SUBMIT_SLEEP "0" typedef struct torque_driver_struct torque_driver_type; @@ -67,10 +71,13 @@ extern "C" { const void * torque_driver_get_option(const void * __driver, const char * option_key); bool torque_driver_set_option(void * __driver, const char * option_key, const void * value); - void torque_driver_init_option_list(stringlist_type * option_list); - + void torque_driver_init_option_list(stringlist_type * option_list); + void torque_job_create_submit_script(const char * run_path, const char * submit_cmd, int argc, const char ** job_argv); - + int torque_driver_get_submit_sleep( const torque_driver_type * driver ); + FILE * torque_driver_get_debug_stream( const torque_driver_type * driver ); + + UTIL_SAFE_CAST_HEADER(torque_driver); #ifdef __cplusplus diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h index f89706d649..c8100c386d 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h @@ -44,7 +44,7 @@ extern "C" { void * workflow_pop_stack( workflow_type * workflow ); int workflow_size( const workflow_type * workflow); - workflow_job_type * workflow_iget_job( const workflow_type * workflow, int index); + const workflow_job_type * workflow_iget_job( const workflow_type * workflow, int index); stringlist_type * workflow_iget_arguments( const workflow_type * workflow, int index); bool workflow_try_compile( workflow_type * script , const subst_list_type * context); UTIL_IS_INSTANCE_HEADER( workflow ); diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h index 77cb462357..647007cb1b 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h @@ -23,7 +23,7 @@ extern "C" { #endif -#include <ert/config/config.h> +#include <ert/config/config_parser.h> typedef void * (workflow_job_ftype) (void * self , const stringlist_type * arg ); @@ -31,14 +31,14 @@ extern "C" { const char * workflow_job_get_name( const workflow_job_type * workflow_job ); bool workflow_job_internal( const workflow_job_type * workflow_job ); - config_type * workflow_job_alloc_config(); + config_parser_type * workflow_job_alloc_config(); workflow_job_type * workflow_job_alloc(const char * name , bool internal); void workflow_job_free( workflow_job_type * workflow_job ); void workflow_job_free__( void * arg); void workflow_job_set_executable( workflow_job_type * workflow_job , const char * executable ); - workflow_job_type * workflow_job_config_alloc( const char * name , config_type * config , const char * config_file); + workflow_job_type * workflow_job_config_alloc( const char * name , config_parser_type * config , const char * config_file); - void workflow_job_update_config_compiler( const workflow_job_type * workflow_job , config_type * config_compiler ); + void workflow_job_update_config_compiler( const workflow_job_type * workflow_job , config_parser_type * config_compiler ); void workflow_job_set_executable( workflow_job_type * workflow_job , const char * executable); char * workflow_job_get_executable( workflow_job_type * workflow_job); diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h index b260979f4e..b27f77e701 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h @@ -35,9 +35,10 @@ typedef struct workflow_joblist_struct workflow_joblist_type; const workflow_job_type * workflow_joblist_get_job( const workflow_joblist_type * joblist , const char * job_name); void workflow_joblist_add_job( workflow_joblist_type * joblist , const workflow_job_type * job); bool workflow_joblist_add_job_from_file( workflow_joblist_type * joblist , const char * job_name , const char * config_file ); - config_type * workflow_joblist_get_compiler( const workflow_joblist_type * joblist ); - config_type * workflow_joblist_get_job_config( const workflow_joblist_type * joblist ); + config_parser_type * workflow_joblist_get_compiler( const workflow_joblist_type * joblist ); + config_parser_type * workflow_joblist_get_job_config( const workflow_joblist_type * joblist ); bool workflow_joblist_has_job( const workflow_joblist_type * joblist , const char * job_name); + stringlist_type * workflow_joblist_get_job_names(const workflow_joblist_type * joblist); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c b/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c index c9e19de83b..a565f70d3e 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ext_job.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ext_job.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -30,7 +30,9 @@ #include <ert/util/subst_list.h> #include <ert/util/parser.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> +#include <ert/config/config_content.h> +#include <ert/config/config_error.h> #include <ert/job_queue/ext_job.h> @@ -44,7 +46,7 @@ o .... These variables will then contain string values from when the job - configuration is read in, for example this little job + configuration is read in, for example this little job STDOUT my_stdout STDERR my_stderr @@ -70,8 +72,8 @@ This can then be invoked several times, with different key=value arguments for the SRC_FILE and TARGET_FILE: - - + + COPY_FILE(SRC_FILE = file1 , TARGET_FILE = /tmp/file1) COPY_FILE(SRC_FILE = file2 , TARGET_FILE = /tmp/file2) @@ -80,10 +82,10 @@ /* - + jobList = [ - {"executable" : None, + {"executable" : None, "environment" : {"LM_LICENSE_PATH" : "1700@osl001lic.hda.hydro.com:1700@osl002lic.hda.hydro.com:1700@osl003lic.hda.hydro.com", "F_UFMTENDIAN" : "big"}, "target_file":"222", @@ -108,19 +110,19 @@ struct ext_job_struct { char * stdin_file; char * stderr_file; char * license_path; /* If this is NULL - it will be unrestricted ... */ - char * license_root_path; - char * config_file; - int max_running; /* 0 means unlimited. */ + char * license_root_path; + char * config_file; + int max_running; /* 0 means unlimited. */ int max_running_minutes; /* The maximum number of minutes this job is allowed to run - 0: unlimited. */ - subst_list_type * private_args; /* A substitution list of input arguments which is performed before the external substitutions - + subst_list_type * private_args; /* A substitution list of input arguments which is performed before the external substitutions - these are the arguments supplied as key=value pairs in the forward model call. */ char * private_args_string; char * argv_string; stringlist_type * argv; /* This should *NOT* start with the executable */ hash_type * environment; - hash_type * default_mapping; + hash_type * default_mapping; char * help_text; - + bool private_job; /* Can the current user/delete this job? (private_job == true) means the user can edit it. */ bool __valid; /* Temporary variable consulted during the bootstrap - when the ext_job is completely initialized this should NOT be consulted anymore. */ }; @@ -136,7 +138,7 @@ static UTIL_SAFE_CAST_FUNCTION( ext_job , EXT_JOB_TYPE_ID) static ext_job_type * ext_job_alloc__(const char * name , const char * license_root_path , bool private_job) { ext_job_type * ext_job = util_malloc(sizeof * ext_job ); - + UTIL_TYPE_ID_INIT( ext_job , EXT_JOB_TYPE_ID); ext_job->name = util_alloc_string_copy( name ); ext_job->license_root_path = util_alloc_string_copy( license_root_path ); @@ -148,7 +150,7 @@ static ext_job_type * ext_job_alloc__(const char * name , const char * license_r ext_job->stdin_file = NULL; ext_job->stderr_file = NULL; ext_job->environment = hash_alloc(); - ext_job->default_mapping = hash_alloc(); + ext_job->default_mapping = hash_alloc(); ext_job->argv = stringlist_alloc_new(); ext_job->argv_string = NULL; ext_job->__valid = true; @@ -156,13 +158,13 @@ static ext_job_type * ext_job_alloc__(const char * name , const char * license_r ext_job->config_file = NULL; ext_job->max_running = 0; /* 0 means unlimited. */ ext_job->max_running_minutes = 0; /* 0 means unlimited. */ - ext_job->private_job = private_job; /* If private_job == true the job is user editable. */ - ext_job->help_text = NULL; + ext_job->private_job = private_job; /* If private_job == true the job is user editable. */ + ext_job->help_text = NULL; ext_job->private_args_string = NULL; - /* - ext_job->private_args is set explicitly in the ext_job_alloc() - and ext_job_alloc_copy() functions. + /* + ext_job->private_args is set explicitly in the ext_job_alloc() + and ext_job_alloc_copy() functions. */ return ext_job; } @@ -180,7 +182,7 @@ void ext_job_set_help_text( ext_job_type * job , const char * help_text) { job->help_text = util_realloc_string_copy( job->help_text , help_text ); } -/* +/* Exported function - must have name != NULL. Observe that the instance returned from this function is not really usable for anything. @@ -200,7 +202,7 @@ ext_job_type * ext_job_alloc(const char * name , const char * license_root_path ext_job_type * ext_job_alloc_copy(const ext_job_type * src_job) { ext_job_type * new_job = ext_job_alloc__( src_job->name , src_job->license_root_path , true /* All copies are by default private jobs. */); - + new_job->config_file = util_alloc_string_copy(src_job->config_file); new_job->executable = util_alloc_string_copy(src_job->executable); new_job->target_file = util_alloc_string_copy(src_job->target_file); @@ -209,7 +211,7 @@ ext_job_type * ext_job_alloc_copy(const ext_job_type * src_job) { new_job->stdout_file = util_alloc_string_copy(src_job->stdout_file); new_job->stdin_file = util_alloc_string_copy(src_job->stdin_file); new_job->stderr_file = util_alloc_string_copy(src_job->stderr_file); - new_job->license_path = util_alloc_string_copy(src_job->license_path); + new_job->license_path = util_alloc_string_copy(src_job->license_path); ext_job_set_help_text( new_job , src_job->help_text ); @@ -226,9 +228,9 @@ ext_job_type * ext_job_alloc_copy(const ext_job_type * src_job) { hash_insert_hash_owned_ref( new_job->environment , key , util_alloc_string_copy(value) , free); key = hash_iter_get_next_key(iter); } - hash_iter_free(iter); + hash_iter_free(iter); } - + /* The default mapping. */ { @@ -239,13 +241,13 @@ ext_job_type * ext_job_alloc_copy(const ext_job_type * src_job) { hash_insert_hash_owned_ref( new_job->default_mapping , key , util_alloc_string_copy(value) , free); key = hash_iter_get_next_key(iter); } - hash_iter_free(iter); + hash_iter_free(iter); } - + stringlist_deep_copy( new_job->argv , src_job->argv ); - + return new_job; } @@ -266,7 +268,7 @@ void ext_job_free(ext_job_type * ext_job) { util_safe_free(ext_job->argv_string); util_safe_free(ext_job->help_text); util_safe_free(ext_job->private_args_string); - + hash_free( ext_job->default_mapping); hash_free( ext_job->environment ); stringlist_free(ext_job->argv); @@ -285,9 +287,9 @@ static void __update_mode( const char * filename , mode_t add_mode) { /** - The license_path = - - root_license_path / job_name / job_name + The license_path = + + root_license_path / job_name / job_name */ @@ -344,31 +346,31 @@ void ext_job_set_max_time( ext_job_type * ext_job , int max_time ) { */ -void ext_job_set_executable(ext_job_type * ext_job, const char * executable, const char * executable_raw) { +void ext_job_set_executable(ext_job_type * ext_job, const char * executable_abs, const char * executable_input,bool search_path) { - if (util_file_exists(executable)) { + if (util_file_exists(executable_abs)) { /* The @executable parameter points to an existing file; we store the full path as the executable field of the job; we also try to update the mode of the full_path executable to make sure it is executable. */ - char * full_path = util_alloc_realpath( executable ); + char * full_path = util_alloc_realpath( executable_abs ); __update_mode( full_path , S_IRUSR + S_IWUSR + S_IXUSR + S_IRGRP + S_IWGRP + S_IXGRP + S_IROTH + S_IXOTH); /* u:rwx g:rwx o:rx */ ext_job->executable = util_realloc_string_copy(ext_job->executable , full_path); free( full_path ); - } else if (util_file_exists(executable_raw)) { + } else if (util_file_exists(executable_input)) { /* This "if" case means that we have found an executable relative to the current working directory. This is deprecated behaviour, support will be removed */ - char * full_path = util_alloc_abs_path(executable_raw); + char * full_path = util_alloc_abs_path(executable_input); const char * job_description_file = ext_job_get_config_file(ext_job); char * path_to_job_descr_file = util_split_alloc_dirname(job_description_file); char * new_relative_path_to_exe = util_alloc_rel_path(path_to_job_descr_file, full_path); char * relative_config_file = util_alloc_rel_path(NULL , ext_job->config_file); - + fprintf(stderr,"/----------------------------------------------------------------\n"); fprintf(stderr,"| ** WARNING ** \n"); fprintf(stderr,"|\n"); @@ -381,48 +383,52 @@ void ext_job_set_executable(ext_job_type * ext_job, const char * executable, con fprintf(stderr,"| present form, but it is recommended to update: \n"); fprintf(stderr,"|\n"); fprintf(stderr,"| 1. Open the file:%s in an editor \n",relative_config_file); - fprintf(stderr,"|\n"); + fprintf(stderr,"|\n"); fprintf(stderr,"| 2. Change the EXECUTABLE line to: \n"); - fprintf(stderr,"|\n"); + fprintf(stderr,"|\n"); fprintf(stderr,"| EXECUTABLE %s \n" , new_relative_path_to_exe); - fprintf(stderr,"|\n"); + fprintf(stderr,"|\n"); fprintf(stderr,"| The main advantage with this change in behaviour is that the\n"); fprintf(stderr,"| job description file and the executable can be relocated.\n"); fprintf(stderr,"\\----------------------------------------------------------------\n\n"); - ext_job_set_executable(ext_job, full_path, NULL); + ext_job_set_executable(ext_job, full_path, NULL, search_path); free(new_relative_path_to_exe); free(path_to_job_descr_file); free(full_path); free(relative_config_file); - } else if (util_is_abs_path( executable_raw )) { + } else if (util_is_abs_path( executable_input )) { /* If you have given an absolute path (i.e. starting with '/' to a non existing job we mark it as invalid - no possibility to provide context replacement afterwards. The job will be discarded by the calling scope. */ fprintf(stderr , "** Warning: the executable:%s can not be found,\n" - " job:%s will not be available.\n" , executable , ext_job->name ); + " job:%s will not be available.\n" , executable_abs , ext_job->name ); ext_job->__valid = false; } else { - /* Go through the PATH variable to try to locate the executable. */ - char * path_executable = util_alloc_PATH_executable( executable_raw ); - - if (path_executable != NULL) { - ext_job_set_executable( ext_job , path_executable, NULL ); - free( path_executable ); - } else { - /* We take the chance that user will supply a valid subst key for this later; - if the final executable is not an actually executable file when exporting the - job from ext_job_python_fprintf() a big warning will be written on stderr. - */ - fprintf(stderr , "** Warning: Unable to locate the executable %s for job %s.\n" - " Path to executable must be relative to the job description file, or an absolute path.\n" - " Please update job EXECUTABLE for job %s. \n" , executable , ext_job->name, ext_job->name); - ext_job->__valid = false; - } + if (search_path){ + /* Go through the PATH variable to try to locate the executable. */ + char * path_executable = util_alloc_PATH_executable( executable_input ); + + if (path_executable != NULL) { + ext_job_set_executable( ext_job , path_executable, NULL, search_path ); + free( path_executable ); + } else { + /* We take the chance that user will supply a valid subst key for this later; + if the final executable is not an actually executable file when exporting the + job from ext_job_python_fprintf() a big warning will be written on stderr. + */ + fprintf(stderr , "** Warning: Unable to locate the executable %s for job %s.\n" + " Path to executable must be relative to the job description file, or an absolute path.\n" + " Please update job EXECUTABLE for job %s. \n" , executable_abs , ext_job->name, ext_job->name); + ext_job->__valid = false; + } + } else { + ext_job->executable = util_realloc_string_copy(ext_job->executable , executable_input); + } } /* @@ -430,7 +436,7 @@ void ext_job_set_executable(ext_job_type * ext_job, const char * executable, con discard the job. */ if (ext_job->executable != NULL) { - if (util_file_exists(executable)) { + if (util_file_exists(executable_abs)) { if (!util_is_executable( ext_job->executable )) { fprintf(stderr , "** You do not have execute rights to:%s - job will not be available.\n" , ext_job->executable); ext_job->__valid = false; /* Mark the job as NOT successfully installed - the ext_job @@ -568,9 +574,9 @@ static char * __alloc_filtered_string( const char * src_string , const subst_lis free( tmp1 ); } else tmp2 = tmp1; - + return tmp2; - + } static void __fprintf_string(FILE * stream , const char * s , const subst_list_type * private_args, const subst_list_type * global_args) { @@ -579,12 +585,12 @@ static void __fprintf_string(FILE * stream , const char * s , const subst_list_t free( filtered_string ); } - + static void __fprintf_python_string(FILE * stream , const char * id , const char * value, const subst_list_type * private_args, const subst_list_type * global_args) { fprintf(stream , "\"%s\" : " , id); if (value == NULL) fprintf(stream,"None"); - else + else __fprintf_string(stream , value , private_args , global_args); } @@ -615,10 +621,10 @@ static void __fprintf_python_hash(FILE * stream , const char * id , hash_type * fprintf(stream,"\"%s\" : " , key); __fprintf_string(stream , value , private_args , global_args); - + if (counter < (hash_size - 1)) fprintf(stream,","); - + key = hash_iter_get_next_key(iter); } fprintf(stream,"}"); @@ -647,8 +653,8 @@ static void __indent(FILE * stream, int indent) { } -/* - This is special cased to support the default mapping. +/* + This is special cased to support the default mapping. */ static void ext_job_fprintf_python_argList( const ext_job_type * ext_job , FILE * stream , const subst_list_type * global_args) { @@ -659,11 +665,11 @@ static void ext_job_fprintf_python_argList( const ext_job_type * ext_job , FILE char * filtered_string = __alloc_filtered_string(src_string , ext_job->private_args , global_args ); if (hash_has_key( ext_job->default_mapping , filtered_string )) filtered_string = util_realloc_string_copy( filtered_string , hash_get( ext_job->default_mapping , filtered_string )); - + fprintf(stream , "\"%s\"" , filtered_string ); if (index < (stringlist_get_size( ext_job->argv) - 1)) fprintf(stream , "," ); - + free( filtered_string ); } } @@ -671,24 +677,8 @@ static void ext_job_fprintf_python_argList( const ext_job_type * ext_job , FILE } -static bool ext_job_check_executable( const ext_job_type * ext_job , const subst_list_type * global_args) { - bool OK = true; - char * executable; - executable = subst_list_alloc_filtered_string( ext_job->private_args , ext_job->executable ); - if (global_args != NULL) - subst_list_update_string( global_args , &executable ); - - if (!util_is_executable( executable )) - OK = false; - free( executable ); - return OK; -} - void ext_job_python_fprintf(const ext_job_type * ext_job, FILE * stream, const subst_list_type * global_args) { - if (!ext_job_check_executable( ext_job , global_args )) - fprintf(stderr," ** WARNING: The executable:%s could not be located on host computer - job will most probably fail.\n", ext_job->executable); - fprintf(stream," {"); { __indent(stream, 0); __fprintf_python_string(stream , "name" , ext_job->name , ext_job->private_args , NULL); __end_line(stream); @@ -699,7 +689,7 @@ void ext_job_python_fprintf(const ext_job_type * ext_job, FILE * stream, const s __indent(stream, 2); __fprintf_python_string(stream , "stdout" , ext_job->stdout_file , ext_job->private_args, global_args); __end_line(stream); __indent(stream, 2); __fprintf_python_string(stream , "stderr" , ext_job->stderr_file , ext_job->private_args, global_args); __end_line(stream); __indent(stream, 2); __fprintf_python_string(stream , "stdin" , ext_job->stdin_file , ext_job->private_args, global_args); __end_line(stream); - __indent(stream, 2); ext_job_fprintf_python_argList(ext_job , stream , global_args); __end_line(stream); + __indent(stream, 2); ext_job_fprintf_python_argList(ext_job , stream , global_args); __end_line(stream); __indent(stream, 2); __fprintf_python_hash(stream , "environment" , ext_job->environment , ext_job->private_args, global_args); __end_line(stream); __indent(stream, 2); __fprintf_python_string(stream , "license_path" , ext_job->license_path , ext_job->private_args, global_args); __end_line(stream); __indent(stream, 2); __fprintf_python_int( stream , "max_running_minutes" , ext_job->max_running_minutes ); __end_line(stream); @@ -715,8 +705,8 @@ if (value != NULL) \ fprintf(stream , "%16s ", key); \ fprintf(stream , "%s\n" , value); \ } - - + + #define PRINT_KEY_INT( stream , key , value ) \ if (value != 0) \ { \ @@ -776,7 +766,7 @@ void ext_job_fprintf(const ext_job_type * ext_job , FILE * stream) { } -/** +/** The format variable @fmt should contain two '%s' placeholders - one for the job name, and one for the job description file. */ @@ -790,16 +780,16 @@ void ext_job_fprintf_config(const ext_job_type * ext_job , const char * fmt , FI -ext_job_type * ext_job_fscanf_alloc(const char * name , const char * license_root_path , bool private_job , const char * config_file) { +ext_job_type * ext_job_fscanf_alloc(const char * name , const char * license_root_path , bool private_job , const char * config_file, bool search_path) { { mode_t target_mode = S_IRUSR + S_IWUSR + S_IRGRP + S_IWGRP + S_IROTH; /* u+rw g+rw o+r */ __update_mode( config_file , target_mode ); } - + if (util_entry_readable( config_file)) { ext_job_type * ext_job = ext_job_alloc(name , license_root_path , private_job); - config_type * config = config_alloc( ); - + config_parser_type * config = config_alloc( ); + ext_job_set_config_file( ext_job , config_file ); { config_schema_item_type * item; @@ -818,96 +808,101 @@ ext_job_type * ext_job_fscanf_alloc(const char * name , const char * license_roo } config_add_alias(config , "EXECUTABLE" , "PORTABLE_EXE"); - if (config_parse(config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true)) { - if (config_item_set(config , "STDIN")) ext_job_set_stdin_file(ext_job , config_iget(config , "STDIN" , 0,0)); - if (config_item_set(config , "STDOUT")) ext_job_set_stdout_file(ext_job , config_iget(config , "STDOUT" , 0,0)); - if (config_item_set(config , "STDERR")) ext_job_set_stderr_file(ext_job , config_iget(config , "STDERR" , 0,0)); - if (config_item_set(config , "ERROR_FILE")) ext_job_set_error_file(ext_job , config_iget(config , "ERROR_FILE" , 0,0)); - if (config_item_set(config , "TARGET_FILE")) ext_job_set_target_file(ext_job , config_iget(config , "TARGET_FILE" , 0,0)); - if (config_item_set(config , "START_FILE")) ext_job_set_start_file(ext_job , config_iget(config , "START_FILE" , 0,0)); - if (config_item_set(config , "MAX_RUNNING")) ext_job_set_max_running(ext_job , config_iget_as_int(config , "MAX_RUNNING" , 0,0)); - if (config_item_set(config , "MAX_RUNNING_MINUTES")) ext_job_set_max_time(ext_job , config_iget_as_int(config , "MAX_RUNNING_MINUTES" , 0,0)); - - - { - const char * executable = config_get_value_as_abspath(config , "EXECUTABLE"); - const char * executable_raw = config_iget(config , "EXECUTABLE" , 0,0); - ext_job_set_executable(ext_job , executable, executable_raw); - } + { + config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true); + if (config_content_is_valid( content )) { + if (config_content_has_item(content , "STDIN")) ext_job_set_stdin_file(ext_job , config_content_iget(content , "STDIN" , 0,0)); + if (config_content_has_item(content , "STDOUT")) ext_job_set_stdout_file(ext_job , config_content_iget(content , "STDOUT" , 0,0)); + if (config_content_has_item(content , "STDERR")) ext_job_set_stderr_file(ext_job , config_content_iget(content , "STDERR" , 0,0)); + if (config_content_has_item(content , "ERROR_FILE")) ext_job_set_error_file(ext_job , config_content_iget(content , "ERROR_FILE" , 0,0)); + if (config_content_has_item(content , "TARGET_FILE")) ext_job_set_target_file(ext_job , config_content_iget(content , "TARGET_FILE" , 0,0)); + if (config_content_has_item(content , "START_FILE")) ext_job_set_start_file(ext_job , config_content_iget(content , "START_FILE" , 0,0)); + if (config_content_has_item(content , "MAX_RUNNING")) ext_job_set_max_running(ext_job , config_content_iget_as_int(content , "MAX_RUNNING" , 0,0)); + if (config_content_has_item(content , "MAX_RUNNING_MINUTES")) ext_job_set_max_time(ext_job , config_content_iget_as_int(content , "MAX_RUNNING_MINUTES" , 0,0)); + + + { + const char * executable = config_content_get_value_as_abspath(content , "EXECUTABLE"); + const char * executable_raw = config_content_iget(content , "EXECUTABLE" , 0,0); + ext_job_set_executable(ext_job , executable, executable_raw, search_path); + } - { - config_content_node_type * arg_node = config_get_value_node( config , "ARGLIST"); - if (arg_node != NULL) { - int i; - for (i=0; i < config_content_node_get_size( arg_node ); i++) - stringlist_append_copy( ext_job->argv , config_content_node_iget( arg_node , i )); + { + if (config_content_has_item( content , "ARGLIST")) { + config_content_node_type * arg_node = config_content_get_value_node( content , "ARGLIST"); + int i; + for (i=0; i < config_content_node_get_size( arg_node ); i++) + stringlist_append_copy( ext_job->argv , config_content_node_iget( arg_node , i )); + } } - } - - /** - The code assumes that the hash tables are valid, can not be NULL: - */ - { - const config_content_item_type * env_item = config_get_content_item( config , "ENV" ); - if (env_item != NULL) { - for (int ivar = 0; ivar < config_content_item_get_size( env_item ); ivar++) { - const config_content_node_type * env_node = config_content_item_iget_node( env_item , ivar ); - for (int i=0; i < config_content_node_get_size( env_node ); i+= 2) { - const char * key = config_content_node_iget( env_node , i ); - const char * value = config_content_node_iget( env_node , i + 1); - hash_insert_hash_owned_ref( ext_job->environment, key , util_alloc_string_copy( value ) , free); + + /** + The code assumes that the hash tables are valid, can not be NULL: + */ + { + if (config_content_has_item( content , "ENV")) { + const config_content_item_type * env_item = config_content_get_item( content , "ENV" ); + for (int ivar = 0; ivar < config_content_item_get_size( env_item ); ivar++) { + const config_content_node_type * env_node = config_content_item_iget_node( env_item , ivar ); + for (int i=0; i < config_content_node_get_size( env_node ); i+= 2) { + const char * key = config_content_node_iget( env_node , i ); + const char * value = config_content_node_iget( env_node , i + 1); + hash_insert_hash_owned_ref( ext_job->environment, key , util_alloc_string_copy( value ) , free); + } } } } - } - - /* Default mappings; these are used to set values in the argList - which have not been supplied by the calling context. */ - { - const config_content_item_type * default_item = config_get_content_item( config , "DEFAULT"); - if (default_item != NULL) { - for (int ivar = 0; ivar < config_content_item_get_size( default_item ); ivar++) { - const config_content_node_type * default_node = config_content_item_iget_node( default_item , ivar ); - for (int i=0; i < config_content_node_get_size( default_node ); i+= 2) { - const char * key = config_content_node_iget( default_node , i ); - const char * value = config_content_node_iget( default_node , i + 1); - hash_insert_hash_owned_ref( ext_job->default_mapping, key , util_alloc_string_copy( value ) , free); + + /* Default mappings; these are used to set values in the argList + which have not been supplied by the calling context. */ + { + if (config_content_has_item( content , "DEFAULT")) { + const config_content_item_type * default_item = config_content_get_item( content , "DEFAULT"); + for (int ivar = 0; ivar < config_content_item_get_size( default_item ); ivar++) { + const config_content_node_type * default_node = config_content_item_iget_node( default_item , ivar ); + for (int i=0; i < config_content_node_get_size( default_node ); i+= 2) { + const char * key = config_content_node_iget( default_node , i ); + const char * value = config_content_node_iget( default_node , i + 1); + hash_insert_hash_owned_ref( ext_job->default_mapping, key , util_alloc_string_copy( value ) , free); + } } } } + } else { + config_error_type * error = config_content_get_errors( content ); + config_error_fprintf( error , true , stderr ); + exit(1); } - } else { - config_fprintf_errors( config , true , stderr ); - exit(1); + config_content_free( content ); } config_free(config); - + if (!ext_job->__valid) { - /* + /* Something NOT OK (i.e. EXECUTABLE now); free the job instance and return NULL: */ ext_job_free( ext_job ); ext_job = NULL; fprintf(stderr,"** Warning: job: \'%s\' not available ... \n", name ); } - + return ext_job; } else { fprintf(stderr,"** Warning: you do not have permission to read file:\'%s\' - job:%s not available. \n", config_file , name); return NULL; } } - - + + const stringlist_type * ext_job_get_arglist( const ext_job_type * ext_job ) { return ext_job->argv; } /** - + */ //const char * ext_job_get_arglist_as_string( ext_job_type * ext_job ) { @@ -929,19 +924,19 @@ const stringlist_type * ext_job_get_arglist( const ext_job_type * ext_job ) { // buffer_fwrite_char_ptr( buffer , arg ); // if (quote) // buffer_fwrite_char( buffer , ' ' ); -// +// // if (i < (argc - 1)) // buffer_fwrite_char_ptr( buffer , sep ); -// +// // buffer_fwrite_char( buffer , '\0'); // util_safe_free(ext_job->argv_string); // ext_job->argv_string = buffer_alloc_data_copy( buffer ); // buffer_free( buffer ); -// +// // return ext_job->argv_string; // } //} -// +// // //void ext_job_set_arglist_from_string( ext_job_type * ext_job , const char * argv_string ) { // parser_type * parser = parser_alloc(" " , "\"" , NULL , NULL , NULL , NULL ); diff --git a/ThirdParty/Ert/devel/libjob_queue/src/ext_joblist.c b/ThirdParty/Ert/devel/libjob_queue/src/ext_joblist.c index a898a9d2e4..b14464bfb5 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/ext_joblist.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/ext_joblist.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ext_joblist.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ext_joblist.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -54,13 +54,13 @@ shutdown can just be removed. 2. For each job in the joblist a subdirectory is created under the - license_path. + license_path. 3. For each job a license_file is created, and for each time a new instance is checked out a hard_link to this license_file is created - i.e. the number of checked out licenses is a - hard_link count (-1). - + hard_link count (-1). + Step three here is implemented by the job_dispatch script actually running the jobs. @@ -84,7 +84,7 @@ struct ext_joblist_struct { ext_joblist_type * ext_joblist_alloc( ) { ext_joblist_type * joblist = util_malloc( sizeof * joblist ); joblist->jobs = hash_alloc(); - return joblist; + return joblist; } @@ -110,7 +110,7 @@ ext_job_type * ext_joblist_get_job(const ext_joblist_type * joblist , const char ext_job_type * ext_joblist_get_job_copy(const ext_joblist_type * joblist , const char * job_name) { - if (hash_has_key(joblist->jobs , job_name)) + if (hash_has_key(joblist->jobs , job_name)) return ext_job_alloc_copy(hash_get(joblist->jobs , job_name)); else { util_abort("%s: asked for job:%s which does not exist\n",__func__ , job_name); @@ -152,7 +152,7 @@ hash_type * ext_joblist_get_jobs( const ext_joblist_type * joblist ) { return joblist->jobs; } -void ext_joblist_add_jobs_in_directory(ext_joblist_type * joblist , const char * path, const char * license_root_path, bool user_mode ) { +void ext_joblist_add_jobs_in_directory(ext_joblist_type * joblist , const char * path, const char * license_root_path, bool user_mode, bool search_path ) { DIR * dirH = opendir( path ); if (dirH) { while (true) { @@ -161,7 +161,7 @@ void ext_joblist_add_jobs_in_directory(ext_joblist_type * joblist , const char if ((strcmp(entry->d_name , ".") != 0) && (strcmp(entry->d_name , "..") != 0)) { char * full_path = util_alloc_filename( path , entry->d_name , NULL ); if (util_is_file( full_path )) { - ext_job_type * new_job = ext_job_fscanf_alloc(entry->d_name, license_root_path, user_mode, full_path); + ext_job_type * new_job = ext_job_fscanf_alloc(entry->d_name, license_root_path, user_mode, full_path, search_path); if (new_job != NULL) { ext_joblist_add_job(joblist, entry->d_name, new_job); } diff --git a/ThirdParty/Ert/devel/libjob_queue/src/forward_model.c b/ThirdParty/Ert/devel/libjob_queue/src/forward_model.c index 223ee539ee..1db77f4d63 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/forward_model.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/forward_model.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'forward_model.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'forward_model.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -23,7 +23,7 @@ #include <ert/util/util.h> #include <ert/util/subst_list.h> -#include <ert/util/vector.h> +#include <ert/util/vector.h> #include <ert/util/parser.h> #include <ert/job_queue/ext_job.h> @@ -47,7 +47,7 @@ struct forward_model_struct { forward_model_type * forward_model_alloc(const ext_joblist_type * ext_joblist) { forward_model_type * forward_model = util_malloc( sizeof * forward_model ); - + forward_model->jobs = vector_alloc_new(); forward_model->ext_joblist = ext_joblist; @@ -66,7 +66,7 @@ stringlist_type * forward_model_alloc_joblist( const forward_model_type * forwar const ext_job_type * job = vector_iget_const( forward_model->jobs , i); stringlist_append_ref( names , ext_job_get_name( job )); } - + return names; } @@ -88,7 +88,7 @@ ext_job_type * forward_model_add_job(forward_model_type * forward_model , const /** This function is used to set private argument values to jobs in the forward model (i.e. the argument values passed in with KEY=VALUE - pairs in the defining (). + pairs in the defining (). The use of 'index' to get the job is unfortunate , however one forward model can contain several instances of the same job, it is @@ -97,7 +97,7 @@ ext_job_type * forward_model_add_job(forward_model_type * forward_model , const void forward_model_iset_job_arg( forward_model_type * forward_model , int job_index , const char * arg , const char * value) { ext_job_type * job = vector_iget( forward_model->jobs , job_index ); - ext_job_set_private_arg(job , arg , value); + ext_job_set_private_arg(job , arg , value); } @@ -121,7 +121,7 @@ void forward_model_free( forward_model_type * forward_model) { job1 job2 job3(arg1 = value1, arg2 = value2, arg3= value3) and creates a forward model of it. observe the following rules: - + * if the function takes private arguments it is not allowed with space between the end of the function name and the opening parenthesis. @@ -138,7 +138,7 @@ void forward_model_parse_init(forward_model_type * forward_model , const char * while (true) { ext_job_type * current_job; char * job_name; - int job_index; + int job_index; { int job_length = strcspn(p1 , " ("); /* scanning until we meet ' ' or '(' */ job_name = util_alloc_substring_copy(p1 , 0 , job_length); @@ -156,28 +156,28 @@ void forward_model_parse_init(forward_model_type * forward_model , const char * ext_job_set_private_args_from_string( current_job , arg_string ); p1 += (1 + arg_length); } - } + } /*****************************************************************/ /* At this point we are done with the parsing - the rest of the code in this while { } construct is only to check that the - input is well formed. */ + input is well formed. */ { int space_length = strspn(p1 , " "); p1 += space_length; - if (*p1 == '(') + if (*p1 == '(') /* detected lonesome '(' */ util_abort("%s: found space between job:%s and \'(\' - aborting \n",__func__ , job_name); } - /* - now p1 should point at the next character after the job, + /* + now p1 should point at the next character after the job, or after the ')' if the job has arguments. */ - + if (*p1 == '\0') { /* we have parsed the whole string. */ free(job_name); - break; + break; } } } @@ -208,8 +208,8 @@ void forward_model_python_fprintf(const forward_model_type * forward_model , con free(module_file); } -#undef DEFAULT_JOB_MODULE -#undef DEFAULT_JOBLIST_NAME +#undef DEFAULT_JOB_MODULE +#undef DEFAULT_JOBLIST_NAME @@ -223,7 +223,7 @@ forward_model_type * forward_model_alloc_copy(const forward_model_type * forward const ext_job_type * job = vector_iget_const( forward_model->jobs , ijob); vector_append_owned_ref( new->jobs , ext_job_alloc_copy( job ) , ext_job_free__); } - + return new; } diff --git a/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c b/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c index 4b4b1f922f..78cbce65ff 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'job_queue.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'job_queue.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ @@ -42,14 +42,14 @@ 'driver' which actually runs the job. All drivers must support the following functions - submit: This will submit a job, and return a pointer to a + submit: This will submit a job, and return a pointer to a newly allocated queue_job instance. clean: This will clear up all resources used by the job. abort: This will stop the job, and then call clean. - status: This will get the status of the job. + status: This will get the status of the job. When calling the various driver functions the queue layer needs to @@ -59,7 +59,7 @@ When implementing a driver the driver struct MUST start like this: - + struct some_driver { UTIL_TYPE_ID_DECLARATION QUEUE_DRIVER_FUNCTIONS @@ -74,8 +74,8 @@ struct queue_driver_struct { UTIL_TYPE_ID_DECLARATION QUEUE_DRIVER_FIELDS - } - + } + I.e. it only contains the pointers common to all the driver implementations. When calling a driver function the spesific driver will cast to it's datatype. @@ -102,11 +102,11 @@ default 'owner' of the information in the job_queue instance. 2. External scope can: - + o Query the status of the queue / individual jobs. [Read access] o Issue commands to make the queue resubmit/kill/wait/... [Write access] - + Observe that there can be maaany concurrent invokations of the second type. Data structures which can change must obviously be protected with read/write locking, however scalars are NOT protected, i.e the two code blocks: @@ -117,7 +117,7 @@ ... and - + ... return state; @@ -136,7 +136,7 @@ The status of a particular job is given by the job_status field of the job_queue_node_type, the possible values are given by the enum job_status_type, defined in queue_driver.h. - + To actually __GET__ the status of a job we use the driver->status() function which will invoke a driver specific function and return the new status. @@ -160,13 +160,13 @@ This might result in external scope getting a outdated status - live with it. - + 4. The name 'status' indicates that this is read-only property; that is actually not the case. In the main manager function job_queue_run_jobs() action is taken based on the value of the status field, and to initiate certain action on jobs the queue system (and also external scope) can explicitly set the status - of a job (by using the job_queue_change_node_status() function). + of a job (by using the job_queue_change_node_status() function). The most promiment example of this is when we want to run a certain job again, that is achieved with: @@ -202,7 +202,7 @@ capture the exit status of the external programs. - The approach to this is as follows: + The approach to this is as follows: 1. If the job (i.e. the job script) finishes with a failure status we communicate the failure back to the calling scope with no @@ -215,7 +215,7 @@ a) If the job has produced an EXIT file it has failed. b) If the job has produced an OK file it has succeeded. - + c) If neither EXIT nor OK files have been produced we spin for a while waiting for one of the files, if none turn up we will eventually mark the job as failed. @@ -224,9 +224,9 @@ -typedef enum {SUBMIT_OK = 0 , +typedef enum {SUBMIT_OK = 0 , SUBMIT_JOB_FAIL = 1 , /* Typically no more attempts. */ - SUBMIT_DRIVER_FAIL = 2 , /* The driver would not take the job - for whatever reason?? */ + SUBMIT_DRIVER_FAIL = 2 , /* The driver would not take the job - for whatever reason?? */ SUBMIT_QUEUE_CLOSED = 3 } /* The queue is currently not accepting more jobs - either (temporarilty) because of pause or it is going down. */ submit_status_type; @@ -247,7 +247,7 @@ typedef enum {SUBMIT_OK = 0 , 3. If the driver detects that a job has failed it leaves an EXIT file, the exit status is (currently) not reliably transferred back to to the job_queue layer. - + */ struct job_queue_node_struct { @@ -266,43 +266,43 @@ struct job_queue_node_struct { char *stderr_file; /* Name of the file containing stderr information. */ /*-----------------------------------------------------------------*/ void *job_data; /* Driver specific data about this job - fully handled by the driver. */ - int argc; /* The number of commandline arguments to pass when starting the job. */ + int argc; /* The number of commandline arguments to pass when starting the job. */ char **argv; /* The commandline arguments. */ time_t submit_time; /* When was the job added to job_queue - the FIRST TIME. */ time_t sim_start; /* When did the job change status -> RUNNING - the LAST TIME. */ time_t sim_end ; /* When did the job finish successfully */ - pthread_rwlock_t job_lock; /* This lock provides read/write locking of the job_data field. */ + pthread_rwlock_t job_lock; /* This lock provides read/write locking of the job_data field. */ job_callback_ftype *done_callback; job_callback_ftype *retry_callback; /* To determine if job can be retried */ job_callback_ftype *exit_callback; /* Callback to perform any cleanup */ void *callback_arg; }; -static const int status_index[] = { JOB_QUEUE_NOT_ACTIVE , // Initial, allocated job state, job not added - controlled by job_queue +static const int status_index[] = { JOB_QUEUE_NOT_ACTIVE , // Initial, allocated job state, job not added - controlled by job_queue JOB_QUEUE_WAITING , // The job is ready to be started - controlled by job_queue JOB_QUEUE_SUBMITTED , // Job is submitted to driver - temporary state - controlled by job_queue JOB_QUEUE_PENDING , // Job is pending, before actual execution - controlled by queue_driver JOB_QUEUE_RUNNING , // Job is executing - controlled by queue_driver - JOB_QUEUE_DONE , // Job is done (sucessful or not), temporary state - controlled/returned by by queue_driver - JOB_QUEUE_EXIT , // Job is done, with exit status != 0, temporary state - controlled/returned by by queue_driver + JOB_QUEUE_DONE , // Job is done (sucessful or not), temporary state - controlled/returned by by queue_driver + JOB_QUEUE_EXIT , // Job is done, with exit status != 0, temporary state - controlled/returned by by queue_driver JOB_QUEUE_USER_EXIT , // User / queue system has requested killing of job - controlled by job_queue / external scope - JOB_QUEUE_USER_KILLED, // Job has been killed, due to JOB_QUEUE_USER_EXIT, FINAL STATE - controlled by job_queue + JOB_QUEUE_USER_KILLED, // Job has been killed, due to JOB_QUEUE_USER_EXIT, FINAL STATE - controlled by job_queue JOB_QUEUE_SUCCESS , // All good, comes after JOB_QUEUE_DONE, with additional checks, FINAL STATE - controlled by job_queue - JOB_QUEUE_RUNNING_CALLBACK, // Temporary state, while running requested callbacks after an ended job - controlled by job_queue - JOB_QUEUE_FAILED }; // Job has failed, no more retries, FINAL STATE + JOB_QUEUE_RUNNING_CALLBACK, // Temporary state, while running requested callbacks after an ended job - controlled by job_queue + JOB_QUEUE_FAILED }; // Job has failed, no more retries, FINAL STATE -static const char* status_name[] = { "JOB_QUEUE_NOT_ACTIVE" , - "JOB_QUEUE_WAITING" , - "JOB_QUEUE_SUBMITTED" , - "JOB_QUEUE_PENDING" , - "JOB_QUEUE_RUNNING" , - "JOB_QUEUE_DONE" , - "JOB_QUEUE_EXIT" , - "JOB_QUEUE_USER_KILLED" , - "JOB_QUEUE_USER_EXIT" , - "JOB_QUEUE_SUCCESS" , - "JOB_QUEUE_RUNNING_CALLBACK", - "JOB_QUEUE_FAILED" }; +static const char* status_name[] = { "JOB_QUEUE_NOT_ACTIVE" , + "JOB_QUEUE_WAITING" , + "JOB_QUEUE_SUBMITTED" , + "JOB_QUEUE_PENDING" , + "JOB_QUEUE_RUNNING" , + "JOB_QUEUE_DONE" , + "JOB_QUEUE_EXIT" , + "JOB_QUEUE_USER_KILLED" , + "JOB_QUEUE_USER_EXIT" , + "JOB_QUEUE_SUCCESS" , + "JOB_QUEUE_RUNNING_CALLBACK", + "JOB_QUEUE_FAILED" }; @@ -310,9 +310,9 @@ static const char* status_name[] = { "JOB_QUEUE_NOT_ACTIVE" , /** - + This is the struct for a whole queue. Observe the following: - + 1. The number of elements is specified at the allocation time, and all nodes are allocated then; i.e. when xx_insert_job() is called from external scope a new node is not actaully created @@ -333,7 +333,7 @@ struct job_queue_struct { int status_list[JOB_QUEUE_MAX_STATE]; /* The number of jobs in the different states. */ int old_status_list[JOB_QUEUE_MAX_STATE]; /* Should the display be updated ?? */ bool open; /* True if the queue has been reset and is ready for use, false if the queue has been used and not reset */ - bool user_exit; /* If there comes an external signal to abondond the whole thing user_exit will be set to true, and things start to dwindle down. */ + bool user_exit; /* If there comes an external signal to abondond the whole thing user_exit will be set to true, and things start to dwindle down. */ bool running; bool pause_on; bool submit_complete; @@ -358,9 +358,9 @@ static void job_queue_grow( job_queue_type * queue ); static int STATUS_INDEX( job_status_type status ) { int index = 0; - + while (true) { - if (status_index[index] == status) + if (status_index[index] == status) return index; index++; @@ -391,7 +391,7 @@ static int STATUS_INDEX( job_status_type status ) { file in the runpath directory; this function will inspect the EXIT file and determine which job has failed, the reason the job script has given to fail the job (typically missing TARGET_FILE) and - capture the stderr from the job. + capture the stderr from the job. The file is XML formatted: @@ -403,7 +403,7 @@ static int STATUS_INDEX( job_status_type status ) { <stderr> Capture of stderr from the job, can typically be a multiline string. - </stderr> + </stderr> </error> ------------------------------------------------ @@ -411,15 +411,15 @@ static int STATUS_INDEX( job_status_type status ) { job_dispatch.py script. */ -/* +/* This extremely half-assed XML "parsing" should of course be kept a - secret... + secret... */ static char * __alloc_tag_content( const char * xml_buffer , const char * tag) { char * open_tag = util_alloc_sprintf("<%s>" , tag); char * close_tag = util_alloc_sprintf("</%s>" , tag); - + char * start_ptr = strstr( xml_buffer , open_tag ); char * end_ptr = strstr( xml_buffer , close_tag ); char * tag_content = NULL; @@ -427,10 +427,10 @@ static char * __alloc_tag_content( const char * xml_buffer , const char * tag) { if ((start_ptr != NULL) && (end_ptr != NULL)) { int length; start_ptr += strlen(open_tag); - + length = end_ptr - start_ptr; tag_content = util_alloc_substring_copy( start_ptr , 0 , length ); - } + } free( open_tag ); free( close_tag ); @@ -439,10 +439,10 @@ static char * __alloc_tag_content( const char * xml_buffer , const char * tag) { static void job_queue_node_free_error_info( job_queue_node_type * node ) { - util_safe_free(node->error_reason); - util_safe_free(node->stderr_capture); - util_safe_free(node->stderr_file); - util_safe_free(node->failed_job); + util_safe_free(node->error_reason); + util_safe_free(node->stderr_capture); + util_safe_free(node->stderr_file); + util_safe_free(node->failed_job); } @@ -450,7 +450,7 @@ static void job_queue_node_free_error_info( job_queue_node_type * node ) { /** This code is meant to capture which of the jobs has failed; why it has failed and the stderr stream of the failing job. Depending on - the failure circumstances the EXIT file might not be around. + the failure circumstances the EXIT file might not be around. */ static void job_queue_node_fscanf_EXIT( job_queue_node_type * node ) { @@ -458,12 +458,12 @@ static void job_queue_node_fscanf_EXIT( job_queue_node_type * node ) { if (node->exit_file) { if (util_file_exists( node->exit_file )) { char * xml_buffer = util_fread_alloc_file_content( node->exit_file, NULL); - + node->failed_job = __alloc_tag_content( xml_buffer , "job" ); node->error_reason = __alloc_tag_content( xml_buffer , "reason" ); node->stderr_capture = __alloc_tag_content( xml_buffer , "stderr"); node->stderr_file = __alloc_tag_content( xml_buffer , "stderr_file"); - + free( xml_buffer ); } else node->failed_job = util_alloc_sprintf("EXIT file:%s not found - load failure?" , node->exit_file); @@ -475,8 +475,8 @@ static void job_queue_node_fscanf_EXIT( job_queue_node_type * node ) { static void job_queue_node_clear_error_info(job_queue_node_type * node) { node->failed_job = NULL; node->error_reason = NULL; - node->stderr_capture = NULL; - node->stderr_file = NULL; + node->stderr_capture = NULL; + node->stderr_file = NULL; node->run_path = NULL; } @@ -497,13 +497,13 @@ static void job_queue_node_clear(job_queue_node_type * node) { node->done_callback = NULL; node->callback_arg = NULL; node->sim_start = 0; - node->sim_end = 0; + node->sim_end = 0; } static job_queue_node_type * job_queue_node_alloc( ) { job_queue_node_type * node = util_malloc(sizeof * node ); - + job_queue_node_clear(node); job_queue_node_clear_error_info(node); pthread_rwlock_init( &node->job_lock , NULL); @@ -517,19 +517,19 @@ static job_queue_node_type * job_queue_node_alloc( ) { completely, so that calling scope can ask for it - that is the reason there are separate free() and clear functions for the error related fields. */ - + static void job_queue_node_free_data(job_queue_node_type * node) { - util_safe_free( node->job_name ); - util_safe_free( node->exit_file ); - util_safe_free( node->ok_file ); - util_safe_free( node->run_cmd ); + util_safe_free( node->job_name ); + util_safe_free( node->exit_file ); + util_safe_free( node->ok_file ); + util_safe_free( node->run_cmd ); util_free_stringlist( node->argv , node->argc ); if (node->callback_arg) { arg_pack_free( node->callback_arg ); node->callback_arg = NULL; } - if (node->job_data != NULL) + if (node->job_data != NULL) util_abort("%s: internal error - driver spesific job data has not been freed - will leak.\n",__func__); } @@ -537,7 +537,7 @@ static void job_queue_node_free_data(job_queue_node_type * node) { static void job_queue_node_free(job_queue_node_type * node) { job_queue_node_free_data(node); job_queue_node_free_error_info(node); - util_safe_free(node->run_path); + util_safe_free(node->run_path); free(node); } @@ -561,19 +561,19 @@ static void job_queue_node_finalize(job_queue_node_type * node) { static bool job_queue_change_node_status(job_queue_type * , job_queue_node_type * , job_status_type ); -static void job_queue_initialize_node(job_queue_type * queue , - const char * run_cmd , - job_callback_ftype * done_callback, +static void job_queue_initialize_node(job_queue_type * queue , + const char * run_cmd , + job_callback_ftype * done_callback, job_callback_ftype * retry_callback, - job_callback_ftype * exit_callback, - void * callback_arg , - int num_cpu , - const char * run_path , - const char * job_name , - int job_index , - int argc , + job_callback_ftype * exit_callback, + void * callback_arg , + int num_cpu , + const char * run_path , + const char * job_name , + int job_index , + int argc , const char ** argv) { - + job_queue_node_type * node = queue->jobs[job_index]; node->submit_attempt = 0; node->num_cpu = num_cpu; @@ -583,12 +583,12 @@ static void job_queue_initialize_node(job_queue_type * queue , node->argv = util_alloc_stringlist_copy( argv , argc ); util_safe_free(node->run_path); // Might have a value from previous run. - if (util_is_abs_path(run_path)) + if (util_is_abs_path(run_path)) node->run_path = util_alloc_string_copy( run_path ); else node->run_path = util_alloc_realpath( run_path ); - - if ( !util_is_directory(node->run_path) ) + + if ( !util_is_directory(node->run_path) ) util_abort("%s: the run_path: %s does not exist - aborting \n",__func__ , node->run_path); if (queue->exit_file != NULL) @@ -602,18 +602,18 @@ static void job_queue_initialize_node(job_queue_type * queue , node->done_callback = done_callback; node->callback_arg = callback_arg; node->sim_start = 0; - node->sim_end = 0; + node->sim_end = 0; node->submit_time = time( NULL ); /* Now the job is ready to be picked by the queue manager. */ - job_queue_change_node_status(queue , node , JOB_QUEUE_WAITING); + job_queue_change_node_status(queue , node , JOB_QUEUE_WAITING); } static void job_queue_assert_queue_index(const job_queue_type * queue , int queue_index) { - if (queue_index < 0 || queue_index >= queue->active_size) + if (queue_index < 0 || queue_index >= queue->active_size) util_abort("%s: invalid queue_index - internal error - aborting \n",__func__); } @@ -637,18 +637,18 @@ static bool job_queue_change_node_status(job_queue_type * queue , job_queue_node pthread_mutex_lock( &queue->status_mutex ); { job_status_type old_status = job_queue_node_get_status( node ); - + if (new_status != old_status) { node->job_status = new_status; queue->status_list[ STATUS_INDEX(old_status) ]--; queue->status_list[ STATUS_INDEX(new_status) ]++; - - if (new_status == JOB_QUEUE_RUNNING) + + if (new_status == JOB_QUEUE_RUNNING) node->sim_start = time( NULL ); - + if (new_status == JOB_QUEUE_SUCCESS) - node->sim_end = time( NULL ); - + node->sim_end = time( NULL ); + status_change = true; if (new_status == JOB_QUEUE_FAILED) @@ -661,9 +661,9 @@ static bool job_queue_change_node_status(job_queue_type * queue , job_queue_node -/* +/* This frees the storage allocated by the driver - the storage - allocated by the queue layer is retained. + allocated by the queue layer is retained. In the case of jobs which are first marked as successfull by the queue layer, and then subsequently set to status EXIT by the @@ -674,7 +674,7 @@ static bool job_queue_change_node_status(job_queue_type * queue , job_queue_node static void job_queue_free_job_driver_data(job_queue_type * queue , job_queue_node_type * node) { pthread_rwlock_wrlock( &node->job_lock ); { - if (node->job_data != NULL) + if (node->job_data != NULL) queue_driver_free_job( queue->driver , node->job_data ); node->job_data = NULL; } @@ -685,15 +685,15 @@ static void job_queue_free_job_driver_data(job_queue_type * queue , job_queue_no /** Observe that this function should only query the driver for state - change when the job is currently in one of the states: + change when the job is currently in one of the states: - JOB_QUEUE_WAITING || JOB_QUEUE_PENDING || JOB_QUEUE_RUNNING + JOB_QUEUE_WAITING || JOB_QUEUE_PENDING || JOB_QUEUE_RUNNING The other state transitions are handled by the job_queue itself, without consulting the driver functions. */ -/* +/* Will return true if the status has changed since the last time. */ @@ -702,7 +702,7 @@ static bool job_queue_update_status(job_queue_type * queue ) { queue_driver_type *driver = queue->driver; int ijob; - + for (ijob = 0; ijob < queue->active_size; ijob++) { job_queue_node_type * node = queue->jobs[ijob]; @@ -718,12 +718,12 @@ static bool job_queue_update_status(job_queue_type * queue ) { } pthread_rwlock_unlock( &node->job_lock ); } - + /* Has the net status changed? */ { int istat; for (istat = 0; istat < JOB_QUEUE_MAX_STATE; istat++) { - if (queue->old_status_list[istat] != queue->status_list[istat]) + if (queue->old_status_list[istat] != queue->status_list[istat]) update = true; queue->old_status_list[istat] = queue->status_list[istat]; } @@ -741,22 +741,22 @@ static submit_status_type job_queue_submit_job(job_queue_type * queue , int queu job_queue_assert_queue_index(queue , queue_index); { job_queue_node_type * node = queue->jobs[queue_index]; - void * job_data = queue_driver_submit_job( queue->driver , - node->run_cmd , - node->num_cpu , - node->run_path , - node->job_name , - node->argc , + void * job_data = queue_driver_submit_job( queue->driver , + node->run_cmd , + node->num_cpu , + node->run_path , + node->job_name , + node->argc , (const char **) node->argv ); - + if (job_data != NULL) { pthread_rwlock_wrlock( &node->job_lock ); { node->job_data = job_data; node->submit_attempt++; - job_queue_change_node_status(queue , node , JOB_QUEUE_SUBMITTED ); + job_queue_change_node_status(queue , node , JOB_QUEUE_SUBMITTED ); submit_status = SUBMIT_OK; - /* + /* The status JOB_QUEUE_SUBMITTED is internal, and not exported anywhere. The job_queue_update_status() will update this to PENDING or RUNNING at the next call. The important difference between SUBMITTED and WAITING is that SUBMITTED have job_data != NULL and the job_queue_node free function must be called on it. @@ -764,6 +764,11 @@ static submit_status_type job_queue_submit_job(job_queue_type * queue , int queu } pthread_rwlock_unlock( &node->job_lock ); } else + /* + In this case the status of the job itself will be + unmodified; i.e. it will still be WAITING, and a new attempt + to submit it will be performed in the next round. + */ submit_status = SUBMIT_DRIVER_FAIL; } } @@ -863,20 +868,20 @@ int job_queue_get_active_size( const job_queue_type * queue ) { return queue->active_size; } -void job_queue_set_max_job_duration(job_queue_type * queue, int max_duration_seconds) { +void job_queue_set_max_job_duration(job_queue_type * queue, int max_duration_seconds) { queue->max_duration = max_duration_seconds; } int job_queue_get_max_job_duration(const job_queue_type * queue) { - return queue->max_duration; + return queue->max_duration; } void job_queue_set_job_stop_time(job_queue_type * queue, time_t time) { - queue->stop_time = time; -} + queue->stop_time = time; +} time_t job_queue_get_job_stop_time(const job_queue_type * queue) { - return queue->stop_time; + return queue->stop_time; } void job_queue_set_auto_job_stop_time(job_queue_type * queue) { @@ -885,14 +890,14 @@ void job_queue_set_auto_job_stop_time(job_queue_type * queue) { for (int i = 0; i < queue->active_size; ++i) { if (JOB_QUEUE_SUCCESS == job_queue_iget_job_status(queue,i)) { sum_run_time_succeded_jobs += difftime(job_queue_iget_sim_end(queue, i), job_queue_iget_sim_start(queue, i)); - ++num_succeded_jobs; + ++num_succeded_jobs; } } - + if (num_succeded_jobs > 0) { time_t avg_run_time_succeded_jobs = sum_run_time_succeded_jobs / num_succeded_jobs; time_t stop_time = time(NULL) + (avg_run_time_succeded_jobs * 0.25); - job_queue_set_job_stop_time(queue, stop_time); + job_queue_set_job_stop_time(queue, stop_time); } } @@ -916,17 +921,17 @@ void job_queue_set_auto_job_stop_time(job_queue_type * queue) { */ bool job_queue_kill_job_node( job_queue_type * queue , job_queue_node_type * node) { bool result = false; - + pthread_rwlock_wrlock( &node->job_lock ); { if (node->job_status & JOB_QUEUE_CAN_KILL) { queue_driver_type * driver = queue->driver; - /* + /* Jobs with status JOB_QUEUE_WAITING are killable - in the sense that status should be set to JOB_QUEUE_USER_KILLED; but they do not have any driver specific job_data, and the driver->kill_job() function can NOT be called. */ - if (node->job_status != JOB_QUEUE_WAITING) { + if (node->job_status != JOB_QUEUE_WAITING) { queue_driver_kill_job( driver , node->job_data ); queue_driver_free_job( driver , node->job_data ); node->job_data = NULL; @@ -951,7 +956,7 @@ bool job_queue_kill_job( job_queue_type * queue , int job_index) { in combination with resampling, however that is the responsability of the calling scope. */ - + void job_queue_iset_external_restart(job_queue_type * queue , int job_index) { job_queue_node_type * node = queue->jobs[job_index]; node->submit_attempt = 0; @@ -965,7 +970,7 @@ void job_queue_iset_external_restart(job_queue_type * queue , int job_index) { function to inform the queue system that the job has indeed failed. The queue system will then either retry the job, or switch status to JOB_QUEUE_RUN_FAIL. - + This is a bit dangerous beacuse the queue system has said that the job was all hunkadory, and freed the driver related resources @@ -989,7 +994,7 @@ time_t job_queue_iget_sim_start( job_queue_type * queue, int job_index) { time_t job_queue_iget_sim_end( job_queue_type * queue, int job_index) { job_queue_node_type * node = queue->jobs[job_index]; return node->sim_end; -} +} time_t job_queue_iget_submit_time( job_queue_type * queue, int job_index) { job_queue_node_type * node = queue->jobs[job_index]; @@ -1018,16 +1023,16 @@ static void job_queue_print_summary(const job_queue_type *queue, bool status_cha { int waiting = queue->status_list[ STATUS_INDEX(JOB_QUEUE_WAITING) ]; int pending = queue->status_list[ STATUS_INDEX(JOB_QUEUE_PENDING) ]; - - /* + + /* EXIT and DONE are included in "xxx_running", because the target file has not yet been checked. */ int running = queue->status_list[ STATUS_INDEX(JOB_QUEUE_RUNNING) ] + queue->status_list[ STATUS_INDEX(JOB_QUEUE_DONE) ] + queue->status_list[ STATUS_INDEX(JOB_QUEUE_EXIT) ]; int complete = queue->status_list[ STATUS_INDEX(JOB_QUEUE_SUCCESS) ]; int failed = queue->status_list[ STATUS_INDEX(JOB_QUEUE_FAILED) ]; - int loading = queue->status_list[ STATUS_INDEX(JOB_QUEUE_RUNNING_CALLBACK) ]; - + int loading = queue->status_list[ STATUS_INDEX(JOB_QUEUE_RUNNING_CALLBACK) ]; + printf(status_fmt , waiting , pending , running , loading , failed , complete); } } @@ -1046,31 +1051,31 @@ static void job_queue_clear_status( job_queue_type * queue ) { } -/** +/** This function goes through all the nodes and call finalize on them. hat about jobs which were NOT in a CAN_KILL state when the killing was done, i.e. jobs which are in one of the intermediate - load like states?? They + load like states?? They */ void job_queue_reset(job_queue_type * queue) { int i; - for (i=0; i < queue->active_size; i++) + for (i=0; i < queue->active_size; i++) job_queue_node_finalize(queue->jobs[i]); - + job_queue_clear_status( queue ); - + /* - Be ready for the next run + Be ready for the next run */ queue->grow = false; queue->submit_complete = false; queue->pause_on = false; queue->user_exit = false; - queue->open = true; + queue->open = true; queue->active_size = 0; - queue->stop_time = 0; + queue->stop_time = 0; } @@ -1088,15 +1093,15 @@ static void job_queue_user_exit__( job_queue_type * queue ) { static bool job_queue_check_node_status_files( const job_queue_type * job_queue , job_queue_node_type * node) { - if ((node->exit_file != NULL) && util_file_exists(node->exit_file)) + if ((node->exit_file != NULL) && util_file_exists(node->exit_file)) return false; /* It has failed. */ else { - if (node->ok_file == NULL) + if (node->ok_file == NULL) return true; /* If the ok-file has not been set we just return true immediately. */ else { int ok_sleep_time = 1; /* Time to wait between checks for OK|EXIT file. */ int total_wait_time = 0; - + while (true) { if (util_file_exists( node->ok_file )) { return true; @@ -1112,7 +1117,7 @@ static bool job_queue_check_node_status_files( const job_queue_type * job_queue } } } - } + } } } @@ -1129,11 +1134,11 @@ static void * job_queue_run_DONE_callback( void * arg ) { job_queue_free_job_driver_data( job_queue , node ); { bool OK = job_queue_check_node_status_files( job_queue , node ); - + if (OK) if (node->done_callback != NULL) OK = node->done_callback( node->callback_arg ); - + if (OK) job_queue_change_node_status( job_queue , node , JOB_QUEUE_SUCCESS ); else @@ -1165,7 +1170,7 @@ static void * job_queue_run_EXIT_callback( void * arg ) { } job_queue_free_job_driver_data( job_queue , node ); - if (node->submit_attempt < job_queue->max_submit) + if (node->submit_attempt < job_queue->max_submit) job_queue_change_node_status( job_queue , node , JOB_QUEUE_WAITING ); /* The job will be picked up for antother go. */ else { bool retry = false; @@ -1257,10 +1262,10 @@ void job_queue_set_max_running_option(queue_driver_type * driver, int max_runnin running has fallen below the new limit. The updated value will also be pushed down to the current driver. - + NOTE: These next three *max_running functions should not be used, rather use the set_option feature, with MAX_RUNNING. They are (maybe) used by python - therefore not removed. + therefore not removed. */ int job_queue_get_max_running( const job_queue_type * queue ) { return job_queue_get_max_running_option(queue->driver); @@ -1283,12 +1288,12 @@ int job_queue_inc_max_runnning( job_queue_type * queue, int delta ) { static void job_queue_check_expired(job_queue_type * queue) { if ((job_queue_get_max_job_duration(queue) <= 0) && (job_queue_get_job_stop_time(queue) <= 0)) return; - + for (int i = 0; i < queue->active_size; i++) { job_queue_node_type * node = queue->jobs[i]; if (job_queue_node_get_status(node) == JOB_QUEUE_RUNNING) { - time_t now = time(NULL); + time_t now = time(NULL); if ( job_queue_get_max_job_duration(queue) > 0) { double elapsed = difftime(now, node->sim_start); if (elapsed > job_queue_get_max_job_duration(queue)) { @@ -1309,7 +1314,7 @@ bool job_queue_get_open(const job_queue_type * job_queue) { } void job_queue_check_open(job_queue_type* queue) { - if (!job_queue_get_open(queue)) + if (!job_queue_get_open(queue)) util_abort("%s: queue not open and not ready for use; method job_queue_reset must be called before using the queue - aborting\n", __func__ ); } @@ -1325,10 +1330,10 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose util_abort("%s: another thread is already running the queue_manager\n",__func__); else { /* OK - we have got an exclusive lock to the run_jobs code. */ - + //Check if queue is open. Fails hard if not open - job_queue_check_open(queue); - + job_queue_check_open(queue); + const int NUM_WORKER_THREADS = 16; queue->running = true; queue->work_pool = thread_pool_alloc( NUM_WORKER_THREADS , true ); @@ -1336,19 +1341,19 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose bool new_jobs = false; bool cont = true; int phase = 0; - + do { bool local_user_exit = false; /*****************************************************************/ if (queue->user_exit) {/* An external thread has called the job_queue_user_exit() function, and we should kill all jobs, do some clearing up and go home. Observe that we will go through the queue handling codeblock below ONE LAST TIME before exiting. */ - job_queue_user_exit__( queue ); + job_queue_user_exit__( queue ); local_user_exit = true; } - + job_queue_check_expired(queue); - + /*****************************************************************/ { bool update_status = job_queue_update_status( queue ); @@ -1357,17 +1362,17 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose job_queue_print_summary(queue , update_status ); job_queue_update_spinner( &phase ); } - - + + { - int num_complete = queue->status_list[ STATUS_INDEX(JOB_QUEUE_SUCCESS) ] + + int num_complete = queue->status_list[ STATUS_INDEX(JOB_QUEUE_SUCCESS) ] + queue->status_list[ STATUS_INDEX(JOB_QUEUE_FAILED) ] + queue->status_list[ STATUS_INDEX(JOB_QUEUE_USER_KILLED) ]; if ((num_total_run > 0) && (num_total_run == num_complete)) /* The number of jobs completed is equal to the number of jobs we have said we want to run; so we are finished. - */ + */ cont = false; else { if (num_total_run == 0) { @@ -1381,31 +1386,31 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose 2. The user has used job_queue_complete_submit() to signal that no more jobs will be forthcoming. */ - if ((num_complete == queue->active_size) && queue->submit_complete) + if ((num_complete == queue->active_size) && queue->submit_complete) cont = false; } } } - + if (cont) { /* Submitting new jobs */ - int max_submit = 5; /* This is the maximum number of jobs submitted in one while() { ... } below. + int max_submit = 5; /* This is the maximum number of jobs submitted in one while() { ... } below. Only to ensure that the waiting time before a status update is not too long. */ int total_active = queue->status_list[ STATUS_INDEX(JOB_QUEUE_PENDING) ] + queue->status_list[ STATUS_INDEX(JOB_QUEUE_RUNNING) ]; int num_submit_new; - + { int max_running = job_queue_get_max_running( queue ); if (max_running > 0) num_submit_new = util_int_min( max_submit , max_running - total_active ); else - /* + /* If max_running == 0 that should be interpreted as no limit; i.e. the queue layer will attempt to send an unlimited number of jobs to the driver - the driver can reject the jobs. */ num_submit_new = util_int_min( max_submit , queue->status_list[ STATUS_INDEX( JOB_QUEUE_WAITING )]); } - + new_jobs = false; if (queue->status_list[ STATUS_INDEX(JOB_QUEUE_WAITING) ] > 0) /* We have waiting jobs at all */ if (num_submit_new > 0) /* The queue can allow more running jobs */ @@ -1414,13 +1419,13 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose if (new_jobs) { int submit_count = 0; int queue_index = 0; - + while ((queue_index < queue->active_size) && (num_submit_new > 0)) { job_queue_node_type * node = queue->jobs[queue_index]; if (job_queue_node_get_status(node) == JOB_QUEUE_WAITING) { { submit_status_type submit_status = job_queue_submit_job(queue , queue_index); - + if (submit_status == SUBMIT_OK) { num_submit_new--; submit_count++; @@ -1432,15 +1437,15 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose } } - + { /* Checking for complete / exited / overtime jobs */ int queue_index; for (queue_index = 0; queue_index < queue->active_size; queue_index++) { - job_queue_node_type * node = queue->jobs[queue_index]; - + job_queue_node_type * node = queue->jobs[queue_index]; + switch (job_queue_node_get_status(node)) { case(JOB_QUEUE_DONE): job_queue_handle_DONE(queue, node); @@ -1454,21 +1459,21 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose default: break; } - - + + } } - + if (local_user_exit) cont = false; /* This is how we signal that we want to get out . */ - if (queue->grow) - /* + if (queue->grow) + /* The add_job function has signaled that it needs more job slots. We must grow the jobs array. */ job_queue_grow( queue ); - else + else if (!new_jobs && cont) util_usleep(queue->usleep_time); } @@ -1477,22 +1482,22 @@ void job_queue_run_jobs(job_queue_type * queue , int num_total_run, bool verbose } while ( cont ); queue->running = false; } - if (verbose) + if (verbose) printf("\n"); thread_pool_join( queue->work_pool ); thread_pool_free( queue->work_pool ); } - + /* - Set the queue's "open" flag to false to signal that the queue is not ready to be used in a - new job_queue_run_jobs or job_queue_add_job method call as it has not been reset yet. Not - resetting the queue here implies that the queue object is still available for queries after - this method has finished + Set the queue's "open" flag to false to signal that the queue is not ready to be used in a + new job_queue_run_jobs or job_queue_add_job method call as it has not been reset yet. Not + resetting the queue here implies that the queue object is still available for queries after + this method has finished */ - - queue->open = false; - - + + queue->open = false; + + pthread_mutex_unlock( &queue->run_mutex ); } @@ -1514,7 +1519,7 @@ void * job_queue_run_jobs__(void * __arg_pack) { job_queue_type * queue = arg_pack_iget_ptr(arg_pack , 0); int num_total_run = arg_pack_iget_int(arg_pack , 1); bool verbose = arg_pack_iget_bool(arg_pack , 2); - + job_queue_run_jobs(queue , num_total_run , verbose); arg_pack_free( arg_pack ); return NULL; @@ -1528,8 +1533,15 @@ void job_queue_start_manager_thread( job_queue_type * job_queue , pthread_t * qu arg_pack_append_int(queue_args , job_size); arg_pack_append_bool(queue_args , verbose); job_queue_reset(job_queue); + + /* + The running status of the job is set to true here; this is to + guarantee that if calling scope queries the status of the queue + before queue_thread has actually started running the queue. + */ + job_queue->running = true; pthread_create( queue_thread , NULL , job_queue_run_jobs__ , queue_args); -} +} @@ -1539,7 +1551,7 @@ void job_queue_start_manager_thread( job_queue_type * job_queue , pthread_t * qu 1. The job_queue_run_jobs() is run by one thread. 2. Jobs are added asyncronously with job_queue_add_job_mt() from othread threads(s). - + Unfortunately it does not work properly (i.e. Ctrl-C breaks) to use a Python thread to invoke the job_queue_run_jobs() function; and this function is @@ -1548,7 +1560,7 @@ void job_queue_start_manager_thread( job_queue_type * job_queue , pthread_t * qu just return. No reference is retained to the thread actually running the - job_queue_run_jobs() function. + job_queue_run_jobs() function. */ @@ -1571,7 +1583,7 @@ void job_queue_run_jobs_threaded(job_queue_type * queue , int num_total_run, boo JOB_QUEUE_WAITING. This status means the job is ready to be submitted proper to one of the drivers (when a slot is ready). When submitted the job will get (driver specific) job_data != NULL - and status SUBMITTED. + and status SUBMITTED. The internal data structure jobs will grow as needed when new jobs are added. Exactly how this growth takes place is regulated by the @@ -1589,11 +1601,11 @@ void job_queue_run_jobs_threaded(job_queue_type * queue , int num_total_run, boo job_queue_run_jobs() function and it is safe for the job_queue_add_job__() function to manipulate the jobs array itself. - + Other thread running job_queue_run_jobs() | mt == true | Result --------------------------------------------------------------------------- Yes | Yes | OK - Yes | No | Crash and burn + Yes | No | Crash and burn No | Yes | Deadlock No | No | OK --------------------------------------------------------------------------- @@ -1602,25 +1614,25 @@ void job_queue_run_jobs_threaded(job_queue_type * queue , int num_total_run, boo -static int job_queue_add_job__(job_queue_type * queue , - const char * run_cmd , - job_callback_ftype * done_callback, +static int job_queue_add_job__(job_queue_type * queue , + const char * run_cmd , + job_callback_ftype * done_callback, job_callback_ftype * retry_callback, job_callback_ftype * exit_callback, - void * callback_arg , - int num_cpu , - const char * run_path , - const char * job_name , - int argc , - const char ** argv, + void * callback_arg , + int num_cpu , + const char * run_path , + const char * job_name , + int argc , + const char ** argv, bool mt) { - + //Fail hard if queue is not open - job_queue_check_open(queue); - + job_queue_check_open(queue); + if (!queue->user_exit) {/* We do not accept new jobs if a user-shutdown has been iniated. */ int job_index; // This should be better protected lockwise - + pthread_mutex_lock( &queue->queue_mutex ); { if (queue->active_size == queue->alloc_size) { @@ -1631,8 +1643,8 @@ static int job_queue_add_job__(job_queue_type * queue , while (queue->active_size == queue->alloc_size) { sleep( 1 ); } - } else - /* + } else + /* The function is called in single threaded mode, and we are certain that is safe for this thread to manipulate the jobs array directly. @@ -1644,7 +1656,7 @@ static int job_queue_add_job__(job_queue_type * queue , queue->active_size++; } pthread_mutex_unlock( &queue->queue_mutex ); - + job_queue_initialize_node(queue , run_cmd , done_callback , retry_callback , exit_callback, callback_arg , num_cpu , run_path , job_name , job_index , argc , argv); return job_index; /* Handle used by the calling scope. */ } else @@ -1654,38 +1666,38 @@ static int job_queue_add_job__(job_queue_type * queue , /** Adding a new job in multi-threaded mode, i.e. another thread is - running the job_queue_run_jobs() function. -*/ -int job_queue_add_job_mt(job_queue_type * queue , - const char * run_cmd , - job_callback_ftype * done_callback, + running the job_queue_run_jobs() function. +*/ +int job_queue_add_job_mt(job_queue_type * queue , + const char * run_cmd , + job_callback_ftype * done_callback, job_callback_ftype * retry_callback, - job_callback_ftype * exit_callback, - void * callback_arg , - int num_cpu , - const char * run_path , - const char * job_name , - int argc , - const char ** argv) { - return job_queue_add_job__(queue , run_cmd , done_callback, retry_callback, exit_callback , callback_arg , num_cpu , run_path , job_name , argc , argv , true); + job_callback_ftype * exit_callback, + void * callback_arg , + int num_cpu , + const char * run_path , + const char * job_name , + int argc , + const char ** argv) { + return job_queue_add_job__(queue , run_cmd , done_callback, retry_callback, exit_callback , callback_arg , num_cpu , run_path , job_name , argc , argv , true); } /** Adding a new job in single-threaded mode, i.e. no another thread is - accessing the queue. -*/ + accessing the queue. +*/ -int job_queue_add_job_st(job_queue_type * queue , - const char * run_cmd , - job_callback_ftype * done_callback, +int job_queue_add_job_st(job_queue_type * queue , + const char * run_cmd , + job_callback_ftype * done_callback, job_callback_ftype * retry_callback, job_callback_ftype * exit_callback, - void * callback_arg , - int num_cpu , - const char * run_path , - const char * job_name , - int argc , + void * callback_arg , + int num_cpu , + const char * run_path , + const char * job_name , + int argc , const char ** argv) { return job_queue_add_job__(queue , run_cmd , done_callback , retry_callback, exit_callback , callback_arg , num_cpu , run_path , job_name , argc , argv , false); } @@ -1710,7 +1722,7 @@ void job_queue_submit_complete( job_queue_type * queue ){ The calling scope must retain a handle to the current driver and free it. Should (in principle) be possible to change driver on a running system whoaaa. Will read and update the max_running value - from the driver. + from the driver. */ void job_queue_set_driver(job_queue_type * queue , queue_driver_type * driver) { @@ -1723,7 +1735,7 @@ bool job_queue_has_driver(const job_queue_type * queue ) { return false; else return true; -} +} job_driver_type job_queue_lookup_driver_name( const char * driver_name ) { @@ -1758,24 +1770,24 @@ static void job_queue_grow( job_queue_type * queue ) { int alloc_size = util_int_max( 2 * queue->alloc_size , JOB_QUEUE_START_SIZE ); job_queue_node_type ** new_jobs = util_calloc(alloc_size , sizeof * queue->jobs ); job_queue_node_type ** old_jobs = queue->jobs; - if (old_jobs != NULL) + if (old_jobs != NULL) memcpy( new_jobs , queue->jobs , queue->alloc_size * sizeof * queue->jobs ); - - + + { int i; /* Creating the new nodes. */ for (i = queue->alloc_size; i < alloc_size; i++) new_jobs[i] = job_queue_node_alloc(); - + /* Assigning the job pointer to the new array. */ queue->jobs = new_jobs; /* Free the old array - only the pointers, not the actual nodes! */ util_safe_free( old_jobs ); - + /* Update the status with the new nodes. */ - for (i=queue->alloc_size; i < alloc_size; i++) + for (i=queue->alloc_size; i < alloc_size; i++) queue->status_list[ STATUS_INDEX(job_queue_node_get_status(queue->jobs[i])) ]++; queue->alloc_size = alloc_size; @@ -1787,26 +1799,26 @@ static void job_queue_grow( job_queue_type * queue ) { /** Observe that the job_queue returned by this function is NOT ready for use; a driver must be set explicitly with a call to - job_queue_set_driver() first. + job_queue_set_driver() first. */ -job_queue_type * job_queue_alloc(int max_submit , - const char * ok_file , +job_queue_type * job_queue_alloc(int max_submit , + const char * ok_file , const char * exit_file ) { - + job_queue_type * queue = util_malloc(sizeof * queue ); queue->jobs = NULL; queue->usleep_time = 250000; /* 1000000 : 1 second */ - queue->max_ok_wait_time = 60; - queue->max_duration = 0; - queue->stop_time = 0; + queue->max_ok_wait_time = 60; + queue->max_duration = 0; + queue->stop_time = 0; queue->max_submit = max_submit; queue->driver = NULL; queue->ok_file = util_alloc_string_copy( ok_file ); queue->exit_file = util_alloc_string_copy( exit_file ); - queue->open = true; + queue->open = true; queue->user_exit = false; queue->pause_on = false; queue->running = false; @@ -1828,7 +1840,7 @@ job_queue_type * job_queue_alloc(int max_submit , /** Returns true if the queue is currently paused, which means that no - more jobs are submitted. + more jobs are submitted. */ @@ -1865,9 +1877,9 @@ void job_queue_free(job_queue_type * queue) { util_safe_free( queue->exit_file ); { int i; - for (i=0; i < queue->alloc_size; i++) + for (i=0; i < queue->alloc_size; i++) job_queue_node_free(queue->jobs[i]); - + free(queue->jobs); } free(queue); diff --git a/ThirdParty/Ert/devel/libjob_queue/src/job_queue_manager.c b/ThirdParty/Ert/devel/libjob_queue/src/job_queue_manager.c index 6c3db5940b..c9140c2ed0 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/job_queue_manager.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/job_queue_manager.c @@ -27,6 +27,7 @@ #include <ert/util/type_macros.h> #include <ert/job_queue/job_queue.h> +#include <ert/job_queue/queue_driver.h> #include <ert/job_queue/job_queue_manager.h> #define JOB_QUEUE_MANAGER_TYPE_ID 81626006 @@ -66,3 +67,26 @@ void job_queue_manager_wait( job_queue_manager_type * manager) { pthread_join( manager->queue_thread , NULL ); } + + +bool job_queue_manager_is_running( const job_queue_manager_type * manager) { + return job_queue_is_running( manager->job_queue ); +} + +int job_queue_manager_get_num_running( const job_queue_manager_type * manager) { + return job_queue_get_num_running( manager->job_queue ); +} + + +int job_queue_manager_get_num_complete( const job_queue_manager_type * manager) { + return job_queue_get_num_complete( manager->job_queue ); +} + + +bool job_queue_manager_job_complete( const job_queue_manager_type * manager , int job_index) { + job_status_type status = job_queue_iget_job_status( manager->job_queue , job_index ); + if (status & JOB_QUEUE_COMPLETE_STATUS) + return true; + else + return false; +} diff --git a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c b/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c index 31ed9a3b1b..94813f684a 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'lsf_driver.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'lsf_driver.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -37,7 +37,6 @@ - /** Documentation/examples of programming towards the lsf libraries can be found in /prog/LSF/7.0/misc/examples @@ -47,7 +46,7 @@ /* How to call the lsf commands bsub/bjobs/bkill: ---------------------------------------------- - + The commands to submit, monitor and modify LSF jobs are available through library calls through the lsf library. This is a good solution which works well. @@ -57,11 +56,11 @@ the LIM servers, to be able to use the low-level lsb_xxx() function calls the host making the calls must configured (by an LSF administrator) to be a LSF client. - + The lsf_driver can either make use of the proper lsf library calls (lsb_submit(), lsb_openjobinfo(), ...) or alternatively it can issue ssh calls to an external LSF_SERVER and call up the bsub/bkill/bjob - executables on the remote server. + executables on the remote server. All the functions with 'library' in the name are based on library calls, and the functions with 'shell' in the name are based on @@ -78,8 +77,8 @@ lsf headers and the lsf library; that is probably not optimal. - Remote login shell - ------------------ + Remote login shell + ------------------ When submitting with LSF the job will inherit the current environment on the submitting host, and not read the users login @@ -98,13 +97,15 @@ -#define LSF_DRIVER_TYPE_ID 10078365 -#define LSF_JOB_TYPE_ID 9963900 -#define BJOBS_REFRESH_TIME 10 -#define DEFAULT_RSH_CMD "/usr/bin/ssh" -#define DEFAULT_BSUB_CMD "bsub" -#define DEFAULT_BJOBS_CMD "bjobs" -#define DEFAULT_BKILL_CMD "bkill" +#define LSF_DRIVER_TYPE_ID 10078365 +#define LSF_JOB_TYPE_ID 9963900 +#define BJOBS_REFRESH_TIME 10 +#define MAX_ERROR_COUNT 100 +#define SUBMIT_ERROR_SLEEP 2 +#define DEFAULT_RSH_CMD "/usr/bin/ssh" +#define DEFAULT_BSUB_CMD "bsub" +#define DEFAULT_BJOBS_CMD "bjobs" +#define DEFAULT_BKILL_CMD "bkill" @@ -126,21 +127,26 @@ struct lsf_driver_struct { pthread_mutex_t submit_lock; lsf_submit_method_enum submit_method; - + int submit_sleep; + + int error_count; + int max_error_count; + int submit_error_sleep; + /*-----------------------------------------------------------------*/ /* Fields used by the lsf library functions */ #ifdef HAVE_LSF_LIBRARY struct submit lsf_request; - struct submitReply lsf_reply; + struct submitReply lsf_reply; lsb_type * lsb; #endif /*-----------------------------------------------------------------*/ /* Fields used by the shell based functions */ - - int bjobs_refresh_interval; + bool debug_output; + int bjobs_refresh_interval; time_t last_bjobs_update; - hash_type * my_jobs; /* A hash table of all jobs submitted by this ERT instance - + hash_type * my_jobs; /* A hash table of all jobs submitted by this ERT instance - to ensure that we do not check status of old jobs in e.g. ZOMBIE status. */ hash_type * status_map; hash_type * bjobs_cache; /* The output of calling bjobs is cached in this table. */ @@ -167,6 +173,7 @@ lsf_job_type * lsf_job_alloc() { job->num_exec_host = 0; job->exec_host = NULL; + job->lsf_jobnr = 0; job->lsf_jobnr_char = NULL; UTIL_TYPE_ID_INIT( job , LSF_JOB_TYPE_ID); return job; @@ -183,7 +190,7 @@ void lsf_job_free(lsf_job_type * job) { void lsf_job_export_hostnames( const lsf_job_type * job , stringlist_type * hostlist) { int host_nr; - + stringlist_clear( hostlist ); for (host_nr = 0; host_nr < job->num_exec_host; host_nr++) stringlist_append_copy( hostlist , job->exec_host[ host_nr ]); @@ -194,26 +201,27 @@ long lsf_job_get_jobnr( const lsf_job_type * job ) { return job->lsf_jobnr; } - -static int lsf_job_parse_bsub_stdout(const lsf_driver_type * driver , const char * stdout_file) { - int jobid = -1; - FILE * stream = util_fopen(stdout_file , "r"); - if (util_fseek_string(stream , "<" , true , true)) { - char * jobid_string = util_fscanf_alloc_upto(stream , ">" , false); - if (jobid_string != NULL) { - jobid = atoi( jobid_string ); - free( jobid_string ); - } - } - fclose( stream ); - - if (jobid == -1) { - char * file_content = util_fread_alloc_file_content( stdout_file , NULL ); - fprintf(stderr,"Failed to get lsf job id from file: %s \n",stdout_file ); - fprintf(stderr,"bsub command : %s \n",driver->bsub_cmd ); - fprintf(stderr,"%s\n", file_content); - free( file_content ); - util_exit("%s: \n",__func__); +int lsf_job_parse_bsub_stdout(const char * bsub_cmd, const char * stdout_file) { + int jobid = 0; + if ((util_file_exists(stdout_file)) && (util_file_size(stdout_file) > 0)) { + FILE * stream = util_fopen(stdout_file , "r"); + if (util_fseek_string(stream , "<" , true , true)) { + char * jobid_string = util_fscanf_alloc_upto(stream , ">" , false); + if (jobid_string != NULL) { + util_sscanf_int( jobid_string , &jobid); + free( jobid_string ); + } + } + fclose( stream ); + + if (jobid == 0) { + char * file_content = util_fread_alloc_file_content( stdout_file , NULL ); + fprintf(stderr,"Failed to get lsf job id from file: %s \n",stdout_file ); + fprintf(stderr,"bsub command : %s \n",bsub_cmd ); + fprintf(stderr,"%s\n", file_content); + free( file_content ); + util_abort("%s: \n",__func__); + } } return jobid; } @@ -246,7 +254,7 @@ static void lsf_driver_internal_error( const lsf_driver_type * driver ) { fprintf(stderr , "** This lsf driver does NOT have support for using lsf **\n"); fprintf(stderr , "** library calls; but you have tried to submit without setting **\n"); fprintf(stderr , "** a value for LSF_SERVER. Set this and try again. **\n"); -#endif +#endif fprintf(stderr , "*****************************************************************\n\n"); exit(1); } @@ -263,18 +271,18 @@ static void lsf_driver_assert_submit_method( const lsf_driver_type * driver ) { -stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , - const char * lsf_stdout , - const char * job_name , +stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , + const char * lsf_stdout , + const char * job_name , const char * submit_cmd , - int num_cpu , + int num_cpu , int job_argc, const char ** job_argv) { - + stringlist_type * argv = stringlist_alloc_new(); char * num_cpu_string = util_alloc_sprintf("%d" , num_cpu); char * quoted_resource_request = NULL; - + /* The resource request string contains spaces, and when passed through the shell it must be protected with \"..\"; this applies @@ -285,16 +293,16 @@ stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , quoting. */ - if (driver->resource_request != NULL) { - if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) - quoted_resource_request =util_alloc_sprintf("\"%s\"" , driver->resource_request); + if (driver->resource_request != NULL) { + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) + quoted_resource_request =util_alloc_sprintf("\"%s\"" , driver->resource_request); else - quoted_resource_request = util_alloc_string_copy( driver->resource_request ); + quoted_resource_request = util_alloc_string_copy( driver->resource_request ); } if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) stringlist_append_ref( argv , driver->bsub_cmd); - + stringlist_append_ref( argv , "-o" ); stringlist_append_copy( argv , lsf_stdout ); if (driver->queue_name != NULL) { @@ -310,7 +318,7 @@ stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , stringlist_append_ref( argv , "-R"); stringlist_append_copy( argv , quoted_resource_request ); } - + if (driver->login_shell != NULL) { stringlist_append_ref( argv , "-L"); stringlist_append_ref( argv , driver->login_shell ); @@ -319,7 +327,7 @@ stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , stringlist_append_ref( argv , submit_cmd); { int iarg; - for (iarg = 0; iarg < job_argc; iarg++) + for (iarg = 0; iarg < job_argc; iarg++) stringlist_append_ref( argv , job_argv[ iarg ]); } free( num_cpu_string ); @@ -328,11 +336,11 @@ stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , } -static int lsf_driver_submit_internal_job( lsf_driver_type * driver , - const char * lsf_stdout , - const char * job_name , +static int lsf_driver_submit_internal_job( lsf_driver_type * driver , + const char * lsf_stdout , + const char * job_name , const char * submit_cmd , - int num_cpu , + int num_cpu , int argc, const char ** argv) { @@ -349,22 +357,22 @@ static int lsf_driver_submit_internal_job( lsf_driver_type * driver , command = buffer_get_data( command_buffer ); buffer_free_container( command_buffer ); } - + { int options = SUB_JOB_NAME + SUB_OUT_FILE; - - if (driver->queue_name != NULL) + + if (driver->queue_name != NULL) options += SUB_QUEUE; - - if (driver->resource_request != NULL) + + if (driver->resource_request != NULL) options += SUB_RES_REQ; - - if (driver->login_shell != NULL) + + if (driver->login_shell != NULL) options += SUB_LOGIN_SHELL; - + driver->lsf_request.options = options; } - + driver->lsf_request.resReq = driver->resource_request; driver->lsf_request.loginShell = driver->login_shell; driver->lsf_request.queue = driver->queue_name; @@ -378,7 +386,7 @@ static int lsf_driver_submit_internal_job( lsf_driver_type * driver , free( command ); /* I trust the lsf layer is finished with the command? */ if (lsf_jobnr <= 0) fprintf(stderr,"%s: ** Warning: lsb_submit() failed: %s \n",__func__ , lsb_sys_msg( driver->lsb )); - + return lsf_jobnr; } #else @@ -389,36 +397,48 @@ static int lsf_driver_submit_internal_job( lsf_driver_type * driver , -static int lsf_driver_submit_shell_job(lsf_driver_type * driver , - const char * lsf_stdout , - const char * job_name , +static int lsf_driver_submit_shell_job(lsf_driver_type * driver , + const char * lsf_stdout , + const char * job_name , const char * submit_cmd , - int num_cpu , + int num_cpu , int job_argc, const char ** job_argv) { int job_id; - char * tmp_file = util_alloc_tmp_file("/tmp" , "enkf-submit" , true); + char * tmp_file = util_alloc_tmp_file("/tmp" , "enkf-submit" , true); - if (driver->remote_lsf_server != NULL) { + { stringlist_type * remote_argv = lsf_driver_alloc_cmd( driver , lsf_stdout , job_name , submit_cmd , num_cpu , job_argc , job_argv); if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) { char ** argv = util_calloc( 2 , sizeof * argv ); argv[0] = driver->remote_lsf_server; argv[1] = stringlist_alloc_joined_string( remote_argv , " "); + + if (driver->debug_output) + printf("Submitting: %s %s %s \n",driver->rsh_cmd , argv[0] , argv[1]); + util_fork_exec(driver->rsh_cmd , 2 , (const char **) argv , true , NULL , NULL , NULL , tmp_file , NULL); + free( argv[1] ); free( argv ); } else if (driver->submit_method == LSF_SUBMIT_LOCAL_SHELL) { char ** argv = stringlist_alloc_char_ref( remote_argv ); + + if (driver->debug_output) { + printf("Submitting: %s ",driver->bsub_cmd); + stringlist_fprintf(remote_argv , " " , stdout); + printf("\n"); + } + util_fork_exec(driver->bsub_cmd , stringlist_get_size( remote_argv) , (const char **) argv , true , NULL , NULL , NULL , tmp_file , tmp_file); free( argv ); } - + stringlist_free( remote_argv ); } - - job_id = lsf_job_parse_bsub_stdout(driver , tmp_file); + + job_id = lsf_job_parse_bsub_stdout(driver->bsub_cmd , tmp_file); util_unlink_existing( tmp_file ); free(tmp_file); return job_id; @@ -453,7 +473,7 @@ static void lsf_driver_update_bjobs_table(lsf_driver_type * driver) { util_fork_exec(driver->bjobs_cmd , 1 , (const char **) argv , true , NULL , NULL , NULL , tmp_file , NULL); free( argv ); } - + { char user[32]; char status[16]; @@ -471,7 +491,7 @@ static void lsf_driver_update_bjobs_table(lsf_driver_type * driver) { if (hash_has_key( driver->my_jobs , job_id )) /* Consider only jobs submitted by this ERT instance - not old jobs lying around from the same user. */ hash_insert_int(driver->bjobs_cache , job_id , lsf_driver_get_status__( driver , status , job_id)); - + free(job_id); } free(line); @@ -479,14 +499,14 @@ static void lsf_driver_update_bjobs_table(lsf_driver_type * driver) { } fclose(stream); } - util_unlink_existing(tmp_file); + util_unlink_existing(tmp_file); free(tmp_file); } static int lsf_driver_get_job_status_libary(void * __driver , void * __job) { - if (__job == NULL) + if (__job == NULL) /* the job has not been registered at all ... */ return JOB_QUEUE_NOT_ACTIVE; else { @@ -495,15 +515,15 @@ static int lsf_driver_get_job_status_libary(void * __driver , void * __job) { #ifdef HAVE_LSF_LIBRARY lsf_job_type * job = lsf_job_safe_cast( __job ); if (lsb_openjob( driver->lsb , job->lsf_jobnr) != 1) { - /* + /* Failed to get information about the job - we boldly assume the following situation has occured: - + 1. The job is running happily along. 2. The lsf deamon is not responding for a long time. 3. The job finishes, and is eventually expired from the LSF job database. 4. The lsf deamon answers again - but can not find the job... - + */ fprintf(stderr,"Warning: failed to get status information for job:%ld - assuming it is finished. \n", job->lsf_jobnr); status = JOB_QUEUE_DONE; @@ -518,8 +538,10 @@ static int lsf_driver_get_job_status_libary(void * __driver , void * __job) { } #else lsf_driver_internal_error( driver ); + /* the above function calls exit(), so this value is never returned */ + status = JOB_QUEUE_FAILED; #endif - + return status; } } @@ -529,11 +551,11 @@ static int lsf_driver_get_job_status_libary(void * __driver , void * __job) { static int lsf_driver_get_job_status_shell(void * __driver , void * __job) { int status = JOB_STAT_NULL; - + if (__job != NULL) { lsf_job_type * job = lsf_job_safe_cast( __job ); lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); - + { /** Updating the bjobs_table of the driver involves a significant change in @@ -549,19 +571,19 @@ static int lsf_driver_get_job_status_shell(void * __driver , void * __job) { } } pthread_mutex_unlock( &driver->bjobs_mutex ); - - - if (hash_has_key( driver->bjobs_cache , job->lsf_jobnr_char) ) + + + if (hash_has_key( driver->bjobs_cache , job->lsf_jobnr_char) ) status = hash_get_int(driver->bjobs_cache , job->lsf_jobnr_char); else - /* + /* It might be running - but since job != NULL it is at least in the queue system. */ status = JOB_STAT_PEND; } } - + return status; } @@ -586,7 +608,7 @@ job_status_type lsf_driver_convert_status( int lsf_status ) { break; case JOB_STAT_RUN: job_status = JOB_QUEUE_RUNNING; - break; + break; case JOB_STAT_DONE: job_status = JOB_QUEUE_DONE; break; @@ -611,7 +633,7 @@ int lsf_driver_get_job_status_lsf(void * __driver , void * __job) { int lsf_status; lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); - if (driver->submit_method == LSF_SUBMIT_INTERNAL) + if (driver->submit_method == LSF_SUBMIT_INTERNAL) lsf_status = lsf_driver_get_job_status_libary(__driver , __job); else lsf_status = lsf_driver_get_job_status_shell(__driver , __job); @@ -656,7 +678,7 @@ void lsf_driver_kill_job(void * __driver , void * __job) { free( argv[1] ); free( argv ); - } else if (driver->submit_method == LSF_SUBMIT_LOCAL_SHELL) + } else if (driver->submit_method == LSF_SUBMIT_LOCAL_SHELL) util_fork_exec(driver->bkill_cmd , 1 , (const char **) &job->lsf_jobnr_char , true , NULL , NULL , NULL , NULL , NULL); } } @@ -666,41 +688,55 @@ void lsf_driver_kill_job(void * __driver , void * __job) { -void * lsf_driver_submit_job(void * __driver , - const char * submit_cmd , - int num_cpu , - const char * run_path , +void * lsf_driver_submit_job(void * __driver , + const char * submit_cmd , + int num_cpu , + const char * run_path , const char * job_name , - int argc, + int argc, const char ** argv ) { lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); lsf_driver_assert_submit_method( driver ); { lsf_job_type * job = lsf_job_alloc(); + usleep( driver->submit_sleep ); + { char * lsf_stdout = util_alloc_filename(run_path , job_name , "LSF-stdout"); lsf_submit_method_enum submit_method = driver->submit_method; pthread_mutex_lock( &driver->submit_lock ); - + + if (driver->debug_output) + printf("LSF DRIVER submitting using method:%d \n",submit_method); + if (submit_method == LSF_SUBMIT_INTERNAL) { job->lsf_jobnr = lsf_driver_submit_internal_job( driver , lsf_stdout , job_name , submit_cmd , num_cpu , argc, argv); } else { job->lsf_jobnr = lsf_driver_submit_shell_job( driver , lsf_stdout , job_name , submit_cmd , num_cpu , argc, argv); job->lsf_jobnr_char = util_alloc_sprintf("%ld" , job->lsf_jobnr); - hash_insert_ref( driver->my_jobs , job->lsf_jobnr_char , NULL ); + hash_insert_ref( driver->my_jobs , job->lsf_jobnr_char , NULL ); } - + pthread_mutex_unlock( &driver->submit_lock ); free( lsf_stdout ); } - - if (job->lsf_jobnr > 0) + + if (job->lsf_jobnr > 0) return job; else { /* The submit failed - the queue system shall handle NULL return values. */ + driver->error_count++; + + if (driver->error_count >= driver->max_error_count) + util_exit("Maximum number of submit errors exceeded - giving up\n"); + else { + fprintf(stderr,"** ERROR ** Failed when submitting to LSF - will try again.\n"); + usleep( driver->submit_error_sleep ); + } + lsf_job_free(job); return NULL; } @@ -718,16 +754,16 @@ void lsf_driver_free(lsf_driver_type * driver ) { free( driver->bkill_cmd ); free( driver->bjobs_cmd ); free( driver->bsub_cmd ); - + hash_free(driver->status_map); hash_free(driver->bjobs_cache); hash_free(driver->my_jobs); - + #ifdef HAVE_LSF_LIBRARY if (driver->lsb != NULL) lsb_free( driver->lsb ); #endif - + free(driver); driver = NULL; } @@ -748,19 +784,19 @@ static void lsf_driver_set_login_shell( lsf_driver_type * driver, const char * } static void lsf_driver_set_rsh_cmd( lsf_driver_type * driver , const char * rsh_cmd) { - driver->rsh_cmd = util_realloc_string_copy( driver->rsh_cmd , rsh_cmd ); + driver->rsh_cmd = util_realloc_string_copy( driver->rsh_cmd , rsh_cmd ); } static void lsf_driver_set_bsub_cmd( lsf_driver_type * driver , const char * bsub_cmd) { - driver->bsub_cmd = util_realloc_string_copy( driver->bsub_cmd , bsub_cmd ); + driver->bsub_cmd = util_realloc_string_copy( driver->bsub_cmd , bsub_cmd ); } static void lsf_driver_set_bjobs_cmd( lsf_driver_type * driver , const char * bjobs_cmd) { - driver->bjobs_cmd = util_realloc_string_copy( driver->bjobs_cmd , bjobs_cmd ); + driver->bjobs_cmd = util_realloc_string_copy( driver->bjobs_cmd , bjobs_cmd ); } static void lsf_driver_set_bkill_cmd( lsf_driver_type * driver , const char * bkill_cmd) { - driver->bkill_cmd = util_realloc_string_copy( driver->bkill_cmd , bkill_cmd ); + driver->bkill_cmd = util_realloc_string_copy( driver->bkill_cmd , bkill_cmd ); } #ifdef HAVE_LSF_LIBRARY @@ -768,8 +804,8 @@ static void lsf_driver_set_internal_submit( lsf_driver_type * driver) { /* No remote server has been set - assuming we can issue proper library calls. */ /* The BSUB_QUEUE variable must NOT be set when using the shell function, because then stdout is redirected and read. */ - - util_setenv("BSUB_QUIET" , "yes"); + + util_setenv("BSUB_QUIET" , "yes"); driver->submit_method = LSF_SUBMIT_INTERNAL; util_safe_free( driver->remote_lsf_server ); driver->remote_lsf_server = NULL; @@ -789,14 +825,14 @@ static void lsf_driver_set_remote_server( lsf_driver_type * driver , const char util_unsetenv( "BSUB_QUIET" ); { char * tmp_server = util_alloc_strupr_copy( remote_server ); - + if (strcmp(tmp_server , LOCAL_LSF_SERVER) == 0) driver->submit_method = LSF_SUBMIT_LOCAL_SHELL; else if (strcmp(tmp_server , NULL_LSF_SERVER) == 0) // We trap the special string 'NULL' and call again with a true NULL pointer. lsf_driver_set_remote_server( driver , NULL); else driver->submit_method = LSF_SUBMIT_REMOTE_SHELL; - + free( tmp_server ); } } @@ -808,8 +844,30 @@ lsf_submit_method_enum lsf_driver_get_submit_method( const lsf_driver_type * dri return driver->submit_method; } + +static bool lsf_driver_set_debug_output( lsf_driver_type * driver , const char * arg) { + bool debug_output; + bool OK = util_sscanf_bool( arg , &debug_output); + if (OK) + driver->debug_output = debug_output; + + return OK; +} + + +static bool lsf_driver_set_submit_sleep( lsf_driver_type * driver , const char * arg) { + double submit_sleep; + bool OK = util_sscanf_double( arg , &submit_sleep); + if (OK) + driver->submit_sleep = (int) (1000000 * submit_sleep); + + return OK; +} + + + /*****************************************************************/ -/* Generic functions for runtime manipulation of options. +/* Generic functions for runtime manipulation of options. LSF_SERVER LSF_QUEUE @@ -836,7 +894,11 @@ bool lsf_driver_set_option( void * __driver , const char * option_key , const vo lsf_driver_set_bjobs_cmd( driver , value ); else if (strcmp( LSF_BKILL_CMD , option_key) == 0) lsf_driver_set_bkill_cmd( driver , value ); - else + else if (strcmp( LSF_DEBUG_OUTPUT , option_key) == 0) + lsf_driver_set_debug_output( driver , value ); + else if (strcmp( LSF_SUBMIT_SLEEP , option_key) == 0) + lsf_driver_set_submit_sleep( driver , value ); + else has_option = false; } return has_option; @@ -890,7 +952,7 @@ void lsf_driver_init_option_list(stringlist_type * option_list) { /*****************************************************************/ -/* +/* Observe that this driver IS not properly initialized when returning from this function, the option interface must be used to set the keys: @@ -905,18 +967,18 @@ static void lsf_driver_lib_init( lsf_driver_type * lsf_driver ) { #ifdef HAVE_LSF_LIBRARY memset(&lsf_driver->lsf_request , 0 , sizeof (lsf_driver->lsf_request)); lsf_driver->lsf_request.beginTime = 0; - lsf_driver->lsf_request.termTime = 0; + lsf_driver->lsf_request.termTime = 0; lsf_driver->lsf_request.numProcessors = 1; lsf_driver->lsf_request.maxNumProcessors = 1; { int i; - for (i=0; i < LSF_RLIM_NLIMITS; i++) + for (i=0; i < LSF_RLIM_NLIMITS; i++) lsf_driver->lsf_request.rLimits[i] = DEFAULT_RLIMIT; } lsf_driver->lsf_request.options2 = 0; - + lsf_driver->lsb = lsb_alloc(); - if (lsb_ready(lsf_driver->lsb)) + if (lsb_ready(lsf_driver->lsb)) lsb_initialize(lsf_driver->lsb); else { lsb_free( lsf_driver->lsb ); @@ -929,8 +991,8 @@ static void lsf_driver_lib_init( lsf_driver_type * lsf_driver ) { static void lsf_driver_shell_init( lsf_driver_type * lsf_driver ) { lsf_driver->last_bjobs_update = time( NULL ); - lsf_driver->bjobs_cache = hash_alloc(); - lsf_driver->my_jobs = hash_alloc(); + lsf_driver->bjobs_cache = hash_alloc(); + lsf_driver->my_jobs = hash_alloc(); lsf_driver->status_map = hash_alloc(); lsf_driver->bsub_cmd = NULL; lsf_driver->bjobs_cmd = NULL; @@ -956,20 +1018,25 @@ void * lsf_driver_alloc( ) { lsf_driver->submit_method = LSF_SUBMIT_INVALID; lsf_driver->login_shell = NULL; lsf_driver->queue_name = NULL; - lsf_driver->remote_lsf_server = NULL; - lsf_driver->rsh_cmd = NULL; + lsf_driver->remote_lsf_server = NULL; + lsf_driver->rsh_cmd = NULL; lsf_driver->resource_request = NULL; + lsf_driver->error_count = 0; + lsf_driver->max_error_count = MAX_ERROR_COUNT; + lsf_driver->submit_error_sleep = SUBMIT_ERROR_SLEEP * 1000000; lsf_driver_set_bjobs_refresh_interval( lsf_driver , BJOBS_REFRESH_TIME ); pthread_mutex_init( &lsf_driver->submit_lock , NULL ); lsf_driver_lib_init( lsf_driver ); lsf_driver_shell_init( lsf_driver ); - + lsf_driver_set_option( lsf_driver , LSF_SERVER , NULL ); lsf_driver_set_option( lsf_driver , LSF_RSH_CMD , DEFAULT_RSH_CMD ); lsf_driver_set_option( lsf_driver , LSF_BSUB_CMD , DEFAULT_BSUB_CMD ); lsf_driver_set_option( lsf_driver , LSF_BJOBS_CMD , DEFAULT_BJOBS_CMD ); lsf_driver_set_option( lsf_driver , LSF_BKILL_CMD , DEFAULT_BKILL_CMD ); + lsf_driver_set_option( lsf_driver , LSF_DEBUG_OUTPUT , "FALSE"); + lsf_driver_set_option( lsf_driver , LSF_SUBMIT_SLEEP , DEFAULT_SUBMIT_SLEEP); return lsf_driver; } diff --git a/ThirdParty/Ert/devel/libjob_queue/src/queue_driver.c b/ThirdParty/Ert/devel/libjob_queue/src/queue_driver.c index 3778d1c278..27d89578a5 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/queue_driver.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/queue_driver.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'queue_driver.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'queue_driver.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> @@ -57,7 +57,7 @@ struct queue_driver_struct { UTIL_TYPE_ID_DECLARATION; - /* + /* Function pointers - pointing to low level functions in the implementations of e.g. lsf_driver. */ @@ -139,9 +139,9 @@ static bool queue_driver_has_generic_option__(queue_driver_type * driver, const return false; } -/** +/** Set option - can also be used to perform actions - not only setting - of parameters. There is no limit :-) + of parameters. There is no limit :-) */ bool queue_driver_set_option(queue_driver_type * driver, const char * option_key, const void * value) { if (queue_driver_set_generic_option__(driver, option_key, value)) { @@ -164,7 +164,7 @@ bool queue_driver_set_option(queue_driver_type * driver, const char * option_key modified runtime. The driver returned from the queue_driver_alloc_empty() function is - NOT properly initialized and NOT ready for use. + NOT properly initialized and NOT ready for use. */ static queue_driver_type * queue_driver_alloc_empty() { @@ -254,7 +254,7 @@ queue_driver_type * queue_driver_alloc(job_driver_type type) { default: util_abort("%s: unrecognized driver type:%d \n", __func__, type); } - + queue_driver_set_generic_option__(driver, MAX_RUNNING, "0"); return driver; } @@ -289,11 +289,11 @@ const void * queue_driver_get_option(queue_driver_type * driver, const char * op void queue_driver_init_option_list(queue_driver_type * driver, stringlist_type * option_list) { //Add options common for all driver types stringlist_append_ref(option_list, MAX_RUNNING); - + //Add options for the specific driver type - if (driver->init_options) + if (driver->init_options) driver->init_options(option_list); - else + else util_abort("%s: driver:%s does not support run time reading of options\n", __func__, driver->name); } diff --git a/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c b/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c index ee916b8380..b1726f1ecf 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c @@ -341,7 +341,7 @@ void rsh_driver_free__(void * __driver) { } -void rsh_driver_set_host_list( rsh_driver_type * rsh_driver , const hash_type * rsh_host_list) { +void rsh_driver_set_host_list( rsh_driver_type * rsh_driver , hash_type * rsh_host_list) { rsh_driver_clear_host_list( rsh_driver ); if (rsh_host_list != NULL) { hash_iter_type * hash_iter = hash_iter_alloc( rsh_host_list ); @@ -429,8 +429,8 @@ bool rsh_driver_set_option( void * __driver , const char * option_key , const vo rsh_driver_add_host_from_string( driver , value ); else if (strcmp(RSH_HOSTLIST , option_key) == 0) { /* Set full host list - value should be hash of integers. */ if (value != NULL) { - hash_safe_cast_const( value ); - rsh_driver_set_host_list( driver , value ); + hash_type * hash_value = hash_safe_cast( value ); + rsh_driver_set_host_list( driver , hash_value ); } } else if (strcmp( RSH_CLEAR_HOSTLIST , option_key) == 0) /* Value is not considered - this is an action, and not a _set operation. */ diff --git a/ThirdParty/Ert/devel/libjob_queue/src/torque_driver.c b/ThirdParty/Ert/devel/libjob_queue/src/torque_driver.c index 83eb32bd13..5998dd9f1d 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/torque_driver.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/torque_driver.c @@ -1,23 +1,27 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'torque_driver.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'torque_driver.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ +#include <stdio.h> #include <string.h> +#include <unistd.h> + #include <ert/util/util.h> #include <ert/util/type_macros.h> + #include <ert/job_queue/torque_driver.h> @@ -38,6 +42,8 @@ struct torque_driver_struct { int num_cpus_per_node; int num_nodes; char * cluster_label; + int submit_sleep; + FILE * debug_stream; }; struct torque_job_struct { @@ -66,16 +72,29 @@ void * torque_driver_alloc() { torque_driver->num_nodes = 1; torque_driver->cluster_label = NULL; torque_driver->job_prefix = NULL; + torque_driver->debug_stream = NULL; torque_driver_set_option(torque_driver, TORQUE_QSUB_CMD, TORQUE_DEFAULT_QSUB_CMD); torque_driver_set_option(torque_driver, TORQUE_QSTAT_CMD, TORQUE_DEFAULT_QSTAT_CMD); torque_driver_set_option(torque_driver, TORQUE_QDEL_CMD, TORQUE_DEFAULT_QDEL_CMD); torque_driver_set_option(torque_driver, TORQUE_NUM_CPUS_PER_NODE, "1"); torque_driver_set_option(torque_driver, TORQUE_NUM_NODES, "1"); + torque_driver_set_option(torque_driver, TORQUE_SUBMIT_SLEEP, TORQUE_DEFAULT_SUBMIT_SLEEP); return torque_driver; } +static void torque_driver_set_debug_output(torque_driver_type * driver, const char * debug_file) { + if (driver->debug_stream) + fclose( driver->debug_stream ); + + if (debug_file) + driver->debug_stream = util_mkdir_fopen( debug_file , "w"); + else + driver->debug_stream = NULL; +} + + static void torque_driver_set_qsub_cmd(torque_driver_type * driver, const char * qsub_cmd) { driver->qsub_cmd = util_realloc_string_copy(driver->qsub_cmd, qsub_cmd); } @@ -92,6 +111,16 @@ static void torque_driver_set_queue_name(torque_driver_type * driver, const char driver->queue_name = util_realloc_string_copy(driver->queue_name, queue_name); } +static bool torque_driver_set_submit_sleep(torque_driver_type * driver, const char* submit_sleep) { + double seconds_sleep; + if (util_sscanf_double( submit_sleep , &seconds_sleep)) { + driver->submit_sleep = (int) (seconds_sleep * 1000000); + return true; + } else + return false; +} + + static bool torque_driver_set_num_nodes(torque_driver_type * driver, const char* num_nodes_char) { int num_nodes = 0; if (util_sscanf_int(num_nodes_char, &num_nodes)) { @@ -115,7 +144,7 @@ static bool torque_driver_set_keep_qsub_output(torque_driver_type * driver, cons } static void torque_driver_set_job_prefix(torque_driver_type * driver, const char * job_prefix){ - driver->job_prefix = job_prefix; + driver->job_prefix = util_realloc_string_copy( driver->job_prefix , job_prefix); } static void torque_driver_set_cluster_label(torque_driver_type * driver, const char* cluster_label) { @@ -153,8 +182,12 @@ bool torque_driver_set_option(void * __driver, const char * option_key, const vo option_set = torque_driver_set_keep_qsub_output(driver, value); else if (strcmp(TORQUE_CLUSTER_LABEL, option_key) == 0) torque_driver_set_cluster_label(driver, value); - else if(strcmp(TORQUE_JOB_PREFIX_KEY, option_key) == 0) + else if (strcmp(TORQUE_JOB_PREFIX_KEY, option_key) == 0) torque_driver_set_job_prefix(driver, value); + else if (strcmp(TORQUE_DEBUG_OUTPUT, option_key) == 0) + torque_driver_set_debug_output(driver, value); + else if (strcmp(TORQUE_SUBMIT_SLEEP, option_key) == 0) + option_set = torque_driver_set_submit_sleep(driver, value); else option_set = false; } @@ -181,7 +214,7 @@ const void * torque_driver_get_option(const void * __driver, const char * option else if (strcmp(TORQUE_CLUSTER_LABEL, option_key) == 0) return driver->cluster_label; else if(strcmp(TORQUE_JOB_PREFIX_KEY, option_key) == 0) - return driver->job_prefix; + return driver->job_prefix; else { util_abort("%s: option_id:%s not recognized for TORQUE driver \n", __func__, option_key); return NULL; @@ -250,6 +283,20 @@ stringlist_type * torque_driver_alloc_cmd(torque_driver_type * driver, return argv; } +static void torque_debug(torque_driver_type * driver , const char * fmt , ...) { + if (driver->debug_stream) { + { + va_list ap; + va_start(ap , fmt); + vfprintf(driver->debug_stream , fmt , ap ); + va_end(ap); + } + fprintf(driver->debug_stream , "\n"); + fsync( fileno(driver->debug_stream) ); + } +} + + static int torque_job_parse_qsub_stdout(const torque_driver_type * driver, const char * stdout_file) { int jobid; { @@ -275,10 +322,10 @@ void torque_job_create_submit_script(const char * script_filename, const char * if (submit_cmd == NULL) { util_abort("%s: cannot create submit script, because there is no executing commmand specified.", __func__); } - + FILE* script_file = util_fopen(script_filename, "w"); fprintf(script_file, "#!/bin/sh\n"); - + fprintf(script_file, "%s", submit_cmd); for (int i = 0; i < argc; i++) { @@ -288,6 +335,7 @@ void torque_job_create_submit_script(const char * script_filename, const char * util_fclose(script_file); } + static int torque_driver_submit_shell_job(torque_driver_type * driver, const char * run_path, const char * job_name, @@ -295,30 +343,36 @@ static int torque_driver_submit_shell_job(torque_driver_type * driver, int num_cpu, int job_argc, const char ** job_argv) { - int job_id; - char * tmp_file = util_alloc_tmp_file("/tmp", "enkf-submit", true); - char * script_filename = util_alloc_filename(run_path, "qsub_script", "sh"); - torque_job_create_submit_script(script_filename, submit_cmd, job_argc, job_argv); + + usleep( driver->submit_sleep ); { - int p_units_from_driver = driver->num_cpus_per_node * driver->num_nodes; - if (num_cpu > p_units_from_driver) { - util_abort("%s: Error in config, job's config requires %d processing units, but config says %s: %d, and %s: %d, which multiplied becomes: %d \n", - __func__, num_cpu, TORQUE_NUM_CPUS_PER_NODE, driver->num_cpus_per_node, TORQUE_NUM_NODES, driver->num_nodes, p_units_from_driver); - } - stringlist_type * remote_argv = torque_driver_alloc_cmd(driver, job_name, script_filename); - char ** argv = stringlist_alloc_char_ref(remote_argv); - util_fork_exec(driver->qsub_cmd, stringlist_get_size(remote_argv), (const char **) argv, true, NULL, NULL, NULL, tmp_file, NULL); + int job_id; + char * tmp_file = util_alloc_tmp_file("/tmp", "enkf-submit", true); + char * script_filename = util_alloc_filename(run_path, "qsub_script", "sh"); + torque_job_create_submit_script(script_filename, submit_cmd, job_argc, job_argv); + { + int p_units_from_driver = driver->num_cpus_per_node * driver->num_nodes; + if (num_cpu > p_units_from_driver) { + util_abort("%s: Error in config, job's config requires %d processing units, but config says %s: %d, and %s: %d, which multiplied becomes: %d \n", + __func__, num_cpu, TORQUE_NUM_CPUS_PER_NODE, driver->num_cpus_per_node, TORQUE_NUM_NODES, driver->num_nodes, p_units_from_driver); + } + { + stringlist_type * remote_argv = torque_driver_alloc_cmd(driver, job_name, script_filename); + char ** argv = stringlist_alloc_char_ref(remote_argv); + util_fork_exec(driver->qsub_cmd , stringlist_get_size(remote_argv), (const char **) argv, true, NULL, NULL, NULL, tmp_file, NULL); - free(argv); - stringlist_free(remote_argv); - } + free(argv); + stringlist_free(remote_argv); + } + } - job_id = torque_job_parse_qsub_stdout(driver, tmp_file); + job_id = torque_job_parse_qsub_stdout(driver, tmp_file); - util_unlink_existing(tmp_file); - free(tmp_file); + util_unlink_existing(tmp_file); + free(tmp_file); - return job_id; + return job_id; + } } void torque_job_free(torque_job_type * job) { @@ -341,22 +395,23 @@ void * torque_driver_submit_job(void * __driver, int argc, const char ** argv) { torque_driver_type * driver = torque_driver_safe_cast(__driver); - char * local_job_name = NULL; - if(driver->job_prefix != NULL){ - local_job_name = util_alloc_sprintf("%s%s",driver->job_prefix, job_name); - } - else{ - local_job_name = job_name; - } torque_job_type * job = torque_job_alloc(); + + torque_debug( driver , "Submitting job in:%s" , run_path); { + char * local_job_name = NULL; + if (driver->job_prefix) + local_job_name = util_alloc_sprintf("%s%s",driver->job_prefix, job_name); + else + local_job_name = util_alloc_string_copy( job_name ); + job->torque_jobnr = torque_driver_submit_shell_job(driver, run_path, local_job_name, submit_cmd, num_cpu, argc, argv); job->torque_jobnr_char = util_alloc_sprintf("%ld", job->torque_jobnr); - } - if(driver->job_prefix != NULL){ - free(local_job_name); + torque_debug( driver , "Job:%s Id:%d" , run_path , job->torque_jobnr); + free(local_job_name); } + if (job->torque_jobnr > 0) return job; else { @@ -365,7 +420,6 @@ void * torque_driver_submit_job(void * __driver, NULL return values. */ torque_job_free(job); - return NULL; } } @@ -439,16 +493,17 @@ void torque_driver_kill_job(void * __driver, void * __job) { } void torque_driver_free(torque_driver_type * driver) { - + torque_driver_set_debug_output(driver, NULL); util_safe_free(driver->queue_name); free(driver->qdel_cmd); free(driver->qstat_cmd); free(driver->qsub_cmd); free(driver->num_cpus_per_node_char); free(driver->num_nodes_char); + if (driver->job_prefix) + free(driver->job_prefix); free(driver); - driver = NULL; } void torque_driver_free__(void * __driver) { @@ -456,3 +511,10 @@ void torque_driver_free__(void * __driver) { torque_driver_free(driver); } +int torque_driver_get_submit_sleep( const torque_driver_type * driver ) { + return driver->submit_sleep; +} + +FILE * torque_driver_get_debug_stream( const torque_driver_type * driver ) { + return driver->debug_stream; +} diff --git a/ThirdParty/Ert/devel/libjob_queue/src/workflow.c b/ThirdParty/Ert/devel/libjob_queue/src/workflow.c index a8cdd7863d..3867717615 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/workflow.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/workflow.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'workflow.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -28,7 +28,7 @@ #include <ert/util/vector.h> #include <ert/util/subst_list.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/job_queue/workflow.h> #include <ert/job_queue/workflow_job.h> @@ -54,11 +54,11 @@ struct workflow_struct { UTIL_TYPE_ID_DECLARATION; time_t compile_time; bool compiled; - char * src_file; + char * src_file; vector_type * cmd_list; workflow_joblist_type * joblist; config_error_type * last_error; - vector_type * stack; + vector_type * stack; }; /*****************************************************************/ @@ -74,7 +74,7 @@ static cmd_type * cmd_alloc( const workflow_job_type * workflow_job , const stri static UTIL_SAFE_CAST_FUNCTION( cmd , CMD_TYPE_ID ); -static void cmd_free( cmd_type * cmd ){ +static void cmd_free( cmd_type * cmd ){ stringlist_free( cmd->arglist ); free( cmd ); } @@ -125,48 +125,51 @@ bool workflow_try_compile( workflow_type * script , const subst_list_type * cont tmp_file = NULL; } } - + { time_t src_mtime = util_file_mtime( script->src_file ); if (script->compiled) { - if (util_difftime_seconds( src_mtime , script->compile_time ) > 0 ) + if (util_difftime_seconds( src_mtime , script->compile_time ) > 0 ) return true; else { - // Script has been compiled succesfully, but then changed afterwards. + // Script has been compiled succesfully, but then changed afterwards. // We try to recompile; if that fails we are left with 'nothing'. } } } - + { // Try to compile - config_type * config_compiler = workflow_joblist_get_compiler( script->joblist ); + config_parser_type * config_compiler = workflow_joblist_get_compiler( script->joblist ); script->compiled = false; workflow_clear( script ); - config_clear( config_compiler ); { - if (config_parse( config_compiler , src_file , WORKFLOW_COMMENT_STRING , WORKFLOW_INCLUDE , NULL , CONFIG_UNRECOGNIZED_ERROR , true )) { + config_content_type * content = config_parse( config_compiler , src_file , WORKFLOW_COMMENT_STRING , WORKFLOW_INCLUDE , NULL , CONFIG_UNRECOGNIZED_ERROR , true ); + + if (config_content_is_valid( content )) { int cmd_line; - for (cmd_line = 0; cmd_line < config_get_content_size(config_compiler); cmd_line++) { - const config_content_node_type * node = config_iget_content_node( config_compiler , cmd_line ); + for (cmd_line = 0; cmd_line < config_content_get_size(content); cmd_line++) { + const config_content_node_type * node = config_content_iget_node( content , cmd_line ); const char * jobname = config_content_node_get_kw( node ); const workflow_job_type * job = workflow_joblist_get_job( script->joblist , jobname ); cmd_type * cmd = cmd_alloc( job , config_content_node_get_stringlist( node )); - + workflow_add_cmd( script , cmd ); } script->compiled = true; } else - workflow_store_error( script , config_get_errors( config_compiler )); + workflow_store_error( script , config_content_get_errors( content )); + + config_content_free( content ); } } - + if (tmp_file != NULL) { if (script->compiled) remove( tmp_file ); free( tmp_file ); } - } + } // It is legal to remove the script after successfull compilation but // then the context will not be applied at subsequent invocations. @@ -177,7 +180,7 @@ bool workflow_try_compile( workflow_type * script , const subst_list_type * cont bool workflow_run(workflow_type * workflow, void * self , bool verbose , const subst_list_type * context) { vector_clear( workflow->stack ); workflow_try_compile( workflow , context); - + if (workflow->compiled) { int icmd; for (icmd = 0; icmd < vector_get_size( workflow->cmd_list ); icmd++) { @@ -186,7 +189,7 @@ bool workflow_run(workflow_type * workflow, void * self , bool verbose , const s vector_push_front_ref( workflow->stack , return_value ); } return true; - } else + } else return false; } @@ -216,7 +219,7 @@ workflow_type * workflow_alloc( const char * src_file , workflow_joblist_type * script->compiled = false; script->last_error = NULL; script->stack = vector_alloc_new(); - + workflow_try_compile( script , NULL ); return script; } @@ -251,7 +254,7 @@ int workflow_size(const workflow_type * workflow) { return vector_get_size( workflow->cmd_list ); } -workflow_job_type * workflow_iget_job( const workflow_type * workflow, int index) { +const workflow_job_type * workflow_iget_job( const workflow_type * workflow, int index) { const cmd_type * cmd = vector_iget_const( workflow->cmd_list , index ); return cmd->workflow_job; } diff --git a/ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c b/ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c index f582d48130..da6eaae2f7 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'workflow_job.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow_job.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -27,7 +27,7 @@ #include <ert/util/util.h> #include <ert/util/type_macros.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/job_queue/workflow_job.h> @@ -40,7 +40,7 @@ #define MAX_ARG_KEY "MAX_ARG" #define ARG_TYPE_KEY "ARG_TYPE" #define INTERNAL_KEY "INTERNAL" -#define MODULE_KEY "MODULE" +#define MODULE_KEY "MODULE" #define FUNCTION_KEY "FUNCTION" #define SCRIPT_KEY "SCRIPT" #define EXECUTABLE_KEY "EXECUTABLE" @@ -58,7 +58,7 @@ struct workflow_job_struct { UTIL_TYPE_ID_DECLARATION; bool internal; int min_arg; - int max_arg; + int max_arg; int_vector_type * arg_types; // Should contain values from the config_item_types enum in config.h. char * executable; char * internal_script_path; @@ -80,11 +80,11 @@ const char * workflow_job_get_name( const workflow_job_type * workflow_job ) { } -config_type * workflow_job_alloc_config() { - config_type * config = config_alloc(); +config_parser_type * workflow_job_alloc_config() { + config_parser_type * config = config_alloc(); { config_schema_item_type * item; - + item = config_add_schema_item( config , MIN_ARG_KEY , false ); config_schema_item_set_argc_minmax( item , 1 , 1 ); config_schema_item_iset_type( item , 0 , CONFIG_INT ); @@ -109,7 +109,7 @@ config_type * workflow_job_alloc_config() { config_schema_item_iset_type( item , 0 , CONFIG_PATH ); /*---------------------------------------------------------------*/ - + item = config_add_schema_item( config , FUNCTION_KEY , false ); config_schema_item_set_argc_minmax( item , 1 , 1); @@ -128,9 +128,9 @@ config_type * workflow_job_alloc_config() { static UTIL_SAFE_CAST_FUNCTION(workflow_job , WORKFLOW_JOB_TYPE_ID ); -void workflow_job_update_config_compiler( const workflow_job_type * workflow_job , config_type * config_compiler ) { +void workflow_job_update_config_compiler( const workflow_job_type * workflow_job , config_parser_type * config_compiler ) { config_schema_item_type * item = config_add_schema_item( config_compiler , workflow_job->name , false ); - /* + /* Ensure that the arg_types mapping is at least as large as the max_arg value. The arg_type vector will be left padded with CONFIG_STRING values. @@ -223,7 +223,7 @@ void workflow_job_set_max_arg( workflow_job_type * workflow_job , int max_arg) { int workflow_job_get_min_arg( const workflow_job_type * workflow_job ) { return workflow_job->min_arg; } - + int workflow_job_get_max_arg( const workflow_job_type * workflow_job ) { return workflow_job->max_arg; } @@ -248,7 +248,7 @@ static void workflow_job_iset_argtype_string( workflow_job_type * workflow_job , if (type != CONFIG_INVALID) workflow_job_iset_argtype( workflow_job , iarg , type ); - + } @@ -279,8 +279,8 @@ static void workflow_job_validate_internal( workflow_job_type * workflow_job ) { static void workflow_job_validate_external( workflow_job_type * workflow_job ) { if (workflow_job->executable != NULL) { - if (util_is_executable( workflow_job->executable ) && - (workflow_job->module == workflow_job->function) && + if (util_is_executable( workflow_job->executable ) && + (workflow_job->module == workflow_job->function) && (workflow_job->module == NULL)) workflow_job->valid = true; } @@ -289,65 +289,65 @@ static void workflow_job_validate_external( workflow_job_type * workflow_job ) { static void workflow_job_validate( workflow_job_type * workflow_job ) { - if (workflow_job->internal) + if (workflow_job->internal) workflow_job_validate_internal( workflow_job ); - else + else workflow_job_validate_external( workflow_job ); } -workflow_job_type * workflow_job_config_alloc( const char * name , config_type * config , const char * config_file) { - config_clear( config ); - if (config_parse( config , config_file , "--", NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true)) { +workflow_job_type * workflow_job_config_alloc( const char * name , config_parser_type * config , const char * config_file) { + workflow_job_type * workflow_job = NULL; + config_content_type * content = config_parse( config , config_file , "--", NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true); + if (config_content_is_valid( content )) { bool internal = DEFAULT_INTERNAL; - if (config_item_set( config , INTERNAL_KEY)) - internal = config_iget_as_bool( config , INTERNAL_KEY , 0 , 0 ); - + if (config_content_has_item( content , INTERNAL_KEY)) + internal = config_content_iget_as_bool( content , INTERNAL_KEY , 0 , 0 ); + { - workflow_job_type * workflow_job = workflow_job_alloc( name , internal ); - - if (config_item_set( config , MIN_ARG_KEY)) - workflow_job_set_min_arg( workflow_job , config_iget_as_int( config , MIN_ARG_KEY , 0 , 0 )); - - if (config_item_set( config , MAX_ARG_KEY)) - workflow_job_set_max_arg( workflow_job , config_iget_as_int( config , MAX_ARG_KEY , 0 , 0 )); - + workflow_job = workflow_job_alloc( name , internal ); + + if (config_content_has_item( content , MIN_ARG_KEY)) + workflow_job_set_min_arg( workflow_job , config_content_iget_as_int( content , MIN_ARG_KEY , 0 , 0 )); + + if (config_content_has_item( content , MAX_ARG_KEY)) + workflow_job_set_max_arg( workflow_job , config_content_iget_as_int( content , MAX_ARG_KEY , 0 , 0 )); + { int i; - for (i=0; i < config_get_occurences( config , ARG_TYPE_KEY); i++) { - int iarg = config_iget_as_int( config , ARG_TYPE_KEY , i , 0 ); - const char * arg_type = config_iget( config , ARG_TYPE_KEY , i , 1 ); - + for (i=0; i < config_content_get_occurences( content , ARG_TYPE_KEY); i++) { + int iarg = config_content_iget_as_int( content , ARG_TYPE_KEY , i , 0 ); + const char * arg_type = config_content_iget( content , ARG_TYPE_KEY , i , 1 ); + workflow_job_iset_argtype_string( workflow_job , iarg , arg_type ); } } - - if (config_item_set( config , MODULE_KEY)) - workflow_job_set_module( workflow_job , config_get_value( config , MODULE_KEY)); // Could be a pure so name; or a full path ..... Like executable - - if (config_item_set( config , FUNCTION_KEY)) - workflow_job_set_function( workflow_job , config_get_value( config , FUNCTION_KEY)); - - if (config_item_set( config , EXECUTABLE_KEY)) - workflow_job_set_executable( workflow_job , config_get_value_as_abspath( config , EXECUTABLE_KEY)); - - if (config_item_set( config , SCRIPT_KEY)) { - workflow_job_set_internal_script( workflow_job , config_get_value_as_abspath( config , SCRIPT_KEY)); + + if (config_content_has_item( content , MODULE_KEY)) + workflow_job_set_module( workflow_job , config_content_get_value( content , MODULE_KEY)); // Could be a pure so name; or a full path ..... Like executable + + if (config_content_has_item( content , FUNCTION_KEY)) + workflow_job_set_function( workflow_job , config_content_get_value( content , FUNCTION_KEY)); + + if (config_content_has_item( content , EXECUTABLE_KEY)) + workflow_job_set_executable( workflow_job , config_content_get_value_as_abspath( content , EXECUTABLE_KEY)); + + if (config_content_has_item( content , SCRIPT_KEY)) { + workflow_job_set_internal_script( workflow_job , config_content_get_value_as_abspath( content , SCRIPT_KEY)); } workflow_job_validate( workflow_job ); - + if (!workflow_job->valid) { workflow_job_free( workflow_job ); workflow_job = NULL; } - - return workflow_job; } - } else - return NULL; + } + config_content_free( content ); + return workflow_job; } @@ -372,7 +372,7 @@ void workflow_job_free__( void * arg) { The workflow job can return an arbitrary (void *) pointer. It is the calling scopes responsability to interpret this object correctly. If the the workflow job allocates storage the calling scope must - discard it. + discard it. */ static void * workflow_job_run_internal( const workflow_job_type * job, void * self , bool verbose , const stringlist_type * arg) { @@ -385,12 +385,12 @@ static void * workflow_job_run_external( const workflow_job_type * job, bool ver util_fork_exec( job->executable , stringlist_get_size( arg ), - (const char **) argv , + (const char **) argv , true , - NULL , - NULL , - NULL , - NULL , + NULL , + NULL , + NULL , + NULL , NULL ); if (argv != NULL) { diff --git a/ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c b/ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c index 215cd50f23..23806cc81a 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c @@ -1,20 +1,20 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - + Copyright (C) 2012 Statoil ASA, Norway. + The file 'workflow_joblist.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdbool.h> @@ -26,15 +26,15 @@ #include <ert/util/util.h> #include <ert/util/type_macros.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/job_queue/workflow_job.h> #include <ert/job_queue/workflow_joblist.h> struct workflow_joblist_struct { - config_type * workflow_compiler; - config_type * job_config; + config_parser_type * workflow_compiler; + config_parser_type * job_config; hash_type * joblist; }; @@ -80,16 +80,20 @@ bool workflow_joblist_add_job_from_file( workflow_joblist_type * joblist , const if (job) { workflow_joblist_add_job( joblist , job ); return true; - } else + } else return false; } -config_type * workflow_joblist_get_compiler( const workflow_joblist_type * joblist ) { +config_parser_type * workflow_joblist_get_compiler( const workflow_joblist_type * joblist ) { return joblist->workflow_compiler; } -config_type * workflow_joblist_get_job_config( const workflow_joblist_type * joblist ) { +config_parser_type * workflow_joblist_get_job_config( const workflow_joblist_type * joblist ) { return joblist->job_config; } + +stringlist_type * workflow_joblist_get_job_names(const workflow_joblist_type * joblist) { + return hash_alloc_stringlist(joblist->joblist); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt index e0cb9b046f..c3d06dd340 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt @@ -2,6 +2,7 @@ add_executable( job_loadOK job_loadOK.c ) add_executable( job_loadFail job_loadFail.c ) add_executable( create_file create_file.c ) add_executable( job_workflow_test job_workflow_test.c ) +add_executable( job_lsf_parse_bsub_stdout job_lsf_parse_bsub_stdout.c ) add_executable( ext_joblist_test ext_joblist_test.c ) target_link_libraries( job_workflow_test job_queue test_util ) @@ -9,6 +10,9 @@ target_link_libraries( create_file job_queue test_util ) target_link_libraries( job_loadOK job_queue test_util ) target_link_libraries( job_loadFail job_queue test_util ) target_link_libraries( ext_joblist_test job_queue test_util ) +target_link_libraries( job_lsf_parse_bsub_stdout job_queue test_util) + +add_test( job_lsf_parse_bsub_stdout ${EXECUTABLE_OUTPUT_PATH}/job_lsf_parse_bsub_stdout ) add_test( job_workflow_test ${EXECUTABLE_OUTPUT_PATH}/job_workflow_test ${EXECUTABLE_OUTPUT_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/data/internal_job) @@ -35,37 +39,10 @@ target_link_libraries( job_queue_driver_test job_queue test_util ) add_test( job_queue_driver_test ${EXECUTABLE_OUTPUT_PATH}/job_queue_driver_test ) -# This should be a space separated list of servers which will be -# tried out when testing the LSF submit capability. The test program -# will interpret the special strings 'NULL' and 'LOCAL' as follows: -# -# NULL: Submit using the linked in library functions. -# LOCAL: Submit using shell commands on the current server -# -set(LSF_SERVERS "LOCAL" CACHE STRING "List of LSF servers for testing") - -if (HAVE_LSF_LIBRARY) - add_executable( job_lsf_test job_lsf_test.c ) - target_link_libraries( job_lsf_test job_queue util test_util ) - add_test( job_lsf_test ${EXECUTABLE_OUTPUT_PATH}/job_lsf_test ) -endif() - - - -if (HAVE_LSF_LIBRARY) - add_executable( job_lsb job_lsb.c ) - target_link_libraries( job_lsb job_queue util test_util ) - add_test( job_lsb ${EXECUTABLE_OUTPUT_PATH}/job_lsb ) +if (ERT_LSF_SUBMIT_TEST) + include( lsf_tests.cmake ) endif() -add_executable( job_lsf_submit_test job_lsf_submit_test.c ) -target_link_libraries( job_lsf_submit_test job_queue util test_util ) -add_executable( job_program job_program.c ) - -if (LSF_SERVERS) - add_test( job_lsf_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_lsf_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_program ${LSF_SERVERS}) - set_property( TEST job_lsf_submit_test PROPERTY LABELS LSF) -endif() add_executable( job_torque_test job_torque_test.c ) target_link_libraries( job_torque_test job_queue util test_util ) @@ -81,3 +58,5 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/qsub_emulators/ DESTINATION ${EXECUTA add_test(NAME job_torque_submit_test WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND ${EXECUTABLE_OUTPUT_PATH}/job_torque_submit_test dummyparam) set_property(TEST job_torque_submit_test PROPERTY ENVIRONMENT “setenv PATH ${EXECUTABLE_OUTPUT_PATH}:$PATHâ€) set_property(TEST ext_joblist_test PROPERTY LABELS StatoilData ) + + diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/ext_joblist_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/ext_joblist_test.c index 1f6a3d2dba..5dfdc9848b 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/ext_joblist_test.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/ext_joblist_test.c @@ -22,7 +22,7 @@ void load_job_directory(ext_joblist_type * joblist , const char * path, const char * license_root_path) { bool user_mode = false; - ext_joblist_add_jobs_in_directory(joblist , path, license_root_path, user_mode ); + ext_joblist_add_jobs_in_directory(joblist , path, license_root_path, user_mode, true ); test_assert_true( ext_joblist_has_job(joblist, "SYMLINK")); } diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c index 6201572c36..a2e5c20d28 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c @@ -18,13 +18,13 @@ #include <stdlib.h> #include <stdbool.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/job_queue/workflow_job.h> -bool loadConfig(config_type * config , const char * config_file, config_type * config_compiler) { +bool loadConfig(config_parser_type * config , const char * config_file, config_parser_type * config_compiler) { bool OK = false; workflow_job_type * cmd = workflow_job_config_alloc( "NAME" , config , config_file); @@ -42,8 +42,8 @@ bool loadConfig(config_type * config , const char * config_file, config_type * c int main( int argc , char ** argv) { int status = 0; { - config_type * config = workflow_job_alloc_config(); - config_type * config_compiler = config_alloc(); + config_parser_type * config = workflow_job_alloc_config(); + config_parser_type * config_compiler = config_alloc(); int iarg; bool OK = true; diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_loadOK.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadOK.c index 5b94f4e1f6..2e15a636e5 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_loadOK.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadOK.c @@ -18,13 +18,13 @@ #include <stdlib.h> #include <stdbool.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/job_queue/workflow_job.h> -bool loadConfig(config_type * config , const char * config_file , config_type * config_compiler) { +bool loadConfig(config_parser_type * config , const char * config_file , config_parser_type * config_compiler) { bool OK = false; workflow_job_type * cmd = workflow_job_config_alloc( "NAME" , config , config_file); @@ -42,8 +42,8 @@ bool loadConfig(config_type * config , const char * config_file , config_type * int main( int argc , char ** argv) { int status = 0; { - config_type * config = workflow_job_alloc_config(); - config_type * config_compiler = config_alloc(); + config_parser_type * config = workflow_job_alloc_config(); + config_parser_type * config_compiler = config_alloc(); int iarg; bool OK = true; diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_library_submit_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_library_submit_test.c new file mode 100644 index 0000000000..f834ebfdf4 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_library_submit_test.c @@ -0,0 +1,64 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_lsf_submit_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <stdbool.h> +#include <unistd.h> + +#include <assert.h> +#include <ert/util/util.h> + +#include <ert/job_queue/lsf_driver.h> +#include <ert/job_queue/lsf_job_stat.h> + + + +void test_submit(lsf_driver_type * driver, const char * cmd) { + assert( lsf_driver_set_option(driver , LSF_DEBUG_OUTPUT , "TRUE" ) ); + assert( LSF_SUBMIT_INTERNAL == lsf_driver_get_submit_method( driver )); + { + char * run_path = util_alloc_cwd(); + lsf_job_type * job = lsf_driver_submit_job( driver , cmd , 1 , run_path , "NAME" , 0 , NULL ); + assert( job ); + { + { + int lsf_status = lsf_driver_get_job_status_lsf( driver , job ); + assert( (lsf_status == JOB_STAT_RUN) || (lsf_status == JOB_STAT_PEND) ); + } + + lsf_driver_kill_job( driver , job ); + lsf_driver_set_bjobs_refresh_interval( driver , 0 ); + sleep(1); + + { + int lsf_status = lsf_driver_get_job_status_lsf( driver , job ); + assert( lsf_status == JOB_STAT_EXIT); + } + } + + free( run_path ); + } +} + + + +int main( int argc , char ** argv) { + lsf_driver_type * driver = lsf_driver_alloc(); + test_submit(driver , argv[1]); + lsf_driver_free( driver ); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_parse_bsub_stdout.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_parse_bsub_stdout.c new file mode 100644 index 0000000000..3aae17432a --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_parse_bsub_stdout.c @@ -0,0 +1,85 @@ +/* + Copyright (C) 2015 Statoil ASA, Norway. + + The file 'job_lsf_submit_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <stdbool.h> +#include <unistd.h> + + +#include <ert/util/util.h> +#include <ert/util/test_util.h> +#include <ert/util/test_work_area.h> + +#include <ert/job_queue/lsf_driver.h> + + +void test_empty_file() { + const char * stdout_file = "bsub_empty"; + { + FILE * stream = util_fopen(stdout_file , "w"); + fclose( stream ); + } + test_assert_int_equal( lsf_job_parse_bsub_stdout("bsub" , stdout_file ) , 0); +} + + +void test_OK() { + const char * stdout_file = "bsub_OK"; + { + FILE * stream = util_fopen(stdout_file , "w"); + fprintf(stream , "Job <12345> is submitted to default queue <normal>.\n"); + fclose( stream ); + } + test_assert_int_equal( lsf_job_parse_bsub_stdout("bsub" , stdout_file ) , 12345); +} + + +void test_file_does_not_exist() { + test_assert_int_equal( lsf_job_parse_bsub_stdout("bsub" , "does/not/exist") , 0); +} + + + +void parse_invalid( void * arg ) { + const char * filename = (const char*) arg; + lsf_job_parse_bsub_stdout("bsub" , filename); +} + + +void test_parse_fail_abort() { + const char * stdout_file = "bsub_abort"; + { + FILE * stream = util_fopen(stdout_file , "w"); + fprintf(stream , "Job 12345 is submitted to default queue <normal>.\n"); + fclose( stream ); + } + test_assert_util_abort( "lsf_job_parse_bsub_stdout" , parse_invalid , (void *) stdout_file ); +} + + +int main(int argc, char ** argv) { + test_work_area_type * work_area = test_work_area_alloc( "bsub_parse_stdout"); + { + test_empty_file(); + test_file_does_not_exist( ); + test_OK(); + test_parse_fail_abort(); + } + test_work_area_free( work_area ); +} + + diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_remote_submit_test.c similarity index 77% rename from ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_test.c rename to ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_remote_submit_test.c index f539aad745..8d1aab392a 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_test.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_remote_submit_test.c @@ -27,7 +27,8 @@ void test_submit(lsf_driver_type * driver , const char * server , const char * bsub_cmd , const char * bjobs_cmd , const char * bkill_cmd , const char * cmd) { - + + test_assert_true( lsf_driver_set_option(driver , LSF_DEBUG_OUTPUT , "TRUE" ) ); test_assert_true( lsf_driver_set_option(driver , LSF_SERVER , server ) ); if (bsub_cmd != NULL) @@ -42,7 +43,6 @@ void test_submit(lsf_driver_type * driver , const char * server , const char * b { char * run_path = util_alloc_cwd(); lsf_job_type * job = lsf_driver_submit_job( driver , cmd , 1 , run_path , "NAME" , 0 , NULL ); - if (job) { { int lsf_status = lsf_driver_get_job_status_lsf( driver , job ); @@ -52,10 +52,18 @@ void test_submit(lsf_driver_type * driver , const char * server , const char * b lsf_driver_kill_job( driver , job ); lsf_driver_set_bjobs_refresh_interval( driver , 0 ); - sleep(1); + sleep(2); { - int lsf_status = lsf_driver_get_job_status_lsf( driver , job ); + int lsf_status = 0; + for(int i=0; i < 10; i++){ + lsf_status = lsf_driver_get_job_status_lsf( driver , job ); + if (lsf_status != JOB_STAT_EXIT){ + sleep(2); + }else{ + break; + } + } if (lsf_status != JOB_STAT_EXIT) test_error_exit("Got lsf_status:%d expected: %d \n",lsf_status , JOB_STAT_EXIT ); } @@ -69,14 +77,18 @@ void test_submit(lsf_driver_type * driver , const char * server , const char * b int main( int argc , char ** argv) { - lsf_driver_type * driver = lsf_driver_alloc(); - stringlist_type * server_list = stringlist_alloc_from_split( argv[2] , " "); - int iarg; - for (iarg = 0; iarg < stringlist_get_size( server_list ); iarg++) { - const char * server = stringlist_iget( server_list , iarg ); - test_submit(driver , server , NULL , NULL , NULL , argv[1]); + util_install_signals(); + { + int iarg; + lsf_driver_type * driver = lsf_driver_alloc(); + + for (iarg = 2; iarg < argc; iarg++) { + const char * server = argv[iarg]; + printf("Testing lsf server:%s \n",server); + test_submit(driver , server , NULL , NULL , NULL , argv[1]); + } + + lsf_driver_free( driver ); } - stringlist_free( server_list ); - exit(0); } diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_library_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_library_test.c new file mode 100644 index 0000000000..ef327d6df7 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_library_test.c @@ -0,0 +1,66 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_lsf_submit_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. +*/ +#include <stdlib.h> +#include <stdbool.h> +#include <unistd.h> + +#include <ert/util/util.h> +#include <ert/util/test_util.h> + +#include <ert/job_queue/lsf_driver.h> +#include <ert/job_queue/lsf_job_stat.h> + + +void test_submit(lsf_driver_type * driver) { + test_assert_true( lsf_driver_set_option(driver , LSF_DEBUG_OUTPUT , "TRUE" ) ); + test_assert_int_equal( LSF_SUBMIT_INTERNAL , lsf_driver_get_submit_method( driver )); + { + char * run_path = util_alloc_cwd(); + lsf_job_type * job = lsf_driver_submit_job( driver , cmd , 1 , run_path , "NAME" , 0 , NULL ); + if (job) { + { + int lsf_status = lsf_driver_get_job_status_lsf( driver , job ); + if (!((lsf_status == JOB_STAT_RUN) || (lsf_status == JOB_STAT_PEND))) + test_error_exit("Got lsf_status:%d expected: %d or %d \n",lsf_status , JOB_STAT_RUN , JOB_STAT_PEND); + } + + lsf_driver_kill_job( driver , job ); + lsf_driver_set_bjobs_refresh_interval( driver , 0 ); + sleep(1); + + { + int lsf_status = lsf_driver_get_job_status_lsf( driver , job ); + if (lsf_status != JOB_STAT_EXIT) + test_error_exit("Got lsf_status:%d expected: %d \n",lsf_status , JOB_STAT_EXIT ); + } + } else + test_error_exit("lsf_driver_submit_job() returned NULL \n"); + + + free( run_path ); + } +} + + + +int main( int argc , char ** argv) { + lsf_driver_type * driver = lsf_driver_alloc(); + test_submit(driver); + lsf_driver_free( driver ); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_program.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_program.c index 7d3493cfd3..d57e12a030 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_program.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_program.c @@ -17,8 +17,19 @@ */ #include <stdlib.h> #include <unistd.h> +#include <stdbool.h> +#include <stdio.h> + int main( int argc , char ** argv) { - sleep(60 * 5 ); + int max_count = 100; + int count = 0; + while (true) { + sleep(1); + count++; + printf("%d/%d \n",count , max_count); + if (count == max_count) + break; + } exit(0); } diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_submit_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_submit_test.c index 7007b8c2b6..64785efc18 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_submit_test.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_submit_test.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'job_torque_submit_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'job_torque_submit_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdbool.h> @@ -73,6 +73,6 @@ int main(int argc, char ** argv) { } printf("Submit, status and kill OK\n"); torque_driver_free(driver); - + exit(0); } diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_test.c index 909b923617..9466c6aec5 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_test.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_torque_test.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'job_lsf_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_lsf_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdlib.h> #include <stdio.h> @@ -32,6 +32,7 @@ void test_option(torque_driver_type * driver, const char * option, const char * void setoption_setalloptions_optionsset() { torque_driver_type * driver = torque_driver_alloc(); + test_option(driver, TORQUE_QSUB_CMD, "XYZaaa"); test_option(driver, TORQUE_QSTAT_CMD, "xyZfff"); test_option(driver, TORQUE_QDEL_CMD, "ZZyfff"); @@ -43,6 +44,15 @@ void setoption_setalloptions_optionsset() { test_option(driver, TORQUE_CLUSTER_LABEL, "thecluster"); test_option(driver, TORQUE_JOB_PREFIX_KEY, "coolJob"); + test_assert_int_equal( 0 , torque_driver_get_submit_sleep(driver)); + test_assert_NULL( torque_driver_get_debug_stream(driver) ); + + test_assert_true( torque_driver_set_option( driver , TORQUE_SUBMIT_SLEEP , "0.25")); + test_assert_int_equal( 250000 , torque_driver_get_submit_sleep(driver)); + + test_assert_true( torque_driver_set_option( driver , TORQUE_DEBUG_OUTPUT , "/tmp/torqueue_debug.txt")); + test_assert_not_NULL( torque_driver_get_debug_stream(driver) ); + printf("Options OK\n"); torque_driver_free(driver); } @@ -58,6 +68,7 @@ void setoption_set_typed_options_wrong_format_returns_false() { test_assert_false(torque_driver_set_option(driver, TORQUE_KEEP_QSUB_OUTPUT, "ja")); test_assert_false(torque_driver_set_option(driver, TORQUE_KEEP_QSUB_OUTPUT, "22")); test_assert_false(torque_driver_set_option(driver, TORQUE_KEEP_QSUB_OUTPUT, "1.1")); + test_assert_false(torque_driver_set_option(driver, TORQUE_SUBMIT_SLEEP, "X45")); } void getoption_nooptionsset_defaultoptionsreturned() { @@ -86,11 +97,11 @@ void create_submit_script_script_according_to_input() { torque_job_create_submit_script(script_filename, "job_program.py", 2, (const char **) args); free( args ); } - + { FILE* file_stream = util_fopen(script_filename, "r"); bool at_eof = false; - + char * line = util_fscanf_alloc_line(file_stream, &at_eof); test_assert_string_equal("#!/bin/sh", line); free(line); diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c index d9e3ed5738..2e2c62097b 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'job_workflow_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 <http://www.gnu.org/licenses/gpl.html> - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_workflow_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 <http://www.gnu.org/licenses/gpl.html> + for more details. */ #include <stdio.h> #include <stdlib.h> @@ -25,7 +25,7 @@ #include <ert/util/test_work_area.h> #include <ert/util/util.h> -#include <ert/config/config.h> +#include <ert/config/config_parser.h> #include <ert/job_queue/workflow.h> #include <ert/job_queue/workflow_job.h> @@ -37,7 +37,7 @@ void create_workflow( const char * workflow_file , const char * tmp_file , int v fprintf(stream , "CREATE_FILE %s %d\n" , tmp_file , value); fprintf(stream , "READ_FILE %s\n" , tmp_file ); fclose( stream ); - + printf("Have created:%s \n",workflow_file ); } @@ -47,7 +47,7 @@ void create_error_workflow( const char * workflow_file , const char * tmp_file , fprintf(stream , "CREATE_FILE %s %d\n" , tmp_file , value); fprintf(stream , "XREAD_FILE %s\n" , tmp_file ); fclose( stream ); - + printf("Have created:%s \n",workflow_file ); } @@ -61,13 +61,13 @@ void * read_file( void * self , const stringlist_type * args) { { int * return_value = util_malloc( sizeof * return_value ); return_value[0] = value[0]; - + return return_value; } } -static void create_exjob( const char * workflow , const char * bin_path) +static void create_exjob( const char * workflow , const char * bin_path) { FILE * stream = util_fopen( workflow , "w"); fprintf(stream , "EXECUTABLE \"%s/create_file\"\n" , bin_path); @@ -81,10 +81,10 @@ static void create_exjob( const char * workflow , const char * bin_path) void test_has_job(const char * job) { workflow_joblist_type * joblist = workflow_joblist_alloc(); test_assert_false( workflow_joblist_has_job( joblist , "NoNotThis")); - + workflow_joblist_add_job_from_file( joblist , "CREATE_FILE" , job); test_assert_true( workflow_joblist_has_job( joblist , "CREATE_FILE")); - + workflow_joblist_free( joblist ); } @@ -95,44 +95,40 @@ int main( int argc , char ** argv) { const char * internal_workflow = argv[2]; test_work_area_type * work_area = test_work_area_alloc( "job_workflow_test" ); - signal(SIGSEGV , util_abort_signal); + signal(SIGSEGV , util_abort_signal); create_exjob( exjob_file , bin_path ); test_has_job( exjob_file ); { - + int int_value = rand(); int read_value = 100; workflow_joblist_type * joblist = workflow_joblist_alloc(); - + if (!workflow_joblist_add_job_from_file( joblist , "CREATE_FILE" , exjob_file)) { remove( exjob_file ); - { - config_type * job_config = workflow_joblist_get_job_config( joblist ); - config_fprintf_errors( job_config , true , stdout ); - } test_error_exit("Loading job CREATE_FILE failed\n"); } else remove( exjob_file ); - + if (!workflow_joblist_add_job_from_file( joblist , "READ_FILE" , internal_workflow)) test_error_exit("Loading job READ_FILE failed\n"); - + { - config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); + config_parser_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); if (config_get_schema_size( workflow_compiler ) != 2) test_error_exit("Config compiler - wrong size \n"); } - - + + { const char * workflow_file = "workflow"; const char * tmp_file = "fileX"; workflow_type * workflow; - + create_workflow( workflow_file , tmp_file , int_value ); workflow = workflow_alloc(workflow_file , joblist ); unlink( workflow_file ); - + { bool runOK; runOK = workflow_run( workflow , &read_value , false , NULL); @@ -143,26 +139,21 @@ int main( int argc , char ** argv) { test_assert_int_equal( workflow_get_stack_size( workflow ) , 2 ); test_assert_not_NULL( workflow_iget_stack_ptr( workflow , 0 ) ); test_assert_NULL( workflow_iget_stack_ptr( workflow , 1 ) ); - + { void * return_value = workflow_iget_stack_ptr( workflow , 0 ); int return_int = *((int *) return_value); if (int_value != return_int) test_error_exit("Wrong numeric value read back \n"); - + test_assert_not_NULL( workflow_pop_stack( workflow )); test_assert_NULL( workflow_pop_stack( workflow )); test_assert_int_equal( workflow_get_stack_size( workflow ) , 0 ); - + free( return_value ); } - - - } else { - config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); - config_fprintf_errors( workflow_compiler , true ,stdout); unlink( tmp_file ); test_error_exit("Workflow did not run\n"); } @@ -170,7 +161,7 @@ int main( int argc , char ** argv) { } } workflow_joblist_free( joblist ); - + } { workflow_joblist_type * joblist = workflow_joblist_alloc(); @@ -179,7 +170,7 @@ int main( int argc , char ** argv) { int read_value; int int_value = 100; workflow_type * workflow; - + create_workflow( workflow_file , tmp_file , int_value ); workflow = workflow_alloc(workflow_file , joblist ); unlink( workflow_file ); diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/lsf_tests.cmake b/ThirdParty/Ert/devel/libjob_queue/tests/lsf_tests.cmake new file mode 100644 index 0000000000..6e5c413df0 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/lsf_tests.cmake @@ -0,0 +1,57 @@ +# The testing of the lsf submit capabilities is quite troublesome for +# two reasons, and therefor by default disabled: +# +# +# 1. The shell based LSF commands require that user running the +# bsub/bjobs/bxxx command has passwordless ssh configured to log in +# to the lsf server. When the build and testing is run as a common +# 'jenkins' user this becomes difficult. +# +# 2. Submitting through the lsf library requires that the build/test +# server actually is a LIM host; which it typically is not. +# +#----------------------------------------------------------------- +# +# This should be a space separated list of servers which will be +# tried out when testing the LSF submit capability. The test program +# will interpret the special strings 'NULL' and 'LOCAL' as follows: +# +# NULL: Submit using the linked in library functions. +# LOCAL: Submit using shell commands on the current server +# +set(LSF_SERVER "" CACHE STRING "List of LSF servers for testing") + +if (HAVE_LSF_LIBRARY) + add_executable( job_lsf_test job_lsf_test.c ) + target_link_libraries( job_lsf_test job_queue util test_util ) + add_test( job_lsf_test ${EXECUTABLE_OUTPUT_PATH}/job_lsf_test ) +endif() + + + +if (HAVE_LSF_LIBRARY) + add_executable( job_lsb job_lsb.c ) + target_link_libraries( job_lsb job_queue util test_util ) + add_test( job_lsb ${EXECUTABLE_OUTPUT_PATH}/job_lsb ) +endif() + +add_executable( job_lsf_remote_submit_test job_lsf_remote_submit_test.c ) +target_link_libraries( job_lsf_remote_submit_test job_queue util test_util ) + +add_executable( job_lsf_library_submit_test job_lsf_library_submit_test.c ) +target_link_libraries( job_lsf_library_submit_test job_queue util ) + +add_executable( job_program job_program.c ) + +if (LSF_SERVER) + add_test( job_lsf_remote_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_lsf_remote_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_program ${LSF_SERVER} NULL LOCAL) +else() + add_test( job_lsf_remote_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_lsf_remote_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_program NULL LOCAL) +endif() +set_property( TEST job_lsf_remote_submit_test PROPERTY LABELS StatoilData) + +# The test program is installed - actually running the test must be +# handled completely on the outside of this build system. +if (INSTALL_ERT) + install(TARGETS job_program job_lsf_library_submit_test DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +endif() \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libplot/CMakeLists.txt b/ThirdParty/Ert/devel/libplot/CMakeLists.txt index 8c14de8b7e..a4d694e247 100644 --- a/ThirdParty/Ert/devel/libplot/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libplot/CMakeLists.txt @@ -1,12 +1,21 @@ set( PLPLOT_ROOT "" CACHE FILEPATH "Root path for PLPLOT installation") set( PLOT_INSTALL_PREFIX "" CACHE STRING "Prefix for installation of libplot") -set( PLPLOT_INCLUDE_PATH ${PLPLOT_ROOT}/include ) -set( PLPLOT_LIB_PATH ${PLPLOT_ROOT}/lib ) +if(PLPLOT_ROOT) + set( PLPLOT_INCLUDE_PATH ${PLPLOT_ROOT}/include ) + set( PLPLOT_LIB_PATH ${PLPLOT_ROOT}/lib ) +else() + set( PLPLOT_INCLUDE_PATH ) + set( PLPLOT_LIB_PATH ) +endif() + +list(APPEND CMAKE_LIBRARY_PATH ${PLPLOT_LIB_PATH}) +list(APPEND CMAKE_INCLUDE_PATH ${PLPLOT_INCLUDE_PATH}) -find_library( PLPLOT_LIBRARY NAMES plplotd PATHS ${PLPLOT_LIB_PATH} ) -find_path( PLPLOT_HEADER plplot/plplot.h ${PLPLOT_INCLUDE_PATH} ) +find_library(PLPLOT_LIBRARY NAMES plplotd) +find_path( PLPLOT_HEADER plplot/plplot.h) +include_directories( ${PLPLOT_INCLUDE_PATH} ) include_directories( ${PLPLOT_HEADER} ) add_subdirectory( src ) diff --git a/ThirdParty/Ert/devel/libplot/src/plplot_driver.c b/ThirdParty/Ert/devel/libplot/src/plplot_driver.c index a4bab757ec..5b8d51f335 100644 --- a/ThirdParty/Ert/devel/libplot/src/plplot_driver.c +++ b/ThirdParty/Ert/devel/libplot/src/plplot_driver.c @@ -22,6 +22,10 @@ #include <math.h> #include <plplot/plplot.h> +/* version 5.9.10 changes plwid to plwidth */ +#ifndef plwidth +#define plwidth plwid +#endif #include <ert/util/util.h> #include <ert/util/arg_pack.h> diff --git a/ThirdParty/Ert/devel/libplot/src/summary_plot_live.c b/ThirdParty/Ert/devel/libplot/src/summary_plot_live.c index 3ed8427930..73ec6327d2 100644 --- a/ThirdParty/Ert/devel/libplot/src/summary_plot_live.c +++ b/ThirdParty/Ert/devel/libplot/src/summary_plot_live.c @@ -41,7 +41,7 @@ typedef struct summary_plot_gui_struct { GtkTextBuffer *buffer; GtkWidget *text; GtkNotebook *nb; - config_type *config; + config_parser_type *config; const char *conf_file; list_type *list; } summary_plot_gui_type; @@ -84,7 +84,7 @@ static gboolean summary_plot_timout(gpointer data); static char *summary_plot_get_timestamp(); static void summary_plot_append_textbox(summary_plot_gui_type * spg, const char *str, ...); -static config_type *summary_plot_init_config(const char *config_file); +static config_parser_type *summary_plot_init_config(const char *config_file); static void summary_plot_initialize_ensembles(summary_plot_type * sp); static void summary_plot_setup_gui(summary_plot_gui_type * spg); static gboolean summary_plot_canvas_menu(GtkWidget * widget, @@ -413,9 +413,9 @@ void summary_plot_append_textbox(summary_plot_gui_type * spg, } -config_type *summary_plot_init_config(const char *config_file) +config_parser_type *summary_plot_init_config(const char *config_file) { - config_type *config; + config_parser_type *config; config = config_alloc(false); config_init_item(config, "DATA_FILE", 0, NULL, true, false, 0, NULL, 1, diff --git a/ThirdParty/Ert/devel/libsched/applications/perturb_history/perturb_history.c b/ThirdParty/Ert/devel/libsched/applications/perturb_history/perturb_history.c index 9735b50dc1..5fd86a438c 100644 --- a/ThirdParty/Ert/devel/libsched/applications/perturb_history/perturb_history.c +++ b/ThirdParty/Ert/devel/libsched/applications/perturb_history/perturb_history.c @@ -69,7 +69,7 @@ void perturb_wconinje( void * void_kw , int restart_nr , void * arg) { -void config_init(config_type * config ) { +void config_init(config_parser_type * config ) { config_item_type * item; config_add_key_value(config , "NUM_REALIZATIONS" , true , CONFIG_INT ); @@ -98,7 +98,7 @@ void config_init(config_type * config ) { -void load_groups( const config_type * config , const sched_file_type * sched_file , hash_type * group_rates , const sched_history_type * sched_history , const time_t_vector_type * time_vector ) { +void load_groups( const config_parser_type * config , const sched_file_type * sched_file , hash_type * group_rates , const sched_history_type * sched_history , const time_t_vector_type * time_vector ) { int i; for (i=0; i < config_get_occurences( config , "GROUP_RATE" ); i++) { const char * group_name = config_iget( config , "GROUP_RATE" , i , 0 ); @@ -163,7 +163,7 @@ void debug (const time_t_vector_type * time_vector ) { int main( int argc , char ** argv ) { hash_type * group_rates = hash_alloc(); - config_type * config = config_alloc(); + config_parser_type * config = config_alloc(); char * config_file; { char * config_base; diff --git a/ThirdParty/Ert/devel/libsched/src/history.c b/ThirdParty/Ert/devel/libsched/src/history.c index 49c7e1759e..35493a3a71 100644 --- a/ThirdParty/Ert/devel/libsched/src/history.c +++ b/ThirdParty/Ert/devel/libsched/src/history.c @@ -165,12 +165,13 @@ bool history_init_ts( const history_type * history , const char * summary_key , for (int tstep = 0; tstep <= sched_history_get_last_history(history->sched_history); tstep++) { if (sched_history_open( history->sched_history , summary_key , tstep)) { + initOK = true; bool_vector_iset( valid , tstep , true ); double_vector_iset( value , tstep , sched_history_iget( history->sched_history , summary_key , tstep)); } else bool_vector_iset( valid , tstep , false ); } - initOK = true; + } else { diff --git a/ThirdParty/Ert/devel/libsched/src/sched_file.c b/ThirdParty/Ert/devel/libsched/src/sched_file.c index 8f322c41cc..8e1a37cbf8 100644 --- a/ThirdParty/Ert/devel/libsched/src/sched_file.c +++ b/ThirdParty/Ert/devel/libsched/src/sched_file.c @@ -424,15 +424,15 @@ time_t_vector_type * sched_file_alloc_time_t_vector( const sched_file_type * sch static stringlist_type * sched_file_tokenize( const char * filename ) { stringlist_type * token_list; - parser_type * parser = parser_alloc(" \t" , /* Splitters */ + basic_parser_type * parser = basic_parser_alloc(" \t" , /* Splitters */ "\'\"" , /* Quoters */ "\n" , /* Specials - splitters which will be kept. */ "\r" , /* Delete set - these are just deleted. */ "--" , /* Comment start */ "\n"); /* Comment end */ bool strip_quote_marks = false; - token_list = parser_tokenize_file( parser , filename , strip_quote_marks ); - parser_free( parser ); + token_list = basic_parser_tokenize_file( parser , filename , strip_quote_marks ); + basic_parser_free( parser ); return token_list; } diff --git a/ThirdParty/Ert/devel/libsched/src/sched_history.c b/ThirdParty/Ert/devel/libsched/src/sched_history.c index 695fbf5e16..bf7061114e 100644 --- a/ThirdParty/Ert/devel/libsched/src/sched_history.c +++ b/ThirdParty/Ert/devel/libsched/src/sched_history.c @@ -671,19 +671,22 @@ bool sched_history_well_open( const sched_history_type * sched_history , const c */ bool sched_history_open( const sched_history_type * sched_history , const char * key , int report_step) { - const void * index = hash_get(sched_history->index , key ); - if (well_index_is_instance( index )) { - const well_index_type * well_index = well_index_safe_cast_const( index ); - const char * well_name = well_index_get_name( well_index ); - return sched_history_well_open( sched_history , well_name , report_step); - } else if (group_index_is_instance( index )) { - const group_index_type * group_index = group_index_safe_cast_const( index ); - const char * group_name = group_index_get_name( group_index ); - return sched_history_group_exists( sched_history , group_name , report_step); - } else { - util_abort("%s: - hmm internal fuckup \n",__func__); - return false; - } + if(hash_has_key(sched_history->index, key)) { + const void * index = hash_get(sched_history->index , key ); + if (well_index_is_instance( index )) { + const well_index_type * well_index = well_index_safe_cast_const( index ); + const char * well_name = well_index_get_name( well_index ); + return sched_history_well_open( sched_history , well_name , report_step); + } else if (group_index_is_instance( index )) { + const group_index_type * group_index = group_index_safe_cast_const( index ); + const char * group_name = group_index_get_name( group_index ); + return sched_history_group_exists( sched_history , group_name , report_step); + } else { + util_abort("%s: - hmm internal fuckup \n",__func__); + return false; + } + } + return false; } diff --git a/ThirdParty/Ert/devel/python/CMakeLists.txt b/ThirdParty/Ert/devel/python/CMakeLists.txt index db21efb45b..4246b798d5 100644 --- a/ThirdParty/Ert/devel/python/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/CMakeLists.txt @@ -1,5 +1,21 @@ -set(PYTHON_INSTALL_PREFIX "python") +include(cmake/find_python_module.cmake) + +if (ERT_BUILD_GUI) + FIND_PACKAGE(PythonInterp 2.7 REQUIRED) + find_python_module(PyQt4 REQUIRED) +else() + FIND_PACKAGE(PythonInterp 2.7 REQUIRED) +endif() + +if (EXISTS "/etc/debian_version") + set( PYTHON_PACKAGE_PATH "dist-packages") +else() + set( PYTHON_PACKAGE_PATH "site-packages") +endif() +set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in") + + if (BUILD_TESTS) - add_subdirectory( test ) + add_subdirectory( tests ) endif() add_subdirectory( python ) diff --git a/ThirdParty/Ert/devel/python/python/cmake/find_python_module.cmake b/ThirdParty/Ert/devel/python/cmake/find_python_module.cmake similarity index 100% rename from ThirdParty/Ert/devel/python/python/cmake/find_python_module.cmake rename to ThirdParty/Ert/devel/python/cmake/find_python_module.cmake diff --git a/ThirdParty/Ert/devel/python/python/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/CMakeLists.txt index 33b4e9454f..820ca44cc3 100644 --- a/ThirdParty/Ert/devel/python/python/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/CMakeLists.txt @@ -1,13 +1,7 @@ -include(cmake/find_python_module.cmake) -if (ERT_BUILD_GUI) - FIND_PACKAGE(PythonInterp 2.6 REQUIRED) - find_python_module(PyQt4 REQUIRED) -else() - FIND_PACKAGE(PythonInterp 2.6 REQUIRED) -endif() - add_subdirectory( ert ) -if (ERT_BUILD_GUI) - add_subdirectory( ert_gui ) +if (BUILD_ERT) + if (ERT_BUILD_GUI) + add_subdirectory( ert_gui ) + endif() endif() add_subdirectory( bin ) diff --git a/ThirdParty/Ert/devel/python/python/ert/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/CMakeLists.txt index 54b06b739d..115758e233 100644 --- a/ThirdParty/Ert/devel/python/python/ert/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/CMakeLists.txt @@ -24,3 +24,8 @@ IF (BUILD_ERT) add_subdirectory(sched) add_subdirectory(server) ENDIF() + + +configure_file(ert_lib_path_build.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ert/__ert_lib_path.py ) +configure_file(ert_lib_path_install.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ert_lib_path_install.py ) +install(FILES ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ert_lib_path_install.py DESTINATION ${PYTHON_INSTALL_PREFIX}/ert RENAME __ert_lib_path.py) diff --git a/ThirdParty/Ert/devel/python/python/ert/__init__.py b/ThirdParty/Ert/devel/python/python/ert/__init__.py index 79326cbdfc..01f6d4ddc7 100644 --- a/ThirdParty/Ert/devel/python/python/ert/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/__init__.py @@ -72,20 +72,49 @@ required_version_hex = 0x02060000 -ert_lib_path = os.getenv("ERT_LIBRARY_PATH") + +# 1. Start by initialing the ert_lib_path variable to None +ert_lib_path = None + + +# 2. Try to load the __ert_lib_path module; this module has been +# configured by cmake during the build configuration process. The +# module should contain the variable lib_path pointing to the +# directory with shared object files. +try: + import __ert_lib_path + ert_lib_path = __ert_lib_path.lib_path +except ImportError: + pass + + +# 3. Using the environment variable ERT_LIBRARY_PATH it is possible to +# override the default algorithms. If the ERT_LIBRARY_PATH is set +# to a non existing directory a warning will go to stderr and the +# setting will be ignored. +env_lib_path = os.getenv("ERT_LIBRARY_PATH") +if env_lib_path: + if os.path.isdir( env_lib_path ): + ert_lib_path = os.getenv("ERT_LIBRARY_PATH") + else: + sys.stderr.write("Warning: Environment variable ERT_LIBRARY_PATH points to nonexisting directory:%s - ignored" % env_lib_path) + + +# Check that the final ert_lib_path setting corresponds to an existing +# directory. if ert_lib_path: - if not os.path.exists( ert_lib_path ): - # Just use normal loading algorithm - ert_lib_path = None - #else: look in ERT_LIBRARY_PATH -else: - # Look in the default path "../../lib64" - ert_lib_path = os.path.realpath( os.path.join(os.path.dirname( os.path.abspath( __file__)) , "../../lib64") ) if not os.path.exists( ert_lib_path ): ert_lib_path = None - + + + +# Set the module variable ert_lib_path of the ert.cwrap.clib module; +# this is where the actual loading will be performed. cwrap.clib.ert_lib_path = ert_lib_path if sys.hexversion < required_version_hex: raise Exception("ERT Python requires at least version 2.6 of Python") + + +from ert.util import Version diff --git a/ThirdParty/Ert/devel/python/python/ert/analysis/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/analysis/CMakeLists.txt index ad64b69850..5f20dd0a2a 100644 --- a/ThirdParty/Ert/devel/python/python/ert/analysis/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/analysis/CMakeLists.txt @@ -1,6 +1,7 @@ set(PYTHON_SOURCES __init__.py analysis_module.py + linalg.py ) add_python_package("python.ert.analysis." ${PYTHON_INSTALL_PREFIX}/ert/analysis/ "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/devel/python/python/ert/analysis/__init__.py b/ThirdParty/Ert/devel/python/python/ert/analysis/__init__.py index da2d054a07..e453115653 100644 --- a/ThirdParty/Ert/devel/python/python/ert/analysis/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/analysis/__init__.py @@ -16,9 +16,11 @@ import ert.cwrap.clib as clib +import ert.util + ANALYSIS_LIB = clib.ert_load("libanalysis") from .enums import AnalysisModuleOptionsEnum, AnalysisModuleLoadStatusEnum from .analysis_module import AnalysisModule - +from .linalg import Linalg diff --git a/ThirdParty/Ert/devel/python/python/ert/analysis/analysis_module.py b/ThirdParty/Ert/devel/python/python/ert/analysis/analysis_module.py index 39e4dd150d..298849eddc 100644 --- a/ThirdParty/Ert/devel/python/python/ert/analysis/analysis_module.py +++ b/ThirdParty/Ert/devel/python/python/ert/analysis/analysis_module.py @@ -20,9 +20,53 @@ class AnalysisModule(BaseCClass): + VARIABLE_NAMES = { + "LAMBDA0": {"type": float, "description": "Initial Lambda"}, + "USE_PRIOR": {"type": bool, "description": "Use both Prior and Observation Variability"}, + "LAMBDA_REDUCE": {"type": float, "description": "Lambda Reduction Factor"}, + "LAMBDA_INCREASE": {"type": float, "description": "Lambda Incremental Factor"}, + "LAMBDA_MIN": {"type": float, "description": "Minimum Lambda"}, + "LOG_FILE": {"type": str, "description": "Log File"}, + "CLEAR_LOG": {"type": bool, "description": "Clear Existing Log File"}, + "LAMBDA_RECALCULATE": {"type": bool, "description": "Recalculate Lambda after each Iteration"}, + "ENKF_TRUNCATION": {"type": float, "description": "Singular value truncation"}, + "ENKF_NCOMP": {"type": int, "description": "ENKF_NCOMP"}, + "CV_NFOLDS": {"type": int, "description": "CV_NFOLDS"}, + "FWD_STEP_R2_LIMIT": {"type": float, "description": "FWD_STEP_R2_LIMIT"}, + "CV_PEN_PRESS": {"type": bool, "description": "CV_PEN_PRESS"} + } + def __init__(self, rng, user_name, lib_name): c_ptr = AnalysisModule.cNamespace().alloc_external(rng, user_name, lib_name) - super(AnalysisModule , self).__init__(c_ptr) + super(AnalysisModule, self).__init__(c_ptr) + + def getVariableNames(self): + """ @rtype: list of str """ + items = [] + for name in AnalysisModule.VARIABLE_NAMES: + if self.hasVar(name): + items.append(name) + return items + + def getVariableValue(self, name): + """ @rtype: int or float or bool or str """ + variable_type = self.getVariableType(name) + if variable_type == float: + return self.getDouble(name) + elif variable_type == bool: + return self.getBool(name) + elif variable_type == str: + return self.getStr(name) + elif variable_type == int: + return self.getInt(name) + + def getVariableType(self, name): + """ :rtype: type """ + return AnalysisModule.VARIABLE_NAMES[name]["type"] + + def getVariableDescription(self, name): + """ :rtype: str """ + return AnalysisModule.VARIABLE_NAMES[name]["description"] def free(self): AnalysisModule.cNamespace().free(self) @@ -40,32 +84,47 @@ def getTableName(self): return AnalysisModule.cNamespace().get_table_name(self) def getName(self): + """ :rtype: str """ return AnalysisModule.cNamespace().get_name(self) def checkOption(self, flag): return AnalysisModule.cNamespace().check_option(self, flag) def hasVar(self, var): + """ :rtype: bool """ return AnalysisModule.cNamespace().has_var(self, var) def getDouble(self, var): + """ :rtype: float """ return AnalysisModule.cNamespace().get_double(self, var) def getInt(self, var): + """ :rtype: int """ return AnalysisModule.cNamespace().get_int(self, var) def getBool(self, var): - return AnalysisModule.cNamespace().get_bool(self, var) + """ :rtype: bool """ + return AnalysisModule.cNamespace().get_bool(self, var) def getStr(self, var): - test = AnalysisModule.cNamespace().get_str(self, var) - return str(test) + """ :rtype: str """ + test = AnalysisModule.cNamespace().get_str(self, var) + return str(test) + + def initUpdate(self, mask, S, R, dObs, E, D): + print "Running initUpdate" + AnalysisModule.cNamespace().init_update(self, mask, S, R, dObs, E, D) + + def updateA(self, A, S, R, dObs, E, D): + print "Running updateA" + AnalysisModule.cNamespace().updateA(self, A, S, R, dObs, E, D) + + def initX(self, X, A, S, R, dObs, E, D): + AnalysisModule.cNamespace().init_update(self, X, A, S, R, dObs, E, D) cwrapper = CWrapper(ANALYSIS_LIB) -cwrapper.registerType("analysis_module", AnalysisModule) -cwrapper.registerType("analysis_module_obj", AnalysisModule.createPythonObject) -cwrapper.registerType("analysis_module_ref", AnalysisModule.createCReference) +cwrapper.registerObjectType("analysis_module", AnalysisModule) AnalysisModule.cNamespace().alloc_external = cwrapper.prototype("c_void_p analysis_module_alloc_external(rng, char*, char*)") AnalysisModule.cNamespace().free = cwrapper.prototype("void analysis_module_free(analysis_module)") @@ -78,11 +137,9 @@ def getStr(self, var): AnalysisModule.cNamespace().has_var = cwrapper.prototype("bool analysis_module_has_var(analysis_module, char*)") AnalysisModule.cNamespace().get_double = cwrapper.prototype("double analysis_module_get_double(analysis_module, char*)") AnalysisModule.cNamespace().get_int = cwrapper.prototype("int analysis_module_get_int(analysis_module, char*)") -AnalysisModule.cNamespace().get_bool = cwrapper.prototype("bool analysis_module_get_bool(analysis_module, char*)") +AnalysisModule.cNamespace().get_bool = cwrapper.prototype("bool analysis_module_get_bool(analysis_module, char*)") AnalysisModule.cNamespace().get_str = cwrapper.prototype("char* analysis_module_get_ptr(analysis_module, char*)") - - - - - +AnalysisModule.cNamespace().init_update = cwrapper.prototype("void analysis_module_init_update(analysis_module, bool_vector , matrix , matrix , matrix , matrix, matrix)") +AnalysisModule.cNamespace().updateA = cwrapper.prototype("void analysis_module_updateA(analysis_module, matrix , matrix , matrix , matrix, matrix, matrix)") +AnalysisModule.cNamespace().initX = cwrapper.prototype("void analysis_module_initX(analysis_module, matrix , matrix , matrix , matrix , matrix, matrix, matrix)") diff --git a/ThirdParty/Ert/devel/python/python/ert/analysis/linalg.py b/ThirdParty/Ert/devel/python/python/ert/analysis/linalg.py new file mode 100644 index 0000000000..3c301adf86 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/analysis/linalg.py @@ -0,0 +1,39 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'linalg.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from ert.cwrap import BaseCClass, CWrapper +from ert.analysis import ANALYSIS_LIB + + +__all__ = ["numPC"] + +class Linalg(BaseCClass): + """ + The linalg class is a purely static class which mainly serves as a + namespace for a collection of ensemble based linear algebra + methods. + """ + + @staticmethod + def numPC(S , truncation): + if 0 < truncation <= 1: + return Linalg.cNamespace().get_num_PC( S , truncation ) + else: + raise ValueError("truncation must be in the interval (0,1]") + + +cwrapper = CWrapper(ANALYSIS_LIB) +Linalg.cNamespace().get_num_PC = cwrapper.prototype("int enkf_linalg_num_PC( matrix , double)") diff --git a/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt index 9b8601d184..36796dfd77 100644 --- a/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt @@ -2,6 +2,7 @@ set(PYTHON_SOURCES __init__.py config_error.py config_parser.py + config_content.py content_type_enum.py unrecognized_enum.py ) diff --git a/ThirdParty/Ert/devel/python/python/ert/config/__init__.py b/ThirdParty/Ert/devel/python/python/ert/config/__init__.py index df9b843d34..0420a73e17 100644 --- a/ThirdParty/Ert/devel/python/python/ert/config/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/config/__init__.py @@ -20,5 +20,6 @@ from .unrecognized_enum import UnrecognizedEnum from .content_type_enum import ContentTypeEnum -from .config_parser import ConfigParser, SchemaItem, ContentItem, ContentNode +from .config_content import ConfigContent , ContentItem, ContentNode +from .config_parser import ConfigParser, SchemaItem from .config_error import ConfigError diff --git a/ThirdParty/Ert/devel/python/python/ert/config/config_content.py b/ThirdParty/Ert/devel/python/python/ert/config/config_content.py new file mode 100644 index 0000000000..b9dc960930 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/config/config_content.py @@ -0,0 +1,154 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'config_content.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import os.path + +from ert.config import UnrecognizedEnum, CONFIG_LIB, ContentTypeEnum +from ert.cwrap import BaseCClass, CWrapper + +class ContentNode(BaseCClass): + typed_get = {} + + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly!") + + def __len__(self): + return ContentNode.cNamespace().size(self) + + def __assertIndex(self , index): + if isinstance(index, int): + if index < 0: + index += len(self) + + if not 0 <= index < len(self): + raise IndexError + return index + else: + raise TypeError("Invalid argument type: %s" % index) + + + def __getitem__(self, index): + index = self.__assertIndex(index) + + content_type = ContentNode.cNamespace().iget_type(self, index) + typed_get = self.typed_get[content_type] + return typed_get( self , index ) + + + def content(self, sep=" "): + return ContentNode.cNamespace().get_full_string(self, sep) + + + def igetString(self , index): + index = self.__assertIndex(index) + return ContentNode.cNamespace().iget(self , index ) + + + def asList(self): + return [x for x in self] + + + +class ContentItem(BaseCClass): + # Not possible to create new python instances of this class + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly!") + + + def __len__(self): + return ContentItem.cNamespace().size(self) + + + def __getitem__(self, index): + if isinstance(index, int): + if index < 0: + index += len(self) + + if (index >= 0) and (index < len(self)): + return ContentItem.cNamespace().iget_content_node(self, index).setParent(self) + else: + raise IndexError + else: + raise TypeError("[] operator must have integer index") + + + def getValue(self , item_index = -1 , node_index = 0): + node = self[item_index] + return node[node_index] + + + + +class ConfigContent(BaseCClass): + + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly!") + + def __contains__(self , key): + return ConfigContent.cNamespace().has_key(self , key) + + def __getitem__(self , key): + if key in self: + item = ConfigContent.cNamespace().get_item( self , key) + item.setParent( self ) + return item + else: + raise KeyError("Unrecognized key:%s" % key) + + + def hasKey(self,key): + return key in self + + + def getValue(self , key , item_index = -1 , node_index = 0): + item = self[key] + return item.getValue( item_index , node_index ) + + + def isValid(self): + return ConfigContent.cNamespace().is_valid( self ) + + + def free(self): + ConfigContent.cNamespace().free(self) + + + + +cwrapper = CWrapper(CONFIG_LIB) +cwrapper.registerObjectType("config_content", ConfigContent) +cwrapper.registerObjectType("content_item", ContentItem) +cwrapper.registerObjectType("content_node", ContentNode) + +ConfigContent.cNamespace().free = cwrapper.prototype("void config_content_free( config_content )") +ConfigContent.cNamespace().is_valid = cwrapper.prototype("bool config_content_is_valid( config_content )") +ConfigContent.cNamespace().has_key = cwrapper.prototype("bool config_content_has_item( config_content , char*)") +ConfigContent.cNamespace().get_item = cwrapper.prototype("content_item_ref config_content_get_item( config_content , char*)") + +ContentItem.cNamespace().size = cwrapper.prototype("int config_content_item_get_size( content_item )") +ContentItem.cNamespace().iget_content_node = cwrapper.prototype("content_node_ref config_content_item_iget_node( content_item , int)") + +ContentNode.cNamespace().iget = cwrapper.prototype("char* config_content_node_iget( content_node , int)") +ContentNode.cNamespace().size = cwrapper.prototype("int config_content_node_get_size( content_node )") +ContentNode.cNamespace().get_full_string = cwrapper.prototype("char* config_content_node_get_full_string( content_node , char* )") +ContentNode.cNamespace().iget_type = cwrapper.prototype("config_content_type_enum config_content_node_iget_type( content_node , int)") + +ContentNode.typed_get[ContentTypeEnum.CONFIG_INT] = iget_as_int = cwrapper.prototype("int config_content_node_iget_as_int( content_node , int)") +ContentNode.typed_get[ContentTypeEnum.CONFIG_BOOL] = iget_as_bool = cwrapper.prototype("bool config_content_node_iget_as_bool( content_node , int)") +ContentNode.typed_get[ContentTypeEnum.CONFIG_FLOAT] = iget_as_double = cwrapper.prototype("double config_content_node_iget_as_double( content_node , int)") +ContentNode.typed_get[ContentTypeEnum.CONFIG_PATH] = iget_as_path = cwrapper.prototype("char* config_content_node_iget_as_path( content_node , int)") +ContentNode.typed_get[ContentTypeEnum.CONFIG_STRING] = iget_as_string = cwrapper.prototype("char* config_content_node_iget( content_node , int)") + diff --git a/ThirdParty/Ert/devel/python/python/ert/config/config_parser.py b/ThirdParty/Ert/devel/python/python/ert/config/config_parser.py index 99137ba53b..f1d64b72ec 100644 --- a/ThirdParty/Ert/devel/python/python/ert/config/config_parser.py +++ b/ThirdParty/Ert/devel/python/python/ert/config/config_parser.py @@ -16,7 +16,7 @@ import os.path -from ert.config import UnrecognizedEnum, CONFIG_LIB, ContentTypeEnum +from ert.config import UnrecognizedEnum, CONFIG_LIB, ContentTypeEnum , ConfigContent from ert.cwrap import BaseCClass, CWrapper @@ -45,100 +45,61 @@ def free(self): -class ContentItem(BaseCClass): - # Not possible to create new python instances of this class - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") - - - def __len__(self): - return ContentItem.cNamespace().size(self) - - - def __getitem__(self, index): - if isinstance(index, int): - if (index >= 0) and (index < self.__len__()): - return ContentItem.cNamespace().iget_content_node(self, index).setParent(self) - else: - raise IndexError - else: - raise ValueError("[] operator must have integer index") -class ContentNode(BaseCClass): - # Not possible to create new python instances of this class - +class ConfigParser(BaseCClass): def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") + c_ptr = ConfigParser.cNamespace().alloc() + super(ConfigParser, self).__init__(c_ptr) - def __len__(self): - return ContentNode.cNamespace().size(self) + + def __contains__(self , keyword): + return ConfigParser.cNamespace().has_schema_item( self , keyword ) - def __getitem__(self, index): - if isinstance(index, int): - if (index >= 0) and (index < self.__len__()): - return ContentNode.cNamespace().iget(self, index) - else: - raise IndexError - else: - raise ValueError("[] operator must have integer index") - def content(self, sep=" "): - return ContentNode.cNamespace().get_full_string(self, sep) + def add(self, keyword, required=False): + return ConfigParser.cNamespace().add(self, keyword, required).setParent( self ) -class ConfigParser(BaseCClass): - def __init__(self): - c_ptr = ConfigParser.cNamespace().alloc() - super(ConfigParser, self).__init__(c_ptr) + def getSchemaItem(self , keyword): + if keyword in self: + item = ConfigParser.cNamespace().get_schema_item(self, keyword) + item.setParent( self ) + else: + raise KeyError("Config parser does not have item:%s" % keyword) - def add(self, keyword, required=False): - return ConfigParser.cNamespace().add(self, keyword, required).setParent() def parse(self, config_file, comment_string="--", include_kw="INCLUDE", define_kw="DEFINE", unrecognized=UnrecognizedEnum.CONFIG_UNRECOGNIZED_WARN, validate=True): assert isinstance(unrecognized, UnrecognizedEnum) - + + if os.path.exists(config_file): - return ConfigParser.cNamespace().parse(self, config_file, comment_string, include_kw, define_kw, unrecognized, validate) + config_content = ConfigParser.cNamespace().parse(self, config_file, comment_string, include_kw, define_kw, unrecognized, validate) + if config_content.isValid(): + return config_content + else: + raise Exception("Parsing:%s failed" % config_file) else: - raise IOError("File: %s does not exists") - + raise IOError("File: %s does not exists" % config_file) - def __getitem__(self, keyword): - if ConfigParser.cNamespace().has_content(self, keyword): - return ConfigParser.cNamespace().get_content(self, keyword).setParent(self) - else: - return None def free(self): ConfigParser.cNamespace().free(self) cwrapper = CWrapper(CONFIG_LIB) -cwrapper.registerType("config_parser", ConfigParser) -cwrapper.registerType("config_parser_obj", ConfigParser.createPythonObject) -cwrapper.registerType("config_parser_ref", ConfigParser.createCReference) - -cwrapper.registerType("schema_item", SchemaItem) -cwrapper.registerType("schema_item_obj", SchemaItem.createPythonObject) -cwrapper.registerType("schema_item_ref", SchemaItem.createCReference) +cwrapper.registerObjectType("config_parser", ConfigParser) +cwrapper.registerObjectType("schema_item", SchemaItem) -cwrapper.registerType("content_item", ContentItem) -cwrapper.registerType("content_item_obj", ContentItem.createPythonObject) -cwrapper.registerType("content_item_ref", ContentItem.createCReference) - -cwrapper.registerType("content_node", ContentNode) -cwrapper.registerType("content_node_obj", ContentNode.createPythonObject) -cwrapper.registerType("content_node_ref", ContentNode.createCReference) ConfigParser.cNamespace().alloc = cwrapper.prototype("c_void_p config_alloc( )") ConfigParser.cNamespace().add = cwrapper.prototype("schema_item_ref config_add_schema_item( config_parser , char* , bool)") ConfigParser.cNamespace().free = cwrapper.prototype("void config_free( config_parser )") -ConfigParser.cNamespace().parse = cwrapper.prototype("bool config_parse( config_parser , char* , char* , char* , char* , config_unrecognized_enum , bool )") -ConfigParser.cNamespace().has_content = cwrapper.prototype("bool config_has_content_item( config_parser , char*) ") -ConfigParser.cNamespace().get_content = cwrapper.prototype("content_item_ref config_get_content_item( config_parser , char*) ") +ConfigParser.cNamespace().parse = cwrapper.prototype("config_content_obj config_parse( config_parser , char* , char* , char* , char* , config_unrecognized_enum , bool )") +ConfigParser.cNamespace().get_schema_item = cwrapper.prototype("schema_item_ref config_get_schema_item( config_parser , char*)") +ConfigParser.cNamespace().has_schema_item = cwrapper.prototype("bool config_has_schema_item( config_parser , char*)") SchemaItem.cNamespace().alloc = cwrapper.prototype("c_void_p config_schema_item_alloc( char* , bool )") SchemaItem.cNamespace().free = cwrapper.prototype("void config_schema_item_free( schema_item )") @@ -146,11 +107,5 @@ def free(self): SchemaItem.cNamespace().iset_type = cwrapper.prototype("void config_schema_item_iset_type( schema_item , int , config_content_type_enum)") SchemaItem.cNamespace().set_argc_minmax = cwrapper.prototype("void config_schema_item_set_argc_minmax( schema_item , int , int)") -ContentItem.cNamespace().size = cwrapper.prototype("int config_content_item_get_size( content_item )") -ContentItem.cNamespace().iget_content_node = cwrapper.prototype("content_node_ref config_content_item_iget_node( content_item , int)") - -ContentNode.cNamespace().iget = cwrapper.prototype("char* config_content_node_iget( content_node , int)") -ContentNode.cNamespace().size = cwrapper.prototype("int config_content_node_get_size( content_node )") -ContentNode.cNamespace().get_full_string = cwrapper.prototype("char* config_content_node_get_full_string( content_node , char* )") - + diff --git a/ThirdParty/Ert/devel/python/python/ert/cwrap/__init__.py b/ThirdParty/Ert/devel/python/python/ert/cwrap/__init__.py index 81fb76ddcf..702cbcf2ff 100644 --- a/ThirdParty/Ert/devel/python/python/ert/cwrap/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/cwrap/__init__.py @@ -47,7 +47,7 @@ from .cenum import create_enum from .cfile import CFILE from .clib import load, ert_lib_path, ert_load -from .cwrap import CWrapper, CWrapperNameSpace +from .cwrap import CWrapper, CWrapperNameSpace,CWrapError from .basecenum import BaseCEnum diff --git a/ThirdParty/Ert/devel/python/python/ert/cwrap/basecclass.py b/ThirdParty/Ert/devel/python/python/ert/cwrap/basecclass.py index 62b0cacc38..c30014366c 100644 --- a/ThirdParty/Ert/devel/python/python/ert/cwrap/basecclass.py +++ b/ThirdParty/Ert/devel/python/python/ert/cwrap/basecclass.py @@ -82,10 +82,14 @@ def parent(self): return self.__parent def __eq__(self, other): + # This is the last resort comparison function; it will do a + # plain pointer comparison on the underlying C object; or + # Python is-same-object comparison. if isinstance(other, BaseCClass): return self.__c_pointer == other.__c_pointer + else: + return super(BaseCClass , self).__eq__(other) - super(BaseCClass, self).__eq__(other) def free(self): raise NotImplementedError("A BaseCClass requires a free method implementation!") diff --git a/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py b/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py index 610bb9beaf..b599b659c4 100644 --- a/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py +++ b/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py @@ -13,8 +13,21 @@ # # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. -""" -Convenience module for loading shared library. +"""Convenience module for loading shared library. + +Observe that to ensure that all libraries are loaded through the same +code path, all required libraries should be loaded explicitly through +the use of import statements; i.e. the ert.geo package requires the +libert_util librarary, to ensure that the correct version of the +libert_util.so library file is loaded we should manually load that +first as: + + import ert.util + GEO_LIB = clib.ert_load("libert_geometry") + +Otherwise the standard operating system dependency resolve code will +be invoked when loading libert_geometry, and that could in principle +lead to loading a different version of libert_util.so """ import platform @@ -30,6 +43,18 @@ "darwin" : "dylib" } +# Passing None to the CDLL() function means to open a lib handle to +# the current runnning process, i.e. like dlopen( NULL ). We must +# special case this to avoid creating the bogus argument 'None.so'. +def lib_name(lib , platform_key): + if lib is None: + so_name = None + else: + so_name = "%s.%s" % (lib , so_extension[ platform_key ]) + return so_name + + + def __load( lib_list, ert_prefix): """ Thin wrapper around the ctypes.CDLL function for loading shared library. @@ -50,12 +75,13 @@ def __load( lib_list, ert_prefix): dll = None platform_key = platform.system().lower() for lib in lib_list: + so_name = lib_name( lib , platform_key ) try: - if ert_prefix: - ert_lib = os.path.join(ert_lib_path , "%s.%s" % (lib , so_extension[ platform_key ])) + if ert_prefix and so_name: + ert_lib = os.path.join(ert_lib_path , so_name) dll = ctypes.CDLL(ert_lib, ctypes.RTLD_GLOBAL) else: - dll = ctypes.CDLL(lib, ctypes.RTLD_GLOBAL) + dll = ctypes.CDLL(so_name , ctypes.RTLD_GLOBAL) return dll except Exception, exc: error_list[lib] = exc diff --git a/ThirdParty/Ert/devel/python/python/ert/cwrap/cwrap.py b/ThirdParty/Ert/devel/python/python/ert/cwrap/cwrap.py index 21323b05e1..d2f1bb19ce 100644 --- a/ThirdParty/Ert/devel/python/python/ert/cwrap/cwrap.py +++ b/ThirdParty/Ert/devel/python/python/ert/cwrap/cwrap.py @@ -29,6 +29,10 @@ prototype_pattern = "(?P<return>[a-zA-Z][a-zA-Z0-9_*]*) +(?P<function>[a-zA-Z]\w*) *[(](?P<arguments>[a-zA-Z0-9_*, ]*)[)]" + +class CWrapError(Exception): + pass + class CWrapper: # Observe that registered_types is a class attribute, shared # between all CWrapper instances. @@ -121,21 +125,26 @@ def prototype(self, prototype, lib=None): char* -> c_char_p ... - In addition, user register types are recognized and any type registered as a reference - to BaseCClass createCReference and createPythonObject are treated as pointers and converted automatically. + In addition, user register types are recognized and any type + registered as a reference to BaseCClass createCReference and + createPythonObject are treated as pointers and converted + automatically. + """ match = re.match(CWrapper.pattern, prototype) if not match: - sys.stderr.write("Illegal prototype definition: %s\n" % prototype) - return None + raise CWrapError("Illegal prototype definition: %s\n" % prototype) else: restype = match.groupdict()["return"] function_name = match.groupdict()["function"] arguments = match.groupdict()["arguments"].split(",") - - func = getattr(self.__lib, function_name) - + + try: + func = getattr(self.__lib, function_name) + except AttributeError: + raise CWrapError("Can not find function:%s in library:%s" % (function_name , self.__lib)) + return_type = self.__parseType(restype) if inspect.isclass(return_type) and issubclass(return_type, BaseCClass): diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt index 4864f70634..18f8cbfae5 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt @@ -4,12 +4,15 @@ set(PYTHON_SOURCES ecl_case.py ecl_default.py ecl_file.py + ecl_3d_file.py + ecl_init_file.py + ecl_restart_file.py ecl_grav.py ecl_grav_calc.py ecl_grid.py ecl_kw.py + ecl_3dkw.py ecl_npv.py - ecl_queue.py ecl_region.py ecl_rft.py ecl_rft_cell.py @@ -20,8 +23,14 @@ set(PYTHON_SOURCES ecl_sum_vector.py ecl_util.py fortio.py + ecl_sum_keyword_vector.py ) +if (BUILD_ERT) + list(APPEND PYTHON_SOURCES ecl_queue.py) +endif() + + add_python_package("python.ert.ecl" ${PYTHON_INSTALL_PREFIX}/ert/ecl "${PYTHON_SOURCES}" True) @@ -38,7 +47,8 @@ if (EXISTS ${ECL_LOCAL_TARGET}) endif() if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") - add_python_package( "Python ert.ecl.ecl_local" ${PYTHON_INSTALL_PREFIX}/ert/ecl "ecl_local.py" True) + add_python_package( "python.ert.ecl.ecl_local" ${PYTHON_INSTALL_PREFIX}/ert/ecl "ecl_local.py" True) endif() add_subdirectory(faults) +add_subdirectory(rft) diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/__init__.py b/ThirdParty/Ert/devel/python/python/ert/ecl/__init__.py index 195390a922..a534e1d0b6 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/__init__.py @@ -75,17 +75,21 @@ import ert.geo - ECL_LIB = clib.ert_load("libecl") from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode +from .ecl_sum_keyword_vector import EclSumKeyWordVector from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclTypeEnum, EclUtil from .ecl_default import EclDefault from .ecl_rft_cell import EclPLTCell, EclRFTCell from .ecl_rft import EclRFT, EclRFTFile from .fortio import FortIO, openFortIO from .ecl_kw import EclKW -from .ecl_file import EclFile +from .ecl_3dkw import Ecl3DKW +from .ecl_file import EclFile , openEclFile +from .ecl_3d_file import Ecl3DFile +from .ecl_init_file import EclInitFile +from .ecl_restart_file import EclRestartFile from .ecl_grid import EclGrid from .ecl_region import EclRegion from .ecl_subsidence import EclSubsidence @@ -94,5 +98,12 @@ from .ecl_sum_vector import EclSumVector from .ecl_npv import EclNPV , NPVPriceVector -#from .ecl_queue import + +# The EclQueue class uses the libjob_queue library which is only built +# when the full ert distribution is built. If BUILD_ERT == False the +# ecl_queue module is excluded from the build process. +try: + from .ecl_queue import EclQueue +except ImportError: + pass diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py index ec599ab6a8..02b4cc7f1e 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py @@ -49,10 +49,42 @@ # from ecl_util import * # # import ecl_default +import os +warning_message = """ + +The ecl namespace is deprecated and will go away. You are advised to +use one of these alternatives when importing the ert.ecl modules and +classes: + +--------------------------------------------------------------------- +Common prefix: +import ert.ecl as ecl + +Direct import of classes: +from ert.ecl import EclGrid,EclSum +--------------------------------------------------------------------- + +The environment variable ERT_SILENCE_WARNINGS is a colon separated +list which can be used to silence warnings. To silence this particular +warning set: + +ERT_SILENCE_WARNINGS = \"eclimport\" + +""" + + +from warnings import warn + +ert_silence_warnings = os.environ.get("ERT_SILENCE_WARNINGS") +if ert_silence_warnings: + silent_warnings = set( ert_silence_warnings.split(":")) +else: + silent_warnings = set() + +if not "eclimport" in silent_warnings: + warn(warning_message) -#from warnings import warn -#warn("The ecl namespace is deprecated! Please import ecl classes like this: import ert.ecl as ecl!") from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode from .ecl_rft_cell import EclPLTCell, EclRFTCell @@ -66,7 +98,14 @@ from .ecl_subsidence import EclSubsidence from .ecl_grav_calc import deltag, phase_deltag from .ecl_grav import EclGrav -from .ecl_queue import EclQueue + +# The EclQueue class uses the libjob_queue library which is only built +# when the full ert distribution is built. If BUILD_ERT == False the +# ecl_queue module is excluded from the build process. +try: + from .ecl_queue import EclQueue +except ImportError: + pass from .ecl_default import default diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_3d_file.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_3d_file.py new file mode 100644 index 0000000000..27a5ef71c7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_3d_file.py @@ -0,0 +1,42 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from ert.ecl import EclFile, Ecl3DKW + + +class Ecl3DFile(EclFile): + def __init__(self , grid , filename , flags = 0): + self.grid = grid + super(Ecl3DFile, self).__init__(filename , flags) + + + def __getitem__(self , index): + return_arg = super(Ecl3DFile, self).__getitem__( index ) + if isinstance(return_arg,list): + kw_list = return_arg + else: + kw_list = [ return_arg ] + + # Go through all the keywords and try inplace promotion to Ecl3DKW + for kw in kw_list: + try: + Ecl3DKW.castFromKW( kw , self.grid ) + except ValueError: + pass + + + return return_arg + diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_3dkw.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_3dkw.py new file mode 100644 index 0000000000..6f5a7b2879 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_3dkw.py @@ -0,0 +1,230 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_3dkw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +from ecl_kw import EclKW + +class Ecl3DKW(EclKW): + """ + Class for working with Eclipse keywords defined over a grid + + The Ecl3DKW class is derived from the EclKW class, and most of the + methods are implemented in the EclKW base class. The purpose of + the Ecl3DKW class is to simplify working with 3D properties like + PORO or SATNUM. + + The Ecl3DKW class has an attached EclGrid which is used to support + [i,j,k] indexing, and a defined default value which is used when + reading an inactive value. The Ecl3DKW keyword instances are + returned from the EclInitFile and EclRestartFile classes, in + addition you can excplicitly \"cast\" a EclKW keyword to Ecl3DKW + with the Ecl3DKW.castFromKW() classmethod. + + Usage example: + + from ert.ecl import EclInitFile,EclGrid + + grid = EclGrid("ECLIPSE.EGRID") + file = EclInitFile(grid , "ECLIPSE.INIT") + + permx_kw = file["PORO"][0] + porv_kw = file["PORV"][0] + + permx_kw.setDefault( -1 ) + for k in range(grid.getNZ()): + for j in range(grid.getNY()): + for i in range(grid.getNX()): + print \"(%d,%d,%d) Permx:%g Porv:%g\" % (i,j,k,permx_kw[i,j,k] , porv_kw[i,j,k]) + + In the example we open an ECLIPSE INIT file and extract the PERMX + and PORV properties, and then iterate over all the cells in the + grid. + + In the INIT file the PORV keyword is stored with all cells, + whereas the PERMX keyword typically only has the active cells + stored, this active/inactive gymnastics is handled + transparently. With the call: + + permx_kw.setDefault( -1 ) + + we say that we want the value -1 for all inactive cells in the + PERMX property. + + """ + + @classmethod + def create(cls , kw , grid , value_type , default_value = 0 , global_active = False): + if global_active: + size = grid.getGlobalSize() + else: + size = grid.getNumActive( ) + + new_kw = super(Ecl3DKW , cls).create( kw , size , value_type) + new_kw.grid = grid + new_kw.global_active = global_active + new_kw.setDefault( default_value ) + return new_kw + + @classmethod + def read_grdecl( cls , grid , fileH , kw , strict = True , ecl_type = None): + """ + Will load an Ecl3DKW instance from a grdecl formatted filehandle. + + See the base class EclKW.read_grdecl() for more documentation. + """ + kw = super(Ecl3DKW , cls).read_grdecl( fileH , kw , strict , ecl_type) + Ecl3DKW.castFromKW(kw , grid) + return kw + + + + def __getitem__(self , index): + """Will return item [g] or [i,j,k]. + + The __getitem__() methods supports both scalar indexing like + [g] and tuples [i,j,k]. If the input argument is given as a + [i,j,k] tuple it is converted to an active index before the + final lookup. + + If the [i,j,k] input corresponds to an inactive cell in a + keyword with only nactive elements the default value will be + returned. By default the default value will be 0, but another + value can be assigned with the setDefault() method. + """ + if isinstance(index , tuple): + global_index = self.grid.get_global_index( ijk = index ) + if self.global_active: + index = global_index + else: + if not self.grid.active( global_index = global_index): + return self.getDefault() + else: + index = self.grid.get_active_index( ijk = index ) + + + return super(Ecl3DKW , self).__getitem__( index ) + + + + + def __setitem__(self , index , value): + """Set the value of at index [g] or [i,j,k]. + + The __setitem__() methods supports both scalar indexing like + [g] and tuples [i,j,k]. If the input argument is given as a + [i,j,k] tuple it is converted to an active index before the + final assignment. + + If you try to assign an inactive cell in a keyword with only + nactive elements a ValueError() exception will be raised. + """ + if isinstance(index , tuple): + global_index = self.grid.get_global_index( ijk = index ) + if self.global_active: + index = global_index + else: + if not self.grid.active( global_index = global_index): + raise ValueError("Tried to assign value to inactive cell: (%d,%d,%d)" % index) + else: + index = self.grid.get_active_index( ijk = index ) + + + return super(Ecl3DKW , self).__setitem__( index , value ) + + + @classmethod + def castFromKW(cls , kw , grid , default_value = 0): + """Will convert a normal EclKW to a Ecl3DKW. + + The method will convert a normal EclKW instance to Ecl3DKw + instance with an attached grid and a default value. + + The method will check that size of the keyword is compatible + with the grid dimensions, i.e. the keyword must have either + nactive or nx*ny*nz elements. If the size of the keyword is + not compatible with the grid dimensions a ValueError exception + is raised. + + Example: + + 1. Load the poro keyword from a grdecl formatted file. + 2. Convert the keyword to a 3D keyword. + + + from ert.ecl import EclGrid,EclKW,Ecl3DKW + + grid = EclGrid("ECLIPSE.EGRID") + poro = EclKW.read_grdecl(open("poro.grdecl") , "PORO") + Ecl3DKW.castFromKW( poro , grid ) + + print "Porosity in cell (10,11,12):%g" % poro[10,11,12] + """ + if len(kw) == grid.getGlobalSize(): + kw.global_active = True + elif len(kw) == grid.getNumActive(): + kw.global_active = False + else: + raise ValueError("Size mismatch - must have size matching global/active size of grid") + + + kw.__class__ = cls + kw.default_value = default_value + kw.grid = grid + if len(kw) == grid.getGlobalSize(): + kw.global_active = True + else: + kw.global_active = False + + kw.setDefault( default_value ) + return kw + + + def compressedCopy(self): + """Will return a EclKW copy with nactive elements. + + The returned copy will be of type EclKW; i.e. no default + interpolation and only linear access in the [] operator. The + main purpose of this is to facilitate iteration over the + active index, and for writing binary files. + """ + return self.grid.compressedKWCopy( self ) + + + def globalCopy(self): + """Will return a EclKW copy with nx*ny*nz elements. + + The returned copy will be of type EclKW; i.e. no default + interpolation and only linear access in the [] operator. The + main purpose of this is to facilitate iteration over the + global index, and for writing binary files. + """ + return self.grid.globalKWCopy( self , self.getDefault() ) + + + + def dims(self): + return (self.grid.getNX() , self.grid.getNY() , self.grid.getNZ()) + + + def setDefault(self, default_value): + self.default_value = default_value + + + def getDefault(self): + return self.default_value + + + diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py index d49c01d141..0d13f0ee5f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py @@ -22,7 +22,6 @@ import os import warnings from ert.ecl import EclRFTFile, EclGrid, EclSum, EclUtil, EclDefault -from ert.ecl.ecl_queue import EclQueue diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py index 707c83b25a..35a7f61893 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py @@ -230,10 +230,15 @@ def save_kw( self , kw ): def __len__(self): return self.size - + def close(self): - cfunc.close( self ) + if not self.c_ptr is None: + cfunc.close( self ) self.c_ptr = None + + + def free(self): + self.close() def select_block( self, kw , kw_index): @@ -702,7 +707,7 @@ def fwrite( self , fortio ): Fortran IO must be used when reading and writing these files. This method will write the current EclFile instance to a FortIO stream already opened for writing: - + import ert.ecl.ecl as ecl ... fortio = ecl.FortIO( "FILE.XX" ) @@ -712,8 +717,27 @@ def fwrite( self , fortio ): """ cfunc.fwrite( self , fortio , 0 ) + +class EclFileContextManager(object): + + def __init__(self , ecl_file): + self.__ecl_file = ecl_file + + def __enter__(self): + return self.__ecl_file + + def __exit__(self, exc_type, exc_val, exc_tb): + self.__ecl_file.close() + return False + + +def openEclFile( file_name , flags = 0): + return EclFileContextManager( EclFile( file_name , flags )) + + + # 2. Creating a wrapper object around the libecl library, cwrapper = CWrapper(ECL_LIB) cwrapper.registerType( "ecl_file" , EclFile ) @@ -724,7 +748,7 @@ def fwrite( self , fortio ): # used outside this scope. cfunc = CWrapperNameSpace("ecl_file") -cfunc.open = cwrapper.prototype("c_void_p ecl_file_try_open( char* , int )") +cfunc.open = cwrapper.prototype("c_void_p ecl_file_open( char* , int )") cfunc.writable = cwrapper.prototype("bool ecl_file_writable( ecl_file )") cfunc.new = cwrapper.prototype("c_void_p ecl_file_alloc_empty( )") cfunc.save_kw = cwrapper.prototype("void ecl_file_save_kw( ecl_file , ecl_kw )") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py index b3794c03f5..a2e62a9b64 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py @@ -25,11 +25,14 @@ """ import ctypes -import numpy +import numpy import sys import warnings +import os.path +import math from ert.cwrap import CClass, CFILE, CWrapper, CWrapperNameSpace -from ert.ecl import EclTypeEnum, EclKW, ECL_LIB +from ert.util import IntVector +from ert.ecl import EclTypeEnum, EclKW, ECL_LIB, FortIO class EclGrid(CClass): @@ -37,8 +40,62 @@ class EclGrid(CClass): Class for loading and internalizing ECLIPSE GRID/EGRID files. """ + @classmethod + def loadFromGrdecl(cls , filename): + """Will create a new EclGrid instance from grdecl file. + + This function will scan the input file @filename and look for + the keywords required to build a grid. The following keywords + are required: + + SPECGRID ZCORN COORD + + In addition the function will look for and use the ACTNUM and + MAPAXES keywords if they are found; if ACTNUM is not found all + cells are assumed to be active. + + Slightly more exotic grid concepts like dual porosity, NNC + mapping, LGR and coarsened cells will be completely ignored; + if you need such concepts you must have an EGRID file and use + the default EclGrid() constructor - that is also considerably + faster. + """ + + if os.path.isfile(filename): + with open(filename) as f: + specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False) + zcorn = EclKW.read_grdecl(f, "ZCORN") + coord = EclKW.read_grdecl(f, "COORD") + actnum = EclKW.read_grdecl(f, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE) + mapaxes = EclKW.read_grdecl(f, "MAPAXES") + + if specgrid is None: + raise ValueError("The grdecl file:%s was invalid - could not find SPECGRID keyword" % filename) + + if zcorn is None: + raise ValueError("The grdecl file:%s was invalid - could not find ZCORN keyword" % filename) + + if coord is None: + raise ValueError("The grdecl file:%s was invalid - could not find COORD keyword" % filename) + + return EclGrid.create( specgrid , zcorn , coord , actnum , mapaxes ) + else: + raise IOError("No such file:%s" % filename) + + @classmethod + def loadFromFile(cls , filename): + """ + Will inspect the @filename argument and create a new EclGrid instance. + """ + if FortIO.isFortranFile( filename ): + return EclGrid( filename ) + else: + return EclGrid.loadFromGrdecl( filename ) + + @classmethod def create(cls , specgrid , zcorn , coord , actnum , mapaxes = None ): + """ Create a new grid instance from existing keywords. @@ -66,13 +123,30 @@ def create(cls , specgrid , zcorn , coord , actnum , mapaxes = None ): @classmethod def create_rectangular(cls , dims , dV , actnum = None): + return cls.createRectangular( dims , dV , actnum ) + + + @classmethod + def createRectangular(cls , dims , dV , actnum = None): """ Will create a new rectangular grid. @dims = (nx,ny,nz) @dVg = (dx,dy,dz) With the default value @actnum == None all cells will be active, """ obj = object.__new__( cls ) - c_ptr = cfunc.alloc_rectangular( dims[0] , dims[1] , dims[2] , dV[0] , dV[1] , dV[2] , actnum ) + if actnum is None: + c_ptr = cfunc.alloc_rectangular( dims[0] , dims[1] , dims[2] , dV[0] , dV[1] , dV[2] , None ) + else: + if not isinstance(actnum , IntVector): + tmp = IntVector(initial_size = len(actnum)) + for (index , value) in enumerate(actnum): + tmp[index] = value + actnum = tmp + + if not len(actnum) == dims[0] * dims[1] * dims[2]: + raise ValueError("ACTNUM size mismatch: len(ACTNUM):%d Expected:%d" % (len(actnum) , dims[0] * dims[1] * dims[2])) + c_ptr = cfunc.alloc_rectangular( dims[0] , dims[1] , dims[2] , dV[0] , dV[1] , dV[2] , actnum.getDataPtr() ) + obj.init_cobj( c_ptr , cfunc.free ) return obj @@ -131,22 +205,28 @@ def size( self ): @property def nactive( self ): """The number of active cells in the grid.""" - return cfunc.get_active( self ) - + return self.getNumActive() @property def nactive_fracture( self ): """The number of active cells fracture in the grid - for dual porosity.""" return cfunc.get_active_fracture( self ) + @property def dims( self ): + warnings.warn("The dims property is deprecated - use getDims() method instead" , DeprecationWarning) + return self.getDims( ) + + + def getDims(self): """A tuple of four elements: (nx , ny , nz , nactive).""" return ( cfunc.get_nx( self ) , cfunc.get_ny( self ) , cfunc.get_nz( self ) , cfunc.get_active( self ) ) + def getNX(self): """ The number of elements in the x direction""" return cfunc.get_nx( self ) @@ -163,22 +243,59 @@ def getGlobalSize(self): """Returns the total number of cells in this grid""" return cfunc.get_global_size( self ) - def getBoundingBox2D(self , layer = 0): + def getNumActive(self): + """The number of active cells in the grid.""" + return cfunc.get_active( self ) + + + def getBoundingBox2D(self , layer = 0 , lower_left = None , upper_right = None): if 0 <= layer <= self.getNZ(): x = ctypes.c_double() y = ctypes.c_double() z = ctypes.c_double() + + if lower_left is None: + i1 = 0 + j1 = 0 + else: + i1,j1 = lower_left + if not 0 < i1 < self.getNX(): + raise ValueError("lower_left i coordinate invalid") + + if not 0 < j1 < self.getNY(): + raise ValueError("lower_left j coordinate invalid") + + + if upper_right is None: + i2 = self.getNX() + j2 = self.getNY() + else: + i2,j2 = upper_right + + if not 1 < i2 <= self.getNX(): + raise ValueError("upper_right i coordinate invalid") + + if not 1 < j2 <= self.getNY(): + raise ValueError("upper_right j coordinate invalid") + + if not i1 < i2: + raise ValueError("Must have lower_left < upper_right") + + if not j1 < j2: + raise ValueError("Must have lower_left < upper_right") + + - cfunc.get_corner_xyz( self , 0 , 0 , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) + cfunc.get_corner_xyz( self , i1 , j1 , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) p0 = (x.value , y.value ) - cfunc.get_corner_xyz( self , self.getNX() , 0 , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) + cfunc.get_corner_xyz( self , i2 , j1 , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) p1 = (x.value , y.value ) - cfunc.get_corner_xyz( self , self.getNX() , self.getNY() , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) + cfunc.get_corner_xyz( self , i2 , j2 , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) p2 = (x.value , y.value ) - cfunc.get_corner_xyz( self , 0 , self.getNY() , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) + cfunc.get_corner_xyz( self , i1 , j2 , layer , ctypes.byref(x) , ctypes.byref(y) , ctypes.byref(z) ) p3 = (x.value , y.value ) return (p0,p1,p2,p3) @@ -238,17 +355,18 @@ def __global_index( self , active_index = None , global_index = None , ijk = Non ny = self.getNY() nz = self.getNZ() + i,j,k = ijk - if not 0 <= ijk[0] < nx: - raise IndexError("Invalid value i:%d Range: [%d,%d)" % (ijk[0] , 0 , nx)) + if not 0 <= i < nx: + raise IndexError("Invalid value i:%d Range: [%d,%d)" % (i , 0 , nx)) - if not 0 <= ijk[1] < ny: - raise IndexError("Invalid value j:%d Range: [%d,%d)" % (ijk[1] , 0 , ny)) + if not 0 <= j < ny: + raise IndexError("Invalid value j:%d Range: [%d,%d)" % (j , 0 , ny)) - if not 0 <= ijk[2] < nz: - raise IndexError("Invalid value k:%d Range: [%d,%d)" % (ijk[2] , 0 , nz)) + if not 0 <= k < nz: + raise IndexError("Invalid value k:%d Range: [%d,%d)" % (k , 0 , nz)) - global_index = cfunc.get_global_index3( self , ijk[0] , ijk[1] , ijk[2]) + global_index = cfunc.get_global_index3( self , i,j,k) else: if not 0 <= global_index < self.size: raise IndexError("Invalid value global_index:%d Range: [%d,%d)" % (global_index , 0 , self.size)) @@ -435,15 +553,18 @@ def get_corner_xyz(self, corner_nr , active_index = None , global_index = None , return self.getCellCorner(corner_nr , active_index , global_index , ijk) - def getLayerXYZ(self , xy_corner , layer): + def getNodeXYZ(self , i,j,k): + """ + This function returns the position of Vertex (i,j,k). + + The coordinates are in the inclusive interval [0,nx] x [0,ny] x [0,nz]. + """ nx = self.getNX() ny = self.getNY() nz = self.getNZ() - (j , i) = divmod(xy_corner , nx + 1) - k = layer corner = 0 - + if i == nx: i -= 1 corner += 1 @@ -463,6 +584,15 @@ def getLayerXYZ(self , xy_corner , layer): + def getLayerXYZ(self , xy_corner , layer): + nx = self.getNX() + + (j , i) = divmod(xy_corner , nx + 1) + k = layer + return self.getNodeXYZ(i,j,k) + + + def distance( self , global_index1 , global_index2): dx = ctypes.c_double() dy = ctypes.c_double() @@ -551,6 +681,67 @@ def cell_contains( self , x , y , z , active_index = None , global_index = None return cfunc.cell_contains( self , gi , x,y,z) + def findCellXY(self , x, y , k): + """Will find the i,j of cell with utm coordinates x,y. + + The @k input is the layer you are interested in, the allowed + values for k are [0,nz]. If the coordinates (x,y) are found to + be outside the grid a ValueError exception is raised. + """ + if 0 <= k <= self.getNZ(): + i = ctypes.c_int() + j = ctypes.c_int() + ok = cfunc.get_ij_xy( self , x,y,k , ctypes.byref(i) , ctypes.byref(j)) + if ok: + return (i.value , j.value) + else: + raise ValueError("Could not find the point:(%g,%g) in layer:%d" % (x,y,k)) + else: + raise IndexError("Invalid layer value:%d" % k) + + + @staticmethod + def d_cmp(a,b): + return cmp(a[0] , b[0]) + + + def findCellCornerXY(self , x, y , k): + """Will find the corner nr of corner closest to utm coordinates x,y. + + The @k input is the layer you are interested in, the allowed + values for k are [0,nz]. If the coordinates (x,y) are found to + be outside the grid a ValueError exception is raised. + """ + i,j = self.findCellXY(x,y,k) + if k == self.getNZ(): + k -= 1 + corner_shift = 4 + else: + corner_shift = 0 + + nx = self.getNX() + x0,y0,z0 = self.getCellCorner( corner_shift , ijk = (i,j,k)) + d0 = math.sqrt( (x0 - x)*(x0 - x) + (y0 - y)*(y0 - y)) + c0 = i + j*(nx + 1) + + x1,y1,z1 = self.getCellCorner( 1 + corner_shift , ijk = (i,j,k)) + d1 = math.sqrt( (x1 - x)*(x1 - x) + (y1 - y)*(y1 - y)) + c1 = i + 1 + j*(nx + 1) + + x2,y2,z2 = self.getCellCorner( 2 + corner_shift , ijk = (i,j,k)) + d2 = math.sqrt( (x2 - x)*(x2 - x) + (y2 - y)*(y2 - y)) + c2 = i + (j + 1)*(nx + 1) + + x3,y3,z3 = self.getCellCorner( 3 + corner_shift , ijk = (i,j,k)) + d3 = math.sqrt( (x3 - x)*(x3 - x) + (y3 - y)*(y3 - y)) + c3 = i + 1 + (j + 1)*(nx + 1) + + l = [(d0 , c0) , (d1,c1) , (d2 , c2) , (d3,c3)] + l.sort( EclGrid.d_cmp ) + return l[0][1] + + + def cell_regular(self, active_index = None , global_index = None , ijk = None): """ The ECLIPSE grid models often contain various degenerate cells, @@ -796,11 +987,11 @@ def save_grdecl(self , pyfile): cfile = CFILE( pyfile ) cfunc.fprintf_grdecl( self , cfile ) - def save_EGRID( self , filename ): + def save_EGRID( self , filename , output_metric = True): """ Will save the current grid as a EGRID file. """ - cfunc.fwrite_EGRID( self , filename ) + cfunc.fwrite_EGRID( self , filename, output_metric ) def save_GRID( self , filename ): """ @@ -839,6 +1030,34 @@ def write_grdecl( self , ecl_kw , pyfile , special_header = None , default_value raise ValueError("Keyword: %s has invalid size(%d), must be either nactive:%d or nx*ny*nz:%d" % (ecl_kw.name , ecl_kw.size , self.nactive , self.size)) + def exportACTNUM(self): + actnum = IntVector( initial_size = self.getGlobalSize() ) + cfunc.init_actnum( self , actnum.getDataPtr() ) + return actnum + + + def compressedKWCopy(self, kw): + if len(kw) == self.getNumActive(): + return EclKW.copy( kw ) + elif len(kw) == self.getGlobalSize(): + kw_copy = EclKW.create( kw.getName() , self.getNumActive() , kw.getEclType()) + cfunc.compressed_kw_copy( self , kw_copy , kw) + return kw_copy + else: + raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw)) + + def globalKWCopy(self, kw , default_value): + if len(kw) == self.getGlobalSize( ): + return EclKW.copy( kw ) + elif len(kw) == self.getNumActive(): + kw_copy = EclKW.create( kw.getName() , self.getGlobalSize() , kw.getEclType()) + kw_copy.assign( default_value ) + cfunc.global_kw_copy( self , kw_copy , kw) + return kw_copy + else: + raise ValueError("The input keyword must have nx*n*nz or nactive elements. Size:%d invalid" % len(kw)) + + # 2. Creating a wrapper object around the libecl library, # registering the type map : ecl_kw <-> EclKW @@ -884,6 +1103,7 @@ def write_grdecl( self , ecl_kw , pyfile , special_header = None , default_value cfunc.get_cell_corner_xyz1 = cwrapper.prototype("void ecl_grid_get_cell_corner_xyz1( ecl_grid , int , int , double* , double* , double*)") cfunc.get_corner_xyz = cwrapper.prototype("void ecl_grid_get_corner_xyz( ecl_grid , int , int , int, double* , double* , double*)") cfunc.get_xyz1A = cwrapper.prototype("void ecl_grid_get_xyz1A( ecl_grid , int , double* , double* , double*)") +cfunc.get_ij_xy = cwrapper.prototype("bool ecl_grid_get_ij_from_xy( ecl_grid , double , double , int , int* , int*)") cfunc.get_ijk_xyz = cwrapper.prototype("int ecl_grid_get_global_index_from_xyz( ecl_grid , double , double , double , int)") cfunc.cell_contains = cwrapper.prototype("bool ecl_grid_cell_contains_xyz1( ecl_grid , int , double , double , double )") cfunc.cell_regular = cwrapper.prototype("bool ecl_grid_cell_regular1( ecl_grid , int)") @@ -902,7 +1122,9 @@ def write_grdecl( self , ecl_kw , pyfile , special_header = None , default_value cfunc.get_distance = cwrapper.prototype("void ecl_grid_get_distance( ecl_grid , int , int , double* , double* , double*)") cfunc.fprintf_grdecl = cwrapper.prototype("void ecl_grid_fprintf_grdecl( ecl_grid , FILE) ") cfunc.fwrite_GRID = cwrapper.prototype("void ecl_grid_fwrite_GRID( ecl_grid , char* )") -cfunc.fwrite_EGRID = cwrapper.prototype("void ecl_grid_fwrite_EGRID( ecl_grid , char* )") +cfunc.fwrite_EGRID = cwrapper.prototype("void ecl_grid_fwrite_EGRID( ecl_grid , char*, bool )") cfunc.equal = cwrapper.prototype("bool ecl_grid_compare(ecl_grid , ecl_grid , bool, bool)") cfunc.dual_grid = cwrapper.prototype("bool ecl_grid_dual_grid( ecl_grid )") - +cfunc.init_actnum = cwrapper.prototype("void ecl_grid_init_actnum_data( ecl_grid , int* )") +cfunc.compressed_kw_copy = cwrapper.prototype("void ecl_grid_compressed_kw_copy( ecl_grid , ecl_kw , ecl_kw)") +cfunc.global_kw_copy = cwrapper.prototype("void ecl_grid_global_kw_copy( ecl_grid , ecl_kw , ecl_kw)") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_init_file.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_init_file.py new file mode 100644 index 0000000000..57eebb6ff8 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_init_file.py @@ -0,0 +1,21 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from ert.ecl import EclFile, Ecl3DKW , Ecl3DFile + + +class EclInitFile(Ecl3DFile): + pass diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_kw.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_kw.py index ee829e9613..d83d816bd5 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_kw.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_kw.py @@ -39,6 +39,7 @@ """ import ctypes import types +import warnings import numpy from ert.cwrap import CClass, CFILE, CWrapper, CWrapperNameSpace @@ -102,6 +103,9 @@ def create( cls , name, size , data_type): soil_kw = EclKW.new( "SOIL" , 10000 , ECL_FLOAT_TYPE ) """ + if len(name) > 8: + raise ValueError("Sorry - maximum eight characters in keyword name") + obj = cls() c_ptr = cfunc.alloc_new( name , size , data_type ) obj.init_cobj( c_ptr , cfunc.free ) @@ -157,9 +161,9 @@ def copy( cls , src ): @classmethod - def read_grdecl( cls , filename , kw , strict = True , ecl_type = None): + def read_grdecl( cls , fileH , kw , strict = True , ecl_type = None): """ - Function to load an EclKW instance from a grdecl file. + Function to load an EclKW instance from a grdecl formatted filehandle. This constructor can be used to load an EclKW instance from a grdecl formatted file; the input files for petrophysical @@ -226,7 +230,7 @@ def read_grdecl( cls , filename , kw , strict = True , ecl_type = None): it finds in the file. """ - cfile = CFILE( filename ) + cfile = CFILE( fileH ) if kw: if len(kw) > 8: raise TypeError("Sorry keyword:%s is too long, must be eight characters or less." % kw) @@ -250,7 +254,7 @@ def read_grdecl( cls , filename , kw , strict = True , ecl_type = None): return None @classmethod - def fseek_grdecl( cls , filename , kw , rewind = False): + def fseek_grdecl( cls , fileH , kw , rewind = False): """ Will search through the open file and look for string @kw. @@ -274,7 +278,7 @@ def fseek_grdecl( cls , filename , kw , rewind = False): true the function rewind to the beginning of the file and search from there after the initial search. """ - cfile = CFILE( filename ) + cfile = CFILE( fileH ) return cfunc.fseek_grdecl( kw , rewind , cfile) @@ -427,6 +431,12 @@ def __setitem__(self, index ,value): return cfunc.iset_char_ptr( self , index , value) else: raise SystemError("Internal implementation error ...") + elif isinstance( index , slice): + (start , stop , step) = index.indices( len(self) ) + index = start + while index < stop: + self[index] = value + index += step else: raise TypeError("Index should be integer type") @@ -768,14 +778,37 @@ def set_name( self , name ): cfunc.set_header( self , name ) def get_name( self ): - return cfunc.get_header( self ) + return self.getName() name = property( get_name , set_name ) + def getName(self): + return cfunc.get_header( self ) + @property def min_max( self ): + warnings.warn("The min_max property has been renamed to method getMinMax()" , DeprecationWarning) + return self.getMinMax() + + + @property + def max( self ): + warnings.warn("The max property has been renamed to method getMax()" , DeprecationWarning) + mm = self.getMinMax() + return mm[1] + + + @property + def min( self ): + warnings.warn("The min property has been renamed to method getMin()" , DeprecationWarning) + mm = self.getMinMax() + return mm[0] + + + + def getMinMax(self): """ Will return a touple (min,max) for numerical types. @@ -799,16 +832,17 @@ def min_max( self ): return (min.value , max.value) - @property - def max( self ): - return self.min_max[1] + def getMax( self ): + mm = self.getMinMax() + return mm[1] - @property - def min( self ): - return self.min_max[0] - - + def getMin( self ): + mm = self.getMinMax() + return mm[0] + + + @property def numeric(self): if self.ecl_type == EclTypeEnum.ECL_FLOAT_TYPE: @@ -834,6 +868,8 @@ def typeName(self): def getEclType(self): return self.ecl_type + + @property def header( self ): @@ -971,6 +1007,15 @@ def fprintf_data( self , file , fmt = None): cfunc.fprintf_data( self , fmt , cfile ) + def fixUninitialized(self , grid): + """ + Special case function for region code. + """ + dims = grid.getDims( ) + actnum = grid.exportACTNUM( ) + cfunc.fix_uninitialized( self , dims[0] , dims[1], dims[2] , actnum.getDataPtr() ) + + ################################################################# @@ -1034,6 +1079,7 @@ def fprintf_data( self , file , fmt = None): cfunc.max_min_int = cwrapper.prototype("void ecl_kw_max_min_int( ecl_kw , int* , int*)") cfunc.max_min_float = cwrapper.prototype("void ecl_kw_max_min_float( ecl_kw , float* , float*)") cfunc.max_min_double = cwrapper.prototype("void ecl_kw_max_min_double( ecl_kw , double* , double*)") +cfunc.fix_uninitialized = cwrapper.prototype("void ecl_kw_fix_uninitialized( ecl_kw ,int , int , int, int*)") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_region.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_region.py index b7bc88fe10..485f2d3825 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_region.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_region.py @@ -28,8 +28,9 @@ import ctypes import warnings from ert.cwrap import CClass, CWrapper, CWrapperNameSpace +from ert.ecl.faults import Layer from ert.ecl import EclKW, EclTypeEnum, ECL_LIB -from ert.geo import GeoPolygon +from ert.geo import CPolyline from ert.util import IntVector @@ -103,6 +104,14 @@ def __deep_copy__(self , memo): return EclRegion( self.grid , False , c_ptr = cfunc.alloc_copy( self )) + def __zero__(self): + global_list = self.getGlobalList() + if len(global_list) > 0: + return True + else: + return False + + def __iand__(self , other): """ Will perform set intersection operation inplace. @@ -667,7 +676,7 @@ def select_inside_polygon( self , points , intersect = False): implies that the selection polygon will effectively be translated if the pillars are not vertical. """ - cfunc.select_inside_polygon( self , GeoPolygon( points )) + cfunc.select_inside_polygon( self , CPolyline( init_points = points )) @select_method def select_outside_polygon( self , points , intersect = False): @@ -676,7 +685,7 @@ def select_outside_polygon( self , points , intersect = False): See select_inside_polygon for more docuemntation. """ - cfunc.select_outside_polygon( self , GeoPolygon( points )) + cfunc.select_outside_polygon( self , CPolyline( init_points = points )) def deselect_inside_polygon( self , points ): """ @@ -684,7 +693,7 @@ def deselect_inside_polygon( self , points ): See select_inside_polygon for more docuemntation. """ - cfunc.deselect_inside_polygon( self , GeoPolygon( points )) + cfunc.deselect_inside_polygon( self , CPolyline( init_points = points )) def deselect_outside_polygon( self , points ): """ @@ -692,15 +701,53 @@ def deselect_outside_polygon( self , points ): See select_inside_polygon for more docuemntation. """ - cfunc.deselect_outside_polygon( self , GeoPolygon( points )) + cfunc.deselect_outside_polygon( self , CPolyline( init_points = points )) + + + @select_method + def selectTrue( self , ecl_kw , intersect = False): + """ + Assume that input ecl_kw is a boolean mask. + """ + cfunc.select_true( self , ecl_kw ) + + + @select_method + def selectFalse( self , ecl_kw , intersect = False): + """ + Assume that input ecl_kw is a boolean mask. + """ + cfunc.select_false( self , ecl_kw ) + + + @select_method + def selectFromLayer(self , layer , k , value, intersect = False): + """Will select all the cells in in @layer with value @value - at + vertical coordinate @k. + The input @layer should be of type Layer - from the + ert.ecl.faults.layer module. The k value must in the range + [0,grid.nz) and the dimensions of the layer must correspond + exactly to nx,ny of the grid. + """ + grid = self.grid + if k < 0 or k >= grid.getNZ(): + raise ValueError("Invalid k value:%d - must be in range [0,%d)" % (k , grid.getNZ())) + if grid.getNX() != layer.getNX(): + raise ValueError("NX dimension mismatch. Grid:%d layer:%d" % (grid.getNX() , layer.getNX())) + if grid.getNY() != layer.getNY(): + raise ValueError("NY dimension mismatch. Grid:%d layer:%d" % (grid.getNY() , layer.getNY())) + + cfunc.select_from_layer( self , layer , k , value ) + ################################################################# def scalar_apply_kw( self , target_kw , scalar , func_dict , force_active = False): + """ Helper function to apply a function with one scalar arg on target_kw. """ @@ -807,30 +854,46 @@ def ecl_region_instance( self ): def getActiveList(self): + """ + IntVector instance with active indices in the region. + """ active_list = cfunc.get_active_list(self) active_list.setParent(self) return active_list def getGlobalList(self): + """ + IntVector instance with global indices in the region. + """ global_list = cfunc.get_global_list(self) global_list.setParent(self) return global_list + + + def getIJKList(self): + """ + WIll return a Python list of (i,j,k) tuples for the region. + """ + global_list = self.getGlobalList() + ijk_list = [] + for g in global_list: + ijk_list.append( self.grid.get_ijk( global_index = g ) ) + return ijk_list + + + @property def active_list(self): - """ - IntVector instance with active indices in the region. - """ + warnings.warn("The active_list property is deprecated - use method \'getActiveList()\' instead." , DeprecationWarning) return self.getActiveList() @property def global_list(self): - """ - IntVector instance with global indices in the region. - """ + warnings.warn("The global_list property is deprecated - use method \'getGlobalList()\' instead." , DeprecationWarning) return self.getGlobalList() @@ -839,16 +902,16 @@ def active_size( self ): """ Number of active cells in region. """ - warnings.warn("The active_size property is deprecated - use \'active_list.size\' instead." , DeprecationWarning) - return self.active_list.size + warnings.warn("The active_size property is deprecated - use \'len(getActiveList())\' instead." , DeprecationWarning) + return len(self.getActiveList()) @property def global_size( self ): """ Number of global cells in region. """ - warnings.warn("The global_size property is deprecated - use \'global_list.size\' instead." , DeprecationWarning) - return self.global_list.size + warnings.warn("The global_size property is deprecated - use \'len(getGlobalList())\' instead." , DeprecationWarning) + return len(self.getGlobalList()) def contains_ijk( self , i,j,k): """ @@ -996,3 +1059,11 @@ def get_name( self ): cfunc.contains_active = cwrapper.prototype("void ecl_region_contains_active( ecl_region , int )") cfunc.equal = cwrapper.prototype("bool ecl_region_equal( ecl_region , ecl_region )") + +cfunc.select_true = cwrapper.prototype("void ecl_region_select_true( ecl_region , ecl_kw)") +cfunc.select_false = cwrapper.prototype("void ecl_region_select_false( ecl_region , ecl_kw)") +cfunc.deselect_true = cwrapper.prototype("void ecl_region_deselect_true( ecl_region , ecl_kw)") +cfunc.deselect_false = cwrapper.prototype("void ecl_region_deselect_false( ecl_region , ecl_kw)") + +cfunc.select_from_layer = cwrapper.prototype("void ecl_region_select_from_layer( ecl_region , layer , int , int)") +cfunc.deselect_from_layer = cwrapper.prototype("void ecl_region_deselect_from_layer( ecl_region , layer , int , int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_restart_file.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_restart_file.py new file mode 100644 index 0000000000..ee1963aaa9 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_restart_file.py @@ -0,0 +1,21 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from ert.ecl import EclFile, Ecl3DKW , Ecl3DFile + + +class EclRestartFile(Ecl3DFile): + pass diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py index 7fa1178d3e..a93dd9b57a 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py @@ -29,11 +29,13 @@ # regarding order of arguments: The C code generally takes the time # index as the first argument and the key/key_index as second # argument. In the python code this order has been reversed. -from ert.cwrap import BaseCClass, CWrapper +from ert.cwrap import BaseCClass, CWrapper, CFILE from ert.ecl.ecl_sum_vector import EclSumVector from ert.ecl.ecl_smspec_node import EclSMSPECNode from ert.util import StringList, CTime, DoubleVector, TimeVector, IntVector from ert.ecl import ECL_LIB +#, EclSumKeyWordVector + @@ -98,18 +100,18 @@ def __init__(self, load_case , join_string = ":" , include_restart = True): """ c_pointer = EclSum.cNamespace().fread_alloc( load_case , join_string , include_restart) if c_pointer is None: - raise AssertionError("Failed to create summary instance from argument:%s" % load_case) + raise IOError("Failed to create summary instance from argument:%s" % load_case) else: super(EclSum, self).__init__(c_pointer) self._initialize() @staticmethod - def writer(case , start_time , nx,ny,nz , fmt_output = False , unified = True , key_join_string = ":"): + def writer(case , start_time , nx,ny,nz , fmt_output = False , unified = True , time_in_days = True , key_join_string = ":"): """ The writer is not generally usable. """ - return EclSum.cNamespace().create_writer( case , fmt_output , unified , key_join_string , CTime(start_time) , nx , ny , nz) + return EclSum.cNamespace().create_writer( case , fmt_output , unified , key_join_string , CTime(start_time) , time_in_days , nx , ny , nz) def addVariable(self , variable , wgname = None , num = 0 , unit = "None" , default_value = 0): @@ -359,15 +361,22 @@ def check_sim_time( self , date): """ Will check if the input date is in the time span [sim_start , sim_end]. """ - return EclSum.cNamespace().check_sim_time( self , CTime(date) ) + if not isinstance(date, CTime): + date = CTime(date) + return EclSum.cNamespace().check_sim_time( self , date ) + + def get_interp_direct(self,key , date): + + if not isinstance(date, CTime): + date = CTime(date) + return EclSum.cNamespace().get_general_var_from_sim_time( self , date , key ) - def get_interp( self , key , days = None , date = None): """ Will lookup vector @key at time given by @days or @date. - + Requiers exactly one input argument @days or @date; will raise - exception ValueError if this is not satisfied. + exception ValueError if this is not satisfied. The method will check that the time argument is within the time limits of the simulation; if else the method will raise @@ -381,9 +390,11 @@ def get_interp( self , key , days = None , date = None): raise ValueError("Must supply either days or date") if days is None: - if self.check_sim_time( date ): - return EclSum.cNamespace().get_general_var_from_sim_time( self , CTime(date) , key ) + t = CTime(date) + if self.check_sim_time( t ): + return EclSum.cNamespace().get_general_var_from_sim_time( self , t , key ) else: + raise ValueError("date:%s is outside range of simulation data" % date) elif date is None: if EclSum.cNamespace().check_sim_days( self , days ): @@ -782,13 +793,7 @@ def first_day(self): @property def sim_length( self ): - """ - The length of the current dataset in simulation days. - - Will include the length of a leading restart section, - irrespective of whether we have data for this or not. - """ - return EclSum.cNamespace().sim_length( self ) + return self.getSimulationLength( ) @property def start_date(self): @@ -827,7 +832,7 @@ def end_time(self): """ The time of the last (loaded) time step. """ - return CTime(EclSum.cNamespace().get_end_date( self )).datetime() + return self.getEndTime() @property @@ -844,6 +849,22 @@ def getStartTime(self): return CTime( EclSum.cNamespace().get_start_date( self ) ).datetime() + def getEndTime(self): + """ + A Python datetime instance with the last loaded time. + """ + return CTime(EclSum.cNamespace().get_end_date( self )).datetime() + + def getSimulationLength(self): + """ + The length of the current dataset in simulation days. + + Will include the length of a leading restart section, + irrespective of whether we have data for this or not. + """ + return EclSum.cNamespace().sim_length( self ) + + @property def last_report(self): @@ -864,7 +885,7 @@ def first_gt_index( self , key , limit ): Returns the first index where @key is above @limit. """ key_index = EclSum.cNamespace().get_general_var_index( self , key ) - time_index = EclSum.cNamespace().get_first_lt( self , key_index , limit ) + time_index = EclSum.cNamespace().get_first_gt( self , key_index , limit ) return time_index def first_lt_index( self , key , limit ): @@ -926,6 +947,16 @@ def get_general_var_index(self, key): def free(self): EclSum.cNamespace().free(self) + def dumpCSVLine(self, time, keywords, pfile): + """ + Will dump a csv formatted line of the keywords in @keywords, + evaluated at the intertpolated time @time. @pfile should point to an open Python file handle. + """ + cfile = CFILE(pfile ) + ctime = CTime( time ) + EclSum.cNamespace().dump_csv_line(self, ctime, keywords, cfile) + + @classmethod def createCReference(cls, c_pointer, parent=None): result = super(EclSum, cls).createCReference(c_pointer, parent) @@ -999,6 +1030,9 @@ def createPythonObject(cls, c_pointer): EclSum.cNamespace().create_well_list = cwrapper.prototype("stringlist_obj ecl_sum_alloc_well_list( ecl_sum , char* )") EclSum.cNamespace().create_group_list = cwrapper.prototype("stringlist_obj ecl_sum_alloc_group_list( ecl_sum , char* )") -EclSum.cNamespace().create_writer = cwrapper.prototype("ecl_sum_obj ecl_sum_alloc_writer( char* , bool , bool , char* , time_t , int , int , int)") +EclSum.cNamespace().create_writer = cwrapper.prototype("ecl_sum_obj ecl_sum_alloc_writer( char* , bool , bool , char* , time_t , bool , int , int , int)") EclSum.cNamespace().add_variable = cwrapper.prototype("void ecl_sum_add_var(ecl_sum , char* , char* , int , char*, double)") EclSum.cNamespace().add_tstep = cwrapper.prototype("c_void_p ecl_sum_add_tstep(ecl_sum , int , double)") + +import ert.ecl.ecl_sum_keyword_vector +EclSum.cNamespace().dump_csv_line = cwrapper.prototype("void ecl_sum_dump_line_to_csv_file(ecl_sum , time_t , ecl_sum_vector, FILE)") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum_keyword_vector.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum_keyword_vector.py new file mode 100644 index 0000000000..2d0f526ebf --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum_keyword_vector.py @@ -0,0 +1,66 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_sum_keyword_vector.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +import numpy +import datetime + +# Observe that there is some convention conflict with the C code +# regarding order of arguments: The C code generally takes the time +# index as the first argument and the key/key_index as second +# argument. In the python code this order has been reversed. + +from ert.cwrap import BaseCClass, CWrapper +from ert.ecl import ECL_LIB + + + +class EclSumKeyWordVector(BaseCClass): + + + def __init__(self, ecl_sum): + c_pointer = EclSumKeyWordVector.cNamespace().alloc(ecl_sum) + if c_pointer is None: + raise AssertionError("Failed to create summary keyword vector") + else: + super(EclSumKeyWordVector, self).__init__(c_pointer) + + def __len__(self): + return EclSumKeyWordVector.cNamespace().get_size(self) + + def free(self): + EclSumKeyWordVector.cNamespace().free(self) + + def addKeyword(self, keyword): + success = EclSumKeyWordVector.cNamespace().add(self, keyword) + if not success: + raise KeyError("Failed to add keyword to vector") + + def addKeywords(self, keyword_pattern): + EclSumKeyWordVector.cNamespace().add_multiple(self, keyword_pattern) + + + +cwrapper = CWrapper(ECL_LIB) +cwrapper.registerType( "ecl_sum_vector" , EclSumKeyWordVector ) +cwrapper.registerType( "ecl_sum_vector_obj" , EclSumKeyWordVector.createPythonObject ) +cwrapper.registerType( "ecl_sum_vector_ref" , EclSumKeyWordVector.createCReference ) + +EclSumKeyWordVector.cNamespace().alloc = cwrapper.prototype("c_void_p ecl_sum_vector_alloc(ecl_sum )") +EclSumKeyWordVector.cNamespace().free = cwrapper.prototype("void ecl_sum_vector_free(ecl_sum_vector )") +EclSumKeyWordVector.cNamespace().add = cwrapper.prototype("bool ecl_sum_vector_add_key( ecl_sum_vector , char* )") +EclSumKeyWordVector.cNamespace().add_multiple = cwrapper.prototype("void ecl_sum_vector_add_keys( ecl_sum_vector , char* )") +EclSumKeyWordVector.cNamespace().get_size = cwrapper.prototype("int ecl_sum_vector_get_size( ecl_sum_vector )") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/CMakeLists.txt index c073c435cc..bedc35aa82 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/CMakeLists.txt @@ -6,7 +6,6 @@ set(PYTHON_SOURCES fault.py fault_line.py fault_segments.py - region_definition.py layer.py ) diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/__init__.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/__init__.py index afa4256198..17307f8032 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/__init__.py @@ -5,4 +5,3 @@ from .fault_segments import FaultSegment , SegmentMap from .fault_block import FaultBlock , FaultBlockCell from .fault_block_layer import FaultBlockLayer -from .region_definition import RegionDefinition diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault.py index 1e60834720..326ad0fc05 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault.py @@ -14,12 +14,18 @@ # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. +from ert.ecl import EclTypeEnum +from ert.geo import Polyline , CPolyline , GeometryTools +from ert.util import stat +from ert.util import Matrix + from .fault_line import FaultLine from .fault_segments import FaultSegment , SegmentMap -from ert.ecl import EclTypeEnum + class Layer(object): def __init__(self, grid , K): + assert( isinstance(K , int) ) self.__grid = grid self.__K = K self.__fault_lines = [] @@ -53,7 +59,81 @@ def getNeighborCells(self): neighbor_cells += fl.getNeighborCells() return neighbor_cells + def getPolyline(self , name = None): + polyline = CPolyline( name = name) + for fl in self: + polyline += fl.getPolyline() + return polyline + + + def getIJPolyline(self): + """ + Will return a python list of (int,int) tuple. + """ + polyline = [] + for fl in self: + polyline += fl.getIJPolyline() + return polyline + + def numLines(self): + return len(self) + + + # A fault can typically consist of several non connected fault + # segments; right after reading the fault input these can be in a + # complete mess: + # + # 1. The different part of the fault can be in random order. + # + # 2. Within each fault line the micro segments can be ordered in + # reverse. + # + # This method goes through some desparate heuristics trying to + # sort things out. + + def __sortFaultLines(self): + N = len(self.__fault_lines) + x = Matrix(N , 1) + y = Matrix(N , 1) + + for index,line in enumerate(self.__fault_lines): + xc,yc = line.center() + + x[index,0] = xc + y[index,0] = yc + + # y = beta[0] + beta[1] * x + # = a + b * x + beta = stat.polyfit(2 , x , y) + a = beta[0] + b = beta[1] + + perm_list = [] + for index,line in enumerate(self.__fault_lines): + x0 , y0 = line.center() + d = x0 + b*(y0 - a) + perm_list.append((index , d)) + perm_list.sort(key = lambda x: x[1]) + + fault_lines = [] + for (index,d) in perm_list: + fault_lines.append( self.__fault_lines[ index ]) + self.__fault_lines = fault_lines + + + for line in self.__fault_lines: + x1,y1 = line.startPoint() + x2,y2 = line.endPoint() + d1 = x1 + b*(y1 - a) + d2 = x2 + b*(y2 - a) + + if d1 > d2: + line.reverse() + + + + def processSegments(self): if self.__processed: return @@ -72,7 +152,10 @@ def processSegments(self): current_segment.next_segment = self.__segment_map.popNext( current_segment ) current_segment = current_segment.next_segment - + + if len(self.__fault_lines) > 1: + self.__sortFaultLines() + self.__processed = True @@ -94,6 +177,8 @@ def __str__(self): return "Fault:%s" % self.__name def __getitem__(self , K): + if not self.hasLayer(K): + self.addLayer(K) layer = self.__layer_map[K] return layer @@ -114,7 +199,7 @@ def addLayer(self , K): layer = Layer(self.__grid , K) self.__layer_map[K] = layer self.__layer_list.append( layer ) - + def createSegment(self , I1 , I2 , J1 , J2 , face): if face in ["X" , "I"]: @@ -130,8 +215,8 @@ def createSegment(self , I1 , I2 , J1 , J2 , face): C1 = I1 + J1 * (self.nx + 1) C2 = C1 + (1 + I2 - I1) else: - raise Exception("Can only handle X,Y faces") - + return None + return FaultSegment(C1,C2) @@ -183,7 +268,8 @@ def addRecord(self , I1 , I2 , J1 , J2 , K1 , K2 , face): self.addLayer(K) layer = self.__layer_map[K] segment = self.createSegment(I1,I2,J1,J2,face) - layer.addSegment( segment ) + if segment: + layer.addSegment( segment ) def getName(self): @@ -196,4 +282,363 @@ def getNeighborCells(self): neighbor_cells += layer.getNeighborCells() return neighbor_cells + + def getPolyline(self , k): + layer = self[k] + return layer.getPolyline( name = "Polyline[%s]" % self.getName() ) + + + def getIJPolyline(self , k): + layer = self[k] + return layer.getIJPolyline() + + + def numLines( self , k): + layer = self[k] + return layer.numLines() + + + def extendToFault(self , other_fault , k): + polyline = self.getIJPolyline(k) + + p0 = polyline[-2] + p1 = polyline[-1] + ray_dir = GeometryTools.lineToRay( p0 , p1 ) + intersections = GeometryTools.rayPolygonIntersections( p1 , ray_dir , other_fault.getIJPolyline(k)) + if intersections: + p2 = intersections[0][1] + return [p1 , (int(p2[0]) , int(p2[1])) ] + + p0 = polyline[1] + p1 = polyline[0] + ray_dir = GeometryTools.lineToRay( p0 , p1 ) + intersections = GeometryTools.rayPolygonIntersections( p1 , ray_dir , other_fault.getIJPolyline(k)) + if intersections: + if len(intersections) > 1: + d_list = [ GeometryTools.distance( p1 , p[1] ) for p in intersections ] + index = d_list.index( min(d_list) ) + else: + index = 0 + p2 = intersections[index][1] + return [p1 , (int(p2[0]) , int(p2[1])) ] + + raise ValueError("The fault %s can not be extended to intersect with:%s in layer:%d" % (self.getName() , other_fault.getName() , k+1 )) + + + @staticmethod + def __rayIntersect(p0, p1 , polyline): + ray_dir = GeometryTools.lineToRay( p0 , p1 ) + intersections = GeometryTools.rayPolygonIntersections( p1 , ray_dir , polyline) + if intersections: + if len(intersections) > 1: + d_list = [ GeometryTools.distance( p1 , p[1] ) for p in intersections ] + index = d_list.index( min(d_list) ) + else: + index = 0 + p2 = intersections[index][1] + return [p1 , p2] + else: + return None + + + def connectWithPolyline(self , polyline , k): + """ + """ + if self.intersectsPolyline( polyline , k ): + return None + else: + self_polyline = self.getPolyline( k ) + if len(self_polyline) > 0: + return self_polyline.connect( polyline ) + else: + return None + + + def connect(self , target , k): + if isinstance(target, Fault): + polyline = target.getPolyline(k) + else: + polyline = target + return self.connectWithPolyline( polyline , k ) + + + + def extendToPolyline(self , polyline , k): + """Extends the fault until it intersects @polyline in layer @k. + + The return value is a list [(x1,y1) , (x2,y2)] where (x1,y1) + is on the tip of the fault, and (x2,y2) is on the polyline. If + the fault already intersects polyline None is returned, if no + intersection is found a ValueError exception is raised. + + The method will try four different strategies for finding an + intersection between the extension of the fault and the + polyline. Assume the fault and the polyline looks like: + + + Polyline: ---------------------------------------------- + + +------------+ D + | | | + | +-------C + B-----+ + | + A + + The algorithm will then try to intersect the following rays + with the polyline, the first match will return: + + 1. (Pc , Pd) + 2. (Pb , Pa) + 3. (Pa , Pd) + 4. (Pd , Pa) + + The fault object is not directed in any way; i.e. in the case + both (Pc,Pd) and (Pb,Pa) intersects the polyline it is + impossible to know which intersection is returned, without + actually consulting the construction of the fault object. + """ + if self.intersectsPolyline(polyline , k): + return None + + fault_polyline = self.getPolyline( k ) + p0 = fault_polyline[-2] + p1 = fault_polyline[-1] + extension = self.__rayIntersect(p0 , p1 , polyline) + if extension: + return extension + + p0 = fault_polyline[1] + p1 = fault_polyline[0] + extension = self.__rayIntersect(p0 , p1 , polyline) + if extension: + return extension + + p0 = fault_polyline[0] + p1 = fault_polyline[-1] + extension = self.__rayIntersect(p0 , p1 , polyline) + if extension: + return extension + + p0 = fault_polyline[-1] + p1 = fault_polyline[0] + extension = self.__rayIntersect(p0 , p1 , polyline) + if extension: + return extension + + raise ValueError("The fault %s can not be extended to intersect with polyline:%s in layer:%d" % (self.getName() , polyline.getName() , k+1)) + + + def intersectsPolyline(self , polyline , k): + fault_line = self.getPolyline(k) + return fault_line.intersects( polyline ) + + + def intersectsFault(self , other_fault , k): + fault_line = other_fault.getPolyline(k) + return self.intersectsPolyline( fault_line , k ) + + + def extendToFault(self , fault , k): + fault_line = fault.getPolyline(k) + return self.extendToPolyline(fault_line , k) + + def extendToEdge(self, edge , k): + if isinstance(edge , Fault): + return self.extendToFault( edge , k ) + else: + return self.extendToPolyline( edge , k ) + + + def extendToBBox(self , bbox , k , start = True): + fault_polyline = self.getPolyline(k) + if start: + p0 = fault_polyline[1] + p1 = fault_polyline[0] + else: + p0 = fault_polyline[-2] + p1 = fault_polyline[-1] + + ray_dir = GeometryTools.lineToRay(p0,p1) + intersections = GeometryTools.rayPolygonIntersections( p1 , ray_dir , bbox) + if intersections: + p2 = intersections[0][1] + if self.getName(): + name = "Extend:%s" % self.getName() + else: + name = None + + return CPolyline( name = name , init_points = [(p1[0] , p1[1]) , p2]) + else: + raise Exception("Logical error - must intersect with bounding box") + + + def endJoin(self , other , k): + fault_polyline = self.getPolyline(k) + + if isinstance(other , Fault): + other_polyline = other.getPolyline(k) + else: + other_polyline = other + + return GeometryTools.joinPolylines( fault_polyline , other_polyline ) + + + + def connectPolylineOnto(self , polyline , k): + if self.intersectsPolyline( polyline , k): + return None + + self_polyline = self.getPolyline(k) + return polyline.connect( self_polyline ) + + + + def extendPolylineOnto(self , polyline , k): + if self.intersectsPolyline( polyline , k): + return None + + if len(polyline) > 1: + fault_polyline = self.getPolyline(k) + ext1 = self.__rayIntersect( polyline[-2] , polyline[-1] , fault_polyline ) + ext2 = self.__rayIntersect( polyline[0] , polyline[1] , fault_polyline ) + + if ext1 and ext2: + d1 = GeometryTools.distance( ext1[0] , ext1[1] ) + d2 = GeometryTools.distance( ext2[0] , ext2[1] ) + + if d1 < d2: + return ext1 + else: + return ext2 + + if ext1: + return ext1 + else: + return ext2 + else: + raise ValueError("Polyline must have length >= 2") + + + + @staticmethod + def intersectFaultRays(ray1 , ray2): + p1,dir1 = ray1 + p2,dir2 = ray2 + if p1 == p2: + return [] + + dx = p2[0] - p1[0] + dy = p2[1] - p1[1] + if dx != 0: + if dir1[0] * dx <= 0 and dir2[0] * dx >= 0: + raise ValueError("Rays will never intersect") + + if dy != 0: + if dir1[1] * dy <= 0 and dir2[1] * dy >= 0: + raise ValueError("Rays will never intersect") + + if dx*dy != 0: + if dir1[0] != 0: + xc = p2[0] + yc = p1[1] + else: + xc = p1[0] + yc = p2[1] + + coord_list = [p1 , (xc,yc) , p2] + else: + coord_list = [p1,p2] + + return coord_list + + + @staticmethod + def intRay(p1,p2): + if p1 == p2: + raise Exception("Can not form ray from coincident points") + + if p1[0] == p2[0]: + # Vertical line + dx = 0 + if p2[1] > p1[1]: + dy = 1 + elif p2[1] < p1[1]: + dy = -1 + else: + # Horizontal line + if p2[1] != p1[1]: + raise Exception("Invalid direction") + + dy = 0 + if p2[0] > p1[0]: + dx = 1 + else: + dx = -1 + + return [p2 , (dx,dy)] + + + + def getEndRays(self , k): + polyline = self.getIJPolyline(k) + + p0 = polyline[0] + p1 = polyline[1] + p2 = polyline[-2] + p3 = polyline[-1] + + return (Fault.intRay(p1,p0) , Fault.intRay(p2,p3)) + + + + + @staticmethod + def joinFaults(fault1 , fault2 , k): + fault1_rays = fault1.getEndRays(k) + fault2_rays = fault2.getEndRays(k) + + if fault1.intersectsFault( fault2 , k ): + return None + + count = 0 + join = None + try: + join = Fault.intersectFaultRays( fault1_rays[0] , fault2_rays[0] ) + count += 1 + except ValueError: + pass + + try: + join = Fault.intersectFaultRays( fault1_rays[0] , fault2_rays[1] ) + count += 1 + except ValueError: + pass + + try: + join = Fault.intersectFaultRays( fault1_rays[1] , fault2_rays[0] ) + count += 1 + except ValueError: + pass + + try: + join = Fault.intersectFaultRays( fault1_rays[1] , fault2_rays[1] ) + count += 1 + except ValueError: + pass + + if count == 1: + xy_list = [] + for ij in join: + xyz = fault1.__grid.getNodeXYZ( ij[0] , ij[1] , k ) + xy_list.append( (xyz[0] , xyz[1]) ) + + return xy_list + else: + return fault1.endJoin( fault2 , k ) + #raise ValueError("Faults %s and %s could not be uniquely joined" % (fault1.getName() , fault2.getName())) + + + + diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block.py index 84a5536f09..d811b363e6 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block.py @@ -16,7 +16,7 @@ import ctypes from ert.cwrap import BaseCClass, CWrapper -from ert.geo import Polyline, GeometryTools +from ert.geo import Polyline, GeometryTools , CPolylineCollection from ert.util import DoubleVector , IntVector from ert.ecl import ECL_LIB @@ -115,7 +115,9 @@ def getGlobalIndexList(self): def getEdgePolygon(self): x_list = DoubleVector() y_list = DoubleVector() - self.cNamespace().trace_edge( self , x_list , y_list ) + cell_list = IntVector() + + self.cNamespace().trace_edge( self , x_list , y_list , cell_list ) p = Polyline() for (x,y) in zip(x_list , y_list): p.addPoint(x,y) @@ -130,16 +132,21 @@ def containsPolyline(self, polyline): for p in polyline: if GeometryTools.pointInPolygon( p , edge_polyline ): return True - return False + else: + edge_polyline.assertClosed() + return GeometryTools.polylinesIntersect( edge_polyline , polyline ) - def getNeighbours(self): + def getNeighbours(self, polylines = None , connected_only = True): """ Will return a list of FaultBlock instances which are in direct contact with this block. """ neighbour_id_list = IntVector() - self.cNamespace().get_neighbours( self , neighbour_id_list ) + if polylines is None: + polylines = CPolylineCollection() + + self.cNamespace().get_neighbours( self , connected_only , polylines , neighbour_id_list ) parent_layer = self.getParentLayer() neighbour_list = [] @@ -165,6 +172,6 @@ def getParentLayer(self): FaultBlock.cNamespace().get_region_list = cwrapper.prototype("int_vector_ref fault_block_get_region_list(fault_block)") FaultBlock.cNamespace().add_cell = cwrapper.prototype("void fault_block_add_cell(fault_block, int , int)") FaultBlock.cNamespace().get_global_index_list = cwrapper.prototype("int_vector_ref fault_block_get_global_index_list(fault_block)") -FaultBlock.cNamespace().trace_edge = cwrapper.prototype("void fault_block_trace_edge( fault_block, double_vector , double_vector)") -FaultBlock.cNamespace().get_neighbours = cwrapper.prototype("void fault_block_list_neighbours( fault_block , int_vector)") +FaultBlock.cNamespace().trace_edge = cwrapper.prototype("void fault_block_trace_edge( fault_block, double_vector , double_vector , int_vector)") +FaultBlock.cNamespace().get_neighbours = cwrapper.prototype("void fault_block_list_neighbours( fault_block , bool , geo_polygon_collection , int_vector)") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block_layer.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block_layer.py index 1e5c2a98ec..833eed4c8e 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block_layer.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_block_layer.py @@ -18,6 +18,7 @@ from ert.cwrap import BaseCClass, CWrapper from ert.ecl import ECL_LIB from ert.ecl import EclTypeEnum +from ert.ecl.faults import Fault class FaultBlockLayer(BaseCClass): @@ -51,6 +52,17 @@ def __getitem__(self , index): return self.cNamespace().iget_block( self , index ).setParent(self) else: raise IndexError("Index:%d out of range: [0,%d)" % (index , len(self))) + elif isinstance(index,tuple): + i,j = index + if 0 <= i < self.grid_ref.getNX() and 0 <= j < self.grid_ref.getNY(): + geo_layer = self.getGeoLayer() + block_id = geo_layer[i,j] + if block_id == 0: + raise ValueError("No fault block defined for location (%d,%d)" % (i,j)) + else: + return self.getBlock( block_id ) + else: + raise IndexError("Invalid i,j : (%d,%d)" % (i,j)) else: raise TypeError("Index should be integer type") @@ -130,6 +142,55 @@ def exportKeyword(self , kw): self.cNamespace().export_kw( self , kw ) + def addFaultBarrier(self , fault , link_segments = False): + layer = self.getGeoLayer( ) + layer.addFaultBarrier( fault , self.getK() , link_segments ) + + + def addFaultLink(self , fault1 , fault2 ): + if not fault1.intersectsFault( fault2 , self.getK()): + layer = self.getGeoLayer() + layer.addIJBarrier( fault1.extendToFault( fault2 , self.getK() ) ) + + + def joinFaults(self , fault1 , fault2): + if not fault1.intersectsFault( fault2 , self.getK()): + layer = self.getGeoLayer() + try: + layer.addIJBarrier( Fault.joinFaults( fault1 , fault2 , self.getK()) ) + except ValueError: + print "Failed to join faults %s and %s" % (fault1.getName() , fault2.getName()) + raise ValueError("") + + + def addPolylineBarrier(self , polyline): + layer = self.getGeoLayer() + p0 = polyline[0] + c0 = self.grid_ref.findCellCornerXY( p0[0] , p0[1] , self.getK() ) + i,j = self.grid_ref.findCellXY( p0[0] , p0[1] , self.getK() ) + print "%g,%g -> %d,%d %d" % (p0[0] , p0[1] , i,j,c0) + for index in range(1,len(polyline)): + p1 = polyline[index] + c1 = self.grid_ref.findCellCornerXY( p1[0] , p1[1] , self.getK() ) + i,j = self.grid_ref.findCellXY( p1[0] , p1[1] , self.getK() ) + layer.addInterpBarrier( c0 , c1 ) + print "%g,%g -> %d,%d %d" % (p1[0] , p1[1] , i,j,c1) + print "Adding barrier %d -> %d" % (c0 , c1) + c0 = c1 + + + + def getGeoLayer(self): + """Returns the underlying geometric layer.""" + return self.cNamespace().get_layer( self ) + + + def cellContact(self , p1 , p2): + layer = self.getGeoLayer() + return layer.cellContact(p1,p2) + + + cwrapper = CWrapper(ECL_LIB) CWrapper.registerObjectType("fault_block_layer", FaultBlockLayer) @@ -149,3 +210,4 @@ def exportKeyword(self , kw): FaultBlockLayer.cNamespace().scan_layer = cwrapper.prototype("void fault_block_layer_scan_layer( fault_block_layer , layer)") FaultBlockLayer.cNamespace().insert_block_content = cwrapper.prototype("void fault_block_layer_insert_block_content( fault_block_layer , fault_block)") FaultBlockLayer.cNamespace().export_kw = cwrapper.prototype("bool fault_block_layer_export( fault_block_layer , ecl_kw )") +FaultBlockLayer.cNamespace().get_layer = cwrapper.prototype("layer_ref fault_block_layer_get_layer( fault_block_layer )") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_collection.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_collection.py index ac4f74224b..4d03a1d160 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_collection.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_collection.py @@ -14,7 +14,9 @@ # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. import re + from .fault import Fault +from ert.ecl import EclGrid comment_regexp = re.compile("--.*") @@ -29,13 +31,21 @@ def dequote(s): class FaultCollection(object): - def __init__(self , grid , *file_list): + def __init__(self , grid = None , *file_list): self.__fault_list = [] self.__fault_map = {} - self.__grid = grid - for file in file_list: - self.load(file) + if grid is not None: + if not isinstance(grid , EclGrid): + raise ValueError("When supplying a list of files to load - you must have a grid") + + for file in file_list: + self.load(grid , file) + + + + def __contains__(self , fault_name): + return self.__fault_map.has_key( fault_name ) def __len__(self): @@ -63,14 +73,13 @@ def getFault(self , name): def hasFault(self , fault_name): - return self.__fault_map.has_key( fault_name ) + return fault_name in self - def addFault(self, fault_name): - new_fault = Fault(self.__grid , fault_name) - self.__fault_map[fault_name] = new_fault - self.__fault_list.append( new_fault ) - + def addFault(self, fault): + self.__fault_map[fault.getName()] = fault + self.__fault_list.append( fault ) + def splitLine(self , line): tmp = line.split() @@ -93,7 +102,7 @@ def splitLine(self , line): - def loadFaults(self , fileH): + def loadFaults(self , grid , fileH): for line in fileH: line = comment_regexp.sub("" , line) line = line.strip() @@ -103,14 +112,17 @@ def loadFaults(self , fileH): if line: (name , I1 , I2 , J1 , J2 , K1 , K2 , face) = self.splitLine( line ) if not self.hasFault(name): - self.addFault(name) - fault = self.getFault(name) + fault = Fault( grid , name) + self.addFault( fault ) + else: + fault = self.getFault(name) + fault.addRecord(I1 , I2 , J1 , J2 , K1 , K2 , face) - def load(self , file_name): + def load(self , grid , file_name): with open(file_name) as fileH: for line in fileH: if line.startswith("FAULTS"): - self.loadFaults(fileH) + self.loadFaults(grid , fileH) diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_line.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_line.py index 5e40715f12..606bf5293a 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_line.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/fault_line.py @@ -17,8 +17,9 @@ import sys -from ert.geo import Polyline - +from ert.util import DoubleVector,stat +from ert.geo import CPolyline +from .fault_segments import FaultSegment @@ -36,6 +37,7 @@ def __init__(self , grid , k): self.__k = k self.__segment_list = [] self.__polyline = None + self.__ijpolyline = None self.__neighborCells = None def __len__(self): @@ -79,23 +81,41 @@ def tryAppend(self , segment): self.__segment_list.append( segment ) self.__polyline = None + self.__ijpolyline = None return True def getK(self): return self.__k - - def __initPolyline(self): - pl = Polyline() + + def __initIJPolyline(self): + pl = [] + nx = self.__grid.getNX() + ny = self.__grid.getNY() for segment in self: - (x,y,z) = self.__grid.getLayerXYZ( segment.getC1( ) , self.__k ) - pl.addPoint( x,y,z ) - + corner = segment.getC1( ) + i = corner % (nx + 1) + j = corner / (nx + 1) + pl.append( (i,j) ) + segment = self[-1] - (x,y,z) = self.__grid.getLayerXYZ( segment.getC2( ) , self.__k ) - pl.addPoint( x,y,z ) + corner = segment.getC2( ) + i = corner % (nx + 1) + j = corner / (nx + 1) + pl.append( (i,j) ) + + self.__ijpolyline = pl + + + + def __initPolyline(self): + pl = CPolyline() + for (i,j) in self.getIJPolyline(): + x,y,z = self.__grid.getNodeXYZ(i,j,self.__k) + pl.addPoint( x, y) self.__polyline = pl + def getPolyline(self): @@ -104,6 +124,13 @@ def getPolyline(self): return self.__polyline + def getIJPolyline(self): + if self.__ijpolyline is None: + self.__initIJPolyline() + return self.__ijpolyline + + + def __initNeighborCells(self): self.__neighborCells = [] nx = self.__grid.getNX() @@ -158,6 +185,51 @@ def getNeighborCells(self): return self.__neighborCells + + def center(self): + xlist = DoubleVector( ) + ylist = DoubleVector( ) + for segment in self: + C1 = segment.getC1() + C2 = segment.getC2() + (J1 , I1) = divmod(C1 , self.__grid.getNX() + 1) + (J2 , I2) = divmod(C2 , self.__grid.getNX() + 1) + + (x1,y1,z) = self.__grid.getNodePos( I1 , J1 , self.__k ) + (x2,y2,z) = self.__grid.getNodePos( I2 , J2 , self.__k ) + + xlist.append( x1 ) + xlist.append( x2 ) + + ylist.append( y1 ) + ylist.append( y2 ) + + + N = len(xlist) + return (xlist.elementSum()/N , ylist.elementSum()/N ) + + + + def reverse(self): + reverse_list = reversed( self.__segment_list ) + self.__segment_list = [] + for segment in reverse_list: + C1 = segment.getC1() + C2 = segment.getC2() + + rseg = FaultSegment(C2 , C1) + self.tryAppend( rseg ) + + + def startPoint(self): + pl = self.getPolyline() + return pl[0] + + + def endPoint(self): + pl = self.getPolyline() + return pl[-1] + def dump(self): diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/layer.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/layer.py index f0072160e4..95e528a76f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/layer.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/layer.py @@ -17,6 +17,8 @@ import ctypes from ert.cwrap import BaseCClass, CWrapper from ert.ecl import ECL_LIB +from ert.util import IntVector + class Layer(BaseCClass): @@ -27,6 +29,21 @@ def __init__(self , nx , ny): else: raise ValueError("Invalid input - no Layer object created") + @classmethod + def copy(cls , src): + layer = Layer( src.getNX() , src.getNY()) + Layer.cNamespace().copy( layer , src ) + return layer + + + def __assertIJ(self , i,j): + if i < 0 or i >= self.getNX(): + raise ValueError("Invalid layer i:%d" % i) + + if j < 0 or j >= self.getNY(): + raise ValueError("Invalid layer j:%d" % j) + + def __unpackIndex(self , index): try: @@ -34,11 +51,7 @@ def __unpackIndex(self , index): except TypeError: raise ValueError("Index:%s is invalid - must have two integers" % str(index)) - if i < 0 or i >= self.getNX(): - raise ValueError("Invalid layer i:%d" % i) - - if j < 0 or j >= self.getNY(): - raise ValueError("Invalid layer j:%d" % j) + self.__assertIJ(i,j) return (i,j) @@ -48,12 +61,38 @@ def __setitem__(self , index , value): (i,j) = self.__unpackIndex(index) self.cNamespace().set_cell(self , i , j , value ) + def activeCell(self , i,j): + self.__assertIJ(i,j) + return self.cNamespace().active_cell(self , i , j) + + + def updateActive(self , grid , k): + if grid.getNX() != self.getNX(): + raise ValueError("NX dimension mismatch. Grid:%d layer:%d" % (grid.getNX() , self.getNX())) + + if grid.getNY() != self.getNY(): + raise ValueError("NY dimension mismatch. Grid:%d layer:%d" % (grid.getNY() , self.getNY())) + + if k >= grid.getNZ(): + raise ValueError("K value invalid: Grid range [0,%d)" % grid.getNZ()) + + self.cNamespace().update_active(self , grid , k) + + + def __getitem__(self , index): (i,j) = self.__unpackIndex(index) return self.cNamespace().get_cell(self , i , j) - + def bottomBarrier(self , i,j): + self.__assertIJ(i,j) + return self.cNamespace().get_bottom_barrier(self , i , j) + + def leftBarrier(self , i,j): + self.__assertIJ(i,j) + return self.cNamespace().get_left_barrier(self , i , j) + def getNX(self): return self.cNamespace().get_nx(self) @@ -63,15 +102,151 @@ def getNY(self): def free(self): self.cNamespace().free(self) + def cellContact(self , p1 , p2): + i1,j1 = p1 + i2,j2 = p2 + + if not 0 <= i1 < self.getNX(): + raise IndexError("Invalid i1:%d" % i1) + if not 0 <= i2 < self.getNX(): + raise IndexError("Invalid i2:%d" % i2) + if not 0 <= j1 < self.getNY(): + raise IndexError("Invalid i1:%d" % j1) + + if not 0 <= j2 < self.getNY(): + raise IndexError("Invalid i2:%d" % j2) + + return self.cNamespace().cell_contact(self , i1,j1,i2,j2) + + + def addInterpBarrier(self , c1 , c2): + self.cNamespace().add_interp_barrier( self , c1 , c2 ) + + + def addPolylineBarrier(self , polyline , grid , k): + if len(polyline) > 1: + for i in range(len(polyline) - 1): + x1,y1 = polyline[i] + x2,y2 = polyline[i + 1] + + c1 = grid.findCellCornerXY( x1 , y1 , k ) + c2 = grid.findCellCornerXY( x2 , y2 , k ) + + self.addInterpBarrier( c1 , c2 ) + + + + def addFaultBarrier(self , fault , K , link_segments = True ): + fault_layer = fault[K] + num_lines = len(fault_layer) + for index , fault_line in enumerate(fault_layer): + for segment in fault_line: + c1 , c2 = segment.getCorners() + self.cNamespace().add_barrier(self , c1 , c2) + + if index < num_lines - 1: + next_line = fault_layer[index + 1] + next_segment = next_line[0] + next_c1 , next_c2 = next_segment.getCorners() + + if link_segments: + self.addInterpBarrier( c2 , next_c1 ) + + + def addIJBarrier(self , ij_list): + if len(ij_list) < 2: + print "ij_list:%s" % ij_list + raise ValueError("Must have at least two (i,j) points") + + nx = self.getNX() + ny = self.getNY() + p1 = ij_list[0] + i1,j1 = p1 + for p2 in ij_list[1:]: + i2,j2 = p2 + if i1 == i2 or j1 == j2: + if not 0 <= i2 <= nx: + raise ValueError("i value:%d invalid. Valid range: [0,%d] " % (i , i2)) + + if not 0 <= j2 <= ny: + raise ValueError("i value:%d invalid. Valid range: [0,%d] " % (j , j2)) + + Layer.cNamespace().add_ijbarrier( self , i1 , j1 , i2 , j2 ) + p1 = p2 + i1,j1 = p1 + else: + raise ValueError("Must have i1 == i2 or j1 == j2") + + + def cellSum(self): + return Layer.cNamespace().cell_sum( self ) + + + def clearCells(self): + """ + Will reset all cell and edge values to zero. Barriers will be left + unchanged. + """ + Layer.cNamespace().clear_cells( self ) + + + def assign(self , value): + """ + Will set the cell value to @value in all cells. Barriers will not be changed + """ + Layer.cNamespace().assign( self , value ) + + + def updateConnected(self , ij , new_value , org_value = None): + """ + Will update cell value of all cells in contact with cell ij to the + value @new_value. If org_value is not supplied, the current + value in cell ij is used. + """ + if org_value is None: + org_value = self[ij] + + if self[ij] == org_value: + Layer.cNamespace().update_connected( self , ij[0] , ij[1] , org_value , new_value ) + else: + raise ValueError("Cell %s is not equal to %d \n" % (ij , org_value)) + + + def cellsEqual(self , value): + """ + Will return a list [(i1,j1),(i2,j2) , ...(in,jn)] of all cells with value @value. + """ + i_list = IntVector() + j_list = IntVector() + Layer.cNamespace().cells_equal( self , value , i_list , j_list) + ij_list= [] + for (i,j) in zip(i_list , j_list): + ij_list.append( (i,j) ) + return ij_list + cwrapper = CWrapper(ECL_LIB) CWrapper.registerObjectType("layer", Layer) -Layer.cNamespace().alloc = cwrapper.prototype("c_void_p layer_alloc(int, int)") -Layer.cNamespace().free = cwrapper.prototype("void layer_free(layer)") -Layer.cNamespace().get_nx = cwrapper.prototype("int layer_get_nx(layer)") -Layer.cNamespace().get_ny = cwrapper.prototype("int layer_get_ny(layer)") -Layer.cNamespace().set_cell = cwrapper.prototype("void layer_iset_cell_value(layer , int , int , int)") -Layer.cNamespace().get_cell = cwrapper.prototype("int layer_iget_cell_value(layer , int , int )") +Layer.cNamespace().alloc = cwrapper.prototype("c_void_p layer_alloc(int, int)") +Layer.cNamespace().copy = cwrapper.prototype("void layer_memcpy(layer , layer)") +Layer.cNamespace().free = cwrapper.prototype("void layer_free(layer)") +Layer.cNamespace().get_nx = cwrapper.prototype("int layer_get_nx(layer)") +Layer.cNamespace().get_ny = cwrapper.prototype("int layer_get_ny(layer)") +Layer.cNamespace().set_cell = cwrapper.prototype("void layer_iset_cell_value(layer , int , int , int)") +Layer.cNamespace().get_cell = cwrapper.prototype("int layer_iget_cell_value(layer , int , int )") +Layer.cNamespace().get_bottom_barrier = cwrapper.prototype("bool layer_iget_bottom_barrier(layer , int , int )") +Layer.cNamespace().get_left_barrier = cwrapper.prototype("bool layer_iget_left_barrier(layer , int , int )") +Layer.cNamespace().cell_contact = cwrapper.prototype("bool layer_cell_contact(layer , int , int , int , int)") +Layer.cNamespace().add_barrier = cwrapper.prototype("void layer_add_barrier(layer , int , int)") +Layer.cNamespace().add_ijbarrier = cwrapper.prototype("void layer_add_ijbarrier(layer , int , int, int , int)") +Layer.cNamespace().add_interp_barrier = cwrapper.prototype("void layer_add_interp_barrier(layer , int , int)") +Layer.cNamespace().clear_cells = cwrapper.prototype("void layer_clear_cells(layer)") +Layer.cNamespace().assign = cwrapper.prototype("void layer_assign(layer , int)") +Layer.cNamespace().cell_sum = cwrapper.prototype("int layer_get_cell_sum(layer)") +Layer.cNamespace().update_connected = cwrapper.prototype("void layer_update_connected_cells(layer,int,int,int,int)") +Layer.cNamespace().cells_equal = cwrapper.prototype("void layer_cells_equal( layer, int,int_vector,int_vector)") +Layer.cNamespace().active_cell = cwrapper.prototype("bool layer_iget_active( layer, int,int)") +Layer.cNamespace().update_active = cwrapper.prototype("bool layer_update_active( layer, ecl_grid , int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/region_definition.py b/ThirdParty/Ert/devel/python/python/ert/ecl/faults/region_definition.py deleted file mode 100644 index 8f2a115e43..0000000000 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/faults/region_definition.py +++ /dev/null @@ -1,171 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'region_definition.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - -import collections -import os.path - -from ert.geo import Polyline , XYZIo, GeometryTools -from ert.ecl.faults import Fault, FaultBlockLayer , Layer -from ert.ecl import EclKW, EclTypeEnum - -class RegionDefinition(object): - - def __init__(self , region_id): - if not isinstance(region_id , int): - raise TypeError("The region_id input argument must be integer. region_id:%s - invalid" % region_id) - - self.region_id = region_id - self.edges = [] - self.__has_polygon = False - - - - @staticmethod - def create(region_id , faults , edge_names): - regionDef = RegionDefinition( region_id ) - - for edge_name in edge_names: - if isinstance(edge_name , str): - if faults.hasFault( edge_name ): - regionDef.addEdge( faults[ edge_name ] ) - elif os.path.exists( edge_name ): - regionDef.addEdge( XYZIo.readXYZFile( edge_name ) ) - else: - raise ValueError("The elements in edge_list must be strings with either name of faults or filename with polygon. %s: invalid" % edge_name) - else: - raise ValueError("The elements in edge_list must be strings with either name of faults or filename with polygon. %s: invalid" % edge_name) - - return regionDef - - - def getRegionID(self): - return self.region_id - - - def addEdge(self , edge): - if isinstance(edge , Polyline): - self.edges.append( edge ) - self.__has_polygon = True - elif isinstance(edge , Fault): - self.edges.append( edge ) - else: - raise TypeError("Tried to add edge of wrong type; must be Fault or Polyline") - - - - def __convexHull(self , k): - point_list = [] - - if len(self.edges) == 0: - raise Exception("You must add Fault / Polyline edges first") - - for edge in self.edges: - if isinstance(edge , Fault): - fault = edge - layer = fault[k] - for line in layer: - for p in line.getPolyline(): - point_list.append( (p[0] , p[1]) ) - else: - poly_line = edge - for p in poly_line: - point_list.append( (p[0] , p[1]) ) - - return GeometryTools.convexHull( point_list ) - - - def findInternalBlocks(self , grid , fault_block_layer): - block_list = [] - raise NotImplementedError - return block_list - - - def hasPolygon(self): - return self.__has_polygon - - - @staticmethod - def splitFaultBlockClosedPolygon( grid , fault_blocks , polygon ): - """ - Special case code when the region is limited only by one polygon. - """ - new_fault_blocks = FaultBlockLayer( grid , fault_blocks.getK() ) - new_block = new_fault_blocks.addBlock() - - for block in fault_blocks: - for p in block: - if GeometryTools.pointInPolygon( (p.x , p.y) , polygon ): - new_block.addCell(p.i , p.j) - - return new_fault_blocks - - - - - def splitFaultBlocks(self , grid , fault_blocks ): - boundingPolygon = Polyline(init_points = grid.getBoundingBox2D()) - boundingPolygon.assertClosed() - if self.hasPolygon(): - if len(self.edges) == 1: - return self.splitFaultBlockClosedPolygon( grid , fault_blocks , self.edges[0] ) - else: - current_fault_block_layer = fault_blocks - k = fault_blocks.getK() - for edge in self.edges: - if isinstance(edge , Polyline): - # Start on a brand new fault block layer. - next_fault_block_layer = FaultBlockLayer( grid , k ) - for block in current_fault_block_layer: - if block.containsPolyline(edge): - print "Block %d is split due to edge:%s" % (block.getBlockID() , edge.name()) - sliced = GeometryTools.slicePolygon( boundingPolygon , edge ) - inside_list = [] - outside_list = [] - for p in block: - if GeometryTools.pointInPolygon( (p.x , p.y) , sliced ): - inside_list.append( p ) - else: - outside_list.append( p ) - - if len(inside_list) * len(outside_list) == 0: - new_block = next_fault_block_layer.addBlock( ) - for p in inside_list: - new_block.addCell(p.i , p.j) - - for p in outside_list: - new_block.addCell(p.i , p.j) - else: - layer = Layer( grid.getNX() , grid.getNY() ) - for p in inside_list: - layer[p.i , p.j] = 1 - - for p in outside_list: - layer[p.i , p.j] = 2 - - next_fault_block_layer.scanLayer( layer ) - else: - next_fault_block_layer.insertBlockContent( block ) - - current_fault_block_layer = next_fault_block_layer - return current_fault_block_layer - else: - return fault_blocks - - - - - - diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/fortio.py b/ThirdParty/Ert/devel/python/python/ert/ecl/fortio.py index 1d6a12265b..72fd67f211 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/fortio.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/fortio.py @@ -76,20 +76,6 @@ def close(self): FortIO.cNamespace().close(self) self.__open = False - def writeRecord(self, data): - """ - Not a good way of implementing this. ;-) - @type data: bytearray - """ - buffer = (ctypes.c_char * len(data)).from_buffer(data) - FortIO.cNamespace().write_record(self, buffer, len(data)) - - - def readRecordAsString(self, record_size): - """ @rtype: str """ - chars = ctypes.create_string_buffer(record_size) - count = FortIO.cNamespace().read_record(self, chars) - return ctypes.string_at(chars, count) def getPosition(self): @@ -102,6 +88,18 @@ def seek(self, position): # SEEK_END = 2 FortIO.cNamespace().seek(self, position, 0) + @classmethod + def isFortranFile(cls , filename , endian_flip = True): + """@rtype: bool + @type filename: str + + + Will use heuristics to try to guess if @filename is a binary + file written in fortran style. ASCII files will return false, + even if they are structured as ECLIPSE keywords. + """ + return FortIO.cNamespace().guess_fortran( filename , endian_flip ) + def free(self): self.close() @@ -135,12 +133,11 @@ def openFortIO( file_name , mode = FortIO.READ_MODE , fmt_file = False , endian_ FortIO.cNamespace().open_append = cwrapper.prototype("c_void_p fortio_open_append(char*, bool, bool)") FortIO.cNamespace().write_record = cwrapper.prototype("void fortio_fwrite_record(fortio, char*, int)") -FortIO.cNamespace().read_record = cwrapper.prototype("int fortio_fread_record(fortio, char*)") FortIO.cNamespace().get_position = cwrapper.prototype("long fortio_ftell(fortio)") FortIO.cNamespace().seek = cwrapper.prototype("void fortio_fseek(fortio, int)") FortIO.cNamespace().close = cwrapper.prototype("bool fortio_fclose(fortio)") - +FortIO.cNamespace().guess_fortran = cwrapper.prototype("bool fortio_looks_like_fortran_file(char* , bool)") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/rft/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/ecl/rft/CMakeLists.txt new file mode 100644 index 0000000000..9a13752492 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/rft/CMakeLists.txt @@ -0,0 +1,6 @@ +set(PYTHON_SOURCES + __init__.py + well_trajectory.py +) + +add_python_package("python.ert.ecl.rft" ${PYTHON_INSTALL_PREFIX}/ert/ecl/rft "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/rft/__init__.py b/ThirdParty/Ert/devel/python/python/ert/ecl/rft/__init__.py new file mode 100644 index 0000000000..d5a91dfba7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/rft/__init__.py @@ -0,0 +1 @@ +from .well_trajectory import WellTrajectory diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/rft/well_trajectory.py b/ThirdParty/Ert/devel/python/python/ert/ecl/rft/well_trajectory.py new file mode 100644 index 0000000000..adaf2f299c --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/rft/well_trajectory.py @@ -0,0 +1,63 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'well_trajectory.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import sys +import os +from collections import namedtuple + +TrajectoryPoint = namedtuple("TrajectoryPoint", "utm_x utm_y measured_depth true_vertical_depth zone") + +class WellTrajectory: + + def __init__(self , filename): + if os.path.isfile(filename): + self.points = [] + with open(filename) as fileH: + for line in fileH.readlines(): + line = line.partition("--")[0] + line = line.strip() + if line: + point = line.split() + if len(point) < 4 or len(point) > 5: + raise UserWarning("Trajectory data file not on correct format: \"utm_x utm_y md tvd [zone]\" - zone is optional") + + try: + utm_x = float(point[0]) + utm_y = float(point[1]) + md = float(point[2]) + tvd = float(point[3]) + if len(point) > 4: + zone = point[4] + else: + zone = None + except ValueError: + raise UserWarning("Error: Failed to extract data from line %s\n" % line) + + self.points.append(TrajectoryPoint(utm_x , utm_y , md , tvd , zone)) + + else: + raise IOError("File not found:%s" % filename) + + + def __len__(self): + return len(self.points) + + + def __getitem__(self , index): + if index < 0: + index += len(self) + + return self.points[index] diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/enkf/CMakeLists.txt index 4d14ad4a38..ecec6ee9c5 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/CMakeLists.txt @@ -1,7 +1,9 @@ set(PYTHON_SOURCES __init__.py + active_list.py analysis_config.py analysis_iter_config.py + custom_kw_config_set.py ecl_config.py enkf_fs.py enkf_fs_manager.py @@ -10,30 +12,36 @@ set(PYTHON_SOURCES enkf_obs.py enkf_simulation_runner.py enkf_state.py - ens_config.py + ensemble_config.py ert_log.py + ert_run_context.py ert_template.py ert_templates.py ert_workflow_list.py local_config.py local_obsdata.py local_obsdata_node.py + meas_block.py meas_data.py model_config.py node_id.py + obs_block.py obs_data.py plot_config.py post_simulation_hook.py + run_arg.py + runpath_list.py site_config.py state_map.py - run_arg.py - ert_run_context.py + summary_key_matcher.py + summary_key_set.py ) add_python_package("python.ert.enkf" ${PYTHON_INSTALL_PREFIX}/ert/enkf "${PYTHON_SOURCES}" True) add_subdirectory(data) add_subdirectory(enums) +add_subdirectory(export) add_subdirectory(observations) add_subdirectory(plot) add_subdirectory(plot_data) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/__init__.py b/ThirdParty/Ert/devel/python/python/ert/enkf/__init__.py index 2481b1fe88..9aa0b9dcb4 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/__init__.py @@ -16,6 +16,16 @@ import ert.cwrap.clib as clib +import ert.util +import ert.geo +import ert.ecl +import ert.rms +import ert.analysis +import ert.sched +import ert.config +import ert.job_queue + + ENKF_LIB = clib.ert_load("libenkf") @@ -26,32 +36,38 @@ from .enkf_linalg import EnkfLinalg from .util import TimeMap from .state_map import StateMap +from .summary_key_set import SummaryKeySet +from .summary_key_matcher import SummaryKeyMatcher from .enkf_fs import EnkfFs from .ert_workflow_list import ErtWorkflowList - -from .observations import SummaryObservation, ObsVector +from .active_list import ActiveList +from .data import * from .local_obsdata_node import LocalObsdataNode from .local_obsdata import LocalObsdata +from .observations import * + +from .obs_block import ObsBlock from .obs_data import ObsData +from .meas_block import MeasBlock from .meas_data import MeasData from .analysis_iter_config import AnalysisIterConfig from .analysis_config import AnalysisConfig from .ecl_config import EclConfig -from .data import * - +from .custom_kw_config_set import CustomKWConfigSet +from .ensemble_config import EnsembleConfig from .enkf_obs import EnkfObs from .enkf_state import EnKFState -from .ens_config import EnsConfig from .ert_template import ErtTemplate from .ert_templates import ErtTemplates from .local_config import LocalConfig from .model_config import ModelConfig from .plot_config import PlotConfig from .site_config import SiteConfig +from .runpath_list import RunpathList, RunpathNode from .post_simulation_hook import PostSimulationHook from .enkf_simulation_runner import EnkfSimulationRunner @@ -61,5 +77,5 @@ from .enkf_main import EnKFMain from .ert_log import ErtLog - from ert.job_queue import ErtScript as ErtScript +from ert.job_queue import ErtPlugin as ErtPlugin, CancelPluginException as CancelPluginException diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/active_list.py b/ThirdParty/Ert/devel/python/python/ert/enkf/active_list.py new file mode 100644 index 0000000000..ed6332277f --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/active_list.py @@ -0,0 +1,45 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'active_list.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from ert.cwrap import BaseCClass, CWrapper +from ert.enkf import ENKF_LIB + +class ActiveList(BaseCClass): + def __init__(self): + c_ptr = ActiveList.cNamespace().alloc() + super(ActiveList, self).__init__(c_ptr) + + + def getMode(self): + return ActiveList.cNamespace().get_mode(self) + + def addActiveIndex(self, index): + ActiveList.cNamespace().add_index(self , index) + + + def free(self): + ActiveList.cNamespace().free(self) + + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("active_list", ActiveList) + + +ActiveList.cNamespace().alloc = cwrapper.prototype("c_void_p active_list_alloc()") +ActiveList.cNamespace().free = cwrapper.prototype("void active_list_free(active_list)") +ActiveList.cNamespace().get_mode = cwrapper.prototype("active_mode_enum active_list_get_mode(active_list)") +ActiveList.cNamespace().add_index = cwrapper.prototype("void active_list_add_index(active_list , int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py index 0d4afcefec..7decb0f585 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py @@ -17,6 +17,7 @@ from ert.enkf import ENKF_LIB from ert.enkf import AnalysisIterConfig from ert.analysis import AnalysisModule +from ert.util import StringList class AnalysisConfig(BaseCClass): @@ -43,12 +44,20 @@ def get_log_path(self): def set_log_path(self, path): AnalysisConfig.cNamespace().set_log_path(self, path) - def get_alpha(self): + def getEnkfAlpha(self): + """ :rtype: float """ return AnalysisConfig.cNamespace().get_alpha(self) - def set_alpha(self, alpha): + def setEnkfAlpha(self, alpha): AnalysisConfig.cNamespace().set_alpha(self, alpha) + def getStdCutoff(self): + """ :rtype: float """ + return AnalysisConfig.cNamespace().get_std_cutoff(self) + + def setStdCutoff(self, std_cutoff): + AnalysisConfig.cNamespace().set_std_cutoff(self, std_cutoff) + def get_merge_observations(self): return AnalysisConfig.cNamespace().get_merge_observations(self) @@ -84,9 +93,11 @@ def free(self): AnalysisConfig.cNamespace().free(self) def activeModuleName(self): + """ :rtype: str """ return AnalysisConfig.cNamespace().get_active_module_name(self) def getModuleList(self): + """ :rtype: StringList """ return AnalysisConfig.cNamespace().get_module_list(self) def getModule(self, module_name): @@ -97,9 +108,16 @@ def selectModule(self, module_name): """ @rtype: bool """ return AnalysisConfig.cNamespace().select_module(self, module_name) + def getActiveModule(self): + """ :rtype: AnalysisModule """ + return self.getModule(self.activeModuleName()) + + def setGlobalStdScaling(self, std_scaling): + AnalysisConfig.cNamespace().set_global_std_scaling(self, std_scaling) + def getGlobalStdScaling(self): + return AnalysisConfig.cNamespace().get_global_std_scaling(self) - ################################################################## cwrapper = CWrapper(ENKF_LIB) cwrapper.registerType("analysis_config", AnalysisConfig) @@ -114,8 +132,7 @@ def selectModule(self, module_name): AnalysisConfig.cNamespace().set_rerun_start = cwrapper.prototype("void analysis_config_set_rerun_start( analysis_config, int)") AnalysisConfig.cNamespace().get_log_path = cwrapper.prototype("char* analysis_config_get_log_path( analysis_config)") AnalysisConfig.cNamespace().set_log_path = cwrapper.prototype("void analysis_config_set_log_path( analysis_config, char*)") -AnalysisConfig.cNamespace().get_alpha = cwrapper.prototype("double analysis_config_get_alpha(analysis_config)") -AnalysisConfig.cNamespace().set_alpha = cwrapper.prototype("void analysis_config_set_alpha(analysis_config, double)") + AnalysisConfig.cNamespace().get_merge_observations = cwrapper.prototype("bool analysis_config_get_merge_observations(analysis_config)") AnalysisConfig.cNamespace().set_merge_observations = cwrapper.prototype("void analysis_config_set_merge_observations(analysis_config, bool)") AnalysisConfig.cNamespace().get_iter_config = cwrapper.prototype("analysis_iter_config_ref analysis_config_get_iter_config(analysis_config)") @@ -131,3 +148,10 @@ def selectModule(self, module_name): AnalysisConfig.cNamespace().get_module = cwrapper.prototype("analysis_module_ref analysis_config_get_module(analysis_config, char*)") AnalysisConfig.cNamespace().select_module = cwrapper.prototype("bool analysis_config_select_module(analysis_config, char*)") +AnalysisConfig.cNamespace().get_alpha = cwrapper.prototype("double analysis_config_get_alpha(analysis_config)") +AnalysisConfig.cNamespace().set_alpha = cwrapper.prototype("void analysis_config_set_alpha(analysis_config, double)") +AnalysisConfig.cNamespace().get_std_cutoff = cwrapper.prototype("double analysis_config_get_std_cutoff(analysis_config)") +AnalysisConfig.cNamespace().set_std_cutoff = cwrapper.prototype("void analysis_config_set_std_cutoff(analysis_config, double)") + +AnalysisConfig.cNamespace().set_global_std_scaling = cwrapper.prototype("void analysis_config_set_global_std_scaling(analysis_config, double)") +AnalysisConfig.cNamespace().get_global_std_scaling = cwrapper.prototype("double analysis_config_get_global_std_scaling(analysis_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/custom_kw_config_set.py b/ThirdParty/Ert/devel/python/python/ert/enkf/custom_kw_config_set.py new file mode 100644 index 0000000000..00aa748805 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/custom_kw_config_set.py @@ -0,0 +1,51 @@ +from ert.cwrap import CWrapper, BaseCClass +from ert.enkf import ENKF_LIB +from ert.enkf.data.custom_kw_config import CustomKWConfig + + +class CustomKWConfigSet(BaseCClass): + + def __init__(self, filename=None): + if filename is None: + c_ptr = CustomKWConfigSet.cNamespace().alloc() + else: + c_ptr = CustomKWConfigSet.cNamespace().alloc_from_file(filename) + + super(CustomKWConfigSet, self).__init__(c_ptr) + + + def addConfig(self, config): + """ @type config: CustomKWConfig """ + assert isinstance(config, CustomKWConfig) + CustomKWConfigSet.cNamespace().add_config(self, config) + + def getStoredConfigKeys(self): + """ @rtype: StringList """ + return CustomKWConfigSet.cNamespace().get_keys(self) + + def updateConfig(self, config): + """ @type config: CustomKWConfig """ + CustomKWConfigSet.cNamespace().update_config(self, config) + + def fwrite(self, filename): + """ @type filename: str """ + CustomKWConfigSet.cNamespace().fwrite(self, filename) + + def reset(self): + CustomKWConfigSet.cNamespace().reset(self) + + def free(self): + CustomKWConfigSet.cNamespace().free(self) + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("custom_kw_config_set", CustomKWConfigSet) + +CustomKWConfigSet.cNamespace().alloc = cwrapper.prototype("c_void_p custom_kw_config_set_alloc()") +CustomKWConfigSet.cNamespace().alloc_from_file = cwrapper.prototype("c_void_p custom_kw_config_set_alloc_from_file(char*)") +CustomKWConfigSet.cNamespace().free = cwrapper.prototype("void custom_kw_config_set_free(custom_kw_config_set)") +CustomKWConfigSet.cNamespace().reset = cwrapper.prototype("void custom_kw_config_set_reset(custom_kw_config_set)") +CustomKWConfigSet.cNamespace().add_config = cwrapper.prototype("void custom_kw_config_set_add_config(custom_kw_config_set, custom_kw_config)") +CustomKWConfigSet.cNamespace().update_config = cwrapper.prototype("void custom_kw_config_set_update_config(custom_kw_config_set, custom_kw_config)") +CustomKWConfigSet.cNamespace().get_keys = cwrapper.prototype("stringlist_obj custom_kw_config_set_get_keys_alloc(custom_kw_config_set)") +CustomKWConfigSet.cNamespace().fwrite = cwrapper.prototype("void custom_kw_config_set_fwrite(custom_kw_config_set, char*)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/enkf/data/CMakeLists.txt index 502785d8a3..7c5051eae4 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/data/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/CMakeLists.txt @@ -1,12 +1,14 @@ set(PYTHON_SOURCES __init__.py + custom_kw.py + custom_kw_config.py enkf_config_node.py enkf_node.py - gen_kw.py - gen_data.py field.py field_config.py + gen_data.py gen_data_config.py + gen_kw.py gen_kw_config.py summary_config.py ) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/__init__.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/__init__.py index 9857287a53..90d7ba336f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/data/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/__init__.py @@ -2,9 +2,11 @@ from .gen_kw_config import GenKwConfig from .field_config import FieldConfig from .summary_config import SummaryConfig +from .custom_kw_config import CustomKWConfig from .field import Field from .enkf_config_node import EnkfConfigNode +from .custom_kw import CustomKW from .gen_kw import GenKw from .gen_data import GenData from .enkf_node import EnkfNode @@ -13,8 +15,10 @@ "GenKwConfig", "FieldConfig", "SummaryConfig", + "CustomKWConfig", "Field", "EnkfConfigNode", "EnkfNode", + "CustomKW", "GenKw", "GenData"] diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/custom_kw.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/custom_kw.py new file mode 100644 index 0000000000..159aec045e --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/custom_kw.py @@ -0,0 +1,69 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'field_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +from ert.cwrap import BaseCClass, CWrapper +from ert.enkf import ENKF_LIB +from ert.enkf.data import CustomKWConfig +from ert.util import StringList + + +class CustomKW(BaseCClass): + def __init__(self, custom_kw_config): + assert isinstance(custom_kw_config, CustomKWConfig) + c_ptr = CustomKW.cNamespace().alloc(custom_kw_config) + super(CustomKW, self).__init__(c_ptr) + + def fload(self, filename): + """ + @type filename: str + @rtype: bool + """ + return CustomKW.cNamespace().fload(self, filename) + + + def __getitem__(self, key): + """ @rtype: str or float """ + config = self.getConfig() + + if not key in config: + raise KeyError("The key: '%s' is not available!" % key) + + index = config.indexOfKey(key) + + if CustomKW.cNamespace().key_is_null(self, key): + return None + + if config.keyIsDouble(key): + return CustomKW.cNamespace().iget_as_double(self, index) + + return CustomKW.cNamespace().iget_as_string(self, index) + + def getConfig(self): + """ @rtype: CustomKWConfig """ + return CustomKW.cNamespace().get_config(self) + + def free(self): + CustomKW.cNamespace().free(self) + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("custom_kw", CustomKW) + +CustomKW.cNamespace().free = cwrapper.prototype("void custom_kw_free(custom_kw)") +CustomKW.cNamespace().alloc = cwrapper.prototype("c_void_p custom_kw_alloc(custom_kw_config)") +CustomKW.cNamespace().fload = cwrapper.prototype("bool custom_kw_fload(custom_kw, char*)") +CustomKW.cNamespace().get_config = cwrapper.prototype("custom_kw_config_ref custom_kw_get_config(custom_kw)") +CustomKW.cNamespace().key_is_null = cwrapper.prototype("bool custom_kw_key_is_null(custom_kw, char*)") +CustomKW.cNamespace().iget_as_double = cwrapper.prototype("double custom_kw_iget_as_double(custom_kw, int)") +CustomKW.cNamespace().iget_as_string = cwrapper.prototype("char* custom_kw_iget_as_string(custom_kw, int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/custom_kw_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/custom_kw_config.py new file mode 100644 index 0000000000..92d15e1974 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/custom_kw_config.py @@ -0,0 +1,91 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'field_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +from ert.cwrap import BaseCClass, CWrapper +from ert.enkf import ENKF_LIB +from ert.util import StringList + + +class CustomKWConfig(BaseCClass): + def __init__(self, key, result_file, output_file=None): + """ + @type key: str + @type result_file: str + @type output_file: str + """ + c_ptr = CustomKWConfig.cNamespace().alloc_empty(key, result_file, output_file) + super(CustomKWConfig, self).__init__(c_ptr) + + def getName(self): + """ @rtype: str """ + return CustomKWConfig.cNamespace().get_name(self) + + def getResultFile(self): + """ @rtype: str """ + return CustomKWConfig.cNamespace().get_result_file(self) + + def getOutputFile(self): + """ @rtype: str """ + return CustomKWConfig.cNamespace().get_output_file(self) + + def parseResultFile(self, result_file, result): + """ @rtype: bool """ + return CustomKWConfig.cNamespace().parse_result_file(self, result_file, result) + + def keyIsDouble(self, key): + """ @rtype: bool """ + return CustomKWConfig.cNamespace().key_is_double(self, key) + + def indexOfKey(self, key): + """ @rtype: int """ + return CustomKWConfig.cNamespace().index_of_key(self, key) + + def __contains__(self, item): + """ @rtype: bool """ + return CustomKWConfig.cNamespace().has_key(self, item) + + def __len__(self): + """ @rtype: int """ + return CustomKWConfig.cNamespace().size(self) + + def __iter__(self): + keys = self.getKeys() + index = 0 + while index < len(keys): + yield keys[index] + index += 1 + + def free(self): + CustomKWConfig.cNamespace().free(self) + + def getKeys(self): + """ @rtype: StringList """ + return CustomKWConfig.cNamespace().keys(self) + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("custom_kw_config", CustomKWConfig) + +CustomKWConfig.cNamespace().free = cwrapper.prototype("void custom_kw_config_free(custom_kw_config)") +CustomKWConfig.cNamespace().alloc_empty = cwrapper.prototype("c_void_p custom_kw_config_alloc_empty(char*, char*, char*)") +CustomKWConfig.cNamespace().get_name = cwrapper.prototype("char* custom_kw_config_get_name(custom_kw_config)") +CustomKWConfig.cNamespace().get_result_file = cwrapper.prototype("char* custom_kw_config_get_result_file(custom_kw_config)") +CustomKWConfig.cNamespace().get_output_file = cwrapper.prototype("char* custom_kw_config_get_output_file(custom_kw_config)") +CustomKWConfig.cNamespace().parse_result_file = cwrapper.prototype("bool custom_kw_config_parse_result_file(custom_kw_config, char*, stringlist)") +CustomKWConfig.cNamespace().has_key = cwrapper.prototype("bool custom_kw_config_has_key(custom_kw_config, char*)") +CustomKWConfig.cNamespace().key_is_double = cwrapper.prototype("bool custom_kw_config_key_is_double(custom_kw_config, char*)") +CustomKWConfig.cNamespace().index_of_key = cwrapper.prototype("int custom_kw_config_index_of_key(custom_kw_config, char*)") +CustomKWConfig.cNamespace().size = cwrapper.prototype("int custom_kw_config_size(custom_kw_config)") +CustomKWConfig.cNamespace().keys = cwrapper.prototype("stringlist_obj custom_kw_config_get_keys(custom_kw_config)") \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_config_node.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_config_node.py index acb4d22aa2..0193a8a130 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_config_node.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_config_node.py @@ -15,17 +15,13 @@ # for more details. from ert.cwrap import BaseCClass, CWrapper from ert.enkf import ENKF_LIB -from ert.enkf.data import FieldConfig, GenDataConfig, GenKwConfig, SummaryConfig +from ert.enkf.data import FieldConfig, GenDataConfig, GenKwConfig, SummaryConfig, CustomKWConfig from ert.enkf.enums import EnkfTruncationType, ErtImplType, LoadFailTypeEnum, EnkfVarType from ert.ecl import EclGrid class EnkfConfigNode(BaseCClass): - FIELD = 104 - GEN_KW = 107 - SUMMARY = 110 - GEN_DATA = 113 def __init__(self): raise NotImplementedError("Class can not be instantiated directly!") @@ -58,6 +54,10 @@ def getKeywordModelConfig(self): """ @rtype: GenKWConfig """ return GenKwConfig.createCReference(EnkfConfigNode.cNamespace().get_ref(self), parent=self) + def getCustomKeywordModelConfig(self): + """ @rtype: CustomKWConfig """ + return CustomKWConfig.createCReference(EnkfConfigNode.cNamespace().get_ref(self), parent=self) + # def get_enkf_infile(self): # return EnkfConfigNode.cNamespace().get_enkf_infile(self) @@ -100,13 +100,15 @@ def free(self): def getModelConfig(self): implementation_type = self.getImplementationType() - if implementation_type == self.FIELD: + if implementation_type == ErtImplType.FIELD: return self.getFieldModelConfig() - elif implementation_type == self.GEN_DATA: + elif implementation_type == ErtImplType.GEN_DATA: return self.getDataModelConfig() - elif implementation_type == self.GEN_KW: + elif implementation_type == ErtImplType.GEN_KW: return self.getKeywordModelConfig() - elif implementation_type == self.SUMMARY: + elif implementation_type == ErtImplType.CUSTOM_KW: + return self.getCustomKeywordModelConfig() + elif implementation_type == ErtImplType.SUMMARY: return SummaryConfig.createCReference(self.getPointerReference(), parent=self) else: print("[EnkfConfigNode::getModelConfig()] Unhandled implementation model type: %i" % implementation_type) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_node.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_node.py index 8e60c09a1a..489ff9add7 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_node.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/enkf_node.py @@ -15,11 +15,8 @@ # for more details. from ert.cwrap import BaseCClass, CWrapper from ert.enkf import ENKF_LIB, EnkfFs, NodeId -from ert.enkf.data import EnkfConfigNode , GenKw , GenData -from ert.enkf.data.gen_data_config import GenDataConfig -from ert.enkf.enums import EnkfStateType -from ert.enkf.enums.ert_impl_type_enum import ErtImplType - +from ert.enkf.data import EnkfConfigNode, GenKw, GenData, CustomKW +from ert.enkf.enums import ErtImplType class EnkfNode(BaseCClass): def __init__(self, config_node, private=False): @@ -32,13 +29,6 @@ def __init__(self, config_node, private=False): super(EnkfNode, self).__init__(c_pointer, config_node, True) - # def user_get(self, fs, key, report_step, iens, state, value): - # return EnkfNode.cNamespace().user_get(self, fs, key, report_step, iens, state, value) - # - # def user_get_vector( self, fs, key, iens, state, vector): - # return EnkfNode.cNamespace().user_get_vector(self, fs, key, iens, state, vector) - - def valuePointer(self): return EnkfNode.cNamespace().value_ptr(self) @@ -49,23 +39,19 @@ def asGenData(self): return GenData.createCReference(self.valuePointer(), self) - def asGenKw(self): + """ @rtype: GenKw """ impl_type = EnkfNode.cNamespace().get_impl_type(self) assert impl_type == ErtImplType.GEN_KW return GenKw.createCReference(self.valuePointer(), self) + def asCustomKW(self): + """ @rtype: CustomKW """ + impl_type = EnkfNode.cNamespace().get_impl_type(self) + assert impl_type == ErtImplType.CUSTOM_KW - - # def vector_storage(self): - # return EnkfNode.cNamespace().vector_storage(self) - - # def getConfig(self): - # """ @rtype: EnkfConfigNode """ - # #todo: fix this!!!! wrong return type in prototype! - # return EnkfNode.cNamespace().get_config(self).setParent(self) - + return CustomKW.createCReference(self.valuePointer(), self) def tryLoad(self, fs, node_id): """ @@ -78,9 +64,18 @@ def tryLoad(self, fs, node_id): return EnkfNode.cNamespace().try_load(self, fs, node_id) - def save(self , fs , node_id ): - EnkfNode.cNamespace().store(self , fs , True , node_id) + def name(self): + return EnkfNode.cNamespace().get_name(self) + + def load(self, fs, node_id): + if not self.tryLoad(fs, node_id): + raise Exception("Could not load node: %s iens: %d report: %d" % (self.name(), node_id.iens, node_id.report_step)) + def save(self, fs, node_id): + assert isinstance(fs, EnkfFs) + assert isinstance(node_id, NodeId) + + EnkfNode.cNamespace().store(self, fs, True, node_id) def free(self): EnkfNode.cNamespace().free(self) @@ -89,17 +84,13 @@ def free(self): cwrapper = CWrapper(ENKF_LIB) cwrapper.registerObjectType("enkf_node", EnkfNode) -EnkfNode.cNamespace().free = cwrapper.prototype("void enkf_node_free( enkf_node )") +EnkfNode.cNamespace().free = cwrapper.prototype("void enkf_node_free(enkf_node)") EnkfNode.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_node_alloc(enkf_node)") EnkfNode.cNamespace().alloc_private = cwrapper.prototype("c_void_p enkf_node_alloc_private_container(enkf_node)") +EnkfNode.cNamespace().get_name = cwrapper.prototype("char* enkf_node_get_key(enkf_node)") -# EnkfNode.cNamespace().user_get = cwrapper.prototype("bool enkf_node_user_get_no_id(enkf_node , enkf_fs , char* , int, int , c_uint, double*)") -# EnkfNode.cNamespace().user_get_vector = cwrapper.prototype("bool enkf_node_user_get_vector( enkf_node , enkf_fs , char*, int, c_uint, double_vector)") EnkfNode.cNamespace().value_ptr = cwrapper.prototype("c_void_p enkf_node_value_ptr(enkf_node)") -# EnkfNode.cNamespace().vector_storage = cwrapper.prototype("bool enkf_node_vector_storage(enkf_node)") EnkfNode.cNamespace().try_load = cwrapper.prototype("bool enkf_node_try_load(enkf_node, enkf_fs, node_id)") EnkfNode.cNamespace().get_impl_type = cwrapper.prototype("ert_impl_type_enum enkf_node_get_impl_type(enkf_node)") -EnkfNode.cNamespace().store = cwrapper.prototype("void enkf_node_store(enkf_node, enkf_fs , bool , node_id)") -#todo fix this -# EnkfNode.cNamespace().get_config = cwrapper.prototype("c_void_p enkf_node_get_config(enkf_node)") +EnkfNode.cNamespace().store = cwrapper.prototype("void enkf_node_store(enkf_node, enkf_fs, bool, node_id)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/field_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/field_config.py index 3af37b1697..c6ca5debe1 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/data/field_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/field_config.py @@ -18,9 +18,10 @@ class FieldConfig(BaseCClass): - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") - + def __init__(self , kw , grid): + c_ptr = FieldConfig.cNamespace().alloc( kw , grid , None , False ) + super(FieldConfig, self).__init__(c_ptr) + def get_type(self): return FieldConfig.cNamespace().get_type(self) @@ -56,10 +57,9 @@ def free(self): cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("field_config", FieldConfig) -cwrapper.registerType("field_config_obj", FieldConfig.createPythonObject) -cwrapper.registerType("field_config_ref", FieldConfig.createCReference) +cwrapper.registerObjectType("field_config", FieldConfig) +FieldConfig.cNamespace().alloc = cwrapper.prototype("c_void_p field_config_alloc_empty(char* , ecl_grid , c_void_p , bool)") FieldConfig.cNamespace().free = cwrapper.prototype("void field_config_free( field_config )") FieldConfig.cNamespace().get_type = cwrapper.prototype("int field_config_get_type(field_config)") FieldConfig.cNamespace().get_truncation_mode = cwrapper.prototype("int field_config_get_truncation_mode(field_config)") @@ -72,3 +72,4 @@ def free(self): FieldConfig.cNamespace().get_ny = cwrapper.prototype("int field_config_get_ny(field_config)") FieldConfig.cNamespace().get_nz = cwrapper.prototype("int field_config_get_nz(field_config)") FieldConfig.cNamespace().get_grid = cwrapper.prototype("c_void_p field_config_get_grid(field_config)") #todo: fix return type + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_data_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_data_config.py index 86d0f089d1..40fd4fbc2d 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_data_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_data_config.py @@ -15,11 +15,16 @@ # for more details. from ert.cwrap import BaseCClass, CWrapper from ert.enkf import ENKF_LIB +from ert.enkf.enums import GenDataFileType class GenDataConfig(BaseCClass): - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") + def __init__(self, key , input_format = GenDataFileType.ASCII): + # Can currently only create GEN_DATA instances which should be used + # as result variables. + c_pointer = GenDataConfig.cNamespace().alloc( key , input_format ) + super(GenDataConfig, self).__init__(c_pointer) + def get_template_file(self): return GenDataConfig.cNamespace().get_template_file(self) @@ -27,6 +32,20 @@ def get_template_file(self): def get_template_key(self): return GenDataConfig.cNamespace().get_template_key(self) + def getDataSize(self , report_step): + data_size = GenDataConfig.cNamespace().get_data_size(self , report_step) + if data_size < 0: + raise ValueError("No data has been loaded for %s at report step:%d " % (self.getName() , report_step)) + else: + return data_size + + def getActiveMask(self): + return GenDataConfig.cNamespace().get_active_mask(self) + + def getName(self): + return GenDataConfig.cNamespace().get_key(self) + + def get_initial_size(self): return GenDataConfig.cNamespace().get_initial_size(self) @@ -39,20 +58,26 @@ def getInputFormat(self): def free(self): GenDataConfig.cNamespace().free(self) + def hasReportStep(self, report_step): + """ @rtype: bool """ + return GenDataConfig.cNamespace().has_report_step(self, report_step) + cwrapper = CWrapper(ENKF_LIB) cwrapper.registerType("gen_data_config", GenDataConfig) cwrapper.registerType("gen_data_config_obj", GenDataConfig.createPythonObject) cwrapper.registerType("gen_data_config_ref", GenDataConfig.createCReference) -# 3. Installing the c-functions used to manipulate ecl_kw instances. -# These functions are used when implementing the EclKW class, not -# used outside this scope. -GenDataConfig.cNamespace().free = cwrapper.prototype("void gen_data_config_free( gen_data_config )") +GenDataConfig.cNamespace().alloc = cwrapper.prototype("c_void_p gen_data_config_alloc_GEN_DATA_result( char* , gen_data_file_format_type)") +GenDataConfig.cNamespace().free = cwrapper.prototype("void gen_data_config_free( gen_data_config )") GenDataConfig.cNamespace().get_output_format = cwrapper.prototype("gen_data_file_format_type gen_data_config_get_output_format(gen_data_config)") GenDataConfig.cNamespace().get_input_format = cwrapper.prototype("gen_data_file_format_type gen_data_config_get_input_format(gen_data_config)") GenDataConfig.cNamespace().get_template_file = cwrapper.prototype("char* gen_data_config_get_template_file(gen_data_config)") GenDataConfig.cNamespace().get_template_key = cwrapper.prototype("char* gen_data_config_get_template_key(gen_data_config)") GenDataConfig.cNamespace().get_initial_size = cwrapper.prototype("int gen_data_config_get_initial_size(gen_data_config)") +GenDataConfig.cNamespace().has_report_step = cwrapper.prototype("bool gen_data_config_has_report_step(gen_data_config, int)") +GenDataConfig.cNamespace().get_data_size = cwrapper.prototype("int gen_data_config_get_data_size__(gen_data_config , int)") +GenDataConfig.cNamespace().get_key = cwrapper.prototype("char* gen_data_config_get_key(gen_data_config)") +GenDataConfig.cNamespace().get_active_mask = cwrapper.prototype("bool_vector_ref gen_data_config_get_active_mask(gen_data_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_kw_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_kw_config.py index 74d66b485e..9ceac6234b 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_kw_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/data/gen_kw_config.py @@ -54,12 +54,26 @@ def shouldUseLogScale(self, index): def free(self): GenKwConfig.cNamespace().free(self) -################################################################## + def getKey(self): + """ @rtype: str """ + return GenKwConfig.cNamespace().get_key(self) + + def __len__(self): + return GenKwConfig.cNamespace().size(self) + + def __getitem__(self, index): + """ @rtype: str """ + return GenKwConfig.cNamespace().iget_name(self, index) + + def __iter__(self): + index = 0 + while index < len(self): + yield self[index] + index += 1 + cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("gen_kw_config", GenKwConfig) -cwrapper.registerType("gen_kw_config_obj", GenKwConfig.createPythonObject) -cwrapper.registerType("gen_kw_config_ref", GenKwConfig.createCReference) +cwrapper.registerObjectType("gen_kw_config", GenKwConfig) GenKwConfig.cNamespace().free = cwrapper.prototype("void gen_kw_config_free( gen_kw_config )") GenKwConfig.cNamespace().alloc_empty = cwrapper.prototype("c_void_p gen_kw_config_alloc_empty( char*, char* )") @@ -68,4 +82,8 @@ def free(self): GenKwConfig.cNamespace().get_parameter_file = cwrapper.prototype("char* gen_kw_config_get_parameter_file(gen_kw_config)") GenKwConfig.cNamespace().set_parameter_file = cwrapper.prototype("void gen_kw_config_set_parameter_file( gen_kw_config, char* )") GenKwConfig.cNamespace().alloc_name_list = cwrapper.prototype("stringlist_obj gen_kw_config_alloc_name_list(gen_kw_config)") + GenKwConfig.cNamespace().should_use_log_scale = cwrapper.prototype("bool gen_kw_config_should_use_log_scale(gen_kw_config, int)") +GenKwConfig.cNamespace().get_key = cwrapper.prototype("char* gen_kw_config_get_key(gen_kw_config)") +GenKwConfig.cNamespace().size = cwrapper.prototype("int gen_kw_config_get_data_size(gen_kw_config)") +GenKwConfig.cNamespace().iget_name = cwrapper.prototype("char* gen_kw_config_iget_name(gen_kw_config, int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py index 5f0355a762..fe5fe40327 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py @@ -32,6 +32,7 @@ def free(self): #----------------------------------------------------------------- def getEclBase(self): + """ @rtype: str """ return EclConfig.cNamespace().get_eclbase(self) def validateEclBase(self , eclbase_fmt): diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs.py index 959d0da54e..47c5e8488d 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs.py @@ -14,7 +14,7 @@ # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. from ert.cwrap import BaseCClass, CWrapper -from ert.enkf import ENKF_LIB, TimeMap, StateMap +from ert.enkf import ENKF_LIB, TimeMap, StateMap, SummaryKeySet from ert.enkf.enums import EnKFFSType @@ -69,11 +69,12 @@ def isReadOnly(self): self.__checkIfUmounted() return EnkfFs.cNamespace().is_read_only(self) - def refCount(self): self.__checkIfUmounted() return self.cNamespace().get_refcount(self) + def writeCount(self): + return self.cNamespace().get_writecount(self) @classmethod def exists(cls, path): @@ -100,6 +101,23 @@ def free(self): self.umount() + def fsync(self): + EnkfFs.cNamespace().fsync(self) + + def getSummaryKeySet(self): + """ @rtype: SummaryKeySet """ + return EnkfFs.cNamespace().summary_key_set(self).setParent(self) + + def realizationList(self, state): + """ + Will return list of realizations with state == the specified state. + @type state: ert.enkf.enums.RealizationStateEnum + @rtype: ert.util.IntVector + """ + state_map = self.getStateMap() + return state_map.realizationList(state) + + cwrapper = CWrapper(ENKF_LIB) cwrapper.registerObjectType("enkf_fs", EnkfFs) @@ -116,3 +134,6 @@ def free(self): EnkfFs.cNamespace().exists = cwrapper.prototype("bool enkf_fs_exists(char*)") EnkfFs.cNamespace().get_case_name = cwrapper.prototype("char* enkf_fs_get_case_name(enkf_fs)") EnkfFs.cNamespace().is_read_only = cwrapper.prototype("bool enkf_fs_is_read_only(enkf_fs)") +EnkfFs.cNamespace().get_writecount = cwrapper.prototype("int enkf_fs_get_write_count(enkf_fs)") +EnkfFs.cNamespace().fsync = cwrapper.prototype("void enkf_fs_fsync(enkf_fs)") +EnkfFs.cNamespace().summary_key_set = cwrapper.prototype("summary_key_set_ref enkf_fs_get_summary_key_set(enkf_fs)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs_manager.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs_manager.py index 5b550d9921..35a667a83f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs_manager.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_fs_manager.py @@ -1,6 +1,6 @@ import os.path from ert.cwrap import CWrapper, BaseCClass -from ert.enkf import ENKF_LIB, EnkfFs, EnkfStateType, StateMap, TimeMap +from ert.enkf import ENKF_LIB, EnkfFs, EnkfStateType, StateMap, TimeMap, RealizationStateEnum from ert.util import StringList @@ -108,6 +108,33 @@ def getFileSystem(self, case_name, mount_root=None): return fs + def isCaseRunning(self, case_name, mount_root=None): + """ Returns true if case is mounted and write_count > 0 + @rtype: bool + """ + if self.isCaseMounted(case_name, mount_root): + case_fs = self.getFileSystem(case_name, mount_root) + return case_fs.writeCount() > 0 + return False + + + def caseExists(self, case_name): + """ @rtype: bool """ + return case_name in self.getCaseList() + + + def caseHasData(self, case_name): + """ @rtype: bool """ + case_has_data = False + state_map = self.getStateMapForCase(case_name) + + for state in state_map: + if state == RealizationStateEnum.STATE_HAS_DATA: + case_has_data = True + + return case_has_data + + def getCurrentFileSystem(self): """ Returns the currently selected file system @rtype: EnkfFs diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py index 8ee6403df8..4c50d5cfb1 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py @@ -15,18 +15,35 @@ # for more details. from ert.cwrap import BaseCClass, CWrapper -from ert.enkf import AnalysisConfig, EclConfig, EnkfObs, EnKFState, LocalConfig, ModelConfig, EnsConfig, PlotConfig, SiteConfig, ENKF_LIB, EnkfSimulationRunner, EnkfFsManager, ErtWorkflowList, PostSimulationHook +from ert.enkf import AnalysisConfig, EclConfig, EnkfObs, EnKFState, LocalConfig, ModelConfig, EnsembleConfig, PlotConfig, SiteConfig, ENKF_LIB, EnkfSimulationRunner, EnkfFsManager, ErtWorkflowList, PostSimulationHook from ert.enkf.enums import EnkfInitModeEnum from ert.util import SubstitutionList, Log class EnKFMain(BaseCClass): - def __init__(self, model_config, site_config, strict=True): - c_ptr = EnKFMain.cNamespace().bootstrap(site_config, model_config, strict, False) + def __init__(self, model_config, strict=True): + c_ptr = EnKFMain.cNamespace().bootstrap(model_config, strict, False) super(EnKFMain, self).__init__(c_ptr) - self.__simulation_runner = EnkfSimulationRunner(self) - self.__fs_manager = EnkfFsManager(self) + # The model_config argument can be None; the only reason to + # allow that possibility is to be able to test that the + # site-config loads correctly. + if model_config is None: + self.__simulation_runner = None + self.__fs_manager = None + else: + self.__simulation_runner = EnkfSimulationRunner(self) + self.__fs_manager = EnkfFsManager(self) + + + + @staticmethod + def loadSiteConfig(): + """ + This method will load the site config file; the sole purpose + of this method is testing. + """ + EnKFMain( None ) @classmethod @@ -43,7 +60,7 @@ def createNewConfig(config_file, storage_path, case_name, dbase_type, num_realiz def getRealisation(self , iens): """ @rtype: EnKFState """ - if 0 <= iens < len(self): + if 0 <= iens < self.getEnsembleSize(): return EnKFMain.cNamespace().iget_state(self, iens).setParent(self) else: raise IndexError("iens value:%d invalid Valid range: [0,%d)" % (iens , len(self))) @@ -53,7 +70,8 @@ def set_eclbase(self, eclbase): EnKFMain.cNamespace().set_eclbase(self, eclbase) def umount(self): - self.__fs_manager.umount() + if not self.__fs_manager is None: + self.__fs_manager.umount() def free(self): self.umount() @@ -67,7 +85,7 @@ def resizeEnsemble(self, value): EnKFMain.cNamespace().resize_ensemble(self, value) def ensembleConfig(self): - """ @rtype: EnsConfig """ + """ @rtype: EnsembleConfig """ return EnKFMain.cNamespace().get_ens_config(self).setParent(self) def analysisConfig(self): @@ -130,12 +148,9 @@ def getObservations(self): """ @rtype: EnkfObs """ return EnKFMain.cNamespace().get_obs(self).setParent(self) - def load_obs(self, obs_config_file): - EnKFMain.cNamespace().load_obs(self, obs_config_file) - - def reload_obs(self): - EnKFMain.cNamespace().reload_obs(self) - + def loadObservations(self , obs_config_file , clear = True): + EnKFMain.cNamespace().load_obs(self, obs_config_file , clear) + def get_pre_clear_runpath(self): pre_clear = EnKFMain.cNamespace().get_pre_clear_runpath(self) @@ -224,11 +239,11 @@ def getRunContextENSEMPLE_EXPERIMENT(self , fs , iactive , init_mode = EnkfInitM ################################################################## cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("enkf_main", EnKFMain) -cwrapper.registerType("enkf_main_ref", EnKFMain.createCReference) +cwrapper.registerObjectType("enkf_main", EnKFMain) + -EnKFMain.cNamespace().bootstrap = cwrapper.prototype("c_void_p enkf_main_bootstrap(char*, char*, bool, bool)") +EnKFMain.cNamespace().bootstrap = cwrapper.prototype("c_void_p enkf_main_bootstrap(char*, bool, bool)") EnKFMain.cNamespace().free = cwrapper.prototype("void enkf_main_free(enkf_main)") EnKFMain.cNamespace().get_ensemble_size = cwrapper.prototype("int enkf_main_get_ensemble_size( enkf_main )") @@ -251,8 +266,7 @@ def getRunContextENSEMPLE_EXPERIMENT(self , fs , iactive , init_mode = EnkfInitM EnKFMain.cNamespace().resize_ensemble = cwrapper.prototype("void enkf_main_resize_ensemble(enkf_main, int)") EnKFMain.cNamespace().del_node = cwrapper.prototype("void enkf_main_del_node(enkf_main, char*)") EnKFMain.cNamespace().get_obs = cwrapper.prototype("enkf_obs_ref enkf_main_get_obs(enkf_main)") -EnKFMain.cNamespace().load_obs = cwrapper.prototype("void enkf_main_load_obs(enkf_main, char*)") -EnKFMain.cNamespace().reload_obs = cwrapper.prototype("void enkf_main_reload_obs(enkf_main)") +EnKFMain.cNamespace().load_obs = cwrapper.prototype("void enkf_main_load_obs(enkf_main, char* , bool)") EnKFMain.cNamespace().get_pre_clear_runpath = cwrapper.prototype("bool enkf_main_get_pre_clear_runpath(enkf_main)") EnKFMain.cNamespace().set_pre_clear_runpath = cwrapper.prototype("void enkf_main_set_pre_clear_runpath(enkf_main, bool)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py index ebdee60999..bef5c98386 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py @@ -13,24 +13,32 @@ # # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. +import os.path + from ert.cwrap import BaseCClass, CWrapper -from ert.enkf import ENKF_LIB, EnkfFs, LocalObsdata, MeasData, ObsData -from ert.enkf.enums import EnkfStateType +from ert.util import StringList, IntVector +from ert.sched import History +from ert.ecl import EclSum , EclGrid +from ert.enkf import ENKF_LIB, EnkfFs, LocalObsdataNode , LocalObsdata, MeasData, ObsData +from ert.enkf.enums import EnkfStateType, EnkfObservationImplementationType from ert.enkf.observations import ObsVector -from ert.util import StringList, IntVector class EnkfObs(BaseCClass): - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") - + def __init__(self , ensemble_config , history = None , external_time_map = None , grid = None , refcase = None ): + c_ptr = EnkfObs.cNamespace().alloc( history , external_time_map , grid , refcase , ensemble_config ) + super(EnkfObs, self).__init__(c_ptr) + def __len__(self): return EnkfObs.cNamespace().get_size(self) + def __contains__(self , key): + return EnkfObs.cNamespace().has_key(self, key) def __iter__(self): + """ @rtype: ObsVector """ iobs = 0 while iobs < len(self): vector = self[iobs] @@ -53,9 +61,17 @@ def __getitem__(self, key_or_index): else: raise TypeError("Key or index must be of type str or int") - def get_config_file(self): - """ @rtype: Str """ - return EnkfObs.cNamespace().get_config_file(self) + + def createLocalObsdata(self , key , add_active_steps = True): + # Use getAllActiveLocalObsdata() + raise NotImplementedError("Hmmm C function: enkf_obs_alloc_all_active_local_obs() removed") + + + + def getAllActiveLocalObsdata(self , key = "ALL-OBS"): + return EnkfObs.cNamespace().create_all_active_obs( self , key ) + + def getTypedKeylist(self, observation_implementation_type): """ @@ -64,9 +80,33 @@ def getTypedKeylist(self, observation_implementation_type): """ return EnkfObs.cNamespace().alloc_typed_keylist(self, observation_implementation_type) + def obsType(self , key): + if key in self: + return EnkfObs.cNamespace().obs_type( self , key) + else: + raise KeyError("Unknown observation key:%s" % key) + + + def getMatchingKeys(self , pattern , obs_type = None): + """ + Will return a list of all the observation keys matching the input + pattern. The matching is based on fnmatch(). + """ + key_list = EnkfObs.cNamespace().alloc_matching_keylist(self, pattern) + if obs_type: + new_key_list = [] + for key in key_list: + if self.obsType( key ) == obs_type: + new_key_list.append( key ) + return new_key_list + else: + return key_list + + def hasKey(self, key): + """ @rtype: bool """ - return EnkfObs.cNamespace().has_key(self, key) + return key in self def getObservationTime(self, index): @@ -74,13 +114,12 @@ def getObservationTime(self, index): return EnkfObs.cNamespace().iget_obs_time(self, index) - def addObservationVector(self, observation_key, observation_vector): - assert isinstance(observation_key, str) + def addObservationVector(self, observation_vector): assert isinstance(observation_vector, ObsVector) observation_vector.convertToCReference(self) - EnkfObs.cNamespace().add_obs_vector(self, observation_key, observation_vector) + EnkfObs.cNamespace().add_obs_vector(self, observation_vector) def getObservationAndMeasureData(self, fs, local_obsdata, state, active_list, meas_data, obs_data): assert isinstance(fs, EnkfFs) @@ -93,23 +132,41 @@ def getObservationAndMeasureData(self, fs, local_obsdata, state, active_list, me EnkfObs.cNamespace().get_obs_and_measure_data(self, fs, local_obsdata, state, active_list, meas_data, obs_data) + def scaleCorrelatedStd( self , fs , local_obsdata , active_list): + return EnkfObs.cNamespace().scale_correlated_std( self , fs , active_list , local_obsdata ) + + + def load(self , config_file): + if not os.path.isfile( config_file ): + raise IOError("The observation config file:%s does not exist" % config_file) + return EnkfObs.cNamespace().load( self , config_file ) + + + def clear(self): + EnkfObs.cNamespace().clear( self ) + + def free(self): EnkfObs.cNamespace().free(self) cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("enkf_obs", EnkfObs) -cwrapper.registerType("enkf_obs_obj", EnkfObs.createPythonObject) -cwrapper.registerType("enkf_obs_ref", EnkfObs.createCReference) +cwrapper.registerObjectType("enkf_obs", EnkfObs) +EnkfObs.cNamespace().alloc = cwrapper.prototype("c_void_p enkf_obs_alloc( history , time_map , ecl_grid , ecl_sum , ens_config )") EnkfObs.cNamespace().free = cwrapper.prototype("void enkf_obs_free( enkf_obs )") EnkfObs.cNamespace().get_size = cwrapper.prototype("int enkf_obs_get_size( enkf_obs )") -EnkfObs.cNamespace().get_config_file = cwrapper.prototype("char* enkf_obs_get_config_file( enkf_obs )") +EnkfObs.cNamespace().load = cwrapper.prototype("bool enkf_obs_load( enkf_obs , char*)") +EnkfObs.cNamespace().clear = cwrapper.prototype("void enkf_obs_clear( enkf_obs )") EnkfObs.cNamespace().alloc_typed_keylist = cwrapper.prototype("stringlist_obj enkf_obs_alloc_typed_keylist(enkf_obs, enkf_obs_impl_type)") +EnkfObs.cNamespace().alloc_matching_keylist = cwrapper.prototype("stringlist_obj enkf_obs_alloc_matching_keylist(enkf_obs, char*)") EnkfObs.cNamespace().has_key = cwrapper.prototype("bool enkf_obs_has_key(enkf_obs, char*)") +EnkfObs.cNamespace().obs_type = cwrapper.prototype("enkf_obs_impl_type enkf_obs_get_type(enkf_obs, char*)") EnkfObs.cNamespace().get_vector = cwrapper.prototype("obs_vector_ref enkf_obs_get_vector(enkf_obs, char*)") EnkfObs.cNamespace().iget_vector = cwrapper.prototype("obs_vector_ref enkf_obs_iget_vector(enkf_obs, int)") EnkfObs.cNamespace().iget_obs_time = cwrapper.prototype("time_t enkf_obs_iget_obs_time(enkf_obs, int)") -EnkfObs.cNamespace().add_obs_vector = cwrapper.prototype("void enkf_obs_add_obs_vector(enkf_obs, char*, obs_vector)") +EnkfObs.cNamespace().add_obs_vector = cwrapper.prototype("void enkf_obs_add_obs_vector(enkf_obs, obs_vector)") EnkfObs.cNamespace().get_obs_and_measure_data = cwrapper.prototype("void enkf_obs_get_obs_and_measure_data(enkf_obs, enkf_fs, local_obsdata, enkf_state_type_enum, int_vector, meas_data, obs_data)") +EnkfObs.cNamespace().create_all_active_obs = cwrapper.prototype("local_obsdata_obj enkf_obs_alloc_all_active_local_obs( enkf_obs , char*)"); +EnkfObs.cNamespace().scale_correlated_std = cwrapper.prototype("double enkf_obs_scale_correlated_std( enkf_obs , enkf_fs , int_vector , local_obsdata)"); diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_simulation_runner.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_simulation_runner.py index a7de1da1f2..0c7aee0484 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_simulation_runner.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_simulation_runner.py @@ -10,7 +10,7 @@ def __init__(self, enkf_main): assert isinstance(enkf_main, BaseCClass) super(EnkfSimulationRunner, self).__init__(enkf_main.from_param(enkf_main).value, parent=enkf_main, is_reference=True) self.ert = enkf_main - """:type: EnKFMain """ + """:type: ert.enkf.EnKFMain """ def runSimpleStep(self, active_realization_mask, initialization_mode, iter_nr): """ @rtype: bool """ @@ -19,8 +19,12 @@ def runSimpleStep(self, active_realization_mask, initialization_mode, iter_nr): return EnkfSimulationRunner.cNamespace().run_simple_step(self, active_realization_mask, initialization_mode , iter_nr) - def runEnsembleExperiment(self, active_realization_mask): + def runEnsembleExperiment(self, active_realization_mask=None): """ @rtype: bool """ + if active_realization_mask is None: + count = self.ert.getEnsembleSize() + active_realization_mask = BoolVector(default_value=True, initial_size=count) + iter_nr = 0 return self.runSimpleStep(active_realization_mask, EnkfInitModeEnum.INIT_CONDITIONAL, iter_nr) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_state.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_state.py index d79458e046..48ebe4fe17 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_state.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_state.py @@ -51,6 +51,18 @@ def free(self): EnKFState.cNamespace().free(self) + def addSubstKeyword(self , key , value): + """ + Will add a key -> value pair which can be used for search replace + operations in the data file. Observe that the key will be + surrounded by \'<\' and \'>\'. + """ + doc_string = None + if isinstance(value , str): + EnKFState.cNamespace().add_subst_kw( self , key , value , doc_string ) + else: + raise TypeError("The value argument must be a string") + cwrapper = CWrapper(ENKF_LIB) cwrapper.registerType("enkf_state", EnKFState) @@ -61,3 +73,4 @@ def free(self): EnKFState.cNamespace().free = cwrapper.prototype("void enkf_state_free( enkf_state )") EnKFState.cNamespace().has_key = cwrapper.prototype("bool enkf_state_has_node( enkf_state , char* )") EnKFState.cNamespace().get_node = cwrapper.prototype("enkf_node_ref enkf_state_get_node( enkf_state , char* )") +EnKFState.cNamespace().add_subst_kw = cwrapper.prototype("void enkf_state_add_subst_kw( enkf_state , char* , char* , char*)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/ens_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/ens_config.py deleted file mode 100644 index d73c428946..0000000000 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/ens_config.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright (C) 2012 Statoil ASA, Norway. -# -# The file 'ens_config.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -from ert.cwrap import BaseCClass, CWrapper -from ert.enkf import ENKF_LIB -from ert.enkf.data import EnkfConfigNode -from ert.enkf.enums import EnkfVarType, ErtImplType -from ert.util import StringList - - -class EnsConfig(BaseCClass): - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") - - def hasKey(self, key): - """ @rtype: bool """ - return EnsConfig.cNamespace().has_key(self, key) - - def getNode(self, key): - """ @rtype: EnkfConfigNode """ - return EnsConfig.cNamespace().get_node(self, key).setParent(self) - - def alloc_keylist(self): - """ @rtype: StringList """ - return EnsConfig.cNamespace().alloc_keylist(self) - - def add_summary(self, key): - """ @rtype: EnkfConfigNode """ - return EnsConfig.cNamespace().add_summary(self, key, 2).setParent(self) - - def add_gen_kw(self, key): - """ @rtype: EnkfConfigNode """ - return EnsConfig.cNamespace().add_gen_kw(self, key).setParent(self) - - - def addNode(self , config_node): - assert isinstance(config_node , EnkfConfigNode) - EnsConfig.cNamespace().add_node( self , config_node ) - config_node.setParent( self ) - - - def add_field(self, key, eclipse_grid): - """ @rtype: EnkfConfigNode """ - return EnsConfig.cNamespace().add_field(self, key, eclipse_grid).setParent(self) - - def getKeylistFromVarType(self, var_mask): - """ @rtype: StringList """ - assert isinstance(var_mask, EnkfVarType) - return EnsConfig.cNamespace().alloc_keylist_from_var_type(self, var_mask) - - def getKeylistFromImplType(self, ert_impl_type): - """ @rtype: StringList """ - assert isinstance(ert_impl_type, ErtImplType) - return EnsConfig.cNamespace().alloc_keylist_from_impl_type(self, ert_impl_type) - - def free(self): - EnsConfig.cNamespace().free(self) - - - -cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("ens_config", EnsConfig) -cwrapper.registerType("ens_config_obj", EnsConfig.createPythonObject) -cwrapper.registerType("ens_config_ref", EnsConfig.createCReference) - -EnsConfig.cNamespace().free = cwrapper.prototype("void ensemble_config_free( ens_config )") -EnsConfig.cNamespace().has_key = cwrapper.prototype("bool ensemble_config_has_key( ens_config , char* )") -EnsConfig.cNamespace().get_node = cwrapper.prototype("enkf_config_node_ref ensemble_config_get_node( ens_config , char*)") -EnsConfig.cNamespace().alloc_keylist = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist( ens_config )") -EnsConfig.cNamespace().add_summary = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_summary( ens_config, char*, int)") -EnsConfig.cNamespace().add_gen_kw = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_gen_kw( ens_config, char*)") -EnsConfig.cNamespace().add_field = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_field( ens_config, char*, ecl_grid)") -EnsConfig.cNamespace().alloc_keylist_from_var_type = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist_from_var_type(ens_config, enkf_var_type_enum)") -EnsConfig.cNamespace().alloc_keylist_from_impl_type = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist_from_impl_type(ens_config, ert_impl_type_enum)") -EnsConfig.cNamespace().add_node = cwrapper.prototype("void ensemble_config_add_node( ens_config , enkf_config_node )") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/ensemble_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/ensemble_config.py new file mode 100644 index 0000000000..92d8d1469b --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/ensemble_config.py @@ -0,0 +1,106 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'ensemble_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +from ert.cwrap import BaseCClass, CWrapper +from ert.util import StringList +from ert.enkf import ENKF_LIB, SummaryKeyMatcher +from ert.enkf.data import EnkfConfigNode +from ert.enkf.enums import EnkfVarType, ErtImplType + + + +class EnsembleConfig(BaseCClass): + + def __init__(self): + c_ptr = EnsembleConfig.cNamespace().alloc() + super(EnsembleConfig , self).__init__(c_ptr) + + + def __len__(self): + return EnsembleConfig.cNamespace().size( self ) + + + def __getitem__(self , key): + """ @rtype: EnkfConfigNode """ + if key in self: + return EnsembleConfig.cNamespace().get_node(self, key).setParent(self) + else: + raise KeyError("The key:%s is not in the ensemble configuration" % key) + + + def getNode(self, key): + return self[key] + + + def alloc_keylist(self): + """ @rtype: StringList """ + return EnsembleConfig.cNamespace().alloc_keylist(self) + + def add_summary(self, key): + """ @rtype: EnkfConfigNode """ + return EnsembleConfig.cNamespace().add_summary(self, key, 2).setParent(self) + + def add_gen_kw(self, key): + """ @rtype: EnkfConfigNode """ + return EnsembleConfig.cNamespace().add_gen_kw(self, key).setParent(self) + + + def addNode(self , config_node): + assert isinstance(config_node , EnkfConfigNode) + EnsembleConfig.cNamespace().add_node( self , config_node ) + config_node.setParent( self ) + + + def add_field(self, key, eclipse_grid): + """ @rtype: EnkfConfigNode """ + return EnsembleConfig.cNamespace().add_field(self, key, eclipse_grid).setParent(self) + + def getKeylistFromVarType(self, var_mask): + """ @rtype: StringList """ + assert isinstance(var_mask, EnkfVarType) + return EnsembleConfig.cNamespace().alloc_keylist_from_var_type(self, var_mask) + + def getKeylistFromImplType(self, ert_impl_type): + """ @rtype: StringList """ + assert isinstance(ert_impl_type, ErtImplType) + return EnsembleConfig.cNamespace().alloc_keylist_from_impl_type(self, ert_impl_type) + + def __contains__(self, key): + return EnsembleConfig.cNamespace().has_key(self, key) + + def getSummaryKeyMatcher(self): + """ @rtype: SummaryKeyMatcher """ + return EnsembleConfig.cNamespace().summary_key_matcher(self) + + def free(self): + EnsembleConfig.cNamespace().free(self) + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("ens_config", EnsembleConfig) + +EnsembleConfig.cNamespace().alloc = cwrapper.prototype("c_void_p ensemble_config_alloc( )") +EnsembleConfig.cNamespace().free = cwrapper.prototype("void ensemble_config_free( ens_config )") +EnsembleConfig.cNamespace().has_key = cwrapper.prototype("bool ensemble_config_has_key( ens_config , char* )") +EnsembleConfig.cNamespace().size = cwrapper.prototype("int ensemble_config_get_size( ens_config)") +EnsembleConfig.cNamespace().get_node = cwrapper.prototype("enkf_config_node_ref ensemble_config_get_node( ens_config , char*)") +EnsembleConfig.cNamespace().alloc_keylist = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist( ens_config )") +EnsembleConfig.cNamespace().add_summary = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_summary( ens_config, char*, int)") +EnsembleConfig.cNamespace().add_gen_kw = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_gen_kw( ens_config, char*)") +EnsembleConfig.cNamespace().add_field = cwrapper.prototype("enkf_config_node_ref ensemble_config_add_field( ens_config, char*, ecl_grid)") +EnsembleConfig.cNamespace().alloc_keylist_from_var_type = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist_from_var_type(ens_config, enkf_var_type_enum)") +EnsembleConfig.cNamespace().alloc_keylist_from_impl_type = cwrapper.prototype("stringlist_obj ensemble_config_alloc_keylist_from_impl_type(ens_config, ert_impl_type_enum)") +EnsembleConfig.cNamespace().add_node = cwrapper.prototype("void ensemble_config_add_node( ens_config , enkf_config_node )") +EnsembleConfig.cNamespace().summary_key_matcher = cwrapper.prototype("summary_key_matcher_ref ensemble_config_get_summary_key_matcher(ens_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enums/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/CMakeLists.txt index a28fb4e9fb..753946dbca 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enums/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/CMakeLists.txt @@ -12,6 +12,7 @@ set(PYTHON_SOURCES load_fail_type_enum.py realization_state_enum.py gen_data_file_type_enum.py + active_mode_enum.py ) add_python_package("python.ert.enkf.enums" ${PYTHON_INSTALL_PREFIX}/ert/enkf/enums "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enums/__init__.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/__init__.py index 71e1cba411..8c6e73c0b2 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enums/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/__init__.py @@ -10,6 +10,7 @@ from .enkf_truncation_type import EnkfTruncationType from .enkf_fs_type_enum import EnKFFSType from .gen_data_file_type_enum import GenDataFileType +from .active_mode_enum import ActiveMode __all__ = ["EnkfFieldFileFormatEnum", "LoadFailTypeEnum", @@ -22,4 +23,5 @@ "RealizationStateEnum", "EnkfTruncationType", "EnKFFSType", - "GenDataFileType"] + "GenDataFileType", + "ActiveMode"] diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/test_ert_import.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/active_mode_enum.py similarity index 55% rename from ThirdParty/Ert/devel/python/test/ert_tests/test_ert_import.py rename to ThirdParty/Ert/devel/python/python/ert/enkf/enums/active_mode_enum.py index 4e696c7922..9e56c37a9e 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/test_ert_import.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/active_mode_enum.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python # Copyright (C) 2013 Statoil ASA, Norway. # -# The file 'test_ert_import.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'content_type_enum.py' is part of ERT - Ensemble based Reservoir Tool. # # ERT is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,19 +13,19 @@ # # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. -import os +from ert.cwrap import BaseCEnum +from ert.enkf import ENKF_LIB -from ert.test.extended_testcase import ExtendedTestCase -from ert_tests.import_tester import ImportTester +class ActiveMode(BaseCEnum): + ALL_ACTIVE = None + INACTIVE = None + PARTLY_ACTIVE = None -class ImportTest(ExtendedTestCase): - def test_ert(self): - module = __import__("ert") - path = os.path.abspath(module.__file__) - path = os.path.dirname(path) - - self.assertTrue(ImportTester.importRecursively(path, "ert")) +ActiveMode.addEnum("ALL_ACTIVE", 1) +ActiveMode.addEnum("INACTIVE", 2) +ActiveMode.addEnum("PARTLY_ACTIVE", 3) +ActiveMode.registerEnum(ENKF_LIB, "active_mode_enum") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enums/ert_impl_type_enum.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/ert_impl_type_enum.py index 124cc2072c..2e0c31da28 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enums/ert_impl_type_enum.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enums/ert_impl_type_enum.py @@ -23,6 +23,7 @@ class ErtImplType(BaseCEnum): STATIC = None # MULTZ has been removed & MULTFLT FIELD = None # WELL has been removed GEN_KW = None # RELPERM has been removed & HAVANA_FAULT + CUSTOM_KW = None SUMMARY = None # TPGZONE has been removed GEN_DATA = None # PILOT_POINT has been removed SURFACE = None @@ -34,6 +35,7 @@ class ErtImplType(BaseCEnum): ErtImplType.addEnum("STATIC", 100) ErtImplType.addEnum("FIELD", 104) ErtImplType.addEnum("GEN_KW", 107) +ErtImplType.addEnum("CUSTOM_KW", 108) ErtImplType.addEnum("SUMMARY", 110) ErtImplType.addEnum("GEN_DATA", 113) ErtImplType.addEnum("SURFACE", 114) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/ert_workflow_list.py b/ThirdParty/Ert/devel/python/python/ert/enkf/ert_workflow_list.py index 48aeba2c4b..42e77463e2 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/ert_workflow_list.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/ert_workflow_list.py @@ -48,6 +48,21 @@ def getJob(self, job_name): """ @rtype: WorkflowJob """ return ErtWorkflowList.cNamespace().get_job(self, job_name) + def getJobNames(self): + """ @rtype: StringList """ + return ErtWorkflowList.cNamespace().get_job_names(self) + + def getPluginJobs(self): + """ @rtype: list of WorkflowJob """ + plugins = [] + for job_name in self.getJobNames(): + job = self.getJob(job_name) + if job.isPlugin(): + plugins.append(job) + return plugins + + + cwrapper = CWrapper(ENKF_LIB) cwrapper.registerObjectType("ert_workflow_list", ErtWorkflowList) @@ -61,4 +76,5 @@ def getJob(self, job_name): ErtWorkflowList.cNamespace().add_job = cwrapper.prototype("void ert_workflow_list_add_job(ert_workflow_list, char*, char*)") ErtWorkflowList.cNamespace().has_job = cwrapper.prototype("bool ert_workflow_list_has_job(ert_workflow_list, char*)") -ErtWorkflowList.cNamespace().get_job = cwrapper.prototype("workflow_job_ref ert_workflow_list_get_job(ert_workflow_list, char*)") \ No newline at end of file +ErtWorkflowList.cNamespace().get_job = cwrapper.prototype("workflow_job_ref ert_workflow_list_get_job(ert_workflow_list, char*)") +ErtWorkflowList.cNamespace().get_job_names = cwrapper.prototype("stringlist_obj ert_workflow_list_get_job_names(ert_workflow_list)") \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/enkf/export/CMakeLists.txt new file mode 100644 index 0000000000..54dca03101 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/CMakeLists.txt @@ -0,0 +1,15 @@ +set(PYTHON_SOURCES + __init__.py + arg_loader.py + custom_kw_collector.py + design_matrix_reader.py + gen_data_collector.py + gen_data_observation_collector.py + gen_kw_collector.py + misfit_collector.py + summary_collector.py + summary_observation_collector.py +) + +add_python_package("python.ert.enkf.export" ${PYTHON_INSTALL_PREFIX}/ert/enkf/export "${PYTHON_SOURCES}" True) + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/__init__.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/__init__.py new file mode 100644 index 0000000000..6bd788d815 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/__init__.py @@ -0,0 +1,20 @@ +from .design_matrix_reader import DesignMatrixReader +from .summary_observation_collector import SummaryObservationCollector +from .summary_collector import SummaryCollector +from .gen_kw_collector import GenKwCollector +from .gen_data_collector import GenDataCollector +from .gen_data_observation_collector import GenDataObservationCollector +from .misfit_collector import MisfitCollector +from .custom_kw_collector import CustomKWCollector +from .arg_loader import ArgLoader + +__all__ = ["DesignMatrixReader", + "SummaryCollector", + "SummaryObservationCollector", + "GenKwCollector", + "MisfitCollector", + "CustomKWCollector", + "GenDataCollector", + "GenDataObservationCollector", + "ArgLoader"] + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/arg_loader.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/arg_loader.py new file mode 100644 index 0000000000..0f23e4ab2a --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/arg_loader.py @@ -0,0 +1,46 @@ +import math +from pandas import DataFrame, MultiIndex +import numpy +from ert.enkf import ErtImplType, EnKFMain, EnkfFs, RealizationStateEnum, GenKwConfig +from ert.enkf.plot_data import EnsemblePlotGenData +from ert.util import BoolVector + + +class ArgLoader(object): + + + @staticmethod + def load(filename , column_names = None): + rows = 0 + columns = 0 + with open(filename,"r") as fileH: + for line in fileH.readlines(): + rows += 1 + columns = max(columns , len( line.split()) ) + + if not column_names is None: + if len(column_names) <= columns: + columns = len(column_names) + else: + raise ValueError("To many coloumns in input") + + data = numpy.empty(shape=(rows , columns) , dtype=numpy.float64) + data.fill( numpy.nan ) + + row = 0 + with open(filename) as fileH: + for line in fileH.readlines(): + tmp = line.split( ) + print tmp + for column in range(columns): + data[row][column] = float(tmp[column]) + row += 1 + + + if column_names is None: + column_names = [] + for column in range(columns): + column_names.append( "Column%d" % column ) + + data_frame = DataFrame( data = data , columns = column_names) + return data_frame diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/custom_kw_collector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/custom_kw_collector.py new file mode 100644 index 0000000000..74116f2f18 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/custom_kw_collector.py @@ -0,0 +1,77 @@ +from pandas import DataFrame +from ert.enkf import ErtImplType, EnKFMain, EnkfFs, RealizationStateEnum, CustomKWConfig, EnkfNode, NodeId, \ + EnkfStateType + + +class CustomKWCollector(object): + + @staticmethod + def getAllCustomKWKeys(ert): + """ @rtype: list of str """ + custom_kw_keys = ert.ensembleConfig().getKeylistFromImplType(ErtImplType.CUSTOM_KW) + custom_kw_keys = [key for key in custom_kw_keys] + + custom_kw_list = [] + for name in custom_kw_keys: + enkf_config_node = ert.ensembleConfig().getNode(name) + custom_kw_config = enkf_config_node.getModelConfig() + assert isinstance(custom_kw_config, CustomKWConfig) + + for key in custom_kw_config: + custom_kw_list.append("%s:%s" % (name, key)) + + return custom_kw_list + + @staticmethod + def groupKeys(keys): + grouped_keys = {} + for key in keys: + name, keyword = key.split(":") + + if not name in grouped_keys: + grouped_keys[name] = [] + + grouped_keys[name].append(keyword) + + return grouped_keys + + + @staticmethod + def loadAllCustomKWData(ert, case_name, keys=None): + """ + @type ert: EnKFMain + @type case_name: str + @type keys: list of str + @rtype: DataFrame + """ + fs = ert.getEnkfFsManager().getFileSystem(case_name) + + realizations = fs.realizationList(RealizationStateEnum.STATE_HAS_DATA) + + custom_kw_keys = CustomKWCollector.getAllCustomKWKeys(ert) + + if keys is not None: + custom_kw_keys = [key for key in keys if key in custom_kw_keys] # ignore keys that doesn't exist + + custom_kw_data = DataFrame(index=realizations, columns=custom_kw_keys) + custom_kw_data.index.name = "Realization" + + custom_kw_keys = CustomKWCollector.groupKeys(custom_kw_keys) + + for name in custom_kw_keys: + ensemble_config_node = ert.ensembleConfig().getNode(name) + enkf_node = EnkfNode(ensemble_config_node) + + keys = custom_kw_keys[name] + + for realization_number in realizations: + node_id = NodeId(0, realization_number, EnkfStateType.FORECAST) + if enkf_node.tryLoad(fs, node_id): + custom_kw = enkf_node.asCustomKW() + + for key in keys: + value = custom_kw[key] + custom_kw_data["%s:%s" % (name, key)][realization_number] = value + + return custom_kw_data + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/design_matrix_reader.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/design_matrix_reader.py new file mode 100644 index 0000000000..0e31707f03 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/design_matrix_reader.py @@ -0,0 +1,15 @@ +import pandas as pd +from pandas import DataFrame + + +class DesignMatrixReader(object): + + @staticmethod + def loadDesignMatrix(filename): + """@rtype: DataFrame""" + dm = pd.read_csv(filename, delim_whitespace=True) + """ @type dm: pd.DataFrame """ + dm = dm.rename(columns={dm.columns[0]:"Realization"}) + dm = dm.set_index(["Realization"]) + + return dm diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_data_collector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_data_collector.py new file mode 100644 index 0000000000..9ee2127d11 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_data_collector.py @@ -0,0 +1,45 @@ +import math +from pandas import DataFrame, MultiIndex +import numpy +from ert.enkf import ErtImplType, EnKFMain, EnkfFs, RealizationStateEnum, GenKwConfig +from ert.enkf.plot_data import EnsemblePlotGenData +from ert.util import BoolVector + + +class GenDataCollector(object): + + + @staticmethod + + def loadGenData(ert, case_name, key, report_step): + """@type ert: EnKFMain + @type case_name: str + @type key: str + @type report_step: int + @rtype: DataFrame + + In the returned dataframe the realisation index runs along the + rows, and the gen_data element index runs vertically along the + columns. + """ + fs = ert.getEnkfFsManager().getFileSystem(case_name) + realizations = fs.realizationList( RealizationStateEnum.STATE_HAS_DATA ) + config_node = ert.ensembleConfig().getNode(key) + gen_data_config = config_node.getModelConfig() + + ensemble_data = EnsemblePlotGenData( config_node , fs , report_step ) + # The data size and active can only be inferred *after* the EnsembleLoad. + data_size = gen_data_config.getDataSize( report_step ) + active_mask = gen_data_config.getActiveMask() + + data_array = numpy.empty(shape=(data_size , len(realizations)) , dtype=numpy.float64) + data_array.fill( numpy.nan ) + for realization_index, realization_number in enumerate(realizations): + realization_vector = ensemble_data[realization_number] + for data_index in range(data_size): + if active_mask[data_index]: + value = realization_vector[data_index] + data_array[data_index][realization_index] = value + + return DataFrame( data = data_array , columns = realizations ) + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_data_observation_collector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_data_observation_collector.py new file mode 100644 index 0000000000..90f65c54e2 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_data_observation_collector.py @@ -0,0 +1,76 @@ +from pandas import DataFrame +from ert.enkf import EnKFMain, EnkfFs, EnkfObservationImplementationType + + +class GenDataObservationCollector(object): + + @staticmethod + def getAllObservationKeys(ert): + """ + @type ert: EnKFMain + @rtype: list of str + """ + enkf_obs = ert.getObservations() + observation_keys = enkf_obs.getTypedKeylist(EnkfObservationImplementationType.GEN_OBS) + return [key for key in observation_keys] + + @staticmethod + def getObservationKeyForDataKey(ert, data_key, data_report_step): + """ + @type ert: EnKFMain + @rtype: str + """ + observation_key = None + + enkf_obs = ert.getObservations() + for obs_vector in enkf_obs: + report_step = obs_vector.activeStep() + key = obs_vector.getDataKey() + + if key == data_key and report_step == data_report_step: + observation_key = obs_vector.getObservationKey() + + return observation_key + + + + @staticmethod + def loadGenDataObservations(ert, case_name, keys=None): + """ + @type ert: EnKFMain + @type case_name: str + @type key: list of str + @rtype: DataFrame + """ + fs = ert.getEnkfFsManager().getFileSystem(case_name) + + observation_keys = GenDataObservationCollector.getAllObservationKeys(ert) + if keys is not None: + observation_keys = [key for key in keys if key in observation_keys] # ignore keys that doesn't exist + + columns = observation_keys + std_columns = ["STD_%s" % key for key in observation_keys] + + enkf_obs = ert.getObservations() + + max_size = 0 + for key in observation_keys: + obs_vector = enkf_obs[key] + report_step = obs_vector.activeStep() + obs_node = obs_vector.getNode(report_step) + """ :type: ert.enkf.observations.GenObservation """ + max_size = max(obs_node.getSize(), max_size) + + data = DataFrame(index=range(max_size), columns=columns + std_columns) + for key in observation_keys: + obs_vector = enkf_obs[key] + report_step = obs_vector.activeStep() + obs_node = obs_vector.getNode(report_step) + """ :type: ert.enkf.observations.GenObservation """ + + for iobs , (value,std) in enumerate(obs_node): + data_index = obs_node.getDataIndex( iobs ) + data[key][data_index] = value + data["STD_%s" % key][data_index] = std + + return data diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_kw_collector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_kw_collector.py new file mode 100644 index 0000000000..f4d40acaaf --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/gen_kw_collector.py @@ -0,0 +1,86 @@ +import math +from pandas import DataFrame, MultiIndex +import numpy +from ert.enkf import ErtImplType, EnKFMain, EnkfFs, RealizationStateEnum, GenKwConfig +from ert.enkf.plot_data import EnsemblePlotGenKW +from ert.util import BoolVector + + +class GenKwCollector(object): + + @staticmethod + def createActiveList(ert, fs): + state_map = fs.getStateMap() + ens_mask = BoolVector(False, ert.getEnsembleSize()) + state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_INITIALIZED | RealizationStateEnum.STATE_HAS_DATA) + active_list = BoolVector.createActiveList(ens_mask) + + return [iens for iens in active_list] + + @staticmethod + def getAllGenKwKeys(ert): + """ @rtype: list of str """ + gen_kw_keys = ert.ensembleConfig().getKeylistFromImplType(ErtImplType.GEN_KW) + gen_kw_keys = [key for key in gen_kw_keys] + + gen_kw_list = [] + for key in gen_kw_keys: + enkf_config_node = ert.ensembleConfig().getNode(key) + gen_kw_config = enkf_config_node.getModelConfig() + assert isinstance(gen_kw_config, GenKwConfig) + + for keyword_index, keyword in enumerate(gen_kw_config): + gen_kw_list.append("%s:%s" % (key, keyword)) + + if gen_kw_config.shouldUseLogScale(keyword_index): + gen_kw_list.append("LOG10_%s:%s" % (key, keyword)) + + return gen_kw_list + + @staticmethod + def loadAllGenKwData(ert, case_name, keys=None): + """ + @type ert: EnKFMain + @type case_name: str + @type keys: list of str + @rtype: DataFrame + """ + fs = ert.getEnkfFsManager().getFileSystem(case_name) + + realizations = GenKwCollector.createActiveList(ert, fs) + + gen_kw_keys = GenKwCollector.getAllGenKwKeys(ert) + + if keys is not None: + gen_kw_keys = [key for key in keys if key in gen_kw_keys] # ignore keys that doesn't exist + + gen_kw_array = numpy.empty(shape=(len(gen_kw_keys), len(realizations)), dtype=numpy.float64) + gen_kw_array.fill(numpy.nan) + + for column_index, key in enumerate(gen_kw_keys): + key, keyword = key.split(":") + + use_log_scale = False + if key.startswith("LOG10_"): + key = key[6:] + use_log_scale = True + + ensemble_config_node = ert.ensembleConfig().getNode(key) + ensemble_data = EnsemblePlotGenKW(ensemble_config_node, fs) + keyword_index = ensemble_data.getIndexForKeyword(keyword) + + for realization_index, realization_number in enumerate(realizations): + realization_vector = ensemble_data[realization_number] + + value = realization_vector[keyword_index] + + if use_log_scale: + value = math.log10(value) + + gen_kw_array[column_index][realization_index] = value + + gen_kw_data = DataFrame(data=numpy.transpose(gen_kw_array), index=realizations, columns=gen_kw_keys) + gen_kw_data.index.name = "Realization" + + return gen_kw_data + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/misfit_collector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/misfit_collector.py new file mode 100644 index 0000000000..700b7e57f1 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/misfit_collector.py @@ -0,0 +1,58 @@ +from pandas import DataFrame +import numpy +from ert.enkf import EnKFMain, EnkfFs, RealizationStateEnum, EnkfStateType +from ert.util import BoolVector + + +class MisfitCollector(object): + + @staticmethod + def createActiveList(ert, fs): + state_map = fs.getStateMap() + ens_mask = BoolVector(False, ert.getEnsembleSize()) + state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA) + active_list = BoolVector.createActiveList(ens_mask) + + return [iens for iens in active_list] + + @staticmethod + def getAllMisfitKeys(ert): + """ @rtype: list of str """ + keys = [] + for obs_vector in ert.getObservations(): + key = "MISFIT:%s" % obs_vector.getObservationKey() + keys.append(key) + + keys.append("MISFIT:TOTAL") + + return keys + + @staticmethod + def loadAllMisfitData(ert, case_name): + """ + @type ert: EnKFMain + @type case_name: str + @rtype: DataFrame + """ + fs = ert.getEnkfFsManager().getFileSystem(case_name) + + realizations = MisfitCollector.createActiveList(ert, fs) + misfit_keys = MisfitCollector.getAllMisfitKeys(ert) + misfit_sum_index = len(misfit_keys) - 1 + + misfit_array = numpy.empty(shape=(len(misfit_keys), len(realizations)), dtype=numpy.float64) + misfit_array.fill(numpy.nan) + misfit_array[misfit_sum_index] = 0.0 + + for column_index, obs_vector in enumerate(ert.getObservations()): + + for realization_index, realization_number in enumerate(realizations): + misfit = obs_vector.getTotalChi2(fs, realization_number, EnkfStateType.FORECAST) + + misfit_array[column_index][realization_index] = misfit + misfit_array[misfit_sum_index][realization_index] += misfit + + misfit_data = DataFrame(data=numpy.transpose(misfit_array), index=realizations, columns=misfit_keys) + misfit_data.index.name = "Realization" + + return misfit_data diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/summary_collector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/summary_collector.py new file mode 100644 index 0000000000..b82053c1b4 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/summary_collector.py @@ -0,0 +1,66 @@ +from pandas import DataFrame, MultiIndex +import numpy +from ert.enkf import ErtImplType, EnKFMain, EnkfFs, RealizationStateEnum +from ert.enkf.plot_data import EnsemblePlotData +from ert.util import BoolVector + + +class SummaryCollector(object): + + @staticmethod + def createActiveList(ert, fs): + state_map = fs.getStateMap() + ens_mask = BoolVector(False, ert.getEnsembleSize()) + state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA) + active_list = BoolVector.createActiveList(ens_mask) + + return [iens for iens in active_list] + + @staticmethod + def getAllSummaryKeys(ert): + """ @rtype: list of str """ + keys = ert.ensembleConfig().getKeylistFromImplType(ErtImplType.SUMMARY) + return sorted([key for key in keys], key=lambda k : k.lower()) + + @staticmethod + def loadAllSummaryData(ert, case_name, keys=None): + """ + @type ert: EnKFMain + @type case_name: str + @type keys: list of str + @rtype: DataFrame + """ + fs = ert.getEnkfFsManager().getFileSystem(case_name) + + time_map = fs.getTimeMap() + dates = [time_map[index].datetime() for index in range(1, len(time_map))] + realizations = SummaryCollector.createActiveList(ert, fs) + + summary_keys = SummaryCollector.getAllSummaryKeys(ert) + if keys is not None: + summary_keys = [key for key in keys if key in summary_keys] # ignore keys that doesn't exist + + summary_array = numpy.empty(shape=(len(summary_keys), len(realizations) * len(dates)), dtype=numpy.float64) + summary_array.fill(numpy.nan) + + for key_index, key in enumerate(summary_keys): + ensemble_config_node = ert.ensembleConfig().getNode(key) + ensemble_data = EnsemblePlotData(ensemble_config_node, fs) + summary_row = summary_array[key_index] + + for realization_index, realization_number in enumerate(realizations): + realization_vector = ensemble_data[realization_number] + column_index = realization_index * len(dates) + + for index in range(1, len(realization_vector)): + if realization_vector.isActive(index): + # assert time_map[index] == realization_vector.getTime(index) + # assert time_map[index].datetime() == dates[index - 1] + value = realization_vector.getValue(index) + summary_row[column_index + index - 1] = value + + + multi_index = MultiIndex.from_product([realizations, dates], names=["Realization", "Date"]) + summary_data = DataFrame(data=numpy.transpose(summary_array), index=multi_index, columns=summary_keys) + return summary_data + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/export/summary_observation_collector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/export/summary_observation_collector.py new file mode 100644 index 0000000000..c434f62ddf --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/export/summary_observation_collector.py @@ -0,0 +1,66 @@ +from pandas import DataFrame, MultiIndex +import numpy +from ert.enkf import ErtImplType, EnKFMain, EnkfFs, RealizationStateEnum, EnkfObservationImplementationType +from ert.enkf.plot_data import EnsemblePlotData +from ert.util import BoolVector + + +class SummaryObservationCollector(object): + + @staticmethod + def getAllObservationKeys(ert): + """ + @type ert: EnKFMain + @rtype: list of str + """ + ensemble_config = ert.ensembleConfig() + keys = sorted([key for key in ensemble_config.getKeylistFromImplType(ErtImplType.SUMMARY)]) + observation_keys = [key for key in keys if len(ensemble_config.getNode(key).getObservationKeys()) > 0] + return observation_keys + + @staticmethod + def loadObservationData(ert, case_name, keys=None): + """ + @type ert: EnKFMain + @type case_name: str + @type keys: list of str + @rtype: DataFrame + """ + fs = ert.getEnkfFsManager().getFileSystem(case_name) + + time_map = fs.getTimeMap() + dates = [time_map[index].datetime() for index in range(1, len(time_map))] + + summary_keys = SummaryObservationCollector.getAllObservationKeys(ert) + if keys is not None: + summary_keys = [key for key in keys if key in summary_keys] # ignore keys that doesn't exist + + columns = summary_keys + std_columns = ["STD_%s" % key for key in summary_keys] + + df = DataFrame(index=dates, columns=columns + std_columns) + + for key in summary_keys: + observation_keys = ert.ensembleConfig().getNode(key).getObservationKeys() + + for obs_key in observation_keys: + observations = ert.getObservations() + observation_data = observations[obs_key] + history_length = ert.getHistoryLength() + + for index in range(0, history_length): + if observation_data.isActive(index): + obs_time = observations.getObservationTime(index).datetime() + node = observation_data.getNode(index) + value = node.getValue() + std = node.getStandardDeviation() + + df[key][obs_time] = value + df["STD_%s" % key][obs_time] = std + + + return df + + @classmethod + def summaryKeyHasObservations(cls, ert, key): + return len(ert.ensembleConfig().getNode(key).getObservationKeys()) > 0 diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata.py b/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata.py index 2c85ac31aa..fa4b20292b 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata.py @@ -15,17 +15,27 @@ def __len__(self): return LocalObsdata.cNamespace().size(self) - def __getitem__(self, index): - """ @rtype: LocalObsdataNode """ - assert isinstance(index, int) - return LocalObsdata.cNamespace().get_node(self, index).setParent(self) - + def __getitem__(self, key): + """ @rtype: LocalObsdataNode """ + if isinstance(key , int): + if int < len: + return LocalObsdata.cNamespace().iget_node(self, key).setParent(self) + else: + raise IndexError("Invalid index") + else: + if key in self: + return LocalObsdata.cNamespace().get_node(self, key).setParent(self) + else: + raise KeyError("Unknown key:%s" % key) + + def __iter__(self): - cur = 0 - while cur < len(self): + cur = 0 + while cur < len(self): yield self[cur] cur += 1 + def addNode(self, node): """ @rtype: bool """ assert isinstance(node, LocalObsdataNode) @@ -33,6 +43,11 @@ def addNode(self, node): already_exists_node_for_key = LocalObsdata.cNamespace().add_node(self, node) return already_exists_node_for_key + + def addObsVector(self , obs_vector): + self.addNode( obs_vector.createLocalObs() ) + + def __contains__(self, item): """ @rtype: bool """ if isinstance(item, str): @@ -61,7 +76,8 @@ def free(self): LocalObsdata.cNamespace().size = cwrapper.prototype("int local_obsdata_get_size(local_obsdata)") LocalObsdata.cNamespace().has_node = cwrapper.prototype("bool local_obsdata_has_node(local_obsdata, char*)") LocalObsdata.cNamespace().add_node = cwrapper.prototype("bool local_obsdata_add_node(local_obsdata, local_obsdata_node)") -LocalObsdata.cNamespace().get_node = cwrapper.prototype("local_obsdata_node_ref local_obsdata_iget(local_obsdata, int)") +LocalObsdata.cNamespace().iget_node = cwrapper.prototype("local_obsdata_node_ref local_obsdata_iget(local_obsdata, int)") +LocalObsdata.cNamespace().get_node = cwrapper.prototype("local_obsdata_node_ref local_obsdata_get(local_obsdata, char*)") LocalObsdata.cNamespace().name = cwrapper.prototype("char* local_obsdata_get_name(local_obsdata)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata_node.py b/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata_node.py index 28a46c0495..cbbfc4ac66 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata_node.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/local_obsdata_node.py @@ -17,20 +17,39 @@ def addRange(self, step_1, step_2): assert isinstance(step_2, int) LocalObsdataNode.cNamespace().add_range(self, step_1, step_2) + + def addTimeStep(self , step): + LocalObsdataNode.cNamespace().add_step(self, step ) + + def free(self): LocalObsdataNode.cNamespace().free(self) + def getStepList(self): + if self.allTimeStepActive(): + raise ValueError("LocalObsdataNode configured with all time step active - can not ask for step list") + return LocalObsdataNode.cNamespace().get_step_list( self ) -cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("local_obsdata_node", LocalObsdataNode) -cwrapper.registerType("local_obsdata_node_obj", LocalObsdataNode.createPythonObject) -cwrapper.registerType("local_obsdata_node_ref", LocalObsdataNode.createCReference) -LocalObsdataNode.cNamespace().alloc = cwrapper.prototype("c_void_p local_obsdata_node_alloc(char*)") -LocalObsdataNode.cNamespace().free = cwrapper.prototype("void local_obsdata_node_free(local_obsdata_node)") -LocalObsdataNode.cNamespace().get_key = cwrapper.prototype("char* local_obsdata_node_get_key(local_obsdata_node)") -LocalObsdataNode.cNamespace().add_range = cwrapper.prototype("void local_obsdata_node_add_range(local_obsdata_node, int, int)") + def getActiveList(self): + return LocalObsdataNode.cNamespace().get_active_list( self ) + def allTimeStepActive(self): + return LocalObsdataNode.cNamespace().all_timestep_active( self ) + + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("local_obsdata_node", LocalObsdataNode) + +LocalObsdataNode.cNamespace().alloc = cwrapper.prototype("c_void_p local_obsdata_node_alloc(char*)") +LocalObsdataNode.cNamespace().free = cwrapper.prototype("void local_obsdata_node_free(local_obsdata_node)") +LocalObsdataNode.cNamespace().get_key = cwrapper.prototype("char* local_obsdata_node_get_key(local_obsdata_node)") +LocalObsdataNode.cNamespace().add_range = cwrapper.prototype("void local_obsdata_node_add_range(local_obsdata_node, int, int)") +LocalObsdataNode.cNamespace().add_step = cwrapper.prototype("void local_obsdata_node_add_tstep(local_obsdata_node, int)") +LocalObsdataNode.cNamespace().get_step_list = cwrapper.prototype("int_vector_ref local_obsdata_node_get_tstep_list(local_obsdata_node)") +LocalObsdataNode.cNamespace().get_active_list = cwrapper.prototype("active_list_ref local_obsdata_node_get_active_list(local_obsdata_node)") +LocalObsdataNode.cNamespace().all_timestep_active = cwrapper.prototype("bool local_obsdata_node_all_timestep_active(local_obsdata_node)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/meas_block.py b/ThirdParty/Ert/devel/python/python/ert/enkf/meas_block.py new file mode 100644 index 0000000000..706377c5b7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/meas_block.py @@ -0,0 +1,104 @@ +from ert.cwrap import BaseCClass, CWrapper +from ert.enkf import ENKF_LIB +from ert.enkf.obs_data import ObsData +from ert.util import Matrix, IntVector , BoolVector + + +class MeasBlock(BaseCClass): + + def __init__(self , obs_key , obs_size , ens_mask): + assert(isinstance(ens_mask , BoolVector)) + c_pointer = MeasBlock.cNamespace().alloc( obs_key , ens_mask , obs_size ) + super(MeasBlock , self).__init__(c_pointer) + + def __str__(self): + s = "" + for iobs in range(self.getObsSize()): + s += "[" + for iens in range(self.getTotalEnsSize()): + if self.iensActive(iens): + s += "%6.3g " % self[iobs,iens] + else: + s += " X " + + s += "]\n" + return s + + def getObsSize(self): + return MeasBlock.cNamespace().get_total_obs_size(self) + + + def getActiveEnsSize(self): + return MeasBlock.cNamespace().get_active_ens_size(self) + + + def getTotalEnsSize(self): + return MeasBlock.cNamespace().get_total_ens_size(self) + + + def __assert_index(self , index): + if isinstance(index , tuple): + iobs,iens = index + if not 0 <= iobs < self.getObsSize(): + raise IndexError("Invalid iobs value:%d Valid range: [0,%d)" % (iobs , self.getObsSize())) + + if not 0 <= iens < self.getTotalEnsSize(): + raise IndexError("Invalid iens value:%d Valid range: [0,%d)" % (iobs , self.getTotalEnsSize())) + + if not self.iensActive( iens ): + raise ValueError("Ensemble member:%d is not active - can not be accessed in the MeasBlock()" % iens) + + return iobs,iens + else: + raise TypeError("The index argument must be 2-tuple") + + + def __setitem__(self, index, value): + iobs , iens = self.__assert_index(index) + MeasBlock.cNamespace().iset_value( self , iens , iobs , value ) + + + def __getitem__(self, index): + iobs,iens = self.__assert_index(index) + return MeasBlock.cNamespace().iget_value( self , iens , iobs ) + + def iensActive(self , iens): + return MeasBlock.cNamespace().iens_active( self , iens ) + + + def free(self): + MeasBlock.cNamespace().free(self) + + + def igetMean(self , iobs): + if 0 <= iobs < self.getObsSize(): + return MeasBlock.cNamespace().iget_mean(self , iobs) + else: + raise IndexError("Invalid observation index:%d valid range: [0,%d)" % (iobs , self.getObsSize())) + + def igetStd(self , iobs): + if 0 <= iobs < self.getObsSize(): + return MeasBlock.cNamespace().iget_std(self , iobs) + else: + raise IndexError("Invalid observation index:%d valid range: [0,%d)" % (iobs , self.getObsSize())) + + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("meas_block", MeasBlock) + +MeasBlock.cNamespace().alloc = cwrapper.prototype("c_void_p meas_block_alloc( char* , bool_vector , int)") +MeasBlock.cNamespace().free = cwrapper.prototype("void meas_block_free( meas_block )") +MeasBlock.cNamespace().get_active_ens_size = cwrapper.prototype("int meas_block_get_active_ens_size( meas_block )") +MeasBlock.cNamespace().get_total_ens_size = cwrapper.prototype("int meas_block_get_total_ens_size( meas_block )") +MeasBlock.cNamespace().get_total_obs_size = cwrapper.prototype("int meas_block_get_total_obs_size( meas_block )") +MeasBlock.cNamespace().iget_value = cwrapper.prototype("double meas_block_iget( meas_block , int , int)") +MeasBlock.cNamespace().iset_value = cwrapper.prototype("void meas_block_iset( meas_block , int , int , double)") +MeasBlock.cNamespace().iget_mean = cwrapper.prototype("double meas_block_iget_ens_mean( meas_block , int )") +MeasBlock.cNamespace().iget_std = cwrapper.prototype("double meas_block_iget_ens_std( meas_block , int )") +MeasBlock.cNamespace().iens_active = cwrapper.prototype("bool meas_block_iens_active( meas_block , int )") + + + + + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/meas_data.py b/ThirdParty/Ert/devel/python/python/ert/enkf/meas_data.py index 5ff0e4312d..cf057b4bac 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/meas_data.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/meas_data.py @@ -6,37 +6,95 @@ class MeasData(BaseCClass): - def __init__(self, active_list): - assert isinstance(active_list, IntVector) - c_pointer = MeasData.cNamespace().alloc(active_list) + def __init__(self, ens_mask): + c_pointer = MeasData.cNamespace().alloc(ens_mask) super(MeasData, self).__init__(c_pointer) + def __len__(self): + return MeasData.cNamespace().get_num_blocks( self ) - def createS(self, size): + + def __contains__(self , index): + if isinstance(index , str): + return MeasData.cNamespace().has_block( self , index) + else: + raise TypeError("The in operator expects a string argument") + + + def __getitem__(self , index): + if isinstance(index , str): + if index in self: + return MeasData.cNamespace().get_block( self , index) + else: + raise KeyError("The obs block:%s is not recognized" % index) + elif isinstance(index,int): + if index < 0: + index += len(self) + + if 0 <= index < len(self): + return MeasData.cNamespace().iget_block( self , index) + else: + raise IndexError("Index out of range") + else: + raise TypeError("The index variable must string or integer") + + + def __str__(self): + s = "" + for block in self: + s += "%s" % block + s += "\n" + return s + + + def createS(self): """ @rtype: Matrix """ - assert isinstance(size, int) - return MeasData.cNamespace().allocS(self, size) + if self.activeObsSize() > 0: + return MeasData.cNamespace().allocS(self) + else: + raise ValueError("No active observations - can not create S") def deactivateZeroStdSamples(self, obs_data): assert isinstance(obs_data, ObsData) self.cNamespace().deactivate_outliers(obs_data, self) + def addBlock(self , obs_key , report_step , obs_size): + return MeasData.cNamespace().add_block( self , obs_key , report_step , obs_size ) + + + def activeObsSize(self): + return MeasData.cNamespace().get_active_obs_size( self ) + + + def getActiveEnsSize(self): + return MeasData.cNamespace().get_active_ens_size(self) + + + def getTotalEnsSize(self): + return MeasData.cNamespace().get_total_ens_size(self) + + def free(self): MeasData.cNamespace().free(self) + cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("meas_data", MeasData) -cwrapper.registerType("meas_data_obj", MeasData.createPythonObject) -cwrapper.registerType("meas_data_ref", MeasData.createCReference) +cwrapper.registerObjectType("meas_data", MeasData) -MeasData.cNamespace().alloc = cwrapper.prototype("c_void_p meas_data_alloc(int_vector)") +MeasData.cNamespace().alloc = cwrapper.prototype("c_void_p meas_data_alloc(bool_vector)") MeasData.cNamespace().free = cwrapper.prototype("void meas_data_free(meas_data)") - -MeasData.cNamespace().allocS = cwrapper.prototype("matrix_obj meas_data_allocS(meas_data, int)") +MeasData.cNamespace().get_active_obs_size = cwrapper.prototype("int meas_data_get_active_obs_size(meas_data)") +MeasData.cNamespace().get_active_ens_size = cwrapper.prototype("int meas_data_get_active_ens_size( meas_data )") +MeasData.cNamespace().get_total_ens_size = cwrapper.prototype("int meas_data_get_total_ens_size( meas_data )") +MeasData.cNamespace().allocS = cwrapper.prototype("matrix_obj meas_data_allocS(meas_data)") +MeasData.cNamespace().add_block = cwrapper.prototype("meas_block_ref meas_data_add_block(meas_data, char* , int , int)") +MeasData.cNamespace().get_num_blocks = cwrapper.prototype("int meas_data_get_num_blocks( meas_data )") +MeasData.cNamespace().has_block = cwrapper.prototype("bool meas_data_has_block( meas_data , char* )") +MeasData.cNamespace().get_block = cwrapper.prototype("meas_block_ref meas_data_get_block( meas_data , char*)") +MeasData.cNamespace().iget_block = cwrapper.prototype("meas_block_ref meas_data_iget_block( meas_data , int)") MeasData.cNamespace().deactivate_outliers = cwrapper.prototype("void enkf_analysis_deactivate_std_zero(obs_data, meas_data)") - diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py index 0318c39f6a..23b63617cb 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py @@ -83,13 +83,21 @@ def free(self): def getFSType(self): return ModelConfig.cNamespace().get_fs_type( self ) - ################################################################## + def getGenKWExportFile(self): + """ @rtype: str """ + return ModelConfig.cNamespace().gen_kw_export_file(self) + + def runpathRequiresIterations(self): + """ @rtype: bool """ + return ModelConfig.cNamespace().runpath_requires_iterations(self) + + def getJobnameFormat(self): + """ @rtype: str """ + return ModelConfig.cNamespace().get_jobname_fmt(self) -cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("model_config", ModelConfig) -cwrapper.registerType("model_config_obj", ModelConfig.createPythonObject) -cwrapper.registerType("model_config_ref", ModelConfig.createCReference) +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("model_config", ModelConfig) ModelConfig.cNamespace().free = cwrapper.prototype("void model_config_free( model_config )") ModelConfig.cNamespace().get_enkf_sched_file = cwrapper.prototype("char* model_config_get_enkf_sched_file( model_config )") @@ -107,4 +115,6 @@ def getFSType(self): ModelConfig.cNamespace().get_history_source = cwrapper.prototype("history_source_enum model_config_get_history_source(model_config)") ModelConfig.cNamespace().select_history = cwrapper.prototype("bool model_config_select_history(model_config, history_source_enum, sched_file, ecl_sum)") ModelConfig.cNamespace().has_history = cwrapper.prototype("bool model_config_has_history(model_config)") - +ModelConfig.cNamespace().gen_kw_export_file = cwrapper.prototype("char* model_config_get_gen_kw_export_file(model_config)") +ModelConfig.cNamespace().runpath_requires_iterations = cwrapper.prototype("bool model_config_runpath_requires_iter(model_config)") +ModelConfig.cNamespace().get_jobname_fmt = cwrapper.prototype("char* model_config_get_jobname_fmt(model_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/obs_block.py b/ThirdParty/Ert/devel/python/python/ert/enkf/obs_block.py new file mode 100644 index 0000000000..870695915a --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/obs_block.py @@ -0,0 +1,67 @@ +from ert.cwrap import BaseCClass, CWrapper +from ert.enkf import ENKF_LIB +from ert.util import Matrix + + +class ObsBlock(BaseCClass): + + def __init__(self , obs_key , obs_size , global_std_scaling=1.0): + error_covar = None + error_covar_owner = False + c_pointer = ObsBlock.cNamespace().alloc(obs_key , obs_size , error_covar , error_covar_owner, global_std_scaling) + super(ObsBlock, self).__init__(c_pointer) + + + def totalSize(self): + return ObsBlock.cNamespace().total_size(self) + + def activeSize(self): + return ObsBlock.cNamespace().active_size(self) + + def __setitem__(self , index , value): + if isinstance(index , int): + if 0 <= index < self.totalSize(): + if len(value) == 2: + d = value[0] + std = value[1] + + ObsBlock.cNamespace().iset(self , index , d , std) + else: + raise TypeError("The value argument must be a two element tuple: (value , std)") + else: + raise IndexError("Invalid index:%d - valid range: [0,%d)" % (index , self.totalSize())) + else: + raise TypeError("The index item must be integer") + + + def __getitem__(self , index): + if isinstance(index , int): + if 0 <= index < self.totalSize(): + value = ObsBlock.cNamespace().iget_value(self , index) + std = ObsBlock.cNamespace().iget_std(self , index) + + return (value,std) + else: + raise IndexError("Invalid index:%d - valid range: [0,%d)" % (index , self.totalSize())) + else: + raise TypeError("The index item must be integer") + + + + def free(self): + ObsBlock.cNamespace().free(self) + + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("obs_block", ObsBlock) + +ObsBlock.cNamespace().alloc = cwrapper.prototype("c_void_p obs_block_alloc(char*, int, matrix, bool, double)") +ObsBlock.cNamespace().free = cwrapper.prototype("void obs_block_free(obs_block)") +ObsBlock.cNamespace().total_size = cwrapper.prototype("int obs_block_get_size( obs_block )") +ObsBlock.cNamespace().active_size = cwrapper.prototype("int obs_block_get_active_size( obs_block )") +ObsBlock.cNamespace().iset = cwrapper.prototype("void obs_block_iset( obs_block , int , double , double)") +ObsBlock.cNamespace().iget_value = cwrapper.prototype("double obs_block_iget_value( obs_block , int)") +ObsBlock.cNamespace().iget_std = cwrapper.prototype("double obs_block_iget_std( obs_block , int)") + + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/obs_data.py b/ThirdParty/Ert/devel/python/python/ert/enkf/obs_data.py index 5884e6aa68..e692b2f831 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/obs_data.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/obs_data.py @@ -6,18 +6,44 @@ class ObsData(BaseCClass): - def __init__(self): - c_pointer = ObsData.cNamespace().alloc() + def __init__(self, global_std_scaling=1.0): + c_pointer = ObsData.cNamespace().alloc(global_std_scaling) super(ObsData, self).__init__(c_pointer) def __len__(self): """ @rtype: int """ return ObsData.cNamespace().active_size(self) - def createDobs(self, size): + + def addBlock(self , obs_key , obs_size): + error_covar = None + error_covar_owner = False + return ObsData.cNamespace().add_block(self , obs_key , obs_size , error_covar , error_covar_owner) + + + def createDObs(self): + """ @rtype: Matrix """ + return ObsData.cNamespace().allocdObs(self) + + def createR(self): + """ @rtype: Matrix """ + return ObsData.cNamespace().allocR(self) + + def createD(self , E , S): """ @rtype: Matrix """ - assert isinstance(size, int) - return ObsData.cNamespace().allocdObs(self, size) + return ObsData.cNamespace().allocD(self , E , S) + + def createE( self , rng , active_ens_size): + """ @rtype: Matrix """ + return ObsData.cNamespace().allocE(self , rng , active_ens_size) + + def scaleMatrix(self, m): + ObsData.cNamespace().scale_matrix(self , m ) + + + def scaleRMatrix(self, R): + ObsData.cNamespace().scale_Rmatrix(self , R ) + def scale(self, S, E=None, D=None, R=None, D_obs=None): assert isinstance(S, Matrix) @@ -27,22 +53,27 @@ def scale(self, S, E=None, D=None, R=None, D_obs=None): assert isinstance(D_obs, (Matrix, NoneType)) ObsData.cNamespace().scale(self, S, E, D, R, D_obs) + def free(self): ObsData.cNamespace().free(self) cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("obs_data", ObsData) -cwrapper.registerType("obs_data_obj", ObsData.createPythonObject) -cwrapper.registerType("obs_data_ref", ObsData.createCReference) +cwrapper.registerObjectType("obs_data", ObsData) -ObsData.cNamespace().alloc = cwrapper.prototype("c_void_p obs_data_alloc()") +ObsData.cNamespace().alloc = cwrapper.prototype("c_void_p obs_data_alloc(double)") ObsData.cNamespace().free = cwrapper.prototype("void obs_data_free(obs_data)") ObsData.cNamespace().active_size = cwrapper.prototype("int obs_data_get_active_size(obs_data)") +ObsData.cNamespace().add_block = cwrapper.prototype("obs_block_ref obs_data_add_block(obs_data , char* , int , matrix , bool)") -ObsData.cNamespace().allocdObs = cwrapper.prototype("matrix_obj obs_data_allocdObs(obs_data, int)") +ObsData.cNamespace().allocdObs = cwrapper.prototype("matrix_obj obs_data_allocdObs(obs_data)") +ObsData.cNamespace().allocR = cwrapper.prototype("matrix_obj obs_data_allocR(obs_data)") +ObsData.cNamespace().allocD = cwrapper.prototype("matrix_obj obs_data_allocD(obs_data , matrix , matrix)") +ObsData.cNamespace().allocE = cwrapper.prototype("matrix_obj obs_data_allocE(obs_data , rng , int)") ObsData.cNamespace().scale = cwrapper.prototype("void obs_data_scale(obs_data, matrix, matrix, matrix, matrix, matrix)") +ObsData.cNamespace().scale_matrix = cwrapper.prototype("void obs_data_scale_matrix(obs_data, matrix)") +ObsData.cNamespace().scale_Rmatrix = cwrapper.prototype("void obs_data_scale_Rmatrix(obs_data, matrix)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/block_observation.py b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/block_observation.py index 77fdfb114a..74834cb11f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/block_observation.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/block_observation.py @@ -14,14 +14,37 @@ # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. from ert.cwrap import BaseCClass, CWrapper -from ert.enkf import ENKF_LIB, NodeId +from ert.enkf import ENKF_LIB, NodeId, FieldConfig -class BlockObservation(BaseCClass): +class BlockDataConfig(object): + + @classmethod + def from_param(cls , instance): + if instance is None: + return ctypes.c_void_p() + elif isinstance(instance , FieldConfig): + return FieldConfig.from_param( instance ) + + # The Container class which is used to support summary based + # source in the BLOCK_OBS configuration is not yet supported + # in Python. - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") + #elif isinstance(instance , ContainerConfig): + # return ContainerConfig.from_param( instance ) + else: + raise ValueError("Currently ONLY field data is supported") + + + +class BlockObservation(BaseCClass): + + def __init__(self , obs_key , data_config , grid): + c_ptr = BlockObservation.cNamespace().alloc( obs_key , data_config , grid ) + super(BlockObservation, self).__init__(c_ptr) + + def getCoordinate(self, index): """ @rtype: tuple of (int, int, int) """ i = BlockObservation.cNamespace().iget_i(self, index) @@ -39,6 +62,13 @@ def __iter__(self): yield cur cur += 1 + def addPoint(self , i,j,k , value , std , sum_key = None): + if sum_key is None: + BlockObservation.cNamespace().add_field_point(self,i,j,k,value,std) + else: + BlockObservation.cNamespace().add_summary_point(self,i,j,k,sum_key,value,std) + + def getValue(self, index): """ @rtype: float """ return BlockObservation.cNamespace().get_value(self, index) @@ -47,6 +77,14 @@ def getStd(self, index): """ @rtype: float """ return BlockObservation.cNamespace().get_std(self, index) + def getStdScaling(self , index): + """ @rtype: float """ + return BlockObservation.cNamespace().get_std_scaling(self, index) + + def updateStdScaling(self , factor , active_list): + BlockObservation.cNamespace().update_std_scaling(self, factor , active_list) + + def getDepth(self, index): """ @rtype: float """ return BlockObservation.cNamespace().get_depth(self, index) @@ -68,15 +106,20 @@ def free(self): cwrapper = CWrapper(ENKF_LIB) cwrapper.registerObjectType("block_obs", BlockObservation) +cwrapper.registerType("block_data_config", BlockDataConfig) +BlockObservation.cNamespace().alloc = cwrapper.prototype("c_void_p block_obs_alloc( char* , block_data_config , ecl_grid )") BlockObservation.cNamespace().free = cwrapper.prototype("void block_obs_free( block_obs )") BlockObservation.cNamespace().iget_i = cwrapper.prototype("int block_obs_iget_i(block_obs, int)") -BlockObservation.cNamespace().iget_j = cwrapper.prototype("int block_obs_iget_j( block_obs, int)") +BlockObservation.cNamespace().iget_j =cwrapper.prototype("int block_obs_iget_j( block_obs, int)") BlockObservation.cNamespace().iget_k = cwrapper.prototype("int block_obs_iget_k( block_obs , int)") BlockObservation.cNamespace().get_size = cwrapper.prototype("int block_obs_get_size( block_obs )") BlockObservation.cNamespace().get_std = cwrapper.prototype("double block_obs_iget_std( block_obs, int )") +BlockObservation.cNamespace().get_std_scaling = cwrapper.prototype("double block_obs_iget_std_scaling( block_obs, int )") +BlockObservation.cNamespace().update_std_scaling = cwrapper.prototype("void block_obs_update_std_scale(block_obs , double , active_list)") BlockObservation.cNamespace().get_value = cwrapper.prototype("double block_obs_iget_value( block_obs, int)") BlockObservation.cNamespace().get_depth = cwrapper.prototype("double block_obs_iget_depth( block_obs, int)") - +BlockObservation.cNamespace().add_field_point = cwrapper.prototype("void block_obs_append_field_obs( block_obs, int,int,int,double,double)") +BlockObservation.cNamespace().add_summary_point = cwrapper.prototype("void block_obs_append_summary_obs( block_obs, int,int,int,double,double)") BlockObservation.cNamespace().iget_data = cwrapper.prototype("double block_obs_iget_data(block_obs, c_void_p, int, node_id)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/gen_observation.py b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/gen_observation.py index ec861862ce..2d4d9c67af 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/gen_observation.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/gen_observation.py @@ -13,34 +13,84 @@ # # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. +import os.path from ert.cwrap import BaseCClass, CWrapper +from ert.util import IntVector from ert.enkf import ENKF_LIB class GenObservation(BaseCClass): - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") - def getValue(self, index): + def __init__(self , obs_key , data_config , scalar_value = None , obs_file = None , data_index = None): + c_pointer = GenObservation.cNamespace().alloc( data_config , obs_key ) + super(GenObservation, self).__init__(c_pointer) + + if scalar_value is None and obs_file is None: + raise ValueError("Exactly one the scalar_value and obs_file arguments must be present") + + if scalar_value is not None and obs_file is not None: + raise ValueError("Exactly one the scalar_value and obs_file arguments must be present") + + if obs_file is not None: + if not os.path.isfile( obs_file ): + raise IOError("The file with observation data:%s does not exist" % obs_file ) + else: + GenObservation.cNamespace().load( self , obs_file ) + else: + obs_value , obs_std = scalar_value + GenObservation.cNamespace().scalar_set( self , obs_value , obs_std ) + + if not data_index is None: + if os.path.isfile( data_index ): + GenObservation.cNamespace().load_data_index( self , data_index ) + else: + index_list = IntVector.active_list( data_index ) + GenObservation.cNamespace().add_data_index( self , index_list ) + + + def __len__(self): + return GenObservation.cNamespace().get_size(self) + + def __getitem__(self , obs_index): + if obs_index < 0: + obs_index += len(self) + + if 0 <= obs_index < len(self): + return (self.getValue(obs_index) , self.getStandardDeviation(obs_index)) + else: + raise IndexError("Valid range: [0,%d)" % len(self)) + + + def getValue(self, obs_index): """ @rtype: float """ - return GenObservation.cNamespace().get_data(self, index) + return GenObservation.cNamespace().get_value(self, obs_index) - def getStandardDeviation(self, index): + def getStandardDeviation(self, obs_index): """ @rtype: float """ - return GenObservation.cNamespace().get_std(self, index) + return GenObservation.cNamespace().get_std(self, obs_index) - def getSize(self): + def getStdScaling(self, obs_index): """ @rtype: float """ - return GenObservation.cNamespace().get_size(self) + return GenObservation.cNamespace().get_std_scaling(self, obs_index) - def getIndex(self, index): - """ @rtype: int """ - return GenObservation.cNamespace().get_index(self, index) + def updateStdScaling(self , factor , active_list): + GenObservation.cNamespace().update_std_scaling(self, factor , active_list) + def getSize(self): + """ @rtype: float """ + return len(self) + def getIndex(self, obs_index): + """ @rtype: int """ + return self.getDataIndex( obs_index ) + + def getDataIndex(self, obs_index): + return GenObservation.cNamespace().get_data_index(self, obs_index) + def free(self): + GenObservation.cNamespace().free(self) @@ -49,8 +99,15 @@ def getIndex(self, index): cwrapper.registerType("gen_obs_obj", GenObservation.createPythonObject) cwrapper.registerType("gen_obs_ref", GenObservation.createCReference) -GenObservation.cNamespace().get_value = cwrapper.prototype("double summary_obs_get_value(summary_obs)") +GenObservation.cNamespace().alloc = cwrapper.prototype("c_void_p gen_obs_alloc__(gen_data_config , char*)") +GenObservation.cNamespace().free = cwrapper.prototype("void gen_obs_free(gen_data_config)") +GenObservation.cNamespace().load = cwrapper.prototype("void gen_obs_load_observation(gen_obs , char*)") +GenObservation.cNamespace().scalar_set = cwrapper.prototype("void gen_obs_set_scalar(gen_obs , double , double)") +GenObservation.cNamespace().get_value = cwrapper.prototype("double gen_obs_iget_value(summary_obs)") +GenObservation.cNamespace().get_std_scaling = cwrapper.prototype("double gen_obs_iget_std_scaling(summary_obs)") GenObservation.cNamespace().get_std = cwrapper.prototype("double gen_obs_iget_std(gen_obs, int)") -GenObservation.cNamespace().get_data = cwrapper.prototype("double gen_obs_iget_data(gen_obs, int)") GenObservation.cNamespace().get_size = cwrapper.prototype("int gen_obs_get_size(gen_obs)") -GenObservation.cNamespace().get_index = cwrapper.prototype("int gen_obs_get_obs_index(gen_obs, int)") +GenObservation.cNamespace().get_data_index = cwrapper.prototype("int gen_obs_get_obs_index(gen_obs, int)") +GenObservation.cNamespace().load_data_index = cwrapper.prototype("void gen_obs_load_data_index(gen_obs , char*)") +GenObservation.cNamespace().add_data_index = cwrapper.prototype("void gen_obs_attach_data_index(gen_obs , int_vector)") +GenObservation.cNamespace().update_std_scaling = cwrapper.prototype("void gen_obs_update_std_scale(gen_obs , double , active_list)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/obs_vector.py b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/obs_vector.py index 9c04c3bbeb..719559535b 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/obs_vector.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/obs_vector.py @@ -40,6 +40,11 @@ def getDataKey(self): """ @rtype: str """ return ObsVector.cNamespace().get_state_kw(self) + def getObservationKey(self): + """ @rtype: str """ + return ObsVector.cNamespace().get_observation_key(self) + + def getNode(self, index): """ @rtype: SummaryObservation or BlockObservation or GenObservation""" @@ -55,6 +60,34 @@ def getNode(self, index): else: raise AssertionError("Node type '%s' currently not supported!" % node_type) + + def __iter__(self): + """ Iterate over active report steps; return node""" + cur = -1 + run = True + for step in self.getStepList(): + yield self.getNode( step ) + + + + def getStepList(self): + """ + Will return an IntVector with the active report steps. + """ + return ObsVector.cNamespace().get_step_list(self) + + def activeStep(self): + """Assuming the observation is only active for one report step, this + method will return that report step - if it is active for more + than one report step the method will raise an exception. + """ + step_list = self.getStepList() + if len(step_list): + return step_list[0] + else: + raise ValueError("The activeStep() method can *ONLY* be called for obervations with one active step") + + def getActiveCount(self): """ @rtype: int """ return ObsVector.cNamespace().get_num_active(self) @@ -80,18 +113,14 @@ def getConfigNode(self): """ @rtype: EnkfConfigNode """ return ObsVector.cNamespace().get_config_node(self).setParent(self) - def __iter__(self): - """ Iterate over active report steps. """ - cur = -1 - run = True - while run: - report_step = self.getNextActiveStep(cur) - if report_step >= 0: - cur = report_step - yield cur - else: - run = False + + def createLocalObs(self): + """ + Will create a LocalObsDataNode instance with all timesteps set. + """ + return ObsVector.cNamespace().create_local_node( self ) + def hasData(self, active_mask, fs): """ @rtype: bool """ return ObsVector.cNamespace().has_data(self, active_mask, fs) @@ -99,6 +128,10 @@ def hasData(self, active_mask, fs): def free(self): ObsVector.cNamespace().free(self) + def getTotalChi2(self, fs, realization_number, state): + """ @rtype: float """ + return ObsVector.cNamespace().get_total_chi2(self, fs, realization_number, state) + cwrapper = CWrapper(ENKF_LIB) cwrapper.registerObjectType("obs_vector", ObsVector) @@ -106,6 +139,7 @@ def free(self): ObsVector.cNamespace().alloc = cwrapper.prototype("c_void_p obs_vector_alloc(enkf_obs_impl_type, char*, enkf_config_node, int)") ObsVector.cNamespace().free = cwrapper.prototype("void obs_vector_free( obs_vector )") ObsVector.cNamespace().get_state_kw = cwrapper.prototype("char* obs_vector_get_state_kw( obs_vector )") +ObsVector.cNamespace().get_observation_key = cwrapper.prototype("char* obs_vector_get_key( obs_vector )") ObsVector.cNamespace().iget_node = cwrapper.prototype("c_void_p obs_vector_iget_node( obs_vector, int)") ObsVector.cNamespace().get_num_active = cwrapper.prototype("int obs_vector_get_num_active( obs_vector )") ObsVector.cNamespace().iget_active = cwrapper.prototype("bool obs_vector_iget_active( obs_vector, int)") @@ -114,3 +148,7 @@ def free(self): ObsVector.cNamespace().get_next_active_step = cwrapper.prototype("int obs_vector_get_next_active_step(obs_vector, int)") ObsVector.cNamespace().has_data = cwrapper.prototype("bool obs_vector_has_data(obs_vector , bool_vector , enkf_fs)") ObsVector.cNamespace().get_config_node = cwrapper.prototype("enkf_config_node_ref obs_vector_get_config_node(obs_vector)") +ObsVector.cNamespace().get_total_chi2 = cwrapper.prototype("double obs_vector_total_chi2(obs_vector, enkf_fs, int, enkf_state_type_enum)") +ObsVector.cNamespace().get_obs_key = cwrapper.prototype("char* obs_vector_get_obs_key(obs_vector)") +ObsVector.cNamespace().get_step_list = cwrapper.prototype("int_vector_ref obs_vector_get_step_list(obs_vector)") +ObsVector.cNamespace().create_local_node = cwrapper.prototype("local_obsdata_node_obj obs_vector_alloc_local_node(obs_vector)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/summary_observation.py b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/summary_observation.py index fe4be1c165..f7c58ff2de 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/observations/summary_observation.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/observations/summary_observation.py @@ -40,23 +40,38 @@ def getStandardDeviation(self): """ @rtype: float """ return SummaryObservation.cNamespace().get_std(self) + def getStdScaling(self , index = 0): + """ @rtype: float """ + return SummaryObservation.cNamespace().get_std_scaling(self) + + def __len__(self): + return 1 + + def getSummaryKey(self): """ @rtype: str """ return SummaryObservation.cNamespace().get_summary_key(self) + + def updateStdScaling(self , factor , active_list): + SummaryObservation.cNamespace().update_std_scale(self , factor , active_list) + + def free(self): SummaryObservation.cNamespace().free(self) + + cwrapper = CWrapper(ENKF_LIB) -cwrapper.registerType("summary_obs", SummaryObservation) -cwrapper.registerType("summary_obs_obj", SummaryObservation.createPythonObject) -cwrapper.registerType("summary_obs_ref", SummaryObservation.createCReference) +cwrapper.registerObjectType("summary_obs", SummaryObservation) SummaryObservation.cNamespace().alloc = cwrapper.prototype("c_void_p summary_obs_alloc(char*, char*, double, double, char*, double)") SummaryObservation.cNamespace().free = cwrapper.prototype("void summary_obs_free(summary_obs)") SummaryObservation.cNamespace().get_value = cwrapper.prototype("double summary_obs_get_value(summary_obs)") SummaryObservation.cNamespace().get_std = cwrapper.prototype("double summary_obs_get_std(summary_obs)") -SummaryObservation.cNamespace().get_summary_key = cwrapper.prototype("char* summary_obs_get_summary_key(summary_obs)") \ No newline at end of file +SummaryObservation.cNamespace().get_std_scaling = cwrapper.prototype("double summary_obs_get_std_scaling(summary_obs)") +SummaryObservation.cNamespace().get_summary_key = cwrapper.prototype("char* summary_obs_get_summary_key(summary_obs)") +SummaryObservation.cNamespace().update_std_scale = cwrapper.prototype("void summary_obs_update_std_scale(summary_obs , double , active_list)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_data_fetcher.py b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_data_fetcher.py index f033dd5fdd..d8828b631a 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_data_fetcher.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_data_fetcher.py @@ -1,4 +1,4 @@ -from ert.enkf import EnsConfig +from ert.enkf import EnsembleConfig from ert.enkf.plot_data import EnsemblePlotData from ert.enkf.enums import ErtImplType from ert.enkf.plot.data_fetcher import DataFetcher @@ -14,9 +14,9 @@ def fetchSupportedKeys(self): def getEnsembleConfigNode(self, key): - """ @rtype: EnsConfig """ + """ @rtype: EnsembleConfig """ ensemble_config = self.ert().ensembleConfig() - assert ensemble_config.hasKey(key) + assert key in ensemble_config return ensemble_config.getNode(key) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_data_fetcher.py b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_data_fetcher.py index 484f0038c3..c248169c36 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_data_fetcher.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_data_fetcher.py @@ -27,9 +27,9 @@ def fetchSupportedKeys(self): return gen_data_list def getEnsembleConfigNode(self, key): - """ @rtype: EnsConfig """ + """ @rtype: EnsembleConfig """ ensemble_config = self.ert().ensembleConfig() - assert ensemble_config.hasKey(key) + assert key in ensemble_config return ensemble_config.getNode(key) def fetchData(self, key, case=None): diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_kw_fetcher.py b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_kw_fetcher.py index 8d04782b82..be9184bbb7 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_kw_fetcher.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/ensemble_gen_kw_fetcher.py @@ -39,9 +39,9 @@ def fetchSupportedKeys(self): def getEnsembleConfigNode(self, key): - """ @rtype: EnsConfig """ + """ @rtype: EnsembleConfig """ ensemble_config = self.ert().ensembleConfig() - assert ensemble_config.hasKey(key) + assert key in ensemble_config return ensemble_config.getNode(key) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/observation_gen_data_fetcher.py b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/observation_gen_data_fetcher.py index 53f7d5b7f8..31c9a2eee5 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/observation_gen_data_fetcher.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/observation_gen_data_fetcher.py @@ -28,7 +28,7 @@ def fetchSupportedKeys(self): obs_keys = self.ert().ensembleConfig().getNode(key).getObservationKeys() for obs_key in obs_keys: obs_vector = self.ert().getObservations()[obs_key] - for report_step in obs_vector: + for report_step in obs_vector.getStepList(): gen_data_list.append("%s@%d" % (key, report_step)) return gen_data_list @@ -76,7 +76,7 @@ def getObsKeyForKey(self, key, key_report_step): obs_keys = self.ert().ensembleConfig().getNode(key).getObservationKeys() for obs_key in obs_keys: obs_vector = self.ert().getObservations()[obs_key] - for report_step in obs_vector: + for report_step in obs_vector.getStepList(): if report_step == key_report_step: return obs_key @@ -112,4 +112,4 @@ def adjustY(y, std): if y >= 0: return max(0, y - std) - return y - std \ No newline at end of file + return y - std diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/pca_fetcher.py b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/pca_fetcher.py index e004696b22..6c330bbbd4 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/plot/pca_fetcher.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/plot/pca_fetcher.py @@ -46,11 +46,11 @@ def calculatePrincipalComponent(self, fs, local_obsdata, truncation_or_ncomp=3): state_map = fs.getStateMap() ens_mask = BoolVector(False, self.ert().getEnsembleSize()) state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA) - active_list = BoolVector.createActiveList(ens_mask) + active_list = ens_mask.createActiveList( ) - if len(active_list) > 0: + if len(ens_mask) > 0: state = EnkfStateType.FORECAST - meas_data = MeasData(active_list) + meas_data = MeasData(ens_mask) obs_data = ObsData() self.ert().getObservations().getObservationAndMeasureData(fs, local_obsdata, state, active_list, meas_data, obs_data) @@ -60,8 +60,8 @@ def calculatePrincipalComponent(self, fs, local_obsdata, truncation_or_ncomp=3): active_size = len(obs_data) if active_size > 0: - S = meas_data.createS(active_size) - D_obs = obs_data.createDobs(active_size) + S = meas_data.createS() + D_obs = obs_data.createDObs() truncation, ncomp = self.truncationOrNumberOfComponents(truncation_or_ncomp) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py index 9231832392..773d619918 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py @@ -25,7 +25,7 @@ def getPath(self): """ @rtype: str """ return PlotConfig.cNamespace().get_path(self) - def set_path(self, path): + def setPath(self, path): PlotConfig.cNamespace().set_path(self, path) def get_driver(self): diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/post_simulation_hook.py b/ThirdParty/Ert/devel/python/python/ert/enkf/post_simulation_hook.py index daa18e082d..e1356058e0 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/post_simulation_hook.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/post_simulation_hook.py @@ -1,10 +1,9 @@ import os import sys from ert.cwrap import BaseCClass, CWrapper -from ert.enkf import ENKF_LIB +from ert.enkf import ENKF_LIB, RunpathList from ert.job_queue import Workflow - class PostSimulationHook(BaseCClass): def __init__(self): @@ -25,6 +24,9 @@ def checkRunpathListFile(self): if not os.path.exists(runpath_list_file): sys.stderr.write("** Warning: the file: %s with a list of runpath directories was not found - QC workflow wil probably fail.\n" % runpath_list_file) + def getRunpathList(self): + """ @rtype: RunpathList """ + return PostSimulationHook.cNamespace().get_runpath_list(self) cwrapper = CWrapper(ENKF_LIB) @@ -33,4 +35,5 @@ def checkRunpathListFile(self): PostSimulationHook.cNamespace().has_workflow = cwrapper.prototype("bool qc_module_has_workflow(qc_module)") PostSimulationHook.cNamespace().get_workflow = cwrapper.prototype("workflow_ref qc_module_get_workflow(qc_module)") PostSimulationHook.cNamespace().get_runpath_list_file = cwrapper.prototype("char* qc_module_get_runpath_list_file(qc_module)") +PostSimulationHook.cNamespace().get_runpath_list = cwrapper.prototype("runpath_list_ref qc_module_get_runpath_list(qc_module)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/run_arg.py b/ThirdParty/Ert/devel/python/python/ert/enkf/run_arg.py index 0ad602d285..6a91bde787 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/run_arg.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/run_arg.py @@ -31,10 +31,12 @@ def ENSEMBLE_EXPERIMENT(cls , fs , iens , runpath , iter = 0): c_ptr = RunArg.cNamespace().alloc_ENSEMBLE_EXPERIMENT(fs , iens , iter , runpath) return RunArg( c_ptr ) - def free(self): RunArg.cNamespace().free(self) + def getQueueIndex(self): + return RunArg.cNamespace().get_queue_index( self ) + @@ -45,3 +47,4 @@ def free(self): RunArg.cNamespace().alloc_ENSEMBLE_EXPERIMENT = cwrapper.prototype("c_void_p run_arg_alloc_ENSEMBLE_EXPERIMENT(enkf_fs , int, int, char*)") RunArg.cNamespace().free = cwrapper.prototype("void run_arg_free(run_arg)") +RunArg.cNamespace().get_queue_index = cwrapper.prototype("int run_arg_get_queue_index(run_arg)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/runpath_list.py b/ThirdParty/Ert/devel/python/python/ert/enkf/runpath_list.py new file mode 100644 index 0000000000..e223eb6545 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/runpath_list.py @@ -0,0 +1,65 @@ +from collections import namedtuple +from ert.cwrap import BaseCClass, CWrapper +from ert.enkf import ENKF_LIB + +RunpathNode = namedtuple("RunpathNode", ["realization", "iteration", "runpath", "basename"]) + +class RunpathList(BaseCClass): + + def __init__(self): + raise NotImplementedError("Class can not be instantiated directly!") + + def __len__(self): + return RunpathList.cNamespace().size(self) + + def __getitem__(self, index): + """ @rtype: RunpathNode """ + if not 0 <= index < len(self): + raise IndexError("Index not in range: 0 <= %d < %d" % (index, len(self))) + + realization = RunpathList.cNamespace().iens(self, index) + iteration = RunpathList.cNamespace().iteration(self, index) + runpath = RunpathList.cNamespace().runpath(self, index) + basename = RunpathList.cNamespace().basename(self, index) + + return RunpathNode(realization, iteration, runpath, basename) + + def __iter__(self): + index = 0 + while index < len(self): + yield self[index] + index += 1 + + + def add(self, realization_number, iteration_number, runpath, basename): + """ + @type realization_number: int + @type iteration_number: int + @type runpath: int + @type basename: int + """ + RunpathList.cNamespace().add(self, realization_number, iteration_number, runpath, basename) + + def clear(self): + RunpathList.cNamespace().clear(self) + + + def free(self): + RunpathList.cNamespace().free(self) + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("runpath_list", RunpathList) + +RunpathList.cNamespace().free = cwrapper.prototype("void runpath_list_free(runpath_list)") + +RunpathList.cNamespace().add = cwrapper.prototype("void runpath_list_add(runpath_list, int, int, char*, char*)") +RunpathList.cNamespace().clear = cwrapper.prototype("void runpath_list_clear(runpath_list)") + +RunpathList.cNamespace().size = cwrapper.prototype("int runpath_list_size(runpath_list)") +RunpathList.cNamespace().iens = cwrapper.prototype("int runpath_list_iget_iens(runpath_list, int)") +RunpathList.cNamespace().iteration = cwrapper.prototype("int runpath_list_iget_iter(runpath_list, int)") +RunpathList.cNamespace().runpath = cwrapper.prototype("char* runpath_list_iget_runpath(runpath_list, int)") +RunpathList.cNamespace().basename = cwrapper.prototype("char* runpath_list_iget_basename(runpath_list, int)") + + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/state_map.py b/ThirdParty/Ert/devel/python/python/ert/enkf/state_map.py index f4422d727c..6d09876d10 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/state_map.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/state_map.py @@ -95,17 +95,30 @@ def selectMatching(self, select_target, select_mask): StateMap.cNamespace().select_matching(self, select_target, select_mask) + def realizationList(self , state_value): + """ + Will create a list of all realisations with state equal to state_value. + + @type state_value: RealizationStateEnum + @rtype: ert.util.IntVector + """ + mask = BoolVector(False, len(self)) + self.selectMatching(mask, state_value) + return BoolVector.createActiveList(mask) + + + def free(self): StateMap.cNamespace().free(self) def load(self,filename): - if not self.cNamespace().fread( self , filename): + if not self.cNamespace().fread(self, filename): raise IOError("Failed to load state map from:%s" % filename) - def save(self,filename): - self.cNamespace().fwrite( self , filename) + def save(self, filename): + self.cNamespace().fwrite(self, filename) diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/summary_key_matcher.py b/ThirdParty/Ert/devel/python/python/ert/enkf/summary_key_matcher.py new file mode 100644 index 0000000000..dc324ebbcb --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/summary_key_matcher.py @@ -0,0 +1,44 @@ +from ert.cwrap import CWrapper, BaseCClass +from ert.enkf import ENKF_LIB +from ert.util import StringList + + +class SummaryKeyMatcher(BaseCClass): + + def __init__(self): + c_ptr = SummaryKeyMatcher.cNamespace().alloc() + + super(SummaryKeyMatcher, self).__init__(c_ptr) + + def addSummaryKey(self, key): + assert isinstance(key, str) + return SummaryKeyMatcher.cNamespace().add_key(self, key) + + def __len__(self): + return SummaryKeyMatcher.cNamespace().size(self) + + def __contains__(self, key): + return SummaryKeyMatcher.cNamespace().match_key(self, key) + + def isRequired(self, key): + """ @rtype: bool """ + return SummaryKeyMatcher.cNamespace().is_required(self, key) + + def keys(self): + """ @rtype: StringList """ + return SummaryKeyMatcher.cNamespace().keys(self) + + def free(self): + SummaryKeyMatcher.cNamespace().free(self) + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("summary_key_matcher", SummaryKeyMatcher) + +SummaryKeyMatcher.cNamespace().alloc = cwrapper.prototype("c_void_p summary_key_matcher_alloc()") +SummaryKeyMatcher.cNamespace().free = cwrapper.prototype("void summary_key_matcher_free(summary_key_matcher)") +SummaryKeyMatcher.cNamespace().size = cwrapper.prototype("int summary_key_matcher_get_size(summary_key_matcher)") +SummaryKeyMatcher.cNamespace().add_key = cwrapper.prototype("void summary_key_matcher_add_summary_key(summary_key_matcher, char*)") +SummaryKeyMatcher.cNamespace().match_key = cwrapper.prototype("bool summary_key_matcher_match_summary_key(summary_key_matcher, char*)") +SummaryKeyMatcher.cNamespace().keys = cwrapper.prototype("stringlist_obj summary_key_matcher_get_keys(summary_key_matcher)") +SummaryKeyMatcher.cNamespace().is_required = cwrapper.prototype("bool summary_key_matcher_summary_key_is_required(summary_key_matcher, char*)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/summary_key_set.py b/ThirdParty/Ert/devel/python/python/ert/enkf/summary_key_set.py new file mode 100644 index 0000000000..65710bea16 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/summary_key_set.py @@ -0,0 +1,54 @@ +from ert.cwrap import CWrapper, BaseCClass +from ert.enkf import ENKF_LIB +from ert.util import StringList + + +class SummaryKeySet(BaseCClass): + + def __init__(self, filename=None, read_only=False): + if filename is None: + c_ptr = SummaryKeySet.cNamespace().alloc() + else: + c_ptr = SummaryKeySet.cNamespace().alloc_from_file(filename, read_only) + + super(SummaryKeySet, self).__init__(c_ptr) + + def addSummaryKey(self, key): + assert isinstance(key, str) + return SummaryKeySet.cNamespace().add_key(self, key) + + def __len__(self): + return SummaryKeySet.cNamespace().size(self) + + def __contains__(self, key): + return SummaryKeySet.cNamespace().has_key(self, key) + + def keys(self): + """ @rtype: StringList """ + return SummaryKeySet.cNamespace().keys(self) + + def isReadOnly(self): + """ @rtype: bool """ + return SummaryKeySet.cNamespace().is_read_only(self) + + + def writeToFile(self, filename): + assert isinstance(filename, str) + SummaryKeySet.cNamespace().fwrite(self, filename) + + def free(self): + SummaryKeySet.cNamespace().free(self) + + +cwrapper = CWrapper(ENKF_LIB) +cwrapper.registerObjectType("summary_key_set", SummaryKeySet) + +SummaryKeySet.cNamespace().alloc = cwrapper.prototype("c_void_p summary_key_set_alloc()") +SummaryKeySet.cNamespace().alloc_from_file = cwrapper.prototype("c_void_p summary_key_set_alloc_from_file(char*, bool)") +SummaryKeySet.cNamespace().free = cwrapper.prototype("void summary_key_set_free(summary_key_set)") +SummaryKeySet.cNamespace().size = cwrapper.prototype("int summary_key_set_get_size(summary_key_set)") +SummaryKeySet.cNamespace().add_key = cwrapper.prototype("bool summary_key_set_add_summary_key(summary_key_set, char*)") +SummaryKeySet.cNamespace().has_key = cwrapper.prototype("bool summary_key_set_has_summary_key(summary_key_set, char*)") +SummaryKeySet.cNamespace().keys = cwrapper.prototype("stringlist_obj summary_key_set_get_keys(summary_key_set)") +SummaryKeySet.cNamespace().is_read_only = cwrapper.prototype("bool summary_key_set_is_read_only(summary_key_set)") +SummaryKeySet.cNamespace().fwrite = cwrapper.prototype("void summary_key_set_fwrite(summary_key_set, char*)") \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/util/time_map.py b/ThirdParty/Ert/devel/python/python/ert/enkf/util/time_map.py index 9363392914..2e2b1d8b97 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/util/time_map.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/util/time_map.py @@ -110,8 +110,35 @@ def __contains__(self , time): return False - def lookupTime(self , time): - index = TimeMap.cNamespace().lookup_time(self , CTime(time)) + def lookupTime(self , time , tolerance_seconds_before = 0, tolerance_seconds_after = 0): + """Will look up the report step corresponding to input @time. + + If the tolerance arguments tolerance_seconds_before and + tolerance_seconds_after have the default value zero we require + an exact match between input time argument and the content of + the time map. + + If the tolerance arguments are supplied the function will + search through the time_map for the report step closest to the + time argument, which satisfies the tolerance criteria. + + With the call: + + lookupTime( datetime.date(2010,1,10) , 3600*24 , 3600*7) + + We will find the report step in the date interval 2010,1,9 - + 2010,1,17 which is closest to 2010,1,10. The tolerance limits + are inclusive. + + If no report step satisfying the criteria is found a + ValueError exception will be raised. + + """ + if tolerance_seconds_before == 0 and tolerance_seconds_after == 0: + index = TimeMap.cNamespace().lookup_time(self , CTime(time)) + else: + index = TimeMap.cNamespace().lookup_time_with_tolerance(self , CTime(time) , tolerance_seconds_before , tolerance_seconds_after) + if index >= 0: return index else: @@ -144,6 +171,8 @@ def dump(self): return step_list + def getLastStep(self): + return TimeMap.cNamespace().last_step(self) ################################################################## @@ -168,4 +197,6 @@ def dump(self): TimeMap.cNamespace().is_strict = cwrapper.prototype("bool time_map_is_strict( time_map )") TimeMap.cNamespace().set_strict = cwrapper.prototype("void time_map_set_strict( time_map , bool)") TimeMap.cNamespace().lookup_time = cwrapper.prototype("int time_map_lookup_time( time_map , time_t)") +TimeMap.cNamespace().lookup_time_with_tolerance = cwrapper.prototype("int time_map_lookup_time_with_tolerance( time_map , time_t , int , int)") TimeMap.cNamespace().lookup_days = cwrapper.prototype("int time_map_lookup_days( time_map , double)") +TimeMap.cNamespace().last_step = cwrapper.prototype("int time_map_get_last_step( time_map )") diff --git a/ThirdParty/Ert/devel/python/python/ert/ert_lib_path_build.py.in b/ThirdParty/Ert/devel/python/python/ert/ert_lib_path_build.py.in new file mode 100644 index 0000000000..d60bc98450 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ert_lib_path_build.py.in @@ -0,0 +1 @@ +lib_path = "${LIBRARY_OUTPUT_PATH}" diff --git a/ThirdParty/Ert/devel/python/python/ert/ert_lib_path_install.py.in b/ThirdParty/Ert/devel/python/python/ert/ert_lib_path_install.py.in new file mode 100644 index 0000000000..a1b335d533 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ert_lib_path_install.py.in @@ -0,0 +1 @@ +lib_path = "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/geo/CMakeLists.txt index 16d6dba465..69c11962a4 100644 --- a/ThirdParty/Ert/devel/python/python/ert/geo/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/geo/CMakeLists.txt @@ -1,6 +1,7 @@ set(PYTHON_SOURCES __init__.py - geo_polygon.py + cpolyline.py + cpolyline_collection.py geometry_tools.py polyline.py xyz_io.py diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/__init__.py b/ThirdParty/Ert/devel/python/python/ert/geo/__init__.py index 3501dbf962..06ccb86b09 100644 --- a/ThirdParty/Ert/devel/python/python/ert/geo/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/geo/__init__.py @@ -23,8 +23,8 @@ ERT_GEOMETRY_LIB = clib.ert_load("libert_geometry") -from .geo_polygon import GeoPolygon - +from .cpolyline import CPolyline +from .cpolyline_collection import CPolylineCollection from .polyline import Polyline from .xyz_io import XYZIo from .geometry_tools import GeometryTools diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/cpolyline.py b/ThirdParty/Ert/devel/python/python/ert/geo/cpolyline.py new file mode 100644 index 0000000000..ad64eece39 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/geo/cpolyline.py @@ -0,0 +1,217 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'ecl_kw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +""" +Create a polygon +""" +import ctypes +import os.path + +from ert.cwrap import BaseCClass, CWrapper +from ert.geo import ERT_GEOMETRY_LIB +from .geometry_tools import GeometryTools + + +class CPolyline(BaseCClass): + def __init__(self, name = None , init_points = []): + c_ptr = CPolyline.cNamespace().alloc_new( name ) + super(CPolyline , self).__init__( c_ptr ) + for (xc, yc) in init_points: + self.addPoint(xc, yc) + + + @staticmethod + def createFromXYZFile(filename , name = None): + if not os.path.isfile(filename): + raise IOError("No such file:%s" % filename) + + polyline = CPolyline.cNamespace().fread_alloc_irap( filename ) + if not name is None: + CPolyline.cNamespace().set_name( polyline , name ) + return polyline + + def __str__(self): + name = self.getName() + if name: + str = "%s [" % name + else: + str = "[" + + for index,p in enumerate(self): + str += "(%g,%g)" % p + if index < len(self) - 1: + str += "," + str += "]" + return str + + + + def __len__(self): + return CPolyline.cNamespace().size( self ) + + + def __getitem__(self , index): + if not isinstance(index,int): + raise TypeError("Index argument must be integer. Index:%s invalid" % index) + + if index < 0: + index += len(self) + + if 0 <= index < len(self): + x = ctypes.c_double() + y = ctypes.c_double() + CPolyline.cNamespace().iget_xy( self , index , ctypes.byref(x) , ctypes.byref(y) ) + + return (x.value , y.value) + else: + raise IndexError("Invalid index:%d valid range: [0,%d)" % (index , len(self))) + + + def segmentIntersects(self, p1 , p2): + return CPolyline.cNamespace().segment_intersects(self , p1[0] , p1[1] , p2[0] , p2[1]) + + + def intersects(self , polyline): + if len(self) > 1: + for index,p2 in enumerate(polyline): + if index == 0: + continue + + p1 = polyline[index - 1] + if self.segmentIntersects(p1 , p2): + return True + + return False + + + + def __iadd__(self , other ): + for p in other: + self.addPoint( p[0] , p[1] ) + return self + + + def __add__(self , other ): + copy = CPolyline( init_points = self) + copy.__iadd__(other) + return copy + + + def __radd__(self , other ): + copy = CPolyline( init_points = other ) + copy.__iadd__(self) + return copy + + def __eq__(self , other): + if super(CPolyline , self).__eq__( other ): + return True + else: + return CPolyline.cNamespace().equal( self, other ) + + + def segmentLength(self): + if len(self) == 0: + raise ValueError("Can not measure length of zero point polyline") + + return CPolyline.cNamespace().segment_length(self) + + def extendToBBox(self , bbox , start = True): + if start: + p0 = self[1] + p1 = self[0] + else: + p0 = self[-2] + p1 = self[-1] + + ray_dir = GeometryTools.lineToRay(p0,p1) + intersections = GeometryTools.rayPolygonIntersections( p1 , ray_dir , bbox) + if intersections: + p2 = intersections[0][1] + if self.getName(): + name = "Extend:%s" % self.getName() + else: + name = None + + return CPolyline( name = name , init_points = [(p1[0] , p1[1]) , p2]) + else: + raise ValueError("Logical error - must intersect with bounding box") + + + + + def addPoint( self, xc, yc , front = False): + if front: + CPolyline.cNamespace().add_point_front(self, xc, yc) + else: + CPolyline.cNamespace().add_point(self, xc, yc) + + + def getName(self): + return CPolyline.cNamespace().get_name( self ) + + + def free(self): + self.cNamespace().free(self) + + + def unzip(self): + x_list = [ ] + y_list = [ ] + for x,y in self: + x_list.append(x) + y_list.append(y) + + return (x_list , y_list) + + + def unzip2(self): + return self.unzip() + + + def connect(self , target): + end1 = self[0] + end2 = self[-1] + + p1 = GeometryTools.nearestPointOnPolyline( end1 , target ) + p2 = GeometryTools.nearestPointOnPolyline( end2 , target ) + + d1 = GeometryTools.distance( p1 , end1 ) + d2 = GeometryTools.distance( p2 , end2 ) + + if d1 < d2: + return [end1 , p1] + else: + return [end2 , p2] + + + + +################################################################# + +cwrapper = CWrapper(ERT_GEOMETRY_LIB) +cwrapper.registerObjectType("geo_polygon", CPolyline) + +CPolyline.cNamespace().alloc_new = cwrapper.prototype("c_void_p geo_polygon_alloc( char* )") +CPolyline.cNamespace().fread_alloc_irap = cwrapper.prototype("geo_polygon_obj geo_polygon_fload_alloc_irap( char* )") +CPolyline.cNamespace().add_point = cwrapper.prototype("void geo_polygon_add_point( geo_polygon , double , double )") +CPolyline.cNamespace().add_point_front = cwrapper.prototype("void geo_polygon_add_point_front( geo_polygon , double , double )") +CPolyline.cNamespace().free = cwrapper.prototype("void geo_polygon_free( geo_polygon )") +CPolyline.cNamespace().size = cwrapper.prototype("int geo_polygon_get_size( geo_polygon )") +CPolyline.cNamespace().iget_xy = cwrapper.prototype("void geo_polygon_iget_xy( geo_polygon , int , double* , double* )") +CPolyline.cNamespace().segment_intersects = cwrapper.prototype("bool geo_polygon_segment_intersects( geo_polygon , double , double, double , double)") +CPolyline.cNamespace().get_name = cwrapper.prototype("char* geo_polygon_get_name( geo_polygon )") +CPolyline.cNamespace().set_name = cwrapper.prototype("void geo_polygon_set_name( geo_polygon , char* )") +CPolyline.cNamespace().segment_length = cwrapper.prototype("double geo_polygon_get_length( geo_polygon)") +CPolyline.cNamespace().equal = cwrapper.prototype("bool geo_polygon_equal( geo_polygon , geo_polygon )") diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/cpolyline_collection.py b/ThirdParty/Ert/devel/python/python/ert/geo/cpolyline_collection.py new file mode 100644 index 0000000000..e4f4d83ff5 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/geo/cpolyline_collection.py @@ -0,0 +1,122 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'cpolyline_collection.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +""" +Create a polygon +""" +import ctypes + +from ert.cwrap import BaseCClass, CWrapper +from ert.geo import ERT_GEOMETRY_LIB , CPolyline + + +class CPolylineCollection(BaseCClass): + def __init__(self): + c_ptr = CPolylineCollection.cNamespace().alloc_new( ) + super(CPolylineCollection , self).__init__( c_ptr ) + self.parent_ref = None + + + def __contains__(self , name): + return CPolylineCollection.cNamespace().has_polyline(self , name) + + + def __len__(self): + return CPolylineCollection.cNamespace().size(self) + + + def __iter__(self): + index = 0 + + while index < len(self): + yield self[index] + index += 1 + + + def __getitem__(self , index): + if isinstance(index , int): + if index < 0: + index += len(self) + + if 0 <= index < len(self): + return CPolylineCollection.cNamespace().iget(self , index).setParent( self ) + else: + raise IndexError("Invalid index:%d - valid range: [0,%d)" % (index , len(self))) + elif isinstance(index , str): + if index in self: + return CPolylineCollection.cNamespace().get(self , index) + else: + raise KeyError("No polyline named:%s" % index) + else: + raise TypeError("The index argument must be string or integer") + + + def shallowCopy(self): + copy = CPolylineCollection() + for pl in self: + CPolylineCollection.cNamespace().add_polyline(copy , pl , False) + # If we make a shallow copy we must ensure that source, owning + # all the polyline objects does not go out of scope. + copy.parent_ref = self + return copy + + + + def addPolyline(self , polyline , name = None): + if not isinstance(polyline , CPolyline): + polyline = CPolyline( init_points = polyline , name = name) + else: + if not name is None: + raise ValueError("The name keyword argument can only be supplied when add not CPOlyline object") + + name = polyline.getName() + if name and name in self: + raise KeyError("The polyline collection already has an object:%s" % name) + + if polyline.isReference(): + CPolylineCollection.cNamespace().add_polyline(self , polyline , False) + else: + polyline.convertToCReference( self ) + CPolylineCollection.cNamespace().add_polyline(self , polyline , True) + + + + def createPolyline(self , name = None): + if name and name in self: + raise KeyError("The polyline collection already has an object:%s" % name) + + polyline = CPolylineCollection.cNamespace().create_polyline(self , name) + return polyline + + + def free(self): + CPolylineCollection.cNamespace().free(self) + + + + +################################################################# + +cwrapper = CWrapper(ERT_GEOMETRY_LIB) +cwrapper.registerObjectType("geo_polygon_collection", CPolylineCollection) + +CPolylineCollection.cNamespace().alloc_new = cwrapper.prototype("c_void_p geo_polygon_collection_alloc( )") +CPolylineCollection.cNamespace().free = cwrapper.prototype("void geo_polygon_collection_free( geo_polygon_collection )" ) +CPolylineCollection.cNamespace().size = cwrapper.prototype("int geo_polygon_collection_size( geo_polygon_collection)" ) +CPolylineCollection.cNamespace().create_polyline = cwrapper.prototype("geo_polygon_ref geo_polygon_collection_create_polygon(geo_polygon_collection , char*)" ) +CPolylineCollection.cNamespace().has_polyline = cwrapper.prototype("bool geo_polygon_collection_has_polygon(geo_polygon_collection , char*)" ) +CPolylineCollection.cNamespace().iget = cwrapper.prototype("geo_polygon_ref geo_polygon_collection_iget_polygon(geo_polygon_collection , int)" ) +CPolylineCollection.cNamespace().get = cwrapper.prototype("geo_polygon_ref geo_polygon_collection_get_polygon(geo_polygon_collection , char*)" ) +CPolylineCollection.cNamespace().add_polyline = cwrapper.prototype("void geo_polygon_collection_add_polygon(geo_polygon_collection , geo_polygon , bool)") diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/geometry_tools.py b/ThirdParty/Ert/devel/python/python/ert/geo/geometry_tools.py index 3feb25ce3c..9c33b89010 100644 --- a/ThirdParty/Ert/devel/python/python/ert/geo/geometry_tools.py +++ b/ThirdParty/Ert/devel/python/python/ert/geo/geometry_tools.py @@ -1,5 +1,5 @@ from math import sqrt - +import sys class GeometryTools(object): EPSILON = 0.000001 @@ -23,9 +23,7 @@ def lineIntersection(p1, p2, p3, p4): # coincident? if abs(numerator_a) < GeometryTools.EPSILON and abs(numerator_b) < GeometryTools.EPSILON and abs(denominator) < GeometryTools.EPSILON: - x = (p1[0] + p2[0]) / 2.0 - y = (p1[1] + p2[1]) / 2.0 - return x, y + return None # parallel? if abs(denominator) < GeometryTools.EPSILON: @@ -144,6 +142,28 @@ def pointInPolygon(p, polygon): return inside + @staticmethod + def extendToEdge(bounding_polygon, poly_line): + """ + """ + assert(bounding_polygon.isClosed()) + for p in poly_line: + if not GeometryTools.pointInPolygon( p , bounding_polygon): + raise ValueError("The point:%s was not inside bounding polygon") + + p1 = poly_line[0] + ray1 = GeometryTools.lineToRay(poly_line[1], poly_line[0]) + intersection1 = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon)[0] # assume convex + + + p2 = poly_line[-1] + assert(GeometryTools.pointInPolygon(p2 , bounding_polygon)) + + ray2 = GeometryTools.lineToRay(poly_line[-2], poly_line[-1]) + intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon) + intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon)[0] # assume convex + + return [intersection1[1]] + poly_line + [intersection2[1]] @staticmethod @@ -161,6 +181,7 @@ def slicePolygon(bounding_polygon, poly_line): p1 = poly_line[0] ray1 = GeometryTools.lineToRay(poly_line[1], poly_line[0]) + tmp = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon) intersection1 = GeometryTools.rayPolygonIntersections(p1, ray1, bounding_polygon)[0] # assume convex p2 = poly_line[-1] @@ -168,6 +189,14 @@ def slicePolygon(bounding_polygon, poly_line): intersection2 = GeometryTools.rayPolygonIntersections(p2, ray2, bounding_polygon)[0] # assume convex + # Check for intersection between the polyline extensions on the inside of the bounadary + internal_intersection = GeometryTools.lineIntersection( p1 , intersection1[1] , p2 , intersection2[1]) + if internal_intersection: + start_point = poly_line[0] + return poly_line + [ internal_intersection , start_point] + + + if intersection2[0] < intersection1[0]: intersection1, intersection2 = intersection2, intersection1 poly_line = list(reversed(poly_line)) @@ -188,6 +217,7 @@ def slicePolygon(bounding_polygon, poly_line): + @staticmethod def lineToRay(p0, p1): """ @@ -206,7 +236,7 @@ def lineToRay(p0, p1): @staticmethod - def rayLineIntersection(point, ray, p1, p2): + def rayLineIntersection(point, ray, p1, p2 , flip_ray = False): """ Finds the intersection between the ray starting at point and the line [p1, p2]. @type point: tuple of (float, float) @@ -214,33 +244,60 @@ def rayLineIntersection(point, ray, p1, p2): @type p1: tuple of (float, float) @type p2: tuple of (float, float) @rtype: tuple of (float, float) or None + + stackoverflow: 563198 """ - denominator = ray[1] * (p2[0] - p1[0]) - ray[0] * (p2[1] - p1[1]) - numerator_a = ray[0] * (p1[1] - point[1]) - ray[1] * (p1[0] - point[0]) - numerator_b = (p2[0] - p1[0]) * (p1[1] - point[1]) - (p2[1] - p1[1]) * (p1[0] - point[0]) + s = (p2[0] - p1[0] , p2[1] - p1[1]) + q = p1 + r = ray + p = point - # coincident? - if abs(numerator_a) < GeometryTools.EPSILON and abs(numerator_b) < GeometryTools.EPSILON and abs(denominator) < GeometryTools.EPSILON: - x = (p1[0] + p2[0]) / 2.0 - y = (p1[1] + p2[1]) / 2.0 - return x, y + p_m_q = (p[0] - q[0] , p[1] - q[1]) + q_m_p = (q[0] - p[0] , q[1] - p[1]) + r_x_s = r[0] * s[1] - r[1]*s[0] + + q_m_p_x_r = q_m_p[0] * r[1] - q_m_p[1] * r[0] + q_m_p_x_s = q_m_p[0] * s[1] - q_m_p[1] * s[0] + + if abs(r_x_s) < GeometryTools.EPSILON and abs(q_m_p_x_r) < GeometryTools.EPSILON: + q_m_p_dot_r = q_m_p[0] * r[0] + q_m_p[1] * r[1] + r_dot_r = r[0] * r[0] + r[1] * r[1] + + p_m_q_dot_s = p_m_q[0] * s[0] + p_m_q[1] * s[1] + s_dot_s = s[0] * s[0] + s[1] * s[1] + + # Coincident + if 0 <= q_m_p_dot_r <= r_dot_r: + return ((p1[0] + p2[0]) / 2 , (p1[1] + p2[1]) / 2) + + # Coincident + if 0 <= p_m_q_dot_s <= s_dot_s: + return ((p1[0] + p2[0]) / 2 , (p1[1] + p2[1]) / 2) - # parallel? - if abs(denominator) < GeometryTools.EPSILON: + return None + + + if abs(r_x_s) < GeometryTools.EPSILON: + # Parallell return None - # intersection along the segments? - mua = numerator_a / denominator - mub = numerator_b / denominator + t = 1.0 * q_m_p_x_s / r_x_s + u = 1.0 * q_m_p_x_r / r_x_s - # for rays mub can be larger than 1.0 - if mua < 0.0 or mua > 1.0 or mub < 0.0: + if t >= 0 and 0 <= u <= 1: + x = p[0] + t*r[0] + y = p[1] + t*r[1] + + return x,y + + if flip_ray: + return GeometryTools.rayLineIntersection( point , (-ray[0] , -ray[1]) , p1 , p2 , False) + else: return None - x = p1[0] + mua * (p2[0] - p1[0]) - y = p1[1] + mua * (p2[1] - p1[1]) - return x, y + + @staticmethod def rayPolygonIntersections(point, ray, polygon): @@ -263,3 +320,129 @@ def rayPolygonIntersections(point, ray, polygon): results.append((index, intersection)) return results + + + @staticmethod + def distance(p1,p2): + if len(p1) != len(p2): + raise ValueError("Different lenght of objects") + + sqr_distance = 0 + for x1,x2 in zip(p1,p2): + sqr_distance += (x1 - x2) * (x1 - x2) + + return sqrt( sqr_distance ) + + + @staticmethod + def joinPolylines(polyline1 , polyline2): + """The shortest straight line connecting polyline1 and polyline2. + + The joinPolylines function does not extend the polylines with + a ray from the end, only the length of the straight line + connecting the various endpoints is considered. If the two + polylines already intersect the function returns None. + """ + + + if len(polyline1) < 1: + raise ValueError("Length of polyline must be >= 1") + + if len(polyline2) < 1: + raise ValueError("Length of polyline must be >= 1") + + if GeometryTools.polylinesIntersect( polyline1 , polyline2): + return None + + p0 = polyline1[0] + p1 = polyline1[-1] + pa = polyline2[0] + pb = polyline2[-1] + + d_list = [ (GeometryTools.distance( p0 , pa ), [p0 , pa]), + (GeometryTools.distance( p0 , pb ), [p0 , pb]), + (GeometryTools.distance( p1 , pa ), [p1 , pa]), + (GeometryTools.distance( p1 , pb ), [p1 , pb]) ] + + d_list.sort( key = lambda x: x[0]) + return d_list[0][1] + + + @staticmethod + def connectPolylines( polyline , target_polyline): + if GeometryTools.polylinesIntersect( polyline , target_polyline ): + return None + + if len(polyline) < 2: + raise ValueError("Polyline must have at least two points") + + d_list = [] + + p0 = polyline[-1] + p1 = polyline[-2] + ray = GeometryTools.lineToRay( p1 , p0 ) + for (index , p) in GeometryTools.rayPolygonIntersections( p0 , ray , target_polyline): + d_list.append( (GeometryTools.distance( p0 , p) , [p0 , p]) ) + + p0 = polyline[0] + p1 = polyline[1] + ray = GeometryTools.lineToRay( p1 , p0 ) + for (index , p) in GeometryTools.rayPolygonIntersections( p0 , ray , target_polyline): + d_list.append( (GeometryTools.distance( p0 , p) , [p0 , p]) ) + + if len(d_list) == 0: + raise ValueError("Polyline %s can not be extended to %s" % (polyline.getName() , target_polyline.getName())) + + d_list.sort( key = lambda x: x[0]) + return d_list[0][1] + + + + @staticmethod + def nearestPointOnPolyline( p , polyline ): + if len(polyline) > 1: + d_list = [ GeometryTools.distance( p , pi ) for pi in polyline ] + index0 = d_list.index( min(d_list) ) + p0 = polyline[index0] + dist0 = d_list[index0] + + dist1 = sys.float_info.max + dist2 = sys.float_info.max + intercept1 = None + intercept2 = None + + index1 = None + index2 = None + if index0 > 0: + index1 = index0 - 1 + + if index0 < len(polyline) - 1: + index2 = index0 + 1 + + if not index1 is None: + p1 = polyline[index1] + dy1 = p1[1] - p0[1] + dx1 = p1[0] - p0[0] + intercept1 = GeometryTools.rayLineIntersection( p , (dy1 , -dx1) , p0 , p1 , True) + if intercept1: + dist1 = GeometryTools.distance( intercept1 , p ) + + + if not index2 is None: + p2 = polyline[index2] + dy2 = p2[1] - p0[1] + dx2 = p2[0] - p0[0] + intercept2 = GeometryTools.rayLineIntersection( p , (dy2 , -dx2) , p0 , p2 , True) + if intercept2: + dist2 = GeometryTools.distance( intercept2 , p ) + + + point_list = [ p0 , intercept1 , intercept2 ] + d_list = [ dist0 , dist1 , dist2 ] + index = d_list.index( min(d_list) ) + + + return point_list[index] + else: + raise ValueError("Polyline must have len() >= 2") + diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/polyline.py b/ThirdParty/Ert/devel/python/python/ert/geo/polyline.py index e1ddac9375..8a11571a31 100644 --- a/ThirdParty/Ert/devel/python/python/ert/geo/polyline.py +++ b/ThirdParty/Ert/devel/python/python/ert/geo/polyline.py @@ -2,7 +2,7 @@ from .geometry_tools import GeometryTools class Polyline(object): - def __init__(self, name="Unnamed" , init_points = None): + def __init__(self, name=None , init_points = None): super(Polyline, self).__init__() self.__name = name self.__points = [] @@ -16,11 +16,29 @@ def __str__(self): s += "]" return s - def name(self): + def getName(self): """ @rtype: str """ return self.__name + def __iadd__(self , other ): + for p in other: + self.__points.append( p ) + return self + + + def __add__(self , other ): + copy = Polyline( init_points = self) + copy.__iadd__(other) + return copy + + + def __radd__(self , other ): + copy = Polyline( init_points = other ) + copy.__iadd__(self) + return copy + + def __eq__(self, other): if len(self) != len(other): return False @@ -76,9 +94,6 @@ def assertClosed(self): def loadPoints(self , points): - if not isinstance( points , collections.Iterable ): - raise TypeError("The input argument points must be iterable") - for point in points: x = point[0] y = point[1] @@ -107,6 +122,15 @@ def __iter__(self): index += 1 + def unzip2(self): + x = [] + y = [] + for p in self: + x.append(p[0]) + y.append(p[1]) + + return (x,y) + def unzip(self): first_point = self[0] @@ -130,3 +154,18 @@ def unzip(self): return (x,y) + def connect(self , target): + end1 = self[0] + end2 = self[-1] + + p1 = GeometryTools.nearestPointOnPolyline( end1 , target ) + p2 = GeometryTools.nearestPointOnPolyline( end2 , target ) + + d1 = GeometryTools.distance( p1 , end1 ) + d2 = GeometryTools.distance( p2 , end2 ) + + if d1 < d2: + return [end1 , p1] + else: + return [end2 , p2] + diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/xyz_io.py b/ThirdParty/Ert/devel/python/python/ert/geo/xyz_io.py index db394d7bed..9f349b339f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/geo/xyz_io.py +++ b/ThirdParty/Ert/devel/python/python/ert/geo/xyz_io.py @@ -8,7 +8,7 @@ def readXYZFile(path): """ @rtype: Polyline """ if not os.path.exists(path): - raise ValueError("Path does not exist '%s'!" % path) + raise IOError("Path does not exist '%s'!" % path) name = os.path.basename(path) @@ -35,7 +35,7 @@ def readXYFile(path): """ @rtype: Polyline """ if not os.path.exists(path): - raise ValueError("Path does not exist '%s'!" % path) + raise IOError("Path does not exist '%s'!" % path) name = os.path.basename(path) diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt index a828f1c0ed..4fd89b4318 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt @@ -1,6 +1,7 @@ set(PYTHON_SOURCES __init__.py driver.py + ert_plugin.py ert_script.py ext_job.py ext_joblist.py diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/__init__.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/__init__.py index 7b902d0df7..5ac1a2b3cc 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/__init__.py @@ -55,6 +55,7 @@ import os import ert.util +import ert.config import ert.cwrap.clib as clib @@ -83,6 +84,7 @@ def setenv( var, value): from .forward_model import ForwardModel from .ert_script import ErtScript +from .ert_plugin import ErtPlugin, CancelPluginException from .function_ert_script import FunctionErtScript from .external_ert_script import ExternalErtScript diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/ert_plugin.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/ert_plugin.py new file mode 100644 index 0000000000..e1beabe5d0 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/ert_plugin.py @@ -0,0 +1,25 @@ +from .ert_script import ErtScript + + +class CancelPluginException(Exception): + def __init__(self, cancel_message): + super(CancelPluginException, self).__init__(cancel_message) + + +class ErtPlugin(ErtScript): + + def getArguments(self, parent=None): + """ @rtype: list """ + return [] + + def getName(self): + """ @rtype: str """ + return str(self.__class__) + + def getDescription(self): + """ @rtype: str """ + return "No description provided!" + + def checkIfCancelled(self): + if self.isCancelled(): + raise CancelPluginException("Plugin '%s' cancelled by user!" % self.getName()) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/ert_script.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/ert_script.py index 5f339c1478..1cc3119be7 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/ert_script.py +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/ert_script.py @@ -18,18 +18,23 @@ def __init__(self, ert): self.__ert = ert self.__is_cancelled = False + self.__failed = False def isVerbose(self): return self.__verbose def ert(self): - """ @rtype: EnKFMain """ + """ @rtype: ert.enkf.EnKFMain """ return self.__ert def isCancelled(self): """ @rtype: bool """ return self.__is_cancelled + def hasFailed(self): + """ @rtype: bool """ + return self.__failed + def cancel(self): self.__is_cancelled = True @@ -41,6 +46,7 @@ def initializeAndRun(self, argument_types, argument_values, verbose=False): @rtype: unknown """ self.__verbose = verbose + self.__failed = False arguments = [] @@ -51,9 +57,20 @@ def initializeAndRun(self, argument_types, argument_values, verbose=False): else: arg_type = str - arguments.append(arg_type(arg_value)) + if arg_value is not None: + arguments.append(arg_type(arg_value)) + else: + arguments.append(None) + + try: + return self.run(*arguments) + except Exception as e: + sys.stderr.write("The script '%s' caused an error while running:\n" % self.__class__.__name__) + traceback.print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback) + self.__failed = True + stack_trace = traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback) + return "".join(stack_trace) - return self.run(*arguments) __module_count = 0 # Need to have unique modules in case of identical object naming in scripts @@ -73,9 +90,10 @@ def loadScriptFromFile(path): def __findErtScriptImplementations(module): """ @rtype: ErtScript """ result = [] - for name, obj in inspect.getmembers(module): - if hasattr(obj, "__bases__") and ErtScript in obj.__bases__: - result.append(obj) + predicate = lambda member : inspect.isclass(member) and member.__module__ == module.__name__ + for name, member in inspect.getmembers(module, predicate): + if ErtScript in inspect.getmro(member): + result.append(member) if len(result) != 1: raise UserWarning("Must have (only) one implementation of ErtScript in a module!") diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue_manager.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue_manager.py index 4b0c2472b6..9840b13a8f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue_manager.py +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue_manager.py @@ -36,15 +36,33 @@ def __init__(self, queue): def startQueue(self , total_size , verbose = False): JobQueueManager.cNamespace().start_queue( self , total_size , verbose ) + def getNumRunning(self): + return JobQueueManager.cNamespace().get_num_running( self ) + + def getNumComplete(self): + return JobQueueManager.cNamespace().get_num_complete( self ) + + def isRunning(self): + return JobQueueManager.cNamespace().is_running( self ) + def free(self): JobQueueManager.cNamespace().free(self) + def jobComplete(self , job_index): + return JobQueueManager.cNamespace().job_complete( self , job_index ) + + + ################################################################# cwrapper = CWrapper(JOB_QUEUE_LIB) cwrapper.registerObjectType("job_queue_manager", JobQueueManager) -JobQueueManager.cNamespace().alloc = cwrapper.prototype("c_void_p job_queue_manager_alloc( job_queue) ") -JobQueueManager.cNamespace().free = cwrapper.prototype("void job_queue_manager_free( job_queue_manager )") -JobQueueManager.cNamespace().start_queue = cwrapper.prototype("void job_queue_manager_start_queue( job_queue_manager , int , bool)") +JobQueueManager.cNamespace().alloc = cwrapper.prototype("c_void_p job_queue_manager_alloc( job_queue) ") +JobQueueManager.cNamespace().free = cwrapper.prototype("void job_queue_manager_free( job_queue_manager )") +JobQueueManager.cNamespace().start_queue = cwrapper.prototype("void job_queue_manager_start_queue( job_queue_manager , int , bool)") +JobQueueManager.cNamespace().get_num_running = cwrapper.prototype("int job_queue_manager_get_num_running( job_queue_manager )") +JobQueueManager.cNamespace().get_num_complete = cwrapper.prototype("int job_queue_manager_get_num_complete( job_queue_manager )") +JobQueueManager.cNamespace().is_running = cwrapper.prototype("bool job_queue_manager_is_running( job_queue_manager )") +JobQueueManager.cNamespace().job_complete = cwrapper.prototype("bool job_queue_manager_job_complete( job_queue_manager , int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/workflow_job.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/workflow_job.py index df414273e8..b58dfc2d9f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/workflow_job.py +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/workflow_job.py @@ -1,7 +1,6 @@ from ert.cwrap import BaseCClass, CWrapper -from ert.job_queue import JOB_QUEUE_LIB, ErtScript, FunctionErtScript +from ert.job_queue import JOB_QUEUE_LIB, ErtScript, FunctionErtScript, ErtPlugin, ExternalErtScript from ert.config import ContentTypeEnum -from ert.job_queue.external_ert_script import ExternalErtScript class WorkflowJob(BaseCClass): @@ -12,6 +11,7 @@ def __init__(self, name, internal=True): self.__script = None """ :type: ErtScript """ + self.__running = False def isInternal(self): """ @rtype: bool """ @@ -49,6 +49,15 @@ def getInternalScriptPath(self): """ @rtype: str """ return WorkflowJob.cNamespace().get_internal_script(self) + def isPlugin(self): + """ @rtype: bool """ + if self.isInternalScript(): + script_obj = ErtScript.loadScriptFromFile(self.getInternalScriptPath()) + return issubclass(script_obj, ErtPlugin) + + return False + + def argumentTypes(self): """ @rtype: list of type """ @@ -76,6 +85,7 @@ def run(self, ert, arguments, verbose=False): @type verbose: bool @rtype: ctypes.c_void_p """ + self.__running = True min_arg = self.minimumArgumentCount() if min_arg > 0 and len(arguments) < min_arg: @@ -89,27 +99,48 @@ def run(self, ert, arguments, verbose=False): if self.isInternalScript(): script_obj = ErtScript.loadScriptFromFile(self.getInternalScriptPath()) self.__script = script_obj(ert) - return self.__script.initializeAndRun(self.argumentTypes(), arguments, verbose=verbose) + result = self.__script.initializeAndRun(self.argumentTypes(), arguments, verbose=verbose) elif self.isInternal() and not self.isInternalScript(): self.__script = FunctionErtScript(ert, self.functionName(), self.argumentTypes(), argument_count=len(arguments)) - return self.__script.initializeAndRun(self.argumentTypes(), arguments, verbose=verbose) + result = self.__script.initializeAndRun(self.argumentTypes(), arguments, verbose=verbose) elif not self.isInternal(): self.__script = ExternalErtScript(ert, self.executable()) - return self.__script.initializeAndRun(self.argumentTypes(), arguments, verbose=verbose) + result = self.__script.initializeAndRun(self.argumentTypes(), arguments, verbose=verbose) else: raise UserWarning("Unknown script type!") + self.__running = False + return result + def cancel(self): if self.__script is not None: self.__script.cancel() + def isRunning(self): + return self.__running + + def isCancelled(self): + return self.__script.isCancelled() + + def hasFailed(self): + """ @rtype: bool """ + return self.__script.hasFailed() + def free(self): WorkflowJob.cNamespace().free(self) + @classmethod + def createCReference(cls, c_pointer, parent=None): + workflow = super(WorkflowJob, cls).createCReference(c_pointer, parent) + workflow.__script = None + workflow.__running = False + return workflow + + CWrapper.registerObjectType("workflow_job", WorkflowJob) cwrapper = CWrapper(JOB_QUEUE_LIB) diff --git a/ThirdParty/Ert/devel/python/python/ert/rms/__init__.py b/ThirdParty/Ert/devel/python/python/ert/rms/__init__.py index f80a3dffa6..ca40c86e4d 100644 --- a/ThirdParty/Ert/devel/python/python/ert/rms/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/rms/__init__.py @@ -1,4 +1,7 @@ from ert.cwrap import clib +import ert.util +import ert.geo +import ert.ecl RMS_LIB = clib.ert_load("librms") diff --git a/ThirdParty/Ert/devel/python/python/ert/server/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/server/CMakeLists.txt index 08c692f2c3..a21ac23d24 100644 --- a/ThirdParty/Ert/devel/python/python/ert/server/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/server/CMakeLists.txt @@ -2,6 +2,7 @@ set(PYTHON_SOURCES __init__.py ert_server.py ert_socket.py + ert_client.py run_context.py ) diff --git a/ThirdParty/Ert/devel/python/python/ert/server/__init__.py b/ThirdParty/Ert/devel/python/python/ert/server/__init__.py index 446c848fea..bcb247e7ab 100644 --- a/ThirdParty/Ert/devel/python/python/ert/server/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/server/__init__.py @@ -1,4 +1,4 @@ -from .ert_server import ErtServer, ErtCmdError +from .ert_server import ErtServer, ERROR , SUCCESS from .ert_socket import ErtSocket +from .ert_client import ErtClient from .run_context import RunContext - diff --git a/ThirdParty/Ert/devel/python/python/ert/server/ert_client.py b/ThirdParty/Ert/devel/python/python/ert/server/ert_client.py new file mode 100644 index 0000000000..6e15ac136c --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/server/ert_client.py @@ -0,0 +1,67 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'ert_server.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import sys +import socket +import json +import datetime +from ert.server import ErtServer + + +class ErtClient(object): + def __init__(self , port , host): + self.socket = socket.socket( socket.AF_INET , socket.SOCK_STREAM) + self.port = port + self.host = host + self.socket.setblocking(1) + try: + self.socket.connect((self.host , self.port)) + except socket.error: + sys.exit("Failed to connect to port:%d at %s." % (port , host)) + + @staticmethod + def convert_to_datetime(data): + result = [] + for d in data: + try: + result.append(datetime.datetime.strptime(d, ErtServer.DATE_FORMAT)) + except: + pass + return result + + def sendRecv(self , data): + self.socket.sendall( json.dumps(data) + "\n" ) + recv = self.socket.recv(4096) + result = json.loads(recv) + + result0 = result[0] + if result0 == "OK": + result = result[1:] + if data == ["TIME_STEP"]: + result = ErtClient.convert_to_datetime(result) + + return result + elif result0 == "ERROR": + raise Exception("Ert server returned error: %s" % result[1:]) + else: + raise Exception("Ert server returned result[0] == %s - must have OK|ERROR as first element in return list" % result[0]) + + + + @staticmethod + def runCommand( cmd , port , host): + client = ErtClient( port , host ) + return client.sendRecv( cmd ) diff --git a/ThirdParty/Ert/devel/python/python/ert/server/ert_server.py b/ThirdParty/Ert/devel/python/python/ert/server/ert_server.py index 2387aa0e29..0a3662af08 100644 --- a/ThirdParty/Ert/devel/python/python/ert/server/ert_server.py +++ b/ThirdParty/Ert/devel/python/python/ert/server/ert_server.py @@ -18,49 +18,84 @@ import threading import json import os +import traceback +import datetime +from time import strftime -from ert.enkf import EnKFMain,RunArg -from ert.enkf.enums import EnkfRunType , EnkfStateType +from ert.enkf import EnKFMain,RunArg,EnkfFsManager +from ert.enkf.enums import EnkfRunType, EnkfStateType, ErtImplType , EnkfVarType , RealizationStateEnum from ert.enkf import NodeId +from ert.util import installAbortSignals from .run_context import RunContext -class ErtCmdError(Exception): - pass +# The server will always return SUCCESS(), or alternatively raise an +# exception. The ert_socket layer will catch the exception an return +# an error message to the client. The error message will be created +# with the ERROR function below. +def SUCCESS(res): + return ["OK"] + res + + +def ERROR(msg , exception = None): + result = ["ERROR", msg] + if exception: + result.append( "%s" % exception ) + return result + + class ErtServer(object): + DATE_FORMAT = '%Y-%m-%d %H:%M:%S' site_config = None - def __init__(self , config_file = None): + def __init__(self , config_file , logger): + installAbortSignals() + + self.queue_lock = threading.Lock() self.ert_handle = None - if config_file: - if os.path.exists(config_file): - self.open( config_file ) - else: - raise IOError("The config file:%s does not exist" % config_file) + self.logger = logger + if os.path.exists(config_file): + self.open( config_file ) + else: + raise IOError("The config file:%s does not exist" % config_file) + self.initCmdTable() self.run_context = None + self.init_fs = None + self.run_fs = None + self.run_count = 0 + + + def SUCCESS(self , res): + self.logger.debug("Success: returning: %s" , res) + return SUCCESS(res) + def ERROR(self , res): + self.logger.debug("ERROR: returning: %s" , res) + return ERROR(res) + def initCmdTable(self): self.cmd_table = {"STATUS" : self.handleSTATUS , "INIT_SIMULATIONS" : self.handleINIT_SIMULATIONS , "ADD_SIMULATION" : self.handleADD_SIMULATION , - "SET_VARIABLE" : self.handleSET_VARIABLE , - "GET_RESULT" : self.handleGET_RESULT } + "GET_RESULT" : self.handleGET_RESULT , + "TIME_STEP": self.handleTIMESTEP } def open(self , config_file): self.config_file = config_file - self.ert_handle = EnKFMain( config_file , ErtServer.site_config ) - + self.ert_handle = EnKFMain( config_file ) + self.logger.info("Have connect ert handle to:%s" , config_file) def close(self): # More cleanup first ... + self.logger.info("Shutting down ert handle") self.ert_handle = None @@ -80,43 +115,85 @@ def __del__(self): def evalCmd(self , cmd_expr): cmd = cmd_expr[0] func = self.cmd_table.get(cmd) - + self.logger.info("Received command: %s" % cmd) + if func: return func(cmd_expr[1:]) else: - raise ErtCmdError("The command:%s was not recognized" % cmd) + raise KeyError("The command:%s was not recognized" % cmd) def handleSTATUS(self , args): if self.isConnected(): if self.run_context is None: - return ["READY"] + return self.SUCCESS(["READY"]) else: - return ["RUNNING" , self.run_context.getNumRunning() , self.run_context.getNumComplete()] + if self.run_context.isRunning(): + if len(args) == 0: + return self.SUCCESS(["RUNNING" , self.run_context.getNumRunning() , self.run_context.getNumComplete()]) + else: + iens = args[0] + if self.run_context.realisationComplete(iens): + return self.SUCCESS(["COMPLETE"]) + else: + return self.SUCCESS(["RUNNING"]) + else: + return self.SUCCESS(["COMPLETE"]) else: - return ["CLOSED"] + return self.SUCCESS(["CLOSED"]) + + + def initSimulations(self , args): + run_size = args[0] + init_case = str(args[1]) + run_case = str(args[2]) + + fs_manager = self.ert_handle.getEnkfFsManager() + self.run_fs = fs_manager.getFileSystem( run_case ) + self.init_fs = fs_manager.getFileSystem( init_case ) + fs_manager.switchFileSystem( self.run_fs ) + + self.run_context = RunContext(self.ert_handle , run_size , self.run_fs , self.run_count) + self.run_count += 1 + return self.handleSTATUS([]) + + + def restartSimulations(self , args): + return self.initSimulations(args) def handleINIT_SIMULATIONS(self , args): - if len(args) == 2: - if self.run_context is None: - run_size = args[0] - init_case = args[1] - self.run_context = RunContext(self.ert_handle , run_size , init_case) - return self.handleSTATUS([]) - else: - raise ErtCmdError("The ert server has already started simulations") + if len(args) == 3: + result = [] + with self.queue_lock: + if self.run_context is None: + self.initSimulations( args ) + else: + if not self.run_context.isRunning(): + self.restartSimulations( args ) + + result = ["OK"] + + return self.SUCCESS(result) else: - raise ErtCmdError("The INIT_SIMULATIONS command expects two arguments: [ensemble_size , init_case]") + raise IndexError("The INIT_SIMULATIONS command expects three arguments: [ensemble_size , init_case, run_case]") + def handleGET_RESULT(self , args): iens = args[0] - report_step = args[1] kw = str(args[2]) + + try: + year,month,day = args[1] + time_map = self.run_fs.getTimeMap( ) + report_step = time_map.lookupTime( datetime.date( year , month , day) , tolerance_seconds_before = 24*3600 , tolerance_seconds_after = 24*3600) + except TypeError: + report_step = args[1] + ensembleConfig = self.ert_handle.ensembleConfig() - if ensembleConfig.hasKey( kw ): - state = self.ert_handle[iens] + if kw in ensembleConfig: + state = self.ert_handle.getRealisation( iens ) node = state[kw] gen_data = node.asGenData() @@ -124,35 +201,60 @@ def handleGET_RESULT(self , args): node_id = NodeId(report_step , iens , EnkfStateType.FORECAST ) if node.tryLoad( fs , node_id ): data = gen_data.getData() - return json.dumps( ["OK"] + data.asList() ) + return self.SUCCESS( ["OK"] + data.asList() ) else: - raise ErtCmdError("Loading iens:%d report:%d kw:%s failed" % (iens , report_step , kw)) + raise Exception("Loading iens:%d report:%d kw:%s failed" % (iens , report_step , kw)) else: - raise ErtCmdError("The keyword:%s is not recognized" % kw) + raise KeyError("The keyword:%s is not recognized" % kw) - def handleSET_VARIABLE(self , args): + + # ["ADD_SIMULATION" , 0 , 1 , 1 [ ["KW1" , ...] , ["KW2" , ....]]] + def handleADD_SIMULATION(self , args): geo_id = args[0] pert_id = args[1] iens = args[2] - kw = str(args[3]) - ensembleConfig = self.ert_handle.ensembleConfig() - if ensembleConfig.hasKey(kw): - state = self.ert_handle[iens] + self.logger.debug("ADD_SIMULATION geo_id:%d pert_id:%d iens:%d" % (geo_id , pert_id , iens)) + kw_list = args[3] + state = self.ert_handle.getRealisation( iens ) + state.addSubstKeyword( "GEO_ID" , "%d" % geo_id ) + + elco_kw = [ l[0] for l in kw_list ] + ens_config = self.ert_handle.ensembleConfig() + + for kw in ens_config.getKeylistFromVarType( EnkfVarType.PARAMETER ): + if not kw in elco_kw: + node = state[kw] + init_id = NodeId(0 , geo_id , EnkfStateType.ANALYZED ) + run_id = NodeId(0 , iens , EnkfStateType.ANALYZED ) + node.load( self.init_fs , init_id ) + node.save( self.run_fs , run_id ) + + for kw_arg in kw_list: + kw = str(kw_arg[0]) + data = kw_arg[1:] + self.logger.debug("ADD_SIMULATION %s : %s" % (kw , data)) + node = state[kw] gen_kw = node.asGenKw() - gen_kw.setValues(args[4:]) - - fs = self.ert_handle.getEnkfFsManager().getCurrentFileSystem() - node_id = NodeId(0 , iens , EnkfStateType.ANALYZED ) - node.save( fs , node_id ) - else: - raise ErtCmdError("The keyword:%s is not recognized" % kw) + gen_kw.setValues(data) + + run_id = NodeId(0 , iens , EnkfStateType.ANALYZED ) + node.save( self.run_fs , run_id ) + self.run_fs.fsync() + state_map = self.run_fs.getStateMap() + state_map[iens] = RealizationStateEnum.STATE_INITIALIZED + + self.run_context.startSimulation( iens ) + return self.handleSTATUS([]) + def handleTIMESTEP(self, args): + enkf_fs_manager = self.ert_handle.getEnkfFsManager() + enkf_fs = enkf_fs_manager.getCurrentFileSystem() + time_map = enkf_fs.getTimeMap() + time_steps = [ ts.datetime().strftime(ErtServer.DATE_FORMAT) for ts in time_map ] - def handleADD_SIMULATION(self , args): - iens = args[0] - self.run_context.startSimulation( iens ) + return self.SUCCESS(time_steps) diff --git a/ThirdParty/Ert/devel/python/python/ert/server/ert_socket.py b/ThirdParty/Ert/devel/python/python/ert/server/ert_socket.py index a8014f9e29..351edc6fba 100644 --- a/ThirdParty/Ert/devel/python/python/ert/server/ert_socket.py +++ b/ThirdParty/Ert/devel/python/python/ert/server/ert_socket.py @@ -20,64 +20,85 @@ import threading import json import traceback +import socket -from ert.server import ErtServer +from ert.server import ErtServer, SUCCESS , ERROR class ErtHandler(SocketServer.StreamRequestHandler): ert_server = None config_file = None - + logger = None def handle(self): - data = self.rfile.readline().strip() + string_data = self.rfile.readline().strip() try: - json_data = json.loads( data ) - if json_data[0] == "QUIT": - self.handleQuit() - else: - self.evalJson( json_data ) + data = json.loads( string_data ) except Exception,e: - self.handleInvalidJSON(data , "%s %s" % (e , traceback.format_exc())) + result = ERROR( "Invalid JSON input" , exception = e) + self.returnToClient( result ) + return + if data[0] == "QUIT": + self.handleQuit() + else: + self.evalCmd( data ) - def evalJson(self , json_data): - cmd = json_data[0] - if cmd == "ECHO": - self.wfile.write( json.dumps( json_data[1:] )) - else: - result = self.ert_server.evalCmd( json_data ) - self.wfile.write( json.dumps( result )) - + def returnToClient(self , data): + self.wfile.write(json.dumps(data)) + + + def evalCmd(self , data): + try: + result = self.ert_server.evalCmd( data ) + except Exception,e: + result = ERROR( "Exception raised" , exception = e) + + self.returnToClient( result ) - - def handleInvalidJSON(self , data , e): - json_string = json.dumps({"ERROR" : "%s" % e , "input" : "%s" % data}) - self.wfile.write( json_string ) - def handleQuit(self): - print "Handling QUIT - shutting down ert server" - self.wfile.write(json.dumps(["QUIT"])) shutdown_thread = threading.Thread( target = self.server.shutdown ) shutdown_thread.start() + self.returnToClient( SUCCESS(["QUIT"]) ) +class ErtSocketServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): + pass + class ErtSocket(object): - def __init__(self , config_file , port , host = "localhost"): - self.open(config_file) - self.server = SocketServer.TCPServer((host , port) , ErtHandler) + def __init__(self , config_file , port , host , logger): + self.server = ErtSocketServer((host , port) , ErtHandler) + self.open(config_file , logger) + + + @staticmethod + def connect(config_file , port , host , logger , info_callback = None , timeout = 60 , sleep_time = 5): + start_time = time.time() + ert_socket = None + while True: + try: + ert_socket = ErtSocket(config_file , port, host , logger) + break + except socket.error: + if info_callback: + info_callback( sleep_time , host , port ) + + if time.time() - start_time > timeout: + break + + time.sleep( sleep_time ) + return ert_socket + + + + def open(self , config_file , logger): + ErtHandler.ert_server = ErtServer( config_file , logger ) - def open(self , config_file): - try: - ert_server = ErtServer( config_file ) - except Exception: - ert_server = ErtServer( ) - ErtHandler.ert_server = ert_server def evalCmd(self , cmd): @@ -87,3 +108,4 @@ def evalCmd(self , cmd): def listen(self): self.server.serve_forever( ) + diff --git a/ThirdParty/Ert/devel/python/python/ert/server/run_context.py b/ThirdParty/Ert/devel/python/python/ert/server/run_context.py index 1356a2b819..b122dc193c 100644 --- a/ThirdParty/Ert/devel/python/python/ert/server/run_context.py +++ b/ThirdParty/Ert/devel/python/python/ert/server/run_context.py @@ -16,32 +16,42 @@ from ert.job_queue import JobQueueManager from ert.enkf import RunArg +from ert.util import BoolVector class RunContext(object): - def __init__(self , ert_handle , size , init_case): + def __init__(self , ert_handle , size , run_fs , run_count): self.ert_handle = ert_handle self.size = size - self.init_case = init_case self.runner = ert_handle.getEnkfSimulationRunner() site_config = self.ert_handle.siteConfig() self.queue_manager = JobQueueManager( site_config.getJobQueue() ) self.queue_manager.startQueue( size , verbose = True ) - fs = self.ert_handle.getEnkfFsManager().getCurrentFileSystem() mask = BoolVector( default_value = True ) mask[size - 1] = True - self.ert_run_context = self.ert_handle.getRunContextENSEMPLE_EXPERIMENT( fs , mask ) + self.ert_handle.addDataKW("<ELCO_RUN_COUNT>" , "%s" % run_count) + self.ert_run_context = self.ert_handle.getRunContextENSEMPLE_EXPERIMENT( run_fs , mask ) + + def isRunning(self): + return self.queue_manager.isRunning() + + def getNumRunning(self): - return 0 + return self.queue_manager.getNumRunning() def getNumComplete(self): - return 0 + return self.queue_manager.getNumComplete() def startSimulation(self , iens): - self.ert_handle.submitSimulation( self.ert_run_context.get(iens) ) - + self.ert_handle.submitSimulation( self.ert_run_context.iensGet( iens )) + + + def realisationComplete(self, iens): + run_arg = self.ert_run_context.iensGet( iens ) + queue_index = run_arg.getQueueIndex() + return self.queue_manager.jobComplete( queue_index ) diff --git a/ThirdParty/Ert/devel/python/python/ert/test/__init__.py b/ThirdParty/Ert/devel/python/python/ert/test/__init__.py index 7463d32523..da9a6f283d 100644 --- a/ThirdParty/Ert/devel/python/python/ert/test/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/test/__init__.py @@ -3,5 +3,8 @@ from .extended_testcase import ExtendedTestCase from .source_enumerator import SourceEnumerator from .test_area import TestArea , TestAreaContext -from .ert_test_context import ErtTestContext, ErtTest from .ert_test_runner import ErtTestRunner +try: + from .ert_test_context import ErtTestContext, ErtTest +except ImportError: + pass diff --git a/ThirdParty/Ert/devel/python/python/ert/test/ert_test_context.py b/ThirdParty/Ert/devel/python/python/ert/test/ert_test_context.py index 3ade33f250..4f51b1d9c6 100644 --- a/ThirdParty/Ert/devel/python/python/ert/test/ert_test_context.py +++ b/ThirdParty/Ert/devel/python/python/ert/test/ert_test_context.py @@ -20,11 +20,11 @@ class ErtTest(BaseCClass): - def __init__(self, test_name, model_config, site_config=None, store_area=False): + def __init__(self, test_name, model_config, store_area=False): if not os.path.exists(model_config): raise IOError("The configuration file: %s does not exist" % model_config) else: - c_ptr = ErtTest.cNamespace().alloc(test_name, model_config, site_config) + c_ptr = ErtTest.cNamespace().alloc(test_name, model_config) super(ErtTest, self).__init__(c_ptr) self.setStore(store_area) @@ -77,12 +77,11 @@ def getCwd(self): class ErtTestContext(object): - def __init__(self, test_name, model_config, site_config=None, store_area=False): + def __init__(self, test_name, model_config, store_area=False): self.__test_name = test_name self.__model_config = model_config - self.__site_config = site_config self.__store_area = store_area - self.__test_context = ErtTest(self.__test_name, self.__model_config, site_config=self.__site_config, store_area=self.__store_area) + self.__test_context = ErtTest(self.__test_name, self.__model_config, store_area=self.__store_area) def __enter__(self): @@ -112,7 +111,7 @@ def getCwd(self): cwrapper = CWrapper(ENKF_LIB) cwrapper.registerObjectType("ert_test", ErtTest) -ErtTest.cNamespace().alloc = cwrapper.prototype("c_void_p ert_test_context_alloc_python( char* , char* , char*)") +ErtTest.cNamespace().alloc = cwrapper.prototype("c_void_p ert_test_context_alloc_python( char* , char*)") ErtTest.cNamespace().set_store = cwrapper.prototype("c_void_p ert_test_context_set_store( ert_test , bool)") ErtTest.cNamespace().free = cwrapper.prototype("void ert_test_context_free( ert_test )") ErtTest.cNamespace().get_enkf_main = cwrapper.prototype("enkf_main_ref ert_test_context_get_main( ert_test )") diff --git a/ThirdParty/Ert/devel/python/python/ert/test/ert_test_runner.py b/ThirdParty/Ert/devel/python/python/ert/test/ert_test_runner.py index 3a80fe4866..0ca274508f 100644 --- a/ThirdParty/Ert/devel/python/python/ert/test/ert_test_runner.py +++ b/ThirdParty/Ert/devel/python/python/ert/test/ert_test_runner.py @@ -46,9 +46,13 @@ def runTestsInClass(classpath, test_verbosity=3): @staticmethod def importClass(classpath): dot = classpath.rfind(".") - class_name = classpath[dot + 1:len(classpath)] - m = __import__(classpath[0:dot], globals(), locals(), [class_name]) - return getattr(m, class_name) + class_name = classpath[dot + 1:] + try: + m = __import__(classpath[0:dot], globals(), locals(), [class_name]) + return getattr(m, class_name) + except ImportError: + print("Failed to import: %s" % classpath) + raise @staticmethod diff --git a/ThirdParty/Ert/devel/python/python/ert/test/extended_testcase.py b/ThirdParty/Ert/devel/python/python/ert/test/extended_testcase.py index f22745f988..3445ab9d12 100644 --- a/ThirdParty/Ert/devel/python/python/ert/test/extended_testcase.py +++ b/ThirdParty/Ert/devel/python/python/ert/test/extended_testcase.py @@ -9,6 +9,10 @@ from unittest import TestCase from .source_enumerator import SourceEnumerator +from ert.util import installAbortSignals +from ert.util import Version + + """ @@ -18,6 +22,7 @@ class ExtendedTestCase(TestCase): def __init__(self , *args , **kwargs): self.__testdata_root = None self.__share_root = None + installAbortSignals() super(ExtendedTestCase , self).__init__(*args , **kwargs) @@ -113,17 +118,22 @@ def createTestPath(self, path, testdata_root=None): if testdata_root is None and self.__testdata_root is None: file_path = os.path.realpath(__file__) build_root = os.path.realpath(os.path.join(os.path.dirname(file_path), "../../../../devel/test-data/")) + site_packages_build_root = os.path.realpath(os.path.join(os.path.dirname(file_path), "../../../../../../devel/test-data/")) src_root = os.path.realpath(os.path.join(os.path.dirname(file_path), "../../../../test-data/")) - - if os.path.exists( build_root ): - root = os.path.realpath( os.environ.get("ERT_TEST_ROOT_PATH", build_root) ) - elif os.path.exists( src_root ): - root = os.path.realpath( os.environ.get("ERT_TEST_ROOT_PATH", src_root) ) + env_root = os.getenv("ERT_TEST_ROOT_PATH") + + if env_root is not None and os.path.exists(env_root): + root = os.path.realpath(env_root) + elif os.path.exists(build_root): + root = os.path.realpath(build_root) + elif os.path.exists(site_packages_build_root): + root = os.path.realpath(site_packages_build_root) + elif os.path.exists(src_root): + root = os.path.realpath(src_root) else: root = None - self.setTestDataRoot( root ) - + self.setTestDataRoot(root) root_path = self.__testdata_root if testdata_root is not None: @@ -139,18 +149,23 @@ def createSharePath(self, path, share_root=None): if share_root is None and self.__share_root is None: file_path = os.path.realpath(__file__) build_root = os.path.realpath(os.path.join(os.path.dirname(file_path), "../../../../devel/share/")) + site_packages_build_root = os.path.realpath(os.path.join(os.path.dirname(file_path), "../../../../../../devel/share/")) src_root = os.path.realpath(os.path.join(os.path.dirname(file_path), "../../../../share/")) - - if os.path.exists(build_root): - root = os.path.realpath( os.environ.get("ERT_SHARE_PATH", build_root)) + env_root = os.getenv("ERT_TEST_ROOT_PATH") + + if env_root is not None and os.path.exists(env_root): + root = os.path.realpath(env_root) + elif os.path.exists(build_root): + root = os.path.realpath(build_root) + elif os.path.exists(site_packages_build_root): + root = os.path.realpath(site_packages_build_root) elif os.path.exists(src_root): - root = os.path.realpath( os.environ.get("ERT_SHARE_PATH", src_root)) + root = os.path.realpath(src_root) else: root = None self.setShareRoot(root) - root_path = self.__share_root if share_root is not None: if not os.path.exists(share_root): @@ -160,6 +175,15 @@ def createSharePath(self, path, share_root=None): return os.path.realpath(os.path.join(root_path , path)) + + def assertNotRaises(self, func): + try: + func() + except: + self.fail() + + + @staticmethod def slowTestShouldNotRun(): """ @@ -167,3 +191,15 @@ def slowTestShouldNotRun(): """ return os.environ.get("SKIP_SLOW_TESTS", "False") == "True" + + + @staticmethod + def requireVersion(major , minor , micro = "git"): + required_version = Version(major, minor , micro) + current_version = Version.currentVersion() + + if required_version < current_version: + return True + else: + return False + diff --git a/ThirdParty/Ert/devel/python/python/ert/util/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/util/CMakeLists.txt index 22a3020516..e8a7ae9876 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/util/CMakeLists.txt @@ -6,10 +6,12 @@ set(PYTHON_SOURCES double_vector.py hash.py int_vector.py + install_abort_signals.py latex.py log.py lookup_table.py matrix.py + profiler.py rng.py stat.py stringlist.py diff --git a/ThirdParty/Ert/devel/python/python/ert/util/__init__.py b/ThirdParty/Ert/devel/python/python/ert/util/__init__.py index 06e8dfec76..6299f5b8d8 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/__init__.py @@ -53,7 +53,7 @@ from .version import Version -from .enums import RngAlgTypeEnum, RngInitModeEnum +from .enums import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum from .ctime import CTime @@ -62,18 +62,19 @@ from .int_vector import IntVector from .bool_vector import BoolVector from .time_vector import TimeVector - from .stringlist import StringList -from .stat import quantile, quantile_sorted +from .rng import RandomNumberGenerator from .matrix import Matrix +from .stat import quantile, quantile_sorted, polyfit from .log import Log from .lookup_table import LookupTable from .buffer import Buffer from .hash import Hash, StringHash, DoubleHash, IntegerHash from .substitution_list import SubstitutionList from .ui_return import UIReturn -from .rng import RandomNumberGenerator from .thread_pool import ThreadPool +from .install_abort_signals import installAbortSignals +from .profiler import Profiler # Check if latex functionality exists in libert_util if hasattr(UTIL_LIB, "latex_alloc"): diff --git a/ThirdParty/Ert/devel/python/python/ert/util/bool_vector.py b/ThirdParty/Ert/devel/python/python/ert/util/bool_vector.py index fb1326f3ba..4dc08051bb 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/bool_vector.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/bool_vector.py @@ -17,6 +17,7 @@ from ert.cwrap import CWrapper from ert.util import UTIL_LIB, VectorTemplate +import warnings class BoolVector(VectorTemplate): @@ -30,7 +31,7 @@ def count(self, value=True): return BoolVector.cNamespace().count_equal(self, value) @classmethod - def active_mask(cls, range_string): + def createActiveMask(cls, range_string): """ Will create a BoolVector instance with the values from @range_string. @@ -47,6 +48,25 @@ def active_mask(cls, range_string): """ return cls.cNamespace().create_active_mask(range_string) + @classmethod + def active_mask(cls, range_string): + """ + Will create a BoolVector instance with the values from @range_string. + + The range_string input should be of the type "1,3-5,9,17", + i.e. integer values separated by commas, and dashes to + represent ranges. If the input string contains ANY invalid + characters the returned active list will be empty: + + "1,4-7,10" => {F,T,F,F,T,T,T,T,F,F,T} + "1,4-7,10X" => {} + + The empty list will evaluate to false + @rtype: BoolVector + """ + warnings.warn("The active_mask(cls, rangs_string) method has been renamed: createActiveMask(cls, rangs_string)" , DeprecationWarning) + return cls.cNamespace().create_active_mask(range_string) + @classmethod def updateActiveMask(cls, range_string, bool_vector): """ @@ -59,7 +79,10 @@ def updateActiveMask(cls, range_string, bool_vector): @classmethod def createFromList(cls, size, source_list): - """Allocates a bool vector from a Python list of indexes""" + """ + Allocates a bool vector from a Python list of indexes + @rtype: BoolVector + """ bool_vector = BoolVector(False, size) for index in source_list: @@ -68,11 +91,10 @@ def createFromList(cls, size, source_list): return bool_vector - @classmethod - def createActiveList(cls, mask): - """ @rtype: IntVectorTemplate """ - assert isinstance(mask, BoolVector) - return cls.cNamespace().active_list(mask) + + def createActiveList(self): + """ @rtype: ert.util.IntVector """ + return BoolVector.cNamespace().active_list(self) cwrapper = CWrapper(UTIL_LIB) @@ -114,7 +136,6 @@ def createActiveList(cls, mask): BoolVector.cNamespace().set_default = cwrapper.prototype("void bool_vector_set_default( bool_vector , bool)") BoolVector.cNamespace().get_default = cwrapper.prototype("bool bool_vector_get_default( bool_vector )") BoolVector.cNamespace().element_size = cwrapper.prototype("int bool_vector_element_size( bool_vector )") -BoolVector.cNamespace().count_equal = cwrapper.prototype("int bool_vector_count_equal( bool_vector, bool)") BoolVector.cNamespace().permute = cwrapper.prototype("void bool_vector_permute(bool_vector, permutation_vector)") BoolVector.cNamespace().sort_perm = cwrapper.prototype("permutation_vector_obj bool_vector_alloc_sort_perm(bool_vector)") @@ -125,3 +146,6 @@ def createActiveList(cls, mask): BoolVector.cNamespace().active_list = cwrapper.prototype("int_vector_obj bool_vector_alloc_active_list(bool_vector)") BoolVector.cNamespace().contains = cwrapper.prototype("bool bool_vector_contains(bool_vector, bool)") BoolVector.cNamespace().select_unique = cwrapper.prototype("void bool_vector_select_unique(bool_vector)") +BoolVector.cNamespace().element_sum = cwrapper.prototype("bool bool_vector_sum(bool_vector)") +BoolVector.cNamespace().get_data_ptr = cwrapper.prototype("bool* bool_vector_get_ptr(bool_vector)") +BoolVector.cNamespace().count_equal = cwrapper.prototype("int bool_vector_count_equal(bool_vector, bool)") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/ctime.py b/ThirdParty/Ert/devel/python/python/ert/util/ctime.py index 637f39fc9a..11498654e5 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/ctime.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/ctime.py @@ -71,7 +71,7 @@ def __gt__(self, other): elif isinstance(other, (int, datetime.datetime, datetime.date)): return self > CTime(other) else: - raise TypeError("CTIme does not support type: %s" % other.__class__) + raise TypeError("CTime does not support type: %s" % other.__class__) def __lt__(self, other): if isinstance(other, CTime): @@ -79,7 +79,7 @@ def __lt__(self, other): elif isinstance(other, (int, datetime.datetime, datetime.date)): return self < CTime(other) else: - raise TypeError("CTIme does not support type: %s" % other.__class__) + raise TypeError("CTime does not support type: %s" % other.__class__) def __ne__(self, other): return not self == other @@ -92,7 +92,7 @@ def __eq__(self, other): elif isinstance(other, type(None)): return False else: - raise TypeError("CTIme does not support type: %s" % other.__class__) + raise TypeError("CTime does not support type: %s" % other.__class__) def __imul__(self, other): value = int(self.value() * other) diff --git a/ThirdParty/Ert/devel/python/python/ert/util/double_vector.py b/ThirdParty/Ert/devel/python/python/ert/util/double_vector.py index cf33e7ff90..dfc0422252 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/double_vector.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/double_vector.py @@ -70,3 +70,7 @@ def __init__(self, default_value=0, initial_size=0): DoubleVector.cNamespace().rsort_perm = cwrapper.prototype("permutation_vector_obj double_vector_alloc_rsort_perm(double_vector)") DoubleVector.cNamespace().contains = cwrapper.prototype("bool double_vector_contains(double_vector, double)") DoubleVector.cNamespace().select_unique = cwrapper.prototype("void double_vector_select_unique(double_vector)") +DoubleVector.cNamespace().element_sum = cwrapper.prototype("double double_vector_sum(double_vector)") +DoubleVector.cNamespace().get_data_ptr = cwrapper.prototype("double* double_vector_get_ptr(double_vector)") +DoubleVector.cNamespace().count_equal = cwrapper.prototype("int double_vector_count_equal(double_vector, double)") +DoubleVector.cNamespace().init_range = cwrapper.prototype("void double_vector_init_range(double_vector, double , double , double)") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/enums/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/util/enums/CMakeLists.txt index da1c0dd254..a1f96b233e 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/enums/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/util/enums/CMakeLists.txt @@ -3,6 +3,7 @@ set(PYTHON_SOURCES rng_alg_type_enum.py rng_init_mode_enum.py ui_return_status_enum.py + llsq_result_enum.py ) add_python_package("python.ert.util.enums" ${PYTHON_INSTALL_PREFIX}/ert/util/enums "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/devel/python/python/ert/util/enums/__init__.py b/ThirdParty/Ert/devel/python/python/ert/util/enums/__init__.py index 297e4da3c1..831c99dabb 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/enums/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/enums/__init__.py @@ -1,3 +1,4 @@ from .rng_init_mode_enum import RngInitModeEnum from .rng_alg_type_enum import RngAlgTypeEnum from .ui_return_status_enum import UIReturnStatusEnum +from .llsq_result_enum import LLSQResultEnum diff --git a/ThirdParty/Ert/devel/python/python/ert/util/enums/llsq_result_enum.py b/ThirdParty/Ert/devel/python/python/ert/util/enums/llsq_result_enum.py new file mode 100644 index 0000000000..623602ac53 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/util/enums/llsq_result_enum.py @@ -0,0 +1,17 @@ +from ert.cwrap import BaseCEnum +from ert.util import UTIL_LIB + + +class LLSQResultEnum(BaseCEnum): + LLSQ_SUCCESS = None + LLSQ_INVALID_DIM = None + LLSQ_UNDETERMINED = None + + +LLSQResultEnum.addEnum("LLSQ_SUCCESS" , 0) +LLSQResultEnum.addEnum("LLSQ_INVALID_DIM" , 1) +LLSQResultEnum.addEnum("LLSQ_UNDETERMINED" , 2) + +LLSQResultEnum.registerEnum(UTIL_LIB, "llsq_result_enum") + + diff --git a/ThirdParty/Ert/devel/python/python/ert/util/install_abort_signals.py b/ThirdParty/Ert/devel/python/python/ert/util/install_abort_signals.py new file mode 100644 index 0000000000..bb5b0d65a8 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/util/install_abort_signals.py @@ -0,0 +1,9 @@ +from ert.util import UTIL_LIB +from ert.cwrap import CWrapper + +def installAbortSignals(): + install_signals() + + +cwrapper = CWrapper(UTIL_LIB) +install_signals = cwrapper.prototype("void util_install_signals()") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/int_vector.py b/ThirdParty/Ert/devel/python/python/ert/util/int_vector.py index edde72daf3..86362269de 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/int_vector.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/int_vector.py @@ -84,7 +84,6 @@ def count(self, value): IntVector.cNamespace().set_default = cwrapper.prototype("void int_vector_set_default( int_vector , int)") IntVector.cNamespace().get_default = cwrapper.prototype("int int_vector_get_default( int_vector )") IntVector.cNamespace().element_size = cwrapper.prototype("int int_vector_element_size( int_vector )") -IntVector.cNamespace().count_equal = cwrapper.prototype("int int_vector_count_equal( int_vector, int)") IntVector.cNamespace().create_active_list = cwrapper.prototype("int_vector_obj string_util_alloc_active_list( char* )") IntVector.cNamespace().permute = cwrapper.prototype("void int_vector_permute(int_vector, permutation_vector)") @@ -92,5 +91,9 @@ def count(self, value): IntVector.cNamespace().rsort_perm = cwrapper.prototype("permutation_vector_obj int_vector_alloc_rsort_perm(int_vector)") IntVector.cNamespace().contains = cwrapper.prototype("bool int_vector_contains(int_vector, int)") IntVector.cNamespace().select_unique = cwrapper.prototype("void int_vector_select_unique(int_vector)") +IntVector.cNamespace().element_sum = cwrapper.prototype("int int_vector_sum(int_vector)") +IntVector.cNamespace().get_data_ptr = cwrapper.prototype("int* int_vector_get_ptr(int_vector)") +IntVector.cNamespace().count_equal = cwrapper.prototype("int int_vector_count_equal(int_vector, int)") +IntVector.cNamespace().init_range = cwrapper.prototype("void int_vector_init_range(int_vector, int , int , int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/matrix.py b/ThirdParty/Ert/devel/python/python/ert/util/matrix.py index 7b8572b432..c83ce3e105 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/matrix.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/matrix.py @@ -38,6 +38,17 @@ def __init__(self, rows, columns , value = 0): self.setAll(value) + def __str__(self): + s = "" + for i in range(self.rows()): + s += "[" + for j in range(self.columns()): + d = Matrix.cNamespace().iget(self, i,j) + s += "%6.3g " % d + s += "]\n" + return s + + def __getitem__(self, index_tuple): if not 0 <= index_tuple[0] < self.rows(): raise IndexError("Expected 0 <= %d < %d" % (index_tuple[0], self.rows())) @@ -58,6 +69,10 @@ def __setitem__(self, index_tuple, value): return Matrix.cNamespace().iset(self, index_tuple[0], index_tuple[1], value) + def dims(self): + return (Matrix.cNamespace().rows(self) , Matrix.cNamespace().columns(self)) + + def rows(self): """ @rtype: int """ return Matrix.cNamespace().rows(self) @@ -86,11 +101,28 @@ def scaleRow(self, row , factor): def setAll(self , value): Matrix.cNamespace().set_all(self, value) + def copyColumn(self , target_column , src_column): + columns = self.columns() + if not 0 <= src_column < columns: + raise ValueError("src column:%d invalid" % src_column) + + if not 0 <= target_column < columns: + raise ValueError("target column:%d invalid" % target_column) + + if src_column != target_column: + # The underlying C function accepts column copy between matrices. + Matrix.cNamespace().copy_column(self, self , target_column , src_column) + + def prettyPrint(self, name, fmt="%6.3g"): Matrix.cNamespace().pretty_print(self, name, fmt) + def randomInit(self , rng): + Matrix.cNamespace().random_init(self, rng) + + def free(self): Matrix.cNamespace().free(self) @@ -109,11 +141,13 @@ def free(self): Matrix.cNamespace().set_all = cwrapper.prototype("void matrix_scalar_set( matrix , double)") Matrix.cNamespace().scale_column = cwrapper.prototype("void matrix_scale_column(matrix , int , double)") Matrix.cNamespace().scale_row = cwrapper.prototype("void matrix_scale_row(matrix , int , double)") +Matrix.cNamespace().copy_column = cwrapper.prototype("void matrix_copy_column(matrix , matrix , int , int)") Matrix.cNamespace().rows = cwrapper.prototype("int matrix_get_rows(matrix)") Matrix.cNamespace().columns = cwrapper.prototype("int matrix_get_columns(matrix)") Matrix.cNamespace().equal = cwrapper.prototype("bool matrix_equal(matrix, matrix)") Matrix.cNamespace().pretty_print = cwrapper.prototype("void matrix_pretty_print(matrix, char*, char*)") +Matrix.cNamespace().random_init = cwrapper.prototype("void matrix_random_init(matrix, rng)") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/profiler.py b/ThirdParty/Ert/devel/python/python/ert/util/profiler.py new file mode 100644 index 0000000000..0493689bfc --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/util/profiler.py @@ -0,0 +1,28 @@ +import StringIO +import cProfile +import pstats +import sys + + +class Profiler(object): + + __profiler = None + """ :type: Profile """ + + @classmethod + def startProfiler(cls, subcalls=True, builtins=True): + cls.__profiler = cProfile.Profile() + cls.__profiler.enable(subcalls=subcalls, builtins=builtins) + + @classmethod + def stopProfiler(cls, sort_method="cumulative"): + if cls.__profiler is not None: + cls.__profiler.disable() + stream = StringIO.StringIO() + stats_printer = pstats.Stats(cls.__profiler, stream=stream).sort_stats(sort_method) + stats_printer.print_stats() + cls.__profiler = None + print(stream.getvalue()) + else: + sys.stderr.write("WARNING: Profiler has not been started!\n") + diff --git a/ThirdParty/Ert/devel/python/python/ert/util/rng.py b/ThirdParty/Ert/devel/python/python/ert/util/rng.py index 1373b1b826..536a67ded3 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/rng.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/rng.py @@ -20,20 +20,36 @@ from ert.util.enums import RngInitModeEnum from ert.util.enums import RngAlgTypeEnum - - class RandomNumberGenerator(BaseCClass): - def __init__(self, alg_type, init_mode): + def __init__(self, alg_type = RngAlgTypeEnum.MZRAN , init_mode = RngInitModeEnum.INIT_CLOCK): assert isinstance(alg_type, RngAlgTypeEnum) assert isinstance(init_mode, RngInitModeEnum) c_ptr = RandomNumberGenerator.cNamespace().rng_alloc(alg_type, init_mode) super(RandomNumberGenerator, self).__init__(c_ptr) + + def stateSize(self): + return RandomNumberGenerator.cNamespace().state_size(self) + + + def setState(self , seed_string): + state_size = self.stateSize() + if len(seed_string) < state_size: + raise ValueError("The seed string must be at least %d characters long" % self.stateSize()) + RandomNumberGenerator.cNamespace().set_state(self , seed_string) + + def getDouble(self): """ @rtype: float """ return RandomNumberGenerator.cNamespace().get_double(self) + + def getInt(self): + """ @rtype: float """ + return RandomNumberGenerator.cNamespace().get_int(self) + + def free(self): RandomNumberGenerator.cNamespace().free(self) @@ -48,3 +64,6 @@ def free(self): RandomNumberGenerator.cNamespace().rng_alloc = cwrapper.prototype("c_void_p rng_alloc(rng_alg_type_enum, rng_init_mode_enum)") RandomNumberGenerator.cNamespace().free = cwrapper.prototype("void rng_free(rng)") RandomNumberGenerator.cNamespace().get_double = cwrapper.prototype("double rng_get_double(rng)") +RandomNumberGenerator.cNamespace().get_int = cwrapper.prototype("int rng_get_int(rng)") +RandomNumberGenerator.cNamespace().state_size = cwrapper.prototype("int rng_state_size(rng)") +RandomNumberGenerator.cNamespace().set_state = cwrapper.prototype("void rng_set_state(rng , char*)") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/stat.py b/ThirdParty/Ert/devel/python/python/ert/util/stat.py index 8342491faf..d32b79d33d 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/stat.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/stat.py @@ -16,6 +16,8 @@ from ert.util import UTIL_LIB +from ert.util import Matrix +from ert.util import LLSQResultEnum from ert.cwrap import CWrapper, CWrapperNameSpace @@ -27,8 +29,55 @@ def quantile_sorted( data, q ): return cfunc.quantile_sorted(data, q) +def polyfit(n,x,y,s = None): + if isinstance(x,Matrix): + xm = x + else: + xm = Matrix( len(x) , 1 ) + for i in range(len(x)): + xm[i,0] = x[i] + + if isinstance(y,Matrix): + ym = y + else: + ym = Matrix( len(y) , 1 ) + for i in range(len(y)): + ym[i,0] = y[i] + + if s: + if isinstance(s , Matrix): + sm = s + else: + sm = Matrix( len(s) , 1 ) + for i in range(len(s)): + sm[i,0] = s[i] + else: + sm = s + + + beta = Matrix( n , 1 ) + res = cfunc.polyfit( beta , xm , ym , sm) + + if not res == LLSQResultEnum.LLSQ_SUCCESS: + raise Exception("Linear Least Squares Estimator failed?") + + l = [] + for i in range(n): + l.append( beta[i,0] ) + + return tuple(l) + + + + + + + + cwrapper = CWrapper(UTIL_LIB) cfunc = CWrapperNameSpace("stat") cfunc.quantile = cwrapper.prototype("double statistics_empirical_quantile( double_vector , double )") cfunc.quantile_sorted = cwrapper.prototype("double statistics_empirical_quantile( double_vector , double )") +cfunc.polyfit = cwrapper.prototype("llsq_result_enum matrix_stat_polyfit(matrix , matrix , matrix , matrix)") + diff --git a/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py b/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py index 15591bf901..143dfcae8d 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py @@ -156,13 +156,14 @@ def pop(self): def append(self, s): """ - Appends a new string @s to list. + Appends a new string @s to list. If the input argument is not a + string the string representation will be appended. """ if isinstance(s, StringType): StringList.cNamespace().append(self, s) else: - sys.exit("Type mismatch") - + StringList.cNamespace().append(self, str(s)) + @property def strings(self): diff --git a/ThirdParty/Ert/devel/python/python/ert/util/substitution_list.py b/ThirdParty/Ert/devel/python/python/ert/util/substitution_list.py index 380c3a34fc..bca5d3bbf2 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/substitution_list.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/substitution_list.py @@ -14,19 +14,42 @@ def addItem(self, key, value, doc_string=""): SubstitutionList.cNamespace().append_copy(self, key, value, doc_string) - def __getitem__(self, index): - if not isinstance(index, int): + def __getitem__(self, index_or_key): + if not isinstance(index_or_key, int): raise IndexError("Index must be a number!") - if index < 0 or index >= len(self): + if index_or_key < 0 or index_or_key >= len(self): raise IndexError("Index must be in the range: [%i, %i]" % (0, len(self) - 1)) - key = SubstitutionList.cNamespace().get_key(self, index) - value = SubstitutionList.cNamespace().get_value(self, index) - doc_string = SubstitutionList.cNamespace().get_doc_string(self, index) + key = SubstitutionList.cNamespace().get_key(self, index_or_key) + value = SubstitutionList.cNamespace().get_value(self, index_or_key) + doc_string = SubstitutionList.cNamespace().get_doc_string(self, index_or_key) return key, value, doc_string + def __iter__(self): + index = 0 + while index < len(self): + yield self[index] + index += 1 + + def __contains__(self, key): + for kw, value, doc in self: + if key == kw: + return True + return False + + def indexForKey(self, key): + if not key in self: + raise KeyError("Key '%s' not in substitution list!" % key) + + for index, key_val_doc in enumerate(self): + if key == key_val_doc[0]: + return index + + return None # Should never happen! + + def free(self): SubstitutionList.cNamespace().free(self) diff --git a/ThirdParty/Ert/devel/python/python/ert/util/time_vector.py b/ThirdParty/Ert/devel/python/python/ert/util/time_vector.py index aa2e6f67a8..133a82bb87 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/time_vector.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/time_vector.py @@ -129,7 +129,9 @@ def createRegular(cls , start , end , deltaString): return timeVector - + + def getDataPtr(self): + raise NotImplementedError("The getDataPtr() function is not implemented for time_t vectors") ################################################################# @@ -180,3 +182,6 @@ def createRegular(cls , start , end , deltaString): TimeVector.cNamespace().rsort_perm = cwrapper.prototype("permutation_vector_obj time_t_vector_alloc_rsort_perm(time_t_vector)") TimeVector.cNamespace().contains = cwrapper.prototype("bool time_t_vector_contains(time_t_vector, time_t)") TimeVector.cNamespace().select_unique = cwrapper.prototype("void time_t_vector_select_unique(time_t_vector)") +TimeVector.cNamespace().element_sum = cwrapper.prototype("time_t time_t_vector_sum(time_t_vector)") +TimeVector.cNamespace().count_equal = cwrapper.prototype("int time_t_vector_count_equal(time_t_vector, time_t)") +TimeVector.cNamespace().init_range = cwrapper.prototype("void time_t_vector_init_range(time_t_vector, time_t , time_t , time_t)") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/vector_template.py b/ThirdParty/Ert/devel/python/python/ert/util/vector_template.py index df4786632c..2cee2212df 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/vector_template.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/vector_template.py @@ -522,3 +522,28 @@ def asList(self): def selectUnique(self): self.cNamespace().select_unique(self) + + def elementSum(self): + return self.cNamespace().element_sum( self ) + + + def getDataPtr(self): + "Low level function which returns a pointer to underlying storage" + # Observe that the get_data_ptr() function is not implemented + # for the TimeVector class. + return self.cNamespace().get_data_ptr(self) + + def countEqual(self , value): + return self.cNamespace().count_equal( self , value ) + + + def initRange(self , min_value , max_value , delta): + """ + Will fill the vector with the values from min_value to + max_value in steps of delta. The upper limit is guaranteed to + be inclusive, even if it is not commensurable with the delta. + """ + if delta == 0: + raise ValueError("Invalid range") + else: + self.cNamespace().init_range( self , min_value , max_value , delta ) diff --git a/ThirdParty/Ert/devel/python/python/ert/util/version.py b/ThirdParty/Ert/devel/python/python/ert/util/version.py index c000a6779a..7f2bd657c1 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/version.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/version.py @@ -2,9 +2,78 @@ from ert.util import UTIL_LIB +def cmp_method(method): + + def cmp_wrapper(self , other): + if not isinstance(other , Version): + other = Version(other[0] , other[1] , other[2]) + + return method(self , other) + + return cmp_wrapper + + class Version(object): __namespace = CNamespace("Version") + def __init__(self , major , minor , micro): + self.major = major + self.minor = minor + self.micro = micro + try: + self.micro_int = int(micro) + self.is_devel = False + except ValueError: + self.micro_int = -1 + self.is_devel = True + + + def isDevelVersion(self): + return self.is_devel + + + def versionString(self): + return "%d.%d.%s" % (self.major , self.minor , self.micro) + + + def versionTuple(self): + return (self.major , self.minor , self.micro) + + def __cmpTuple(self): + return (self.major , self.minor , self.micro_int) + + def __str__(self): + return self.versionString() + + @cmp_method + def __eq__(self , other): + return self.versionTuple() == other.versionTuple() + + def __ne__(self , other): + return not (self == other) + + # All development versions are compared with micro version == -1; + # i.e. the two versions Version(1,2,"Alpha") and + # Version(1,2,"Beta") compare as equal in the >= and <= tests - + # but not in the == test. + + @cmp_method + def __ge__(self , other): + return self.__cmpTuple() >= other.__cmpTuple() + + @cmp_method + def __lt__(self , other): + return not (self >= other) + + @cmp_method + def __le__(self , other): + return self.__cmpTuple() <= other.__cmpTuple() + + @cmp_method + def __gt__(self , other): + return not (self <= other) + + @classmethod def getBuildTime(cls): return Version.cNamespace().build_time() @@ -17,9 +86,19 @@ def getGitCommit(cls, short=False): return Version.cNamespace().git_commit_short() + @classmethod + def currentVersion(cls): + major = Version.cNamespace().major_version() + minor = Version.cNamespace().minor_version() + micro = Version.cNamespace().micro_version() + return Version( major , minor , micro ) + + @classmethod def getVersion(cls): - return Version.cNamespace().ert_version() + v = cls.currentVersion( ) + return v.versionString( ) + @classmethod def cNamespace(cls): @@ -31,4 +110,7 @@ def cNamespace(cls): Version.cNamespace().build_time = cwrapper.prototype("char* version_get_build_time()") Version.cNamespace().git_commit = cwrapper.prototype("char* version_get_git_commit()") Version.cNamespace().git_commit_short = cwrapper.prototype("char* version_get_git_commit_short()") -Version.cNamespace().ert_version = cwrapper.prototype("char* version_get_ert_version()") \ No newline at end of file +Version.cNamespace().major_version = cwrapper.prototype("int version_get_major_ert_version()") +Version.cNamespace().minor_version = cwrapper.prototype("int version_get_minor_ert_version()") +Version.cNamespace().micro_version = cwrapper.prototype("char* version_get_micro_ert_version()") +Version.cNamespace().is_devel = cwrapper.prototype("bool version_is_ert_devel_version()") diff --git a/ThirdParty/Ert/devel/python/python/ert/well/__init__.py b/ThirdParty/Ert/devel/python/python/ert/well/__init__.py index 7f5f0b2144..a8ee5bef10 100644 --- a/ThirdParty/Ert/devel/python/python/ert/well/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert/well/__init__.py @@ -1,4 +1,7 @@ import ert.cwrap.clib as clib +import ert.util +import ert.geo +import ert.ecl ECL_WELL_LIB = clib.ert_load("libecl_well") diff --git a/ThirdParty/Ert/devel/python/python/ert/well/well_type_enum.py b/ThirdParty/Ert/devel/python/python/ert/well/well_type_enum.py index 05767027ae..4fe6026dfb 100644 --- a/ThirdParty/Ert/devel/python/python/ert/well/well_type_enum.py +++ b/ThirdParty/Ert/devel/python/python/ert/well/well_type_enum.py @@ -2,16 +2,16 @@ from ert.well import ECL_WELL_LIB class WellTypeEnum(BaseCEnum): - UNDOCUMENTED_ZERO = None - PRODUCER = None - WATER_INJECTOR = None - GAS_INJECTOR = None - OIL_INJECTOR = None + ERT_UNDOCUMENTED_ZERO = None + ERT_PRODUCER = None + ERT_WATER_INJECTOR = None + ERT_GAS_INJECTOR = None + ERT_OIL_INJECTOR = None -WellTypeEnum.addEnum("UNDOCUMENTED_ZERO", 0) -WellTypeEnum.addEnum("PRODUCER", 10) -WellTypeEnum.addEnum("WATER_INJECTOR", 22) -WellTypeEnum.addEnum("GAS_INJECTOR", 21) -WellTypeEnum.addEnum("OIL_INJECTOR", 78) +WellTypeEnum.addEnum("ERT_UNDOCUMENTED_ZERO", 0) +WellTypeEnum.addEnum("ERT_PRODUCER", 10) +WellTypeEnum.addEnum("ERT_WATER_INJECTOR", 22) +WellTypeEnum.addEnum("ERT_GAS_INJECTOR", 21) +WellTypeEnum.addEnum("ERT_OIL_INJECTOR", 78) WellTypeEnum.registerEnum(ECL_WELL_LIB, "well_type_enum") \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert_gui/CMakeLists.txt index bb20ba911a..f119b0ad23 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert_gui/CMakeLists.txt @@ -13,18 +13,9 @@ add_python_package("python.ert_gui" ${PYTHON_INSTALL_PREFIX}/ert_gui "${PYTHON_ add_subdirectory(ide) add_subdirectory(models) add_subdirectory(pages) +add_subdirectory(shell) add_subdirectory(simulation) add_subdirectory(tools) add_subdirectory(viewer) add_subdirectory(widgets) -#----------------------------------------------------------------- - -set(site_config_target "${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ert_gui/site_config.py") -set(destination "${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}/ert_gui") -set(install_target "${destination}/site_config.py") - -configure_file(site_config.py.in ${site_config_target}) -install(FILES ${site_config_target} DESTINATION ${destination} ) -install(CODE "execute_process(COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc_file ${install_target})") - diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/__init__.py b/ThirdParty/Ert/devel/python/python/ert_gui/__init__.py index a6170de391..0f47f5e5a5 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/__init__.py @@ -1,12 +1,9 @@ import sys import warnings -ABSOLUTE_REQUIRED_VERSION_HEX = 0x02060000 -WARNING_REQUIRED_VERSION_HEX = 0x02070000 +REQUIRED_VERSION_HEX = 0x02070000 -if sys.hexversion < ABSOLUTE_REQUIRED_VERSION_HEX: - raise Exception("ERT GUI Python requires at least version 2.6 of Python") +if sys.hexversion < REQUIRED_VERSION_HEX: + raise Exception("ERT GUI Python requires at least version 2.7 of Python") -# if sys.hexversion < WARNING_REQUIRED_VERSION_HEX: -# warnings.warn("To get optimal graphical performance you should use Python 2.7") diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/gert_main.py b/ThirdParty/Ert/devel/python/python/ert_gui/gert_main.py index 81376fa4fb..db2a86090e 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/gert_main.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/gert_main.py @@ -121,6 +121,7 @@ from ert_gui.ert_splash import ErtSplash from ert_gui.models import ErtConnector from ert_gui.pages.summary_panel import SummaryPanel +from ert_gui.tools.plugins import PluginHandler from ert_gui.simulation.simulation_panel import SimulationPanel from ert_gui.tools import HelpCenter @@ -130,6 +131,7 @@ from ert_gui.tools.manage_cases import ManageCasesTool from ert_gui.tools.plot import PlotTool from ert_gui.tools.export import ExportTool +from ert_gui.tools.plugins import PluginsTool from ert_gui.tools.workflows import WorkflowsTool from ert_gui.widgets import util @@ -171,15 +173,6 @@ def ert(self): def main(argv): - try: - import site_config - site_config_file = site_config.config_file - except ImportError: - site_config_file = None - - if os.getenv("ERT_SITE_CONFIG"): - site_config_file = os.getenv("ERT_SITE_CONFIG") - app = QApplication(argv) #Early so that QT is initialized before other imports app.setWindowIcon(util.resourceIcon("application/window_icon_cutout")) @@ -242,20 +235,23 @@ def main(argv): now = time.time() - ert = Ert(EnKFMain(config_file, site_config = site_config_file, strict=strict)) + ert = Ert(EnKFMain(config_file, strict=strict)) ErtConnector.setErt(ert.ert()) window = GertMainWindow() window.setWidget(SimulationPanel()) + plugin_handler = PluginHandler(ert.ert(), ert.ert().getWorkflowList().getPluginJobs(), window) + help_tool = HelpTool("ERT", window) window.addDock("Configuration Summary", SummaryPanel(), area=Qt.BottomDockWidgetArea) window.addTool(IdeTool(os.path.basename(config_file), ert.reloadERT, help_tool)) window.addTool(PlotTool()) window.addTool(ExportTool()) - window.addTool(WorkflowsTool(ert.reloadERT)) + window.addTool(WorkflowsTool()) window.addTool(ManageCasesTool()) + window.addTool(PluginsTool(plugin_handler)) window.addTool(LoadResultsTool()) window.addTool(help_tool) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/CMakeLists.txt index 2d04a160be..e95326ab5b 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/CMakeLists.txt @@ -6,6 +6,7 @@ set(PYTHON_SOURCES float_argument.py integer_argument.py keyword_definition.py + number_list_string_argument.py path_argument.py percent_argument.py proper_name_argument.py @@ -15,5 +16,5 @@ set(PYTHON_SOURCES string_argument.py ) -add_python_package("python.ert_gui.ide.keywords.definitions" ${PYTHON_INSTALL_PREFIX}/ert_gui/ide/keywords/definitions "${PYTHON_SOURCES}" True) +add_python_package("python.ert_gui.ide.keywords.definitions" ${PYTHON_INSTALL_PREFIX}/ert_gui/ide/keywords/definitions "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/__init__.py b/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/__init__.py index a0ca018085..aac0683937 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/__init__.py @@ -9,6 +9,7 @@ from .proper_name_format_argument import ProperNameFormatArgument from .proper_name_format_string_argument import ProperNameFormatStringArgument from .range_string_argument import RangeStringArgument +from .number_list_string_argument import NumberListStringArgument from .argument_definition import ArgumentDefinition from .keyword_definition import KeywordDefinition diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/number_list_string_argument.py b/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/number_list_string_argument.py new file mode 100644 index 0000000000..6f5d245fda --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/ide/keywords/definitions/number_list_string_argument.py @@ -0,0 +1,43 @@ +import re +from ert_gui.ide.keywords.definitions import ArgumentDefinition + + +class NumberListStringArgument(ArgumentDefinition): + + NOT_A_VALID_NUMBER_LIST_STRING = "The input should be of the type: <b><pre>\n\t23,5.5,11,1.01,3\n</pre></b>i.e. numeric values separated by commas." + VALUE_NOT_A_NUMBER = "The value: '%s' is not a number." + + PATTERN = re.compile("^[0-9\.\-+, \t]+$") + + def __init__(self, **kwargs): + super(NumberListStringArgument, self).__init__(**kwargs) + + def validate(self, token): + validation_status = super(NumberListStringArgument, self).validate(token) + + if not validation_status: + return validation_status + else: + match = NumberListStringArgument.PATTERN.match(token) + + if match is None: + validation_status.setFailed() + validation_status.addToMessage(NumberListStringArgument.NOT_A_VALID_NUMBER_LIST_STRING) + else: + + groups = token.split(",") + + for group in groups: + group = group.strip() + + if len(group) > 0: + try: + num = float(group.strip()) + except ValueError: + validation_status.setFailed() + validation_status.addToMessage(NumberListStringArgument.VALUE_NOT_A_NUMBER % group) + + + validation_status.setValue(token) + + return validation_status diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/main_window.py b/ThirdParty/Ert/devel/python/python/ert_gui/main_window.py index 7625ba4146..ccecd82500 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/main_window.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/main_window.py @@ -1,5 +1,5 @@ from PyQt4.QtCore import QSettings, Qt -from PyQt4.QtGui import QMainWindow, qApp, QWidget, QVBoxLayout, QDockWidget, QAction +from PyQt4.QtGui import QMainWindow, qApp, QWidget, QVBoxLayout, QDockWidget, QAction, QToolButton from ert_gui.about_dialog import AboutDialog @@ -51,6 +51,10 @@ def addTool(self, tool): self.tools[tool.getName()] = tool self.toolbar.addAction(tool.getAction()) + if tool.isPopupMenu(): + tool_button = self.toolbar.widgetForAction(tool.getAction()) + tool_button.setPopupMode(QToolButton.InstantPopup) + def __createMenu(self): file_menu = self.menuBar().addMenu("&File") diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/init/case_list.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/init/case_list.py index 1f6f3fc13c..340dc7a97a 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/init/case_list.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/init/case_list.py @@ -18,9 +18,9 @@ def addItem(self, value): self.observable().notify(ListModelMixin.LIST_CHANGED_EVENT) - def getAllCasesWithData(self): + def getAllCasesWithDataAndNotRunning(self): cases = self.getList() - cases_with_data = [] + cases_with_data_and_not_running = [] for case in cases: case_has_data = False state_map = self.ert().getEnkfFsManager().getStateMapForCase(case) @@ -29,10 +29,10 @@ def getAllCasesWithData(self): if state == RealizationStateEnum.STATE_HAS_DATA: case_has_data = True - if case_has_data: - cases_with_data.append(case) + if case_has_data and not self.ert().getEnkfFsManager().isCaseRunning(case): + cases_with_data_and_not_running.append(case) - return cases_with_data + return cases_with_data_and_not_running def getCaseRealizationStates(self, case_name): diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/plot/report_steps.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/plot/report_steps.py index 7b6450c933..20887a4b1c 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/plot/report_steps.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/plot/report_steps.py @@ -15,7 +15,7 @@ def __init__(self): def getReportSteps(self): """ @rtype: TimeMap """ if self.__time_map is None: - case_list = CaseList().getAllCasesWithData() + case_list = CaseList().getAllCasesWithDataAndNotRunning() for case in case_list: time_map = self.ert().getEnkfFsManager().getTimeMapForCase(case) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/active_realizations_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/active_realizations_model.py index 2935532672..845ba3c68f 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/active_realizations_model.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/active_realizations_model.py @@ -41,7 +41,7 @@ def getDefaultValue(self): def getActiveRealizationsMask(self): count = EnsembleSizeModel().getValue() - mask = BoolVector.active_mask(self.getValue()) + mask = BoolVector.createActiveMask(self.getValue()) if mask is None: raise ValueError("Error while parsing range string!") diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/sensitivity_study_parameters_is_included_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/sensitivity_study_parameters_is_included_model.py index 39a372d5f1..50990ceda9 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/sensitivity_study_parameters_is_included_model.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/connectors/run/sensitivity_study_parameters_is_included_model.py @@ -25,5 +25,5 @@ def isTrue(self): return self.__model.getIsIncluded(self.__parameter_name) - def setTrue(self, is_included): + def setState(self, is_included): self.__model.setIsIncluded(self.__parameter_name, is_included) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/boolean_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/boolean_model.py index 09c3e5254c..13951b43db 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/boolean_model.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/boolean_model.py @@ -12,6 +12,6 @@ def isTrue(self): """ @rtype: bool """ raise AbstractMethodError(self, "isTrue") - def setTrue(self, value): + def setState(self, value): raise AbstractMethodError(self, "setTrue") diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/CMakeLists.txt index d9b1bdd087..f48937f005 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/CMakeLists.txt @@ -1,7 +1,11 @@ set(PYTHON_SOURCES __init__.py + default_boolean_model.py + default_name_format_model.py + default_path_model.py function_button_model.py + string_model.py ) -add_python_package("python.ert_gui.models.mixins.connectorless" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/mixins/connectorless "${PYTHON_SOURCES}" True) +add_python_package("python.ert_gui.models.mixins.connectorless" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/mixins/connectorless "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/__init__.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/__init__.py index d0ae835fc2..1e4cbfe915 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/__init__.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/__init__.py @@ -1 +1,5 @@ -from .function_button_model import FunctionButtonModel \ No newline at end of file +from .function_button_model import FunctionButtonModel +from .default_path_model import DefaultPathModel +from .default_boolean_model import DefaultBooleanModel +from .string_model import StringModel +from .default_name_format_model import DefaultNameFormatModel diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_boolean_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_boolean_model.py new file mode 100644 index 0000000000..b2454b711f --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_boolean_model.py @@ -0,0 +1,20 @@ +from ert_gui.models.mixins import BooleanModelMixin + + +class DefaultBooleanModel(BooleanModelMixin): + + def __init__(self, state=True): + self.__state = state + super(DefaultBooleanModel, self).__init__() + + def setState(self, value): + self.__state = value + self.observable().notify(self.BOOLEAN_VALUE_CHANGED_EVENT) + + def isTrue(self): + """ @rtype: bool """ + return self.__state + + + + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_name_format_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_name_format_model.py new file mode 100644 index 0000000000..b34afafc76 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_name_format_model.py @@ -0,0 +1,22 @@ +from ert_gui.models.mixins import BasicModelMixin + + +class DefaultNameFormatModel(BasicModelMixin): + def __init__(self, default_name_format="default_%d"): + self.__default_name_format = default_name_format + self.__name_format = default_name_format + super(DefaultNameFormatModel, self).__init__() + + + def getValue(self): + """ @rtype: str """ + return self.__name_format + + + def setValue(self, name_format): + if name_format is None or name_format.strip() == "" or name_format == self.__default_name_format: + self.__name_format = self.__default_name_format + else: + self.__name_format = name_format + + self.observable().notify(self.VALUE_CHANGED_EVENT) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_path_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_path_model.py new file mode 100644 index 0000000000..f42642b27c --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/default_path_model.py @@ -0,0 +1,50 @@ +from ert_gui.models.mixins import PathModelMixin + + +class DefaultPathModel (PathModelMixin): + def __init__(self, default_path, is_required=True, must_be_a_directory=False, must_be_a_file=True, must_exist=False, must_be_absolute=False, must_be_executable=False): + self.__path = default_path + super(DefaultPathModel, self).__init__() + + self.path_is_required = is_required + self.path_must_be_a_directory = must_be_a_directory + self.path_must_be_a_file = must_be_a_file + self.path_must_be_executable = must_be_executable + self.path_must_exist = must_exist + self.path_must_be_absolute = must_be_absolute + + + def pathIsRequired(self): + """ @rtype: bool """ + return self.path_is_required + + def pathMustBeADirectory(self): + """ @rtype: bool """ + return self.path_must_be_a_directory + + def pathMustBeAFile(self): + """ @rtype: bool """ + return self.path_must_be_a_file + + def pathMustBeExecutable(self): + """ @rtype: bool """ + return self.path_must_be_executable + + def pathMustExist(self): + """ @rtype: bool """ + return self.path_must_exist + + def pathMustBeAbsolute(self): + """ @rtype: bool """ + return self.path_must_be_absolute + + def getPath(self): + """ @rtype: str """ + return self.__path + + def setPath(self, value): + """ + @type value: str + """ + self.__path = value + self.observable().notify(self.PATH_CHANGED_EVENT) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/string_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/string_model.py new file mode 100644 index 0000000000..a8a2ef0ce4 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/connectorless/string_model.py @@ -0,0 +1,20 @@ +from ert_gui.models.mixins import BasicModelMixin + + +class StringModel(BasicModelMixin): + + def __init__(self, value = ""): + self.__value = value + super(StringModel , self).__init__() + + def setValue(self, value): + self.__value = value + self.observable().notify(self.VALUE_CHANGED_EVENT) + + def getValue(self): + """ @rtype: str """ + return self.__value + + + + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/model.py b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/model.py index fd9d55c280..c48b2a4ca6 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/model.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/models/mixins/model.py @@ -6,11 +6,11 @@ def __init__(self, obj, function_name): class ModelMixin(object): - def __init__(self, *args): + def __init__(self, *args, **kwargs): pass # print("%s init" % self.__class__.__name__) - def __new__(cls, *args): + def __new__(cls, *args, **kwargs): # print("Construct: %s" % cls.__name__) obj = super(ModelMixin, cls).__new__(cls) obj.__observable = Observable(cls.__name__) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/pages/run_dialog.py b/ThirdParty/Ert/devel/python/python/ert_gui/pages/run_dialog.py index 10ce2451b0..dc37053900 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/pages/run_dialog.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/pages/run_dialog.py @@ -3,6 +3,7 @@ from PyQt4.QtGui import QDialog, QVBoxLayout, QLayout, QMessageBox, QPushButton, QHBoxLayout, QColor, QLabel from ert_gui.models.connectors.run import SimulationsTracker from ert_gui.models.mixins.run_model import RunModelMixin +from ert_gui.tools.plot.plot_tool import PlotTool from ert_gui.widgets import util from ert_gui.widgets.legend import Legend from ert_gui.widgets.progress import Progress @@ -56,6 +57,11 @@ def __init__(self, run_model): self.running_time = QLabel("") + self.plot_tool = PlotTool() + self.plot_tool.setParent(self) + self.plot_button = QPushButton(self.plot_tool.getName()) + self.plot_button.clicked.connect(self.plot_tool.trigger) + self.kill_button = QPushButton("Kill simulations") self.done_button = QPushButton("Done") self.done_button.setHidden(True) @@ -76,6 +82,7 @@ def __init__(self, run_model): button_layout.addWidget(self.processing_animation) button_layout.addWidget(self.running_time) button_layout.addStretch() + button_layout.addWidget(self.plot_button) button_layout.addWidget(self.kill_button) button_layout.addWidget(self.done_button) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert_gui/shell/CMakeLists.txt new file mode 100644 index 0000000000..026580a845 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/CMakeLists.txt @@ -0,0 +1,25 @@ +set(PYTHON_SOURCES + __init__.py + analysis_module.py + cases.py + custom_kw_keys.py + debug.py + ertshell.py + gen_data_keys.py + gen_kw_keys.py + observations.py + plot_settings.py + plugins.py + results.py + shell_context.py + shell_function.py + shell_plot.py + shell_tools.py + simulations.py + smoother.py + summary_keys.py + workflows.py +) + +add_python_package("python.ert_gui.shell" ${PYTHON_INSTALL_PREFIX}/ert_gui/shell "${PYTHON_SOURCES}" True) + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/__init__.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/__init__.py new file mode 100644 index 0000000000..d75f55d025 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/__init__.py @@ -0,0 +1,9 @@ +from .shell_tools import autoCompleteList, extractFullArgument, getPossibleFilenameCompletions, pathify, createParameterizedHelpFunction, autoCompleteListWithSeparator, matchItems +from .shell_function import ShellFunction, assertConfigLoaded + +from .plot_settings import PlotSettings +from .shell_plot import ShellPlot + +from .shell_context import ShellContext + +from .ertshell import ErtShell diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/analysis_module.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/analysis_module.py new file mode 100644 index 0000000000..a2b242ba26 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/analysis_module.py @@ -0,0 +1,93 @@ +from ert_gui.shell import ShellFunction, assertConfigLoaded, extractFullArgument, autoCompleteListWithSeparator, matchItems + + +class AnalysisModule(ShellFunction): + def __init__(self, shell_context): + super(AnalysisModule, self).__init__("analysis_module", shell_context) + + self.addHelpFunction("current", None, "Shows the current analysis module.") + self.addHelpFunction("list", None, "Shows a list of the available analysis modules.") + self.addHelpFunction("options", None, "Shows a list of the available options for the current analysis module.") + self.addHelpFunction("select", "<analysis_module>", "Select an analysis module.") + self.addHelpFunction("set", "<variable_name> <value>", "Set a variable value.") + + + @assertConfigLoaded + def do_current(self, args): + analysis_module = self.ert().analysisConfig().activeModuleName() + print("Analysis Module set to: %s" % analysis_module) + + @assertConfigLoaded + def do_list(self, args): + items = self.getAnalysisModules() + self.columnize(items) + + def getAnalysisModules(self): + analysis_modules = self.ert().analysisConfig().getModuleList() + items = [analysis_module for analysis_module in analysis_modules] + return items + + @assertConfigLoaded + def do_select(self, line): + keys = matchItems(line, self.getAnalysisModules()) + + if len(keys) == 0 or len(keys) > 1: + self.lastCommandFailed("Must enter a single valid Analysis Module") + + analysis_module_name = list(keys)[0] + self.ert().analysisConfig().selectModule(analysis_module_name) + + @assertConfigLoaded + def complete_select(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.getAnalysisModules()) + + @assertConfigLoaded + def do_variables(self, args): + active_module = self.ert().analysisConfig().getActiveModule() + variables = active_module.getVariableNames() + + format = " %-20s %-6s %-20s %s" + print(format % ("Name", "Type", "Value", "Description")) + + for variable_name in variables: + variable_type = active_module.getVariableType(variable_name).__name__ + variable_value = active_module.getVariableValue(variable_name) + variable_description = active_module.getVariableDescription(variable_name) + print(format % (variable_name, variable_type, variable_value, variable_description)) + + + @assertConfigLoaded + def do_set(self, line): + arguments = self.splitArguments(line) + + if len(arguments) > 1: + active_module = self.ert().analysisConfig().getActiveModule() + variables = active_module.getVariableNames() + variable, argument = line.split(" ", 1) + + if not variable in variables: + self.lastCommandFailed("Variable with name: %s, not available in analysis module!" % variable) + else: + variable_type = active_module.getVariableType(variable) + try: + value = variable_type(argument) + active_module.setVar(variable, argument) + except ValueError: + self.lastCommandFailed("Unable to convert '%s' into to a: %s" % (argument, variable_type.__name__)) + + else: + self.lastCommandFailed("This keyword requires a variable name and a value.") + + + + @assertConfigLoaded + def complete_set(self, text, line, begidx, endidx): + arguments = self.splitArguments(line) + + if len(arguments) > 2 or len(arguments) == 2 and not text: + return [] + + active_module = self.ert().analysisConfig().getActiveModule() + variables = active_module.getVariableNames() + return autoCompleteListWithSeparator(text, variables) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/cases.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/cases.py new file mode 100644 index 0000000000..9cc5f87efc --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/cases.py @@ -0,0 +1,107 @@ +from ert_gui.shell import ShellFunction, autoCompleteList, assertConfigLoaded + + +class Cases(ShellFunction): + def __init__(self, shell_context): + super(Cases, self).__init__("case", shell_context) + + self.addHelpFunction("list", None, "Shows a list of all available cases.") + self.addHelpFunction("select", "<case_name>", "Change the current file system to the named case.") + self.addHelpFunction("create", "<case_name>", "Create a new case with the specified named.") + self.addHelpFunction("summary_key_set", None, "Shows a list of the stored summary keys.") + self.addHelpFunction("state", "[case_name]", "Shows a list of the states of the individual realizations. " + "Uses the current case if no case name is provided.") + self.addHelpFunction("time_map", "[case_name]", "Shows a list of the time/report steps of the case. " + "Uses the current case if no case name is provided.") + + @assertConfigLoaded + def do_list(self, line): + fs_list = self.getFileSystemNames() + current_fs = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + max_length = max([len(fs) for fs in fs_list]) + case_format = "%1s %-" + str(max_length) + "s %s" + for fs in fs_list: + current = "" + if fs == current_fs: + current = "*" + + state = "No Data" + if self.ert().getEnkfFsManager().caseHasData(fs): + state = "Data" + + print(case_format % (current, fs, state)) + + def getFileSystemNames(self): + return sorted([fs for fs in self.ert().getEnkfFsManager().getCaseList()]) + + + @assertConfigLoaded + def do_select(self, case_name): + case_name = case_name.strip() + if case_name in self.getFileSystemNames(): + fs = self.ert().getEnkfFsManager().getFileSystem(case_name) + self.ert().getEnkfFsManager().switchFileSystem(fs) + else: + self.lastCommandFailed("Unknown case '%s'" % case_name) + + @assertConfigLoaded + def complete_select(self, text, line, begidx, endidx): + return autoCompleteList(text, self.getFileSystemNames()) + + + @assertConfigLoaded + def do_create(self, line): + arguments = self.splitArguments(line) + + if len(arguments) == 1: + case_name = arguments[0] + if case_name not in self.getFileSystemNames(): + fs = self.ert().getEnkfFsManager().getFileSystem(case_name) + self.ert().getEnkfFsManager().switchFileSystem(fs) + else: + self.lastCommandFailed("Case '%s' already exists!" % case_name) + else: + self.lastCommandFailed("Expected one argument: <case_name> received: '%s'" % line) + + @assertConfigLoaded + def do_summary_key_set(self, line): + fs = self.ert().getEnkfFsManager().getCurrentFileSystem() + key_set = sorted([key for key in fs.getSummaryKeySet().keys()]) + self.columnize(key_set) + + @assertConfigLoaded + def do_state(self, case_name): + case_name = case_name.strip() + if not case_name: + case_name = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + elif not case_name in self.getFileSystemNames(): + self.lastCommandFailed("Unknown case name '%s'" % case_name) + return False + + state_map = self.ert().getEnkfFsManager().getStateMapForCase(case_name) + states = ["%d: %s" % (index, state) for index, state in enumerate(state_map)] + + self.columnize(states) + + @assertConfigLoaded + def complete_state(self, text, line, begidx, endidx): + return autoCompleteList(text, self.getFileSystemNames()) + + @assertConfigLoaded + def do_time_map(self, case_name): + case_name = case_name.strip() + if not case_name: + case_name = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + elif not case_name in self.getFileSystemNames(): + self.lastCommandFailed("Unknown case name '%s'" % case_name) + return False + + time_map = self.ert().getEnkfFsManager().getTimeMapForCase(case_name) + report_steps = ["%d: %s" % (index, report_step_time) for index, report_step_time in enumerate(time_map)] + + self.columnize(report_steps) + + @assertConfigLoaded + def complete_time_map(self, text, line, begidx, endidx): + return autoCompleteList(text, self.getFileSystemNames()) + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/custom_kw_keys.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/custom_kw_keys.py new file mode 100644 index 0000000000..b65f7a0ced --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/custom_kw_keys.py @@ -0,0 +1,53 @@ +from ert.enkf import ErtImplType, CustomKWConfig, EnkfStateType, RealizationStateEnum +from ert.enkf.data.enkf_node import EnkfNode +from ert.enkf.export.custom_kw_collector import CustomKWCollector +from ert.enkf.node_id import NodeId +from ert.util import BoolVector +from ert_gui.shell import ShellFunction, assertConfigLoaded, extractFullArgument, autoCompleteListWithSeparator +from ert_gui.shell.shell_tools import matchItems + + +class CustomKWKeys(ShellFunction): + def __init__(self, shell_context): + super(CustomKWKeys, self).__init__("custom_kw", shell_context) + self.addHelpFunction("list", None, "List all CustomKW keys.") + self.addHelpFunction("print", "<key>", "Print all realization data for the specified key.") + + + def fetchSupportedKeys(self): + custom_kw_keys = self.ert().ensembleConfig().getKeylistFromImplType(ErtImplType.CUSTOM_KW) + + keys = [] + for name in custom_kw_keys: + enkf_config_node = self.ert().ensembleConfig().getNode(name) + custom_kw_config = enkf_config_node.getModelConfig() + assert isinstance(custom_kw_config, CustomKWConfig) + + for key in custom_kw_config: + keys.append("%s:%s" % (name, key)) + + return keys + + @assertConfigLoaded + def do_list(self, line): + self.columnize(self.fetchSupportedKeys()) + + + @assertConfigLoaded + def do_print(self, line): + keys = matchItems(line, self.fetchSupportedKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one CustomKW key") + return False + + case_name = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + + data = CustomKWCollector.loadAllCustomKWData(self.ert(), case_name, keys) + print(data) + + + @assertConfigLoaded + def complete_print(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.fetchSupportedKeys()) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/debug.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/debug.py new file mode 100644 index 0000000000..54eee75d37 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/debug.py @@ -0,0 +1,34 @@ +from ert_gui.shell import ShellFunction, assertConfigLoaded + + +class Debug(ShellFunction): + def __init__(self, shell_context): + super(Debug, self).__init__("debug", shell_context) + self.addHelpFunction("last_plugin_result", None, "Shows the last plugin result.") + self.addHelpFunction("eval", "<Python expression>", "Evaluate a Python expression. " + "The last plugin result is defined as: x") + + shell_context["debug"] = self + self.__last_plugin_result = None + self.__local_variables = {} + + + def setLastPluginResult(self, result): + self.__last_plugin_result = result + + def do_last_plugin_result(self, line): + print("Last plugin result: %s" % self.__last_plugin_result) + + def do_eval(self, line): + line = line.strip() + + if len(line) > 0: + self.__local_variables["x"] = self.__last_plugin_result + try: + exec(line, self.__local_variables) + except Exception as e: + print("Error: The expression caused an exception!") + print(e) + else: + print("Error: A python expression is required!") + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/ertshell.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/ertshell.py new file mode 100644 index 0000000000..82155e57d8 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/ertshell.py @@ -0,0 +1,167 @@ +import atexit +from cmd import Cmd +import readline +import os + +from ert.enkf import EnKFMain +from ert_gui.shell.analysis_module import AnalysisModule +from ert_gui.shell.custom_kw_keys import CustomKWKeys +from ert_gui.shell.debug import Debug +from ert_gui.shell.cases import Cases +from ert_gui.shell.gen_data_keys import GenDataKeys +from ert_gui.shell.gen_kw_keys import GenKWKeys +from ert_gui.shell.results import Results +from ert_gui.shell.plugins import Plugins +from ert_gui.shell.simulations import Simulations +from ert_gui.shell.smoother import Smoother +from ert_gui.shell.summary_keys import SummaryKeys +from ert_gui.shell.workflows import Workflows +from ert_gui.shell.observations import Observations +from ert_gui.shell import extractFullArgument, getPossibleFilenameCompletions, PlotSettings, ShellContext + +import matplotlib + + +class ErtShell(Cmd): + prompt = "--> " + intro = " :::::::::::::::::::::::::::::::::::::\n" \ + " :: ::\n" \ + " :: ______ ______ _______ ::\n" \ + " :: | ____| | __ \ |__ __| ::\n" \ + " :: | |__ | |__) | | | ::\n" \ + " :: | __| | _ / | | ::\n" \ + " :: | |____ | | \ \ | | ::\n" \ + " :: |______| |_| \_\ |_| ::\n" \ + " :: ::\n" \ + " :: Ensemble based Reservoir Tool ::\n" \ + " :::::::::::::::::::::::::::::::::::::\n" \ + "\n" \ + "Interactive shell for working with ERT.\n" \ + "\n" \ + "-- Type help for a list of supported commands.\n" \ + "-- Type exit or press Ctrl+D to end the shell session.\n" \ + "-- Press Tab for auto completion.\n" \ + "-- Arrow up/down for history.\n" + + + def __init__(self, forget_history=False): + Cmd.__init__(self) + + shell_context = ShellContext(self) + self.__shell_context = shell_context + + if not forget_history: + self.__history_file = os.path.join(os.path.expanduser("~/.ertshell/ertshell.history")) + self.__init_history() + else: + self.__history_file = None + + matplotlib.rcParams["backend"] = "Qt4Agg" + matplotlib.rcParams["interactive"] = True + matplotlib.rcParams["mathtext.default"] = "regular" + matplotlib.rcParams["verbose.level"] = "helpful" + matplotlib.rcParams["verbose.fileo"] = "sys.stderr" + + + try: + matplotlib.style.use("ggplot") # available from version 1.4 + except AttributeError: + pass + + Debug(shell_context) + PlotSettings(shell_context) + Workflows(shell_context) + Cases(shell_context) + Plugins(shell_context) + SummaryKeys(shell_context) + GenDataKeys(shell_context) + GenKWKeys(shell_context) + Results(shell_context) + Simulations(shell_context) + CustomKWKeys(shell_context) + AnalysisModule(shell_context) + Smoother(shell_context) + Observations(shell_context) + + self.__last_command_failed = False + + + def __init_history(self): + try: + readline.set_history_length(100) + readline.read_history_file(self.__history_file) + except IOError: + pass + atexit.register(self.__save_history) + + def __save_history(self): + if self.__history_file is not None: + if not os.path.exists(os.path.dirname(self.__history_file)): + os.makedirs(os.path.dirname(self.__history_file)) + + readline.write_history_file(self.__history_file) + + def emptyline(self): + pass + + def do_load_config(self, config_file): + if os.path.exists(config_file) and os.path.isfile(config_file): + self.shellContext().setErt(EnKFMain(config_file)) + else: + self.lastCommandFailed("Config file '%s' not found!\n" % config_file) + + def complete_load_config(self, text, line, begidx, endidx): + argument = extractFullArgument(line, endidx) + return getPossibleFilenameCompletions(argument) + + + def help_load_config(self): + print("\n".join(("load_config config_file", + " Loads a config file."))) + + def do_cwd(self, line): + cwd = os.getcwd() + print("Current directory: %s" % cwd) + + def help_cwd(self): + print("Show the current directory.") + + def do_exit(self, line): + if self.shellContext().ert() is not None: + self.shellContext().ert().free() + return True + + def help_exit(self): + return "\n".join(("exit", + " End the shell session.")), + + do_EOF = do_exit + + def help_EOF(self): + return "\n".join(("EOF", + " The same as exit. (Ctrl+D)")), + + def shellContext(self): + return self.__shell_context + + def default(self, line): + Cmd.default(self, line) + self.__last_command_failed = True + + def precmd(self, line): + self.__last_command_failed = False + return Cmd.precmd(self, line) + + def invokeCommand(self, line): + self.__last_command_failed = False + self.onecmd(line) + return not self.__last_command_failed + + def lastCommandFailed(self, message): + print("Error: %s" % message) + self.__last_command_failed = True + + + + + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/gen_data_keys.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/gen_data_keys.py new file mode 100644 index 0000000000..457d01f5a0 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/gen_data_keys.py @@ -0,0 +1,94 @@ +from ert.enkf import ErtImplType, EnkfObservationImplementationType +from ert.enkf.export import GenDataCollector +from ert.enkf.export.gen_data_observation_collector import GenDataObservationCollector +from ert_gui.shell import ShellFunction, extractFullArgument, autoCompleteListWithSeparator, ShellPlot, \ + assertConfigLoaded +from ert_gui.shell.shell_tools import matchItems + + +class GenDataKeys(ShellFunction): + def __init__(self, shell_context): + super(GenDataKeys, self).__init__("gen_data", shell_context) + self.addHelpFunction("list", None, "Shows a list of all available gen_data keys.") + self.addHelpFunction("plot", "<key_1> [key_2..key_n]", "Plot the specified key(s).") + self.addHelpFunction("print", "<key_1> [key_2..key_n]", "Print the values for the specified key(s).") + + + def fetchSupportedKeys(self): + gen_data_keys = self.ert().ensembleConfig().getKeylistFromImplType(ErtImplType.GEN_DATA) + gen_data_list = [] + for key in gen_data_keys: + enkf_config_node = self.ert().ensembleConfig().getNode(key) + gen_data_config = enkf_config_node.getDataModelConfig() + + for report_step in range(self.ert().getHistoryLength() + 1): + if gen_data_config.hasReportStep(report_step): + gen_data_list.append("%s@%d" % (key, report_step)) + + return gen_data_list + + + @assertConfigLoaded + def do_list(self, line): + keys = sorted(self.fetchSupportedKeys()) + + self.columnize(keys) + + + @assertConfigLoaded + def do_plot(self, line): + keys = matchItems(line, self.fetchSupportedKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one GenData key") + return False + + case_list = self.shellContext()["plot_settings"].getCurrentPlotCases() + + for key in keys: + key, report_step = key.split("@", 1) + report_step = int(report_step) + plot = ShellPlot("%s at report step: %d" %(key, report_step)) + for case_name in case_list: + data = GenDataCollector.loadGenData(self.ert(), case_name, key, report_step) + + if not data.empty: + plot.plotGenData(data, legend_label=case_name) + + obs_key = GenDataObservationCollector.getObservationKeyForDataKey(self.ert(), key, report_step) + + if obs_key is not None: + obs_data = GenDataObservationCollector.loadGenDataObservations(self.ert(), case_name, [obs_key]) + + if not obs_data.empty: + plot.plotObservations(obs_data, obs_key) + + plot.showLegend() + + + @assertConfigLoaded + def complete_plot(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.fetchSupportedKeys()) + + @assertConfigLoaded + def do_print(self, line): + keys = matchItems(line, self.fetchSupportedKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one GenData key") + return False + + case_name = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + + for key in keys: + key, report_step = key.split("@", 1) + report_step = int(report_step) + data = GenDataCollector.loadGenData(self.ert(), case_name, key, report_step) + print(data) + + + @assertConfigLoaded + def complete_print(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.fetchSupportedKeys()) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/gen_kw_keys.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/gen_kw_keys.py new file mode 100644 index 0000000000..6c732918a9 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/gen_kw_keys.py @@ -0,0 +1,89 @@ +from ert.enkf.export.gen_kw_collector import GenKwCollector +from ert_gui.shell import ShellFunction, extractFullArgument, autoCompleteListWithSeparator, ShellPlot, \ + assertConfigLoaded +from ert_gui.shell.shell_tools import matchItems + + +class GenKWKeys(ShellFunction): + def __init__(self, shell_context): + super(GenKWKeys, self).__init__("gen_kw", shell_context) + self.addHelpFunction("list", None, "Shows a list of all available gen_kw keys.") + self.addHelpFunction("histogram", "<key_1> [key_2..key_n]", "Plot the histogram for the specified key(s).") + self.addHelpFunction("density", "<key_1> [key_2..key_n]", "Plot the density for the specified key(s).") + self.addHelpFunction("print", "<key_1> [key_2..key_n]", "Print the values for the specified key(s).") + + + def fetchSupportedKeys(self): + return GenKwCollector.getAllGenKwKeys(self.ert()) + + @assertConfigLoaded + def do_list(self, line): + keys = sorted(self.fetchSupportedKeys()) + + self.columnize(keys) + + @assertConfigLoaded + def do_histogram(self, line): + keys = matchItems(line, self.fetchSupportedKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one GenKW key") + return False + + case_list = self.shellContext()["plot_settings"].getCurrentPlotCases() + + for key in keys: + for case_name in case_list: + data = GenKwCollector.loadAllGenKwData(self.ert(), case_name, [key]) + if not data.empty: + plot = ShellPlot(key) + plot.histogram(data, key, log_on_x=key.startswith("LOG10_")) + + @assertConfigLoaded + def complete_histogram(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.fetchSupportedKeys()) + + + @assertConfigLoaded + def do_density(self, line): + keys = matchItems(line, self.fetchSupportedKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one GenKW key") + return False + + case_list = self.shellContext()["plot_settings"].getCurrentPlotCases() + + for key in keys: + plot = ShellPlot(key) + for case_name in case_list: + data = GenKwCollector.loadAllGenKwData(self.ert(), case_name, [key]) + + if not data.empty: + plot.density(data, key, legend_label=case_name) + plot.showLegend() + + @assertConfigLoaded + def complete_density(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.fetchSupportedKeys()) + + @assertConfigLoaded + def do_print(self, line): + keys = matchItems(line, self.fetchSupportedKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one GenKW key") + return False + + case_name = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + + data = GenKwCollector.loadAllGenKwData(self.ert(), case_name, keys) + print(data) + + + @assertConfigLoaded + def complete_print(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.fetchSupportedKeys()) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/observations.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/observations.py new file mode 100644 index 0000000000..fc7bf15345 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/observations.py @@ -0,0 +1,33 @@ +import os +from ert_gui.shell import ShellFunction, assertConfigLoaded, extractFullArgument, getPossibleFilenameCompletions + + +class Observations(ShellFunction): + def __init__(self, shell_context): + super(Observations, self).__init__("observations", shell_context) + self.addHelpFunction("list", None, "List all observation keys.") + self.addHelpFunction("clear", None, "Remove all observations.") + self.addHelpFunction("load", "<observations_file>", "Add observations from the specified file.") + + @assertConfigLoaded + def do_list(self, line): + keys = [obs_vector.getObservationKey() for obs_vector in self.shellContext().ert().getObservations()] + print("Observation keys:") + self.columnize(keys) + + + @assertConfigLoaded + def do_clear(self, line): + self.shellContext().ert().getObservations().clear() + + @assertConfigLoaded + def do_load(self, config_file): + if os.path.exists(config_file) and os.path.isfile(config_file): + self.shellContext().ert().getObservations().load(config_file) + else: + self.lastCommandFailed("Observations file '%s' not found!\n" % config_file) + + @assertConfigLoaded + def complete_load(self, text, line, begidx, endidx): + argument = extractFullArgument(line, endidx) + return getPossibleFilenameCompletions(argument) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/plot_settings.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/plot_settings.py new file mode 100644 index 0000000000..641f8592b0 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/plot_settings.py @@ -0,0 +1,86 @@ +from ert_gui.shell import ShellFunction, assertConfigLoaded, autoCompleteList, extractFullArgument, \ + getPossibleFilenameCompletions + + +class PlotSettings(ShellFunction): + + def __init__(self, shell_context): + super(PlotSettings, self).__init__("plot_settings", shell_context) + + self.__cases = None + + self.addHelpFunction("path", None, "Shows the currently selected output path for plots.") + self.addHelpFunction("set_path", "<path>", "Sets the plot output path.") + self.addHelpFunction("current", None, "Shows the selected plot source cases.") + self.addHelpFunction("select", "[case_1..case_n]", "Select one or more cases as default plot sources. " + "Empty resets to current case.") + + shell_context["plot_settings"] = self + + def getCurrentPlotCases(self): + """ @rtype: list of str """ + + if self.__cases is None: + case_name = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + return [case_name] + + return self.__cases + + @assertConfigLoaded + def do_current(self, line): + keys = sorted(self.getCurrentPlotCases()) + self.columnize(keys) + + + @assertConfigLoaded + def do_select(self, line): + case_names = self.splitArguments(line) + + possible_cases = self.getAllCaseList() + cases = [] + for case_name in case_names: + if case_name in possible_cases: + cases.append(case_name) + else: + self.lastCommandFailed("Unknown case '%s'" % case_name) + + if len(cases) > 0: + self.__cases = cases + else: + self.__cases = None + + + @assertConfigLoaded + def complete_select(self, text, line, begidx, endidx): + return autoCompleteList(text, self.getAllCaseList()) + + + def getAllCaseList(self): + fs_manager = self.ert().getEnkfFsManager() + all_case_list = fs_manager.getCaseList() + all_case_list = [case for case in all_case_list] + return all_case_list + + + @assertConfigLoaded + def do_path(self, line): + path = self.ert().plotConfig().getPath() + print("Plot path: %s" % path) + + @assertConfigLoaded + def do_set_path(self, line): + arguments = self.splitArguments(line) + + if len(arguments) == 1: + path = arguments[0] + self.ert().plotConfig().setPath(path) + elif len(arguments) > 1: + self.lastCommandFailed("Can only set one path. If you require spaces in your path, surround it with quotes: \"path with space\".") + else: + self.lastCommandFailed("A path is required!") + + + @assertConfigLoaded + def complete_set_path(self, text, line, begidx, endidx): + argument = extractFullArgument(line, endidx) + return getPossibleFilenameCompletions(argument) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/plugins.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/plugins.py new file mode 100644 index 0000000000..009513350a --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/plugins.py @@ -0,0 +1,165 @@ +import inspect +from ert.job_queue import ErtScript, CancelPluginException +from ert_gui.shell import ShellFunction, assertConfigLoaded, autoCompleteList + + +class Plugins(ShellFunction): + def __init__(self, shell_context): + super(Plugins, self).__init__("plugins", shell_context) + + self.addHelpFunction("list", None, "Shows a list of all available plugins.") + self.addHelpFunction("run", "<plugin_name> [args]", "Run a named plugin with either arguments or default input GUI.") + self.addHelpFunction("arguments", "<plugin_name>", "Shows a list of expected arguments for a specified plugin.") + self.addHelpFunction("help", "<plugin_name>", "Shows help for the specified plugin if available.") + + @assertConfigLoaded + def do_list(self, line): + plugins = self.getPluginNames() + if len(plugins) > 0: + self.columnize(plugins) + else: + print("No plugins available.") + + + @assertConfigLoaded + def do_run(self, line): + arguments = self.splitArguments(line) + + if len(arguments) < 1: + print("Error: This keyword requires a name of a plugin to run.") + else: + plugin_name = arguments[0] + plugin_job = self.getWorkflowJob(plugin_name) + + if plugin_job is not None: + try: + script = self.getScript(plugin_job) + if len(arguments) > 1: + arguments = arguments[1:] + else: + arguments = script.getArguments(None) + result = plugin_job.run(self.ert(), arguments) + + self.shellContext()["debug"].setLastPluginResult(result) + + print(result) + except CancelPluginException: + print("Plugin cancelled before execution!") + else: + self.lastCommandFailed("Unknown plugin: '%s'" % plugin_name) + + + @assertConfigLoaded + def complete_run(self, text, line, begidx, endidx): + arguments = self.splitArguments(line) + + if len(arguments) > 2 or len(arguments) == 2 and not text: + return [] + return autoCompleteList(text, self.getPluginNames()) + + + @assertConfigLoaded + def do_arguments(self, plugin_name): + plugin_job = self.getWorkflowJob(plugin_name) + + if plugin_job is not None: + script, arguments = self.getScriptAndArguments(plugin_job) + + if len(arguments) > 1: + print("The plugin: '%s' takes the following required <...> and/or optional [...] arguments:\n" % plugin_name) + arguments_format = " %-25s %-35s %-20s" + print(arguments_format % ("Arguments", "Default Value", "Type")) + + for argument in arguments: + + if not argument["optional"]: + argument_format = "<%s>" + else: + argument_format = "[%s]" + + print(arguments_format % (argument_format % argument["name"], argument["default"], argument["type"].__name__)) + else: + print("Plugin has no arguments.") + else: + self.lastCommandFailed("Unknown plugin: '%s'" % plugin_name) + + @assertConfigLoaded + def complete_arguments(self, text, line, begidx, endidx): + arguments = self.splitArguments(line) + + if len(arguments) > 2 or len(arguments) == 2 and not text: + return [] + return autoCompleteList(text, self.getPluginNames()) + + + @assertConfigLoaded + def do_help(self, line): + arguments = self.splitArguments(line) + + if len(arguments) < 1: + self.lastCommandFailed("This keyword requires a name of a plugin to run.") + else: + plugin_name = arguments[0] + plugin_job = self.getWorkflowJob(plugin_name) + + if plugin_job is not None: + script = self.getScript(plugin_job) + + print(script.__doc__) + else: + self.lastCommandFailed("Unknown plugin: '%s'" % plugin_name) + + + @assertConfigLoaded + def complete_help(self, text, line, begidx, endidx): + arguments = self.splitArguments(line) + + if len(arguments) > 2 or len(arguments) == 2 and not text: + return [] + return autoCompleteList(text, self.getPluginNames()) + + def getPluginNames(self): + plugin_jobs = self.ert().getWorkflowList().getPluginJobs() + return [plugin.name() for plugin in plugin_jobs] + + + def getWorkflowJob(self, plugin_name): + """ @rtype: WorkflowJob """ + plugin_name = plugin_name.strip() + plugin_jobs = self.ert().getWorkflowList().getPluginJobs() + plugin_job = next((job for job in plugin_jobs if job.name() == plugin_name), None) + return plugin_job + + + def getScript(self, plugin_job): + script_obj = ErtScript.loadScriptFromFile(plugin_job.getInternalScriptPath()) + script = script_obj(self.ert()) + return script + + def getScriptAndArguments(self, plugin_job): + script = self.getScript(plugin_job) + arg_spec = inspect.getargspec(script.run) + + arguments = [] + + if len(arg_spec.args) > 1: + + for argument_name, argument_type in zip(arg_spec.args[1:], plugin_job.argumentTypes()): + arguments.append({ + "name": argument_name, + "type": argument_type, + "default": "", + "optional": False + }) + + if arg_spec.defaults is not None: + for index, value in enumerate(reversed(arg_spec.defaults)): + arguments[len(arguments) - 1 - index]["default"] = value + + min_arg_count = plugin_job.minimumArgumentCount() + + for index, argument in enumerate(arguments): + if index >= min_arg_count: + argument["optional"] = True + + return script, arguments diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/results.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/results.py new file mode 100644 index 0000000000..f1f1f4dd21 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/results.py @@ -0,0 +1,50 @@ +from ert.util import BoolVector +from ert_gui.shell import ShellFunction, assertConfigLoaded + + +class Results(ShellFunction): + def __init__(self, shell_context): + super(Results, self).__init__("results", shell_context) + + self.addHelpFunction("runpath", None, "Shows the current runpath.") + self.addHelpFunction("load", "<realizations>", "Load results from the specified realizations.") #todo iterations + + @assertConfigLoaded + def do_runpath(self, args): + runpath = self.ert().getModelConfig().getRunpathAsString() + print("Runpath set to: %s" % runpath) + + + @assertConfigLoaded + def do_load(self, args): + arguments = self.splitArguments(args) + + if len(arguments) < 1: + self.lastCommandFailed("Loading requires a realization mask.") + return False + + realization_count = self.ert().getEnsembleSize() + + mask = BoolVector(False, realization_count) + mask_success = BoolVector.updateActiveMask(arguments[0], mask) + + if not mask_success: + self.lastCommandFailed("The realization mask: '%s' is not valid." % arguments[0]) + return False + + fs = self.ert().getEnkfFsManager().getCurrentFileSystem() + self.ert().loadFromForwardModel(mask, 0, fs) + + + @assertConfigLoaded + def complete_load(self, text, line, begidx, endidx): + arguments = self.splitArguments(line) + + if len(arguments) > 2 or len(arguments) == 2 and not text: + return [] + + if not text: + return ["0-%d" % self.ert().getEnsembleSize()] # todo should generate based on realization directories. + + return [] + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_context.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_context.py new file mode 100644 index 0000000000..f66027d826 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_context.py @@ -0,0 +1,34 @@ +class ShellContext(object): + def __init__(self, shell): + super(ShellContext, self).__init__() + + self.__shell = shell + """ :type: Cmd """ + + self.__ert = None + """ :type: EnKFMain """ + + self.__settings = {} + + + def ert(self): + """ @rtype: ert.enkf.enkf_main.EnKFMain """ + return self.__ert + + def setErt(self, ert): + """ @type ert: ert.enkf.enkf_main.EnKFMain """ + if self.__ert is not None: + self.__ert.free() + self.__ert = None + + self.__ert = ert + + def shell(self): + """ @rtype: ErtShell """ + return self.__shell + + def __setitem__(self, key, value): + self.__settings[key] = value + + def __getitem__(self, key): + return self.__settings[key] \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_function.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_function.py new file mode 100644 index 0000000000..a512aa4eb0 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_function.py @@ -0,0 +1,158 @@ +from math import floor +import shlex +import textwrap +from ert_gui.shell import createParameterizedHelpFunction, autoCompleteList + +def assertConfigLoaded(func): + def wrapper(self, *args, **kwargs): + # prefixes should be either do_ or complete_ + if func.__name__.startswith("complete_"): + result = [] + verbose = False + else: + result = False + verbose = True + + if self.isConfigLoaded(verbose=verbose): + result = func(self, *args, **kwargs) + + return result + + wrapper.__doc__ = func.__doc__ + wrapper.__name__ = func.__name__ + + return wrapper + + +class ShellFunction(object): + command_help_message = "The command: '%s' supports the following keywords:" + + def __init__(self, name, shell_context): + super(ShellFunction, self).__init__() + self.__shell_context = shell_context + """ :type: ert_gui.shell.ShellContext """ + self.name = name + """ :type: str """ + + setattr(self.shellContext().shell().__class__, "do_%s" % name, self.doKeywords) + setattr(self.shellContext().shell().__class__, "complete_%s" % name, self.completeKeywords) + setattr(self.shellContext().shell().__class__, "help_%s" % name, self.helpKeywords) + + def shellContext(self): + """ :rtype: ShellContext """ + return self.__shell_context + + def ert(self): + """ @rtype: ert.enkf.enkf_main.EnKFMain """ + return self.__shell_context.ert() + + def isConfigLoaded(self, verbose=True): + """ @rtype: bool """ + if self.ert() is None: + if verbose: + print("Error: A config file has not been loaded!") + return False + return True + + def addHelpFunction(self, function_name, parameter, help_message): + setattr(self.__class__, "help_%s" % function_name, createParameterizedHelpFunction(parameter, help_message)) + + def findKeywords(self): + return [name[3:] for name in dir(self.__class__) if name.startswith("do_")] + + def helpKeywords(self): + print(self.command_help_message % self.name) + keywords = self.findKeywords() + keyword_column_width = self.widthAsPercentageOfConsoleWidth(20) + parameter_column_width = self.widthAsPercentageOfConsoleWidth(30) + help_column_width = self.widthAsPercentageOfConsoleWidth(48) + help_format = " %-" + str(keyword_column_width) + "s %-" + str(parameter_column_width) + "s %-" + str(help_column_width) + "s" + print(help_format % ("Keyword", "Parameter(s)", "Help")) + + for keyword in keywords: + message = "No help available!" + parameters = None + if hasattr(self, "help_%s" % keyword): + func = getattr(self, "help_%s" % keyword) + parameters, message = func() + + message = textwrap.wrap(message, help_column_width) + print(help_format % (keyword, parameters, message[0])) + + if len(message) > 1: + for line in message[1:]: + print(help_format % ("", "", line)) + + + def completeKeywords(self, text, line, begidx, endidx): + arguments = shlex.split(line) + assert arguments[0] == self.name + + line = line[len(self.name) + 1:] + begidx = begidx - len(self.name) + 1 + endidx = endidx - len(self.name) + 1 + keyword, sep, arguments = line.partition(' ') + + if begidx >= len(keyword) and keyword in self.findKeywords(): + if hasattr(self, "complete_%s" % keyword): + func = getattr(self, "complete_%s" % keyword) + return func(text, line, begidx, endidx) + else: + return [] + else: + return autoCompleteList(text, self.findKeywords()) + + def doKeywords(self, line): + keyword, sep, arguments = line.partition(' ') + + if hasattr(self, "do_%s" % keyword): + func = getattr(self, "do_%s" % keyword) + return func(arguments) + else: + self.lastCommandFailed("Unknown keyword: '%s'" % keyword) + + def splitArguments(self, line): + """ @rtype: list of str """ + return shlex.split(line) + + def columnize(self, items): + self.shellContext().shell().columnize(items, self.getTerminalSize()[0]) + + + def widthAsPercentageOfConsoleWidth(self, percentage): + width, height = self.getTerminalSize() + return int(floor(percentage * width / 100.0)) + + + def getTerminalSize(self): + """ + @rtype: tuple of (int,int) + @return: Console dimensions as: width, height + """ + import os + env = os.environ + + def ioctl_GWINSZ(fd): + try: + import fcntl, termios, struct, os + cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) + except: + return + return cr + + cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) + + if not cr: + try: + fd = os.open(os.ctermid(), os.O_RDONLY) + cr = ioctl_GWINSZ(fd) + os.close(fd) + except: + pass + + if not cr: + cr = (env.get('LINES', 25), env.get('COLUMNS', 80)) + return int(cr[1]), int(cr[0]) + + def lastCommandFailed(self, message): + self.shellContext().shell().lastCommandFailed(message) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_plot.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_plot.py new file mode 100644 index 0000000000..3293ce7c05 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_plot.py @@ -0,0 +1,185 @@ +from math import ceil, sqrt, floor +import itertools +from matplotlib.patches import Rectangle + +import matplotlib.pyplot as plt +from pandas import DataFrame +import pylab +import numpy +from scipy.stats import gaussian_kde + + +class ShellPlot(object): + + + + def __init__(self, name): + super(ShellPlot, self).__init__() + clist = plt.rcParams['axes.color_cycle'] + self.__color_cycle = itertools.cycle(clist) + + self.figure = plt.figure() + self.figure.autofmt_xdate() + plt.title(name) + + self.__legend_items = [] + self.__legend_labels = [] + + + def nextColor(self): + return self.__color_cycle.next() + + + def plotObservations(self, data, value_column, color='k'): + data = data.dropna() + plt.errorbar(x=data.index.values, y=data[value_column], yerr=data["STD_%s" % value_column], + fmt='none', ecolor=color, alpha=0.8) + + + def plot(self, data, value_column, color=None, legend_label=''): + if color is None: + color = self.nextColor() + + data = data.reset_index() + data = data.pivot(index="Date", columns="Realization", values=value_column) + + plt.ylabel("Value") + plt.xlabel("Date") + plt.xticks(rotation=30) + lines = plt.plot_date(x=data.index.values, y=data, color=color, alpha=0.8, marker=None, linestyle="-") + + if len(lines) > 0: + self.__legend_items.append(lines[0]) + self.__legend_labels.append(legend_label) + + + def plotGenData(self, data, color=None, legend_label=''): + if color is None: + color = self.nextColor() + + plt.ylabel("Value") + plt.xlabel("Index") + plt.xticks(rotation=30) + lines = plt.plot(data.index.values, data, color=color, alpha=0.8, marker=None, linestyle="-") + + if len(lines) > 0: + self.__legend_items.append(lines[0]) + self.__legend_labels.append(legend_label) + + + def showLegend(self): + plt.legend(self.__legend_items, self.__legend_labels) + + + def plotArea(self, data, value_column, color=None, legend_label=''): + if color is None: + color = self.nextColor() + + data = data.reset_index() + data = data.pivot(index="Date", columns="Realization", values=value_column) + + df = DataFrame() + + df["Minimum"] = data.min(axis=1) + df["Maximum"] = data.max(axis=1) + + plt.fill_between(df.index.values, df["Minimum"].values, df["Maximum"].values, alpha=0.5, color=color) + plt.ylabel("Value") + plt.xlabel("Date") + plt.xticks(rotation=30) + + r = Rectangle((0, 0), 1, 1, color=color) # creates rectangle patch for legend use. + + self.__legend_items.append(r) + self.__legend_labels.append(legend_label) + + + def plotQuantiles(self, data, value_column, color=None, legend_label=''): + if color is None: + color = self.nextColor() + + data = data.reset_index() + data = data.pivot(index="Date", columns="Realization", values=value_column) + + df = DataFrame() + + df["Minimum"] = data.min(axis=1) + df["Maximum"] = data.max(axis=1) + df["Mean"] = data.mean(axis=1) + df["p10"] = data.quantile(0.1, axis=1) + df["p33"] = data.quantile(0.33, axis=1) + df["p50"] = data.quantile(0.50, axis=1) + df["p67"] = data.quantile(0.67, axis=1) + df["p90"] = data.quantile(0.90, axis=1) + + plt.plot(df.index.values, df["Minimum"].values, alpha=1, linestyle="--", color=color) + plt.plot(df.index.values, df["Maximum"].values, alpha=1, linestyle="--", color=color) + plt.plot(df.index.values, df["p50"].values, alpha=1, linestyle="--", color=color) + plt.fill_between(df.index.values, df["p10"].values, df["p90"].values, alpha=0.3, color=color) + plt.fill_between(df.index.values, df["p33"].values, df["p67"].values, alpha=0.5, color=color) + + plt.ylabel("Value") + plt.xlabel("Date") + plt.xticks(rotation=30) + + r = Rectangle((0, 0), 1, 1, color=color) # creates rectangle patch for legend use. + + self.__legend_items.append(r) + self.__legend_labels.append(legend_label) + + + def histogram(self, data, name, log_on_x=False, color=None): + if color is None: + color = self.nextColor() + + bins = int(ceil(sqrt(len(data.index)))) + + if log_on_x: + bins = ShellPlot._histogramLogBins(data, bins) + + plt.hist(data[name].values, alpha=0.8, bins=bins, color=color) + plt.ylabel("Count") + + if log_on_x: + plt.xticks(bins, ["$10^{%s}$" % (int(value) if value.is_integer() else "%.1f" % value) for value in bins]) #LaTeX formatting + + def density(self, data, name, legend_label='', color=None): + if color is None: + color = self.nextColor() + + values = data[name].values + sample_range = values.max() - values.min() + indexes = numpy.linspace(values.min() - 0.5 * sample_range, values.max() + 0.5 * sample_range, 1000) + gkde = gaussian_kde(values) + evaluated_gkde = gkde.evaluate(indexes) + + plt.ylabel("Density") + lines = plt.plot(indexes, evaluated_gkde, linewidth=2, color=color) + + if len(lines) > 0: + self.__legend_items.append(lines[0]) + self.__legend_labels.append(legend_label) + + + @staticmethod + def _histogramLogBins(data, bin_count): + """ + @type data: pandas.DataFrame + @rtype: int + """ + data = data[data.columns[0]] + + min_value = int(floor(float(data.min()))) + max_value = int(ceil(float(data.max()))) + + log_bin_count = max_value - min_value + + if log_bin_count < bin_count: + next_bin_count = log_bin_count * 2 + + if bin_count - log_bin_count > next_bin_count - bin_count: + log_bin_count = next_bin_count + else: + log_bin_count = bin_count + + return numpy.linspace(min_value, max_value, log_bin_count) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_tools.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_tools.py new file mode 100644 index 0000000000..1578fb8810 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/shell_tools.py @@ -0,0 +1,84 @@ +import fnmatch +import os +import shlex + + +def autoCompleteList(text, items): + if not text: + completions = items + else: + completions = [item for item in items if item.lower().startswith(text.lower())] + return completions + +def containsAny(string, chars): + return True in [char in string for char in chars] + +def findRightMostSeparator(text, separators): + max_pos = 0 + + for separator in separators: + pos = text.rfind(separator) + max_pos = max(pos, max_pos) + + return max_pos + +def autoCompleteListWithSeparator(text, items, separators=":,@"): + if containsAny(text, separators): + auto_complete_list = autoCompleteList(text, items) + separator_pos = findRightMostSeparator(text, separators) + auto_complete_list = [item[separator_pos + 1:] for item in auto_complete_list] + else: + auto_complete_list = autoCompleteList(text, items) + + return auto_complete_list + + +def createParameterizedHelpFunction(parameters, help_message): + def helpFunction(self): + return parameters, help_message + + return helpFunction + + +def pathify(head, tail): + path = os.path.join(head, tail) + if os.path.isdir(path): + return "%s/" % tail + return tail + + +def getPossibleFilenameCompletions(text, separators="-"): + head, tail = os.path.split(text.strip()) + if head == "": # no head + head = "." + files = os.listdir(head) + + separator_pos = 0 + if containsAny(tail, separators): + separator_pos = findRightMostSeparator(tail, separators) + 1 + + return [pathify(head, f)[separator_pos:] for f in files if f.startswith(tail)] + + +def extractFullArgument(line, endidx): + newstart = line.rfind(" ", 0, endidx) + return line[newstart:endidx].strip() + + +def matchItems(line, items): + patterns = shlex.split(line) + + result_items = set() + + for pattern in patterns: + pattern_matches = set() + for item in items: + if fnmatch.fnmatch(item.lower(), pattern.lower()): # case-insensitive matching + pattern_matches.add(item) + + if len(pattern_matches) == 0: + print("Error: Name/Pattern '%s' does not match anything." % pattern) + else: + result_items = result_items | pattern_matches + + return result_items \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/simulations.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/simulations.py new file mode 100644 index 0000000000..f6d0d2394d --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/simulations.py @@ -0,0 +1,48 @@ +import time +from datetime import datetime +from ert.enkf import EnkfSimulationRunner +from ert_gui.shell import ShellFunction, assertConfigLoaded + + +class Simulations(ShellFunction): + def __init__(self, shell_context): + super(Simulations, self).__init__("simulations", shell_context) + self.addHelpFunction("settings", None, "Show simulations settings.") + self.addHelpFunction("ensemble_experiment", None, "Run Ensemble Experiment.") + + + @assertConfigLoaded + def do_settings(self, line): + runpath = self.ert().getModelConfig().getRunpathAsString() + + iteration_count = self.ert().analysisConfig().getAnalysisIterConfig().getNumIterations() + realizations = self.ert().getEnsembleSize() + + print("Runpath: %s" % runpath) + print("Iteration count: %d" % iteration_count) + print("Realization count: %d" % realizations) + + + @assertConfigLoaded + def do_ensemble_experiment(self, line): + simulation_runner = EnkfSimulationRunner(self.ert()) + + now = time.time() + + print("Ensemble Experiment started at: %s" % datetime.now().isoformat(sep=" ")) + success = simulation_runner.runEnsembleExperiment() + + if not success: + print("Error: Simulations failed!") + return + + print("Ensemble Experiment post processing!") + simulation_runner.runPostWorkflow() + + print("Ensemble Experiment completed at: %s" % datetime.now().isoformat(sep=" ")) + + diff = time.time() - now + print("Running time: %d seconds" % int(diff)) + + + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/smoother.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/smoother.py new file mode 100644 index 0000000000..c51f6e46a9 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/smoother.py @@ -0,0 +1,77 @@ +from ert.enkf import EnkfSimulationRunner +from ert_gui.shell import ShellFunction, assertConfigLoaded + + +class Smoother(ShellFunction): + def __init__(self, shell_context): + super(Smoother, self).__init__("smoother", shell_context) + self.addHelpFunction("update", "<target_case>", "Run smoother update on the current case, placing the results in the target case.") + self.addHelpFunction("overlap_alpha", "[alpha_value]", "Show or set the overlap alpha.") + self.addHelpFunction("std_cutoff", "[cutoff_value]", "Show or set the standard deviation cutoff value (>0).") + self.addHelpFunction("global_std_scaling", "[std_scaling]", "Show or set the global standard deviation scaling value (>0) applied to updates.") + + + @assertConfigLoaded + def do_update(self, line): + arguments = self.splitArguments(line) + + if len(arguments) == 1: + case_name = arguments[0] + target_fs = self.ert().getEnkfFsManager().getFileSystem(case_name) + simulation_runner = EnkfSimulationRunner(self.ert()) + success = simulation_runner.smootherUpdate(target_fs) + + if not success: + self.lastCommandFailed("Unable to perform update") + + else: + self.lastCommandFailed("Expected one argument: <target_fs> received: '%s'" % line) + + + @assertConfigLoaded + def do_overlap_alpha(self, line): + value = line.strip() + if value == "": + analysis_config = self.shellContext().ert().analysisConfig() + print("Overlap Alpha = %f" % analysis_config.getEnkfAlpha()) + else: + try: + value = float(value) + analysis_config = self.shellContext().ert().analysisConfig() + analysis_config.setEnkfAlpha(value) + print("Overlap Alpha set to: %f" % analysis_config.getEnkfAlpha()) + except ValueError: + self.lastCommandFailed("Expected a number") + + + @assertConfigLoaded + def do_std_cutoff(self, line): + value = line.strip() + if value == "": + analysis_config = self.shellContext().ert().analysisConfig() + print("Standard Deviation Cutoff = %f" % analysis_config.getStdCutoff()) + else: + try: + value = float(value) + analysis_config = self.shellContext().ert().analysisConfig() + analysis_config.setStdCutoff(value) + print("Standard Deviation Cutoff set to: %f" % analysis_config.getStdCutoff()) + except ValueError: + self.lastCommandFailed("Expected a number") + + + + @assertConfigLoaded + def do_global_std_scaling(self, line): + value = line.strip() + if value == "": + analysis_config = self.shellContext().ert().analysisConfig() + print("Global Standard Deviation Scaling = %f" % analysis_config.getGlobalStdScaling()) + else: + try: + value = float(value) + analysis_config = self.shellContext().ert().analysisConfig() + analysis_config.setGlobalStdScaling(value) + print("Global Standard Deviation Scaling set to: %f" % analysis_config.getGlobalStdScaling()) + except ValueError: + self.lastCommandFailed("Expected a number") \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/summary_keys.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/summary_keys.py new file mode 100644 index 0000000000..5b6ebd3c19 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/summary_keys.py @@ -0,0 +1,152 @@ +from ert.enkf import ErtImplType +from ert.enkf.export.summary_collector import SummaryCollector +from ert.enkf.export.summary_observation_collector import SummaryObservationCollector +from ert_gui.shell import ShellFunction, assertConfigLoaded, extractFullArgument, autoCompleteListWithSeparator, ShellPlot +from ert_gui.shell.shell_tools import matchItems + + +class SummaryKeys(ShellFunction): + def __init__(self, shell_context): + super(SummaryKeys, self).__init__("summary", shell_context) + + self.addHelpFunction("list", None, "Shows a list of all available summary keys. (* = with observations)") + self.addHelpFunction("observations", None, "Shows a list of all available summary key observations.") + self.addHelpFunction("matchers", None, "Shows a list of all summary keys that the ensemble will match " + "against during simulations and manual load.") + self.addHelpFunction("add_matcher", "<summary_key>", "Add a matcher to the summary key matcher set.") + self.addHelpFunction("plot", "<key_1> [key_2..key_n]", "Plot the specified key(s).") + self.addHelpFunction("plot_area", "<key_1> [key_2..key_n]", "Plot the area between the minimum and maximum for the specified key(s).") + + @assertConfigLoaded + def do_list(self, line): + ensemble_config = self.ert().ensembleConfig() + keys = sorted([key for key in ensemble_config.getKeylistFromImplType(ErtImplType.SUMMARY)]) + observation_keys = [key for key in keys if len(ensemble_config.getNode(key).getObservationKeys()) > 0] + + result = ["*%s" % key if key in observation_keys else " %s" % key for key in keys] + + self.columnize(result) + + @assertConfigLoaded + def do_observations(self, line): + keys = self.summaryKeys() + + observation_keys = [] + for key in keys: + obs_keys = self.ert().ensembleConfig().getNode(key).getObservationKeys() + observation_keys.extend(obs_keys) + + self.columnize(observation_keys) + + @assertConfigLoaded + def do_matchers(self, line): + ensemble_config = self.ert().ensembleConfig() + summary_key_matcher = ensemble_config.getSummaryKeyMatcher() + keys = sorted(["*%s" % key if summary_key_matcher.isRequired(key) else " %s" % key for key in summary_key_matcher.keys()]) + + self.columnize(keys) + + @assertConfigLoaded + def do_add_matcher(self, line): + args = self.splitArguments(line) + + if len(args) < 1: + self.lastCommandFailed("A summary key is required.") + return False + + + self.ert().ensembleConfig().getSummaryKeyMatcher().addSummaryKey(args[0].strip()) + + + def summaryKeys(self): + ensemble_config = self.ert().ensembleConfig() + return sorted([key for key in ensemble_config.getKeylistFromImplType(ErtImplType.SUMMARY)]) + + + @assertConfigLoaded + def do_plot(self, line): + keys = matchItems(line, self.summaryKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one Summary key") + return False + + case_list = self.shellContext()["plot_settings"].getCurrentPlotCases() + + for key in keys: + plot = ShellPlot(key) + for case_name in case_list: + data = SummaryCollector.loadAllSummaryData(self.ert(), case_name, [key]) + if not data.empty: + plot.plot(data, value_column=key, legend_label=case_name) + + if len(case_list) > 0 and SummaryObservationCollector.summaryKeyHasObservations(self.ert(), key): + observation_data = SummaryObservationCollector.loadObservationData(self.ert(), case_list[0], [key]) + + if not observation_data.empty: + plot.plotObservations(observation_data, value_column=key) + + plot.showLegend() + + @assertConfigLoaded + def complete_plot(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.summaryKeys()) + + @assertConfigLoaded + def do_plot_area(self, line): + keys = matchItems(line, self.summaryKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one Summary key") + return False + + case_list = self.shellContext()["plot_settings"].getCurrentPlotCases() + + for key in keys: + plot = ShellPlot(key) + for case_name in case_list: + data = SummaryCollector.loadAllSummaryData(self.ert(), case_name, [key]) + if not data.empty: + plot.plotArea(data, value_column=key, legend_label=case_name) + + if len(case_list) > 0 and SummaryObservationCollector.summaryKeyHasObservations(self.ert(), key): + observation_data = SummaryObservationCollector.loadObservationData(self.ert(), case_list[0], [key]) + if not observation_data.empty: + plot.plotObservations(observation_data, value_column=key) + + plot.showLegend() + + @assertConfigLoaded + def complete_plot_area(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.summaryKeys()) + + @assertConfigLoaded + def do_plot_quantile(self, line): + keys = matchItems(line, self.summaryKeys()) + + if len(keys) == 0: + self.lastCommandFailed("Must have at least one Summary key") + return False + + case_list = self.shellContext()["plot_settings"].getCurrentPlotCases() + + for key in keys: + plot = ShellPlot(key) + for case_name in case_list: + data = SummaryCollector.loadAllSummaryData(self.ert(), case_name, [key]) + if not data.empty: + plot.plotQuantiles(data, value_column=key, legend_label=case_name) + + if len(case_list) > 0 and SummaryObservationCollector.summaryKeyHasObservations(self.ert(), key): + observation_data = SummaryObservationCollector.loadObservationData(self.ert(), case_list[0], [key]) + if not observation_data.empty: + plot.plotObservations(observation_data, value_column=key) + + plot.showLegend() + + @assertConfigLoaded + def complete_plot_quantile(self, text, line, begidx, endidx): + key = extractFullArgument(line, endidx) + return autoCompleteListWithSeparator(key, self.summaryKeys()) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/shell/workflows.py b/ThirdParty/Ert/devel/python/python/ert_gui/shell/workflows.py new file mode 100644 index 0000000000..6dab53496a --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/shell/workflows.py @@ -0,0 +1,39 @@ +from ert.job_queue import WorkflowRunner +from ert_gui.shell import ShellFunction, assertConfigLoaded, autoCompleteList + + +class Workflows(ShellFunction): + def __init__(self, shell_context): + super(Workflows, self).__init__("workflows", shell_context) + + self.addHelpFunction("list", None, "Shows a list of all available workflows.") + self.addHelpFunction("run", "<workflow_name>", "Run a named workflow.") + + def getWorkflowNames(self): + return [workflow for workflow in self.ert().getWorkflowList().getWorkflowNames()] + + @assertConfigLoaded + def do_list(self, line): + workflows = self.getWorkflowNames() + if len(workflows) > 0: + self.columnize(workflows) + else: + print("No workflows available.") + + @assertConfigLoaded + def do_run(self, workflow): + workflow = workflow.strip() + if workflow in self.getWorkflowNames(): + workflow_list = self.ert().getWorkflowList() + workflow = workflow_list[workflow] + context = workflow_list.getContext() + + runner = WorkflowRunner(workflow, self.ert(), context) + runner.run() + runner.wait() + else: + self.lastCommandFailed("Unknown workflow: '%s'" % workflow) + + @assertConfigLoaded + def complete_run(self, text, line, begidx, endidx): + return autoCompleteList(text, self.getWorkflowNames()) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/site_config.py.in b/ThirdParty/Ert/devel/python/python/ert_gui/site_config.py.in deleted file mode 100644 index 34da72fb97..0000000000 --- a/ThirdParty/Ert/devel/python/python/ert_gui/site_config.py.in +++ /dev/null @@ -1 +0,0 @@ -config_file = "${SITE_CONFIG_FILE}" diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert_gui/tools/CMakeLists.txt index ecab75219d..b321023f01 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/tools/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/CMakeLists.txt @@ -9,7 +9,8 @@ add_python_package("python.ert_gui.tools" ${PYTHON_INSTALL_PREFIX}/ert_gui/tool add_subdirectory(export) add_subdirectory(help) add_subdirectory(ide) +add_subdirectory(load_results) add_subdirectory(manage_cases) add_subdirectory(plot) +add_subdirectory(plugins) add_subdirectory(workflows) -add_subdirectory(load_results) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/export/export_realizations_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/export/export_realizations_model.py index 78b2bcd58d..341551b6b5 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/tools/export/export_realizations_model.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/export/export_realizations_model.py @@ -45,7 +45,7 @@ def getDefaultValue(self): return "0-%d" % (self.__realization_count - 1) def getActiveRealizationsMask(self): - mask = BoolVector.active_mask(self.getValue()) + mask = BoolVector.createActiveMask(self.getValue()) if mask is None: raise ValueError("Error while parsing range string!") diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_case_model.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_case_model.py index e12fed8f9e..fcb59930c3 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_case_model.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_case_model.py @@ -47,7 +47,7 @@ def itemAt(self, index): def getAllItems(self): if self.__data is None: - self.__data = CaseList().getAllCasesWithData() + self.__data = CaseList().getAllCasesWithDataAndNotRunning() return self.__data diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_scale_widget.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_scale_widget.py index 5459fc3631..20bb964f88 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_scale_widget.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plot/plot_scale_widget.py @@ -15,8 +15,8 @@ def __init__(self, type_key, title, select_min_time_value=False): self.__type_key = type_key self.__type = None - self.__double_spinner = self.createDoubleSpinner(minimum=-999999999.0, maximum=999999999.0) - self.__integer_spinner = self.createIntegerSpinner(minimum=0, maximum=999999999) + self.__double_spinner = self.createDoubleSpinner(minimum=-1e15, maximum=1e15) + self.__integer_spinner = self.createIntegerSpinner(minimum=0, maximum=1e10) self.__time_map = ReportStepsModel().getList() self.__time_index_map = {} @@ -140,4 +140,4 @@ def setType(self, spinner_type): def getType(self): - return self.__type \ No newline at end of file + return self.__type diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/CMakeLists.txt new file mode 100644 index 0000000000..26ba15fee6 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/CMakeLists.txt @@ -0,0 +1,11 @@ +set(PYTHON_SOURCES + __init__.py + plugin.py + plugin_handler.py + plugin_runner.py + plugins_tool.py + process_job_dialog.py +) + +add_python_package("python.ert_gui.tools.plugins" ${PYTHON_INSTALL_PREFIX}/ert_gui/tools/plugins "${PYTHON_SOURCES}" True) + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/__init__.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/__init__.py new file mode 100644 index 0000000000..d3509c4f5d --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/__init__.py @@ -0,0 +1,5 @@ +from .process_job_dialog import ProcessJobDialog +from .plugin import Plugin +from .plugin_runner import PluginRunner +from .plugin_handler import PluginHandler +from .plugins_tool import PluginsTool diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin.py new file mode 100644 index 0000000000..1a4ee460b3 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin.py @@ -0,0 +1,54 @@ +from ert.job_queue import ErtScript, ErtPlugin, WorkflowJob + +class Plugin(object): + def __init__(self, ert, workflow_job): + """ + @type ert: ert.enkf.EnKFMain + @type workflow_job: WorkflowJob + """ + self.__ert = ert + self.__workflow_job = workflow_job + self.__parent_window = None + + script = self.__loadPlugin() + self.__name = script.getName() + self.__description = script.getDescription() + + + def __loadPlugin(self): + """ @rtype: ErtPlugin """ + script_obj = ErtScript.loadScriptFromFile(self.__workflow_job.getInternalScriptPath()) + script = script_obj(self.__ert) + return script + + def getName(self): + """ @rtype: str """ + return self.__name + + def getDescription(self): + """ @rtype: str """ + return self.__description + + def getArguments(self): + """ + Returns a list of arguments. Either from GUI or from arbitrary code. + If the user for example cancels in the GUI a CancelPluginException is raised. + @rtype: list """ + script = self.__loadPlugin() + return script.getArguments(self.__parent_window) + + + def setParentWindow(self, parent_window): + self.__parent_window = parent_window + + def getParentWindow(self): + """ @rtype: QWidget """ + return self.__parent_window + + def ert(self): + """ @rtype: ert.enkf.enkf_main.EnKFMain """ + return self.__ert + + def getWorkflowJob(self): + """ @rtype: WorkflowJob """ + return self.__workflow_job diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin_handler.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin_handler.py new file mode 100644 index 0000000000..6622bfc79e --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin_handler.py @@ -0,0 +1,37 @@ +from ert.job_queue import WorkflowJob +from .plugin import Plugin + + +class PluginHandler(object): + + def __init__(self, ert, plugin_jobs, parent_window): + """ @type plugin_jobs: list of WorkflowJob """ + self.__ert = ert + self.__plugins = [] + + for job in plugin_jobs: + plugin = Plugin(self.__ert, job) + self.__plugins.append(plugin) + plugin.setParentWindow(parent_window) + + self.__plugins = sorted(self.__plugins, key=Plugin.getName) + + + def ert(self): + """ @rtype: ert.enkf.enkf_main.EnKFMain """ + return self.__ert + + def __iter__(self): + """ @rtype: Plugin """ + index = 0 + while index < len(self.__plugins): + yield self.__plugins[index] + index += 1 + + def __getitem__(self, index): + """ @rtype: Plugin """ + return self.__plugins[index] + + + def __len__(self): + return len(self.__plugins) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin_runner.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin_runner.py new file mode 100644 index 0000000000..44978a8999 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugin_runner.py @@ -0,0 +1,91 @@ +from functools import partial +from threading import Thread +import time +from ert.job_queue.ert_plugin import CancelPluginException +from ert_gui.tools.plugins import Plugin, ProcessJobDialog +from ert.job_queue import WorkflowJob + +class PluginRunner(object): + def __init__(self, plugin): + """ + @type plugin: Plugin + """ + super(PluginRunner, self).__init__() + + self.__plugin = plugin + + self.__plugin_finished_callback = lambda : None + + self.__result = None + + def run(self): + try: + plugin = self.__plugin + + arguments = plugin.getArguments() + dialog = ProcessJobDialog(plugin.getName(), plugin.getParentWindow()) + + dialog.cancelConfirmed.connect(self.cancel) + + run_function = partial(self.__runWorkflowJob, plugin, arguments) + + workflow_job_thread = Thread(name="ert_gui_workflow_job_thread") + workflow_job_thread.setDaemon(True) + workflow_job_thread.run = run_function + workflow_job_thread.start() + + + poll_function = partial(self.__pollRunner, plugin, dialog) + + poll_thread = Thread(name="ert_gui_workflow_job_poll_thread") + poll_thread.setDaemon(True) + poll_thread.run = poll_function + poll_thread.start() + + dialog.show() + except CancelPluginException: + print("Plugin cancelled before execution!") + + def __runWorkflowJob(self, plugin, arguments): + workflow_job = plugin.getWorkflowJob() + self.__result = workflow_job.run(plugin.ert(), arguments) + + + def __pollRunner(self, plugin, dialog): + self.wait() + + details = "" + if self.__result is not None: + details = str(self.__result) + + if plugin.getWorkflowJob().hasFailed(): + dialog.presentError.emit("Job Failed!", "The job '%s' has failed while running!" % plugin.getName(), details) + dialog.disposeDialog.emit() + elif plugin.getWorkflowJob().isCancelled(): + dialog.presentInformation.emit("Job Cancelled!", "The job '%s' was cancelled successfully!" % plugin.getName(), details) + dialog.disposeDialog.emit() + else: + dialog.presentInformation.emit("Job Completed!", "The job '%s' was completed successfully!" % plugin.getName(), details) + dialog.disposeDialog.emit() + + self.__plugin_finished_callback() + + + def isRunning(self): + """ @rtype: bool """ + return self.__plugin.getWorkflowJob().isRunning() + + def isCancelled(self): + """ @rtype: bool """ + return self.__plugin.getWorkflowJob().isCancelled() + + def cancel(self): + if self.isRunning(): + self.__plugin.getWorkflowJob().cancel() + + def wait(self): + while self.isRunning(): + time.sleep(1) + + def setPluginFinishedCallback(self, callback): + self.__plugin_finished_callback = callback \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugins_tool.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugins_tool.py new file mode 100644 index 0000000000..057c31e3b6 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/plugins_tool.py @@ -0,0 +1,33 @@ +from PyQt4.QtGui import QMenu +from ert_gui.models.connectors.init import CaseList +from ert_gui.tools import Tool +from ert_gui.widgets import util +from ert_gui.tools.plugins import PluginHandler, PluginRunner + + +class PluginsTool(Tool): + def __init__(self, plugin_handler): + """ + @type plugin_handler: PluginHandler + """ + enabled = len(plugin_handler) > 0 + super(PluginsTool, self).__init__("Plugins", "tools/plugins", util.resourceIcon("ide/plugin"), enabled, popup_menu=True) + + self.__plugins = {} + + menu = QMenu() + for plugin in plugin_handler: + plugin_runner = PluginRunner(plugin) + plugin_runner.setPluginFinishedCallback(self.trigger) + + self.__plugins[plugin] = plugin_runner + plugin_action = menu.addAction(plugin.getName()) + plugin_action.setToolTip(plugin.getDescription()) + plugin_action.triggered.connect(plugin_runner.run) + + self.getAction().setMenu(menu) + + + def trigger(self): + CaseList().externalModificationNotification() # plugin may have added new cases. + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/process_job_dialog.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/process_job_dialog.py new file mode 100644 index 0000000000..ce41a37ebe --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/plugins/process_job_dialog.py @@ -0,0 +1,120 @@ +from PyQt4.QtCore import Qt, pyqtSignal, QSize +from PyQt4.QtGui import QDialog, QVBoxLayout, QLayout, QPushButton, QHBoxLayout, QWidget, QLabel, QMessageBox, QSizePolicy, QSpacerItem +from ert_gui.widgets import util + + +class ProcessJobDialog(QDialog): + + disposeDialog = pyqtSignal() + presentInformation = pyqtSignal(str, str, str) + presentError = pyqtSignal(str, str, str) + + closeButtonPressed = pyqtSignal() + cancelConfirmed = pyqtSignal() + + def __init__(self, title, parent=None): + QDialog.__init__(self, parent) + + self.__parent = parent + self.setWindowTitle(title) + self.setModal(True) + self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) + self.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint) + self.setWindowFlags(self.windowFlags() & ~Qt.WindowCancelButtonHint) + + layout = QVBoxLayout() + layout.setSizeConstraint(QLayout.SetFixedSize) + + widget = QWidget() + widget_layout = QHBoxLayout() + + size = 64 + spin_movie = util.resourceMovie("ide/loading.gif") + spin_movie.setSpeed(60) + spin_movie.setScaledSize(QSize(size, size)) + spin_movie.start() + + processing_animation = QLabel() + processing_animation.setMaximumSize(QSize(size, size)) + processing_animation.setMinimumSize(QSize(size, size)) + processing_animation.setMovie(spin_movie) + widget_layout.addWidget(processing_animation) + + self.processing_label = QLabel("Processing job: '%s'" % title) + widget_layout.addWidget(self.processing_label, Qt.AlignBottom) + + widget.setLayout(widget_layout) + + layout.addWidget(widget) + + button_layout = QHBoxLayout() + self.close_button = QPushButton("Close") + self.close_button.clicked.connect(self.closeButtonPressed.emit) + button_layout.addStretch() + button_layout.addWidget(self.close_button) + + layout.addStretch() + layout.addLayout(button_layout) + + self.setLayout(layout) + + self.disposeDialog.connect(self.reject) + self.presentInformation.connect(self.__presentInformation) + self.presentError.connect(self.__presentError) + self.closeButtonPressed.connect(self.__confirmCancel) + + + def disableCloseButton(self): + self.close_button.setEnabled(False) + + def enableCloseButton(self): + self.close_button.setEnabled(True) + + def keyPressEvent(self, q_key_event): + if not self.close_button.isEnabled() and q_key_event.key() == Qt.Key_Escape: + pass + else: + QDialog.keyPressEvent(self, q_key_event) + + def closeEvent(self, close_event): + close_event.ignore() + self.closeButtonPressed.emit() + + def __createMsgBox(self, title, message, details): + msg_box = QMessageBox(self.parent()) + msg_box.setText(title) + msg_box.setInformativeText(message) + + if len(details) > 0: + msg_box.setDetailedText(details) + + horizontal_spacer = QSpacerItem(500, 0, QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) + layout = msg_box.layout() + layout.addItem(horizontal_spacer, layout.rowCount(), 0, 1, layout.columnCount()) + + return msg_box + + + def __presentInformation(self, title, message, details): + msg_box = self.__createMsgBox(title, message, details) + msg_box.setIcon(QMessageBox.Information) + + msg_box.exec_() + + def __presentError(self, title, message, details): + msg_box = self.__createMsgBox(title, message, details) + msg_box.setIcon(QMessageBox.Critical) + + msg_box.exec_() + + + def __confirmCancel(self): + cancel_box = self.__createMsgBox("Confirm Cancel", "Are you sure you want to cancel the running job?", "") + cancel_box.setIcon(QMessageBox.Question) + cancel_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + cancel_box.exec_() + + cancel = cancel_box.result() + + if cancel == QMessageBox.Yes: + self.cancelConfirmed.emit() diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/tool.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/tool.py index 516b230429..67034a0efb 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/tools/tool.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/tool.py @@ -3,7 +3,7 @@ class Tool(object): - def __init__(self, name, help_link="", icon=None, enabled=True, checkable=False): + def __init__(self, name, help_link="", icon=None, enabled=True, checkable=False, popup_menu=False): super(Tool, self).__init__() self.__icon = icon self.__name = name @@ -11,6 +11,7 @@ def __init__(self, name, help_link="", icon=None, enabled=True, checkable=False) self.__enabled = enabled self.__checkable = checkable self.__help_link = help_link + self.__is_popup_menu = popup_menu self.__action = QAction(self.getIcon(), self.getName(), None) self.__action.setIconText(self.getName()) @@ -51,3 +52,6 @@ def setVisible(self, visible): def setEnabled(self, enabled): self.__action.setEnabled(enabled) + + def isPopupMenu(self): + return self.__is_popup_menu diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/run_workflow_widget.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/run_workflow_widget.py index 2739486b5e..74904defd9 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/run_workflow_widget.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/run_workflow_widget.py @@ -13,7 +13,6 @@ class RunWorkflowWidget(QWidget): workflowSucceeded = pyqtSignal() workflowFailed = pyqtSignal() workflowKilled = pyqtSignal() - reloadErtTriggered = pyqtSignal() def __init__(self): QWidget.__init__(self) @@ -79,8 +78,7 @@ def createSpinWidget(self): def cancelWorkflow(self): if self.__workflow_runner.isRunning(): - - cancel = QMessageBox.question(self, "Confirm stop", "ERT might need to shut down when a workflow is stopped - do you want to proceed?", QMessageBox.Yes | QMessageBox.No) + cancel = QMessageBox.question(self, "Confirm Cancel", "Are you sure you want to cancel the running workflow?", QMessageBox.Yes | QMessageBox.No) if cancel == QMessageBox.Yes: self.__workflow_runner.cancel() @@ -89,7 +87,6 @@ def cancelWorkflow(self): def startWorkflow(self): self.__running_workflow_dialog = WorkflowDialog("Running Workflow", self.createSpinWidget(), self) - #self.__running_workflow_dialog.disableCloseButton() self.__running_workflow_dialog.closeButtonPressed.connect(self.cancelWorkflow) workflow_thread = Thread(name="ert_gui_workflow_thread") diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/workflows_tool.py b/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/workflows_tool.py index a7a4290025..8d85203301 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/workflows_tool.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/tools/workflows/workflows_tool.py @@ -7,15 +7,13 @@ class WorkflowsTool(Tool): - def __init__(self,reload_function): - self.reload_function = reload_function + def __init__(self): enabled = len(WorkflowsModel().getList()) > 0 super(WorkflowsTool, self).__init__("Run Workflow", "tools/workflows", util.resourceIcon("ide/to_do_list_checked_1"), enabled) def trigger(self): run_workflow_widget = RunWorkflowWidget() - run_workflow_widget.reloadErtTriggered.connect(self.reload_function) dialog = ClosableDialog("Run workflow", run_workflow_widget, self.parent()) dialog.exec_() CaseList().externalModificationNotification() # workflow may have added new cases. diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/camera.py b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/camera.py index 667f1a006c..687e0d72f9 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/camera.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/camera.py @@ -14,12 +14,15 @@ def __init__(self): self.__height_aspect = 1.0 self.__aspect = 1.0 - self.__orthographic_projection = False + self.__orthographic_projection = True self.__mirror_x = False self.__mirror_y = False self.__mirror_z = False + self.__x = 0 + self.__y = 0 + self.resetCamera() @@ -27,6 +30,10 @@ def resetCamera(self): rot_y = UnityQuaternion(180.0, 0.0, 1.0, 0.0) self.__quaternion = rot_y * UnityQuaternion(0.0, 1.0, 0.0, 0.0) self.__zoom = 1.0 + self.__x = 0 + self.__y = 0 + + def rotate(self, x, y, z=0.0): rot_x = UnityQuaternion(x, 1.0, 0.0, 0.0) @@ -45,9 +52,15 @@ def __applyProjection(self): gluPerspective(60 * self.__zoom, self.__aspect, 0.1, 3000) + def translate(self , dx, dy): + self.__x += dx + self.__y += dy + + + def applyCamera(self): glMatrixMode(GL_MODELVIEW) - glTranslate(0.0, 0.0, -1.0) + glTranslate(self.__x, self.__y , -1.0) glRotate(self.__quaternion.getAngleAsDegrees(), self.__quaternion.X, self.__quaternion.Y, self.__quaternion.Z) if self.__mirror_x: diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_settings_widget.py b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_settings_widget.py index 009903a91c..146b7ae869 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_settings_widget.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_settings_widget.py @@ -25,10 +25,10 @@ def __init__(self, max_slice_count, color_scales): self.addCheckBox("Hide inactive cells", self.inactiveCellsHidden) self.addSpinBox("Slice #", 0, max_slice_count - 1, self.currentSliceChanged) - self.addCheckBox("Orthographic proj.", self.toggleOrthographicProjection) + self.addCheckBox("Orthographic proj.", self.toggleOrthographicProjection , initial_state = True) self.addCheckBox("Lighting", self.toggleLighting) self.addComboBox("Color scale", self.colorScalesChanged, color_scales) - self.addCheckBox("Region scaling", self.regionToggling) + self.addCheckBox("Region scaling", self.regionToggling , initial_state = True) self.addCheckBox("Interpolate data", self.toggleInterpolation) self.addCheckBox("Mirror X", self.mirrorX) self.addCheckBox("Mirror Y", self.mirrorY) @@ -38,10 +38,12 @@ def __init__(self, max_slice_count, color_scales): self.setLayout(self.__layout) - def addCheckBox(self, label, signal): + def addCheckBox(self, label, signal, initial_state = False): checkbox = QCheckBox() checkbox.toggled.connect(signal) self.__layout.addRow(label, checkbox) + checkbox.setChecked( initial_state ) + def addSpinBox(self, label, min_value, max_value, signal): @@ -55,4 +57,4 @@ def addComboBox(self, label, signal, choices): combo = QComboBox() combo.addItems(choices) combo.currentIndexChanged[QString].connect(signal) - self.__layout.addRow(label, combo) \ No newline at end of file + self.__layout.addRow(label, combo) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer.py b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer.py index 1b50b14add..3503921cc6 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer.py @@ -1,4 +1,5 @@ import os +from collections import OrderedDict from OpenGL.GL import * from PyQt4.QtCore import Qt from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget @@ -76,6 +77,7 @@ def loadKWData(path, keyword, ecl_type=EclTypeEnum.ECL_FLOAT_TYPE): min_value = kw_data.min data_range = kw_data.max - kw_data.min + #result = (value - min) / range result = [] for value in kw_data: value = float(value - min_value) / data_range @@ -148,8 +150,8 @@ def loadFaults(grid , fault_file): def createDataStructures(grid_path=None, grid_data_path=None , polyline_root_path = None): if grid_path is not None: nx, ny, nz, grid_data, bounds, grid = loadGridData(grid_path) - data, data_range = loadKWData(grid_data_path, "FLTBLCK", ecl_type=EclTypeEnum.ECL_INT_TYPE) - faults = loadFaults( grid , os.path.join(polyline_root_path , "faults.grdecl")) + data, data_range = loadKWData(grid_data_path, "REGIONS", ecl_type=EclTypeEnum.ECL_INT_TYPE) + #faults = loadFaults( grid , os.path.join(polyline_root_path , "faults.grdecl")) else: # nx, ny, nz, grid_data, bounds = loadGridData("/Volumes/Statoil/data/faultregion/grid.grdecl") # data, data_range = loadKWData("/Volumes/Statoil/data/faultregion/fltblck.grdecl", "FLTBLCK", ecl_type=EclTypeEnum.ECL_INT_TYPE) @@ -158,6 +160,9 @@ def createDataStructures(grid_path=None, grid_data_path=None , polyline_root_pat data, data_range = loadKWData("/Volumes/Statoil/data/TestCase/eclipse/include/example_permx.GRDECL", "PERMX", ecl_type=EclTypeEnum.ECL_FLOAT_TYPE) faults = loadFaults( grid , os.path.join("/Volumes/Statoil/data/TestCase/eclipse/include" , "example_faults_sim.GRDECL")) + + + grid_texture = Texture3D(nx, ny, nz, grid_data, GL_RGBA32F, GL_RGBA) attribute_texture = Texture3D(nx, ny, nz, data) @@ -165,6 +170,7 @@ def createDataStructures(grid_path=None, grid_data_path=None , polyline_root_pat textures = {"grid": grid_texture, "grid_data": attribute_texture} + faults = None return textures, bounds, nx, ny, nz, data_range , faults @@ -197,6 +203,10 @@ def readPolylines(root_path): grid_data_path = None polyline_root_path = None + grid_path = "/d/proj/bg/enkf/ErtTestData/ECLIPSE/Mariner2/input/grids/maureen.grid.42" + grid_data_path = "/d/proj/bg/enkf/ErtTestData/ECLIPSE/Mariner2/output/maureen.regions" + + if len(sys.argv) == 4: grid_path = sys.argv[1] grid_data_path = sys.argv[2] @@ -220,7 +230,9 @@ def readPolylines(root_path): slice_settings = SliceSettingsWidget(max_slice_count=nz, color_scales=color_scales.keys()) slice_settings.inactiveCellsHidden.connect(viewer.hideInactiveCells) slice_settings.currentSliceChanged.connect(viewer.setCurrentSlice) + slice_settings.toggleOrthographicProjection.connect(viewer.useOrthographicProjection) + slice_settings.toggleLighting.connect(viewer.useLighting) slice_settings.colorScalesChanged.connect(viewer.changeColorScale) slice_settings.regionToggling.connect(viewer.useRegionScaling) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer_widget.py b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer_widget.py index b572723281..130374f585 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer_widget.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/viewer/slice_viewer_widget.py @@ -74,7 +74,7 @@ def __init__(self, textures=None, volume_bounds=None, color_scales=None, data_ra self.__hide_inactive_cells = False self.__lighting = False - self.__region_scaling = False + self.__region_scaling = True self.__flat_polylines = False @@ -236,7 +236,8 @@ def mouseMoveEvent(self, q_mouse_event): diff_x = q_mouse_event.x() - self.__mouse["x"] diff_y = q_mouse_event.y() - self.__mouse["y"] - self.__camera.rotate(0.0, 0.0, diff_y / 2.0) + #self.__camera.rotate(0.0, 0.0, diff_y / 2.0) + self.__camera.translate(diff_x / 1000.0 , diff_y / 1000.0 ) self.__mouse["x"] = q_mouse_event.x() self.__mouse["y"] = q_mouse_event.y() diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/CMakeLists.txt index 21ed5cf0ad..db5de5af8f 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/CMakeLists.txt @@ -8,6 +8,7 @@ set(PYTHON_SOURCES closable_dialog.py cogwheel.py combo_choice.py + custom_dialog.py double_box.py double_spinner.py error_popup.py @@ -16,7 +17,9 @@ set(PYTHON_SOURCES keyword_list.py keyword_table.py legend.py + list_edit_box.py list_spin_box.py + option_widget.py path_chooser.py path_format.py progress.py @@ -32,5 +35,5 @@ set(PYTHON_SOURCES workflow_dialog.py ) -add_python_package("python.ert_gui.widgets" ${PYTHON_INSTALL_PREFIX}/ert_gui/widgets "${PYTHON_SOURCES}" True) +add_python_package("python.ert_gui.widgets" ${PYTHON_INSTALL_PREFIX}/ert_gui/widgets "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/checkbox.py b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/checkbox.py index ac5e78ee3a..8b19e89380 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/checkbox.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/checkbox.py @@ -26,15 +26,15 @@ class CheckBox(HelpedWidget): """A checbox widget for booleans. The data structure expected and sent to the getter and setter is a boolean.""" - def __init__(self, model, check_label="Do this", help_link="", show_label = True, alt_label=None, default_check_state=True): + def __init__(self, model, label="Checkbox", help_link="", show_label=True, alt_label=None, default_check_state=True): """Construct a checkbox widget for booleans""" - HelpedWidget.__init__(self, check_label, help_link) + HelpedWidget.__init__(self, label, help_link) if show_label: - if alt_label != None: + if alt_label is not None: self.check = QCheckBox(alt_label, self) else: - self.check = QCheckBox(check_label,self) + self.check = QCheckBox(label,self) else: self.check = QCheckBox(self) @@ -59,7 +59,7 @@ def __init__(self, model, check_label="Do this", help_link="", show_label = True def contentsChanged(self): """Called whenever the contents of the checbox changes.""" - self.model.setTrue(self.check.isChecked()) + self.model.setState(self.check.isChecked()) def modelChanged(self): diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/custom_dialog.py b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/custom_dialog.py new file mode 100644 index 0000000000..9abc952aeb --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/custom_dialog.py @@ -0,0 +1,106 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'validated_dialog.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +from PyQt4.QtCore import Qt, QSize, SIGNAL +from PyQt4.QtGui import QDialog, QColor, QFormLayout, QLabel, QWidget, QDialogButtonBox, QLayout +from ert_gui.widgets.helped_widget import HelpedWidget + + +class CustomDialog(QDialog): + + INVALID_COLOR = QColor(255, 235, 235) + + def __init__(self, title = "Title", description = "Description", parent=None): + QDialog.__init__(self, parent) + + self.__option_list = [] + """ :type: list of HelpedWidget """ + + self.setModal(True) + self.setWindowTitle(title) + # self.setMinimumWidth(250) + # self.setMinimumHeight(150) + + self.layout = QFormLayout() + self.layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) + self.layout.setSizeConstraint(QLayout.SetFixedSize) + + label = QLabel(description) + label.setAlignment(Qt.AlignHCenter) + + self.layout.addRow(self.createSpace(5)) + self.layout.addRow(label) + self.layout.addRow(self.createSpace(10)) + + self.ok_button = None + + + self.setLayout(self.layout) + + def notValid(self, msg): + """Called when the name is not valid.""" + self.ok_button.setEnabled(False) + + def valid(self): + """Called when the name is valid.""" + self.ok_button.setEnabled(True) + + def optionValidationChanged(self): + valid = True + for option in self.__option_list: + if not option.isValid(): + valid = False + self.notValid("One or more options are incorrectly set!") + + if valid: + self.valid() + + + def showAndTell(self): + """ + Shows the dialog modally and returns the true or false (accept/reject) + @rtype: bool + """ + self.optionValidationChanged() + return self.exec_() + + def createSpace(self, size = 5): + """Creates a widget that can be used as spacing on a panel.""" + qw = QWidget() + qw.setMinimumSize(QSize(size, size)) + + return qw + + + def addOption(self, option_widget): + """ + @type option_widget: HelpedWidget + """ + assert isinstance(option_widget, HelpedWidget) + self.__option_list.append(option_widget) + option_widget.validationChanged.connect(self.optionValidationChanged) + self.layout.addRow(option_widget.getLabel(), option_widget) + + + def addButtons(self): + buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) + self.ok_button = buttons.button(QDialogButtonBox.Ok) + self.ok_button.setEnabled(False) + + self.layout.addRow(self.createSpace(10)) + self.layout.addRow(buttons) + + self.connect(buttons, SIGNAL('accepted()'), self.accept) + self.connect(buttons, SIGNAL('rejected()'), self.reject) diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/helped_widget.py b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/helped_widget.py index 5bb3aec5e1..a7f051f8a0 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/helped_widget.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/helped_widget.py @@ -24,8 +24,6 @@ class HelpedWidget(QWidget): def __init__(self, widget_label="", help_link=""): QWidget.__init__(self) - - if not widget_label == "": self.label = widget_label + ":" else: @@ -40,7 +38,7 @@ def __init__(self, widget_label="", help_link=""): self.setLayout(self.widget_layout) self.setMinimumHeight(20) - HelpedWidget.__error_popup = ErrorPopup() + self.__error_popup = ErrorPopup() self.destroyed.connect(self.cleanup) @@ -67,13 +65,14 @@ def setValidationMessage(self, message, validation_type=WARNING): if message == "": self.validation_type = None self.validation_message = None - HelpedWidget.__error_popup.hide() + self.__error_popup.hide() self.validationChanged.emit(True) else: self.validation_type = validation_type self.validation_message = message - HelpedWidget.__error_popup.presentError(self, self.validation_message) + if self.hasFocus() or self.underMouse(): + self.__error_popup.presentError(self, self.validation_message) self.validationChanged.emit(False) # HelpCenter.getHelpCenter("ERT").setHelpMessageLink() @@ -92,20 +91,25 @@ def enterEvent(self, event): # HelpedWidget.__error_popup = ErrorPopup() if self.validation_message is not None: - HelpedWidget.__error_popup.presentError(self, self.validation_message) + self.__error_popup.presentError(self, self.validation_message) def leaveEvent(self, event): QWidget.leaveEvent(self, event) - if HelpedWidget.__error_popup is not None: - HelpedWidget.__error_popup.hide() + if self.__error_popup is not None: + self.__error_popup.hide() def cleanup(self): """ Remove any model attachment or similar. Called when QT object is destroyed.""" pass + def hideEvent(self, hide_event): + self.__error_popup.hide() + super(HelpedWidget, self).hideEvent(hide_event) + + @staticmethod def addHelpToWidget(widget, link): original_enter_event = widget.enterEvent diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/list_edit_box.py b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/list_edit_box.py new file mode 100644 index 0000000000..b00b86aa9e --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/list_edit_box.py @@ -0,0 +1,181 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'path_chooser.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +from PyQt4.QtCore import SIGNAL, Qt, QSize +from PyQt4.QtGui import QLineEdit, QCompleter, QToolButton, QInputDialog, QMessageBox +from ert_gui.widgets.helped_widget import HelpedWidget +from ert_gui.widgets.util import resourceIcon + + +class AutoCompleteLineEdit(QLineEdit): + #http://blog.elentok.com/2011/08/autocomplete-textbox-for-multiple.html + def __init__(self, items, parent=None): + super(AutoCompleteLineEdit, self).__init__(parent) + + self.__separators = [",", " "] + + self.__completer = QCompleter(items, self) + self.__completer.setWidget(self) + self.__completer.activated[str].connect(self.__insertCompletion) + self.__completer.setCaseSensitivity(Qt.CaseInsensitive) + + self.__keysToIgnore = [Qt.Key_Enter, Qt.Key_Return, Qt.Key_Escape, Qt.Key_Tab] + + def __insertCompletion(self, completion): + extra = len(completion) - len(self.__completer.completionPrefix()) + extra_text = completion[-extra:] + extra_text += ', ' + self.setText(self.text() + extra_text) + + + def textUnderCursor(self): + text = self.text() + text_under_cursor = '' + i = self.cursorPosition() - 1 + while i >=0 and text[i] not in self.__separators: + text_under_cursor = text[i] + text_under_cursor + i -= 1 + return text_under_cursor + + + def keyPressEvent(self, event): + if self.__completer.popup().isVisible(): + if event.key() in self.__keysToIgnore: + event.ignore() + return + + super(AutoCompleteLineEdit, self).keyPressEvent(event) + + completion_prefix = self.textUnderCursor() + if completion_prefix != self.__completer.completionPrefix(): + self.__updateCompleterPopupItems(completion_prefix) + if len(event.text()) > 0 and len(completion_prefix) > 0: + self.__completer.complete() + if len(completion_prefix) == 0: + self.__completer.popup().hide() + + + def __updateCompleterPopupItems(self, completionPrefix): + self.__completer.setCompletionPrefix(completionPrefix) + self.__completer.popup().setCurrentIndex(self.__completer.completionModel().index(0,0)) + + + +class ListEditBox(HelpedWidget): + ITEM_DOES_NOT_EXIST_MSG = "The item: '%s' is not a possible choice." + NO_ITEMS_SPECIFIED_MSG = "The list must contain at least one item or * (for all)." + DEFAULT_MSG = "A list of comma separated case names or * for all." + + def __init__(self, possible_items, label="ListEdit", help_link=""): + HelpedWidget.__init__(self, label, help_link) + + self.__editing = True + self.__valid = True + self.__possible_items = possible_items + + self.list_edit_line = AutoCompleteLineEdit(possible_items, self) + self.list_edit_line.setMinimumWidth(350) + + self.addWidget(self.list_edit_line) + + dialog_button = QToolButton(self) + dialog_button.setIcon(resourceIcon("ide/small/add")) + dialog_button.setIconSize(QSize(16, 16)) + self.connect(dialog_button, SIGNAL('clicked()'), self.addChoice) + self.addWidget(dialog_button) + + + self.valid_color = self.list_edit_line.palette().color(self.list_edit_line.backgroundRole()) + + self.list_edit_line.setText("") + self.__editing = False + + self.connect(self.list_edit_line, SIGNAL('editingFinished()'), self.validateList) + self.connect(self.list_edit_line, SIGNAL('textChanged(QString)'), self.validateList) + + self.validateList() + + + def getListText(self): + text = str(self.list_edit_line.text()) + text = "".join(text.split()) + return text + + def getItems(self): + text = self.getListText() + items = text.split(",") + + if len(items) == 1 and items[0] == "*": + items = self.__possible_items + + return [item for item in items if len(item) > 0] + + + def validateList(self): + """Called whenever the list is modified""" + palette = self.list_edit_line.palette() + + items = self.getItems() + + valid = True + message = "" + + if len(items) == 0: + valid = False + message = ListEditBox.NO_ITEMS_SPECIFIED_MSG + else: + for item in items: + if item not in self.__possible_items: + valid = False + message = ListEditBox.ITEM_DOES_NOT_EXIST_MSG % item + + + + validity_type = self.WARNING + + if not valid: + color = self.ERROR_COLOR + else: + color = self.valid_color + + self.__valid = valid + + self.setValidationMessage(message, validity_type) + self.list_edit_line.setToolTip(message) + palette.setColor(self.list_edit_line.backgroundRole(), color) + + self.list_edit_line.setPalette(palette) + + if valid: + self.list_edit_line.setToolTip(ListEditBox.DEFAULT_MSG) + + def addChoice(self): + if len(self.__possible_items) == 0: + QMessageBox.information(self, "No items", "No items available for selection!") + else: + item, ok = QInputDialog.getItem(self, "Select a case", "Select a case to add to the case list:", self.__possible_items) + + if ok: + item = str(item).strip() + text = str(self.list_edit_line.text()).rstrip() + + if len(text) == 0: + text = item + ", " + elif text.endswith(","): + text += " " + item + else: + text += ", " + item + + self.list_edit_line.setText(text) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/option_widget.py b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/option_widget.py new file mode 100644 index 0000000000..fe47521077 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/option_widget.py @@ -0,0 +1,67 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'string_box.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +from PyQt4 import QtGui, QtCore +from ert_gui.widgets.helped_widget import HelpedWidget + + +class OptionWidget(HelpedWidget): + """Shows a tab widget. Validation status is against the current selected tab/widget.""" + + def __init__(self, path_label="Option", help_link=""): + HelpedWidget.__init__(self, path_label, help_link) + + self.tab_widget = QtGui.QTabWidget() + self.tab_widget.currentChanged.connect(self.validateTabs) + self.addWidget(self.tab_widget) + self.__widgets = {} + """ :type: dict of (int, HelpedWidget) """ + + + def validateTabs(self): + valid = self.isValid() + + if not valid: + self.validationChanged.emit(False) + else: + self.validationChanged.emit(True) + + def addHelpedWidget(self, label, helped_widget): + """ + @type label: str + @type helped_widget: HelpedWidget + """ + + index = self.tab_widget.addTab(helped_widget, label) + self.__widgets[index] = helped_widget + helped_widget.validationChanged.connect(self.validateTabs) + + def isValid(self): + current_widget = self.getCurrentWidget() + + if current_widget is not None: + return current_widget.isValid() + return False + + def getCurrentWidget(self): + index = self.tab_widget.currentIndex() + if index in self.__widgets: + return self.__widgets[index] + return None + + + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/path_chooser.py b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/path_chooser.py index 3a0f42b352..8dcec2732d 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/path_chooser.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/path_chooser.py @@ -24,14 +24,16 @@ class PathChooser(HelpedWidget): """ - PathChooser shows, enables choosing of and validates paths. + PathChooser: shows, enables choosing of and validates paths. The data structure expected and sent to the models getValue and setValue is a string. """ - file_does_not_exist_msg = "The specified path does not exist." - file_is_not_executable_msg = "The specified file is not an executable." - path_is_not_a_file_msg = "The specified path must be a file." - required_field_msg = "A value is required." + PATH_DOES_NOT_EXIST_MSG = "The specified path does not exist." + FILE_IS_NOT_EXECUTABLE_MSG = "The specified file is not an executable." + PATH_IS_NOT_A_FILE_MSG = "The specified path must be a file." + PATH_IS_NOT_ABSOLUTE_MSG = "The specified path must be an absolute path." + PATH_IS_NOT_A_DIRECTORY_MSG = "The specified path must be a directory." + REQUIRED_FIELD_MSG = "A path is required." # UNDEFINED = 0 # REQUIRED = 1 @@ -44,15 +46,17 @@ def __init__(self, model, path_label="Path", help_link=""): HelpedWidget.__init__(self, path_label, help_link) self.__editing = True + self.__valid = True self.path_line = QLineEdit() + self.path_line.setMinimumWidth(250) self.addWidget(self.path_line) dialog_button = QToolButton(self) - dialog_button.setIcon(resourceIcon("folder")) + dialog_button.setIcon(resourceIcon("ide/small/folder")) dialog_button.setIconSize(QSize(16, 16)) - self.connect(dialog_button, SIGNAL('clicked()'), self.selectDirectory) + self.connect(dialog_button, SIGNAL('clicked()'), self.selectPath) self.addWidget(dialog_button) self.valid_color = self.path_line.palette().color(self.path_line.backgroundRole()) @@ -63,55 +67,67 @@ def __init__(self, model, path_label="Path", help_link=""): assert isinstance(model, PathModelMixin) self.model = model model.observable().attach(PathModelMixin.PATH_CHANGED_EVENT, self.getPathFromModel) - self.getPathFromModel() self.connect(self.path_line, SIGNAL('editingFinished()'), self.validatePath) self.connect(self.path_line, SIGNAL('editingFinished()'), self.contentsChanged) self.connect(self.path_line, SIGNAL('textChanged(QString)'), self.validatePath) + self.getPathFromModel() + + + + def isPathValid(self, path): + """ @rtype: tuple of (bool, str) """ + path = path.strip() + path_exists = os.path.exists(path) + is_file = os.path.isfile(path) + is_directory = os.path.isdir(path) + is_executable = os.access(path, os.X_OK) + is_absolute = os.path.isabs(path) + + valid = True + message = "" + + if path == "": + if self.model.pathIsRequired(): + valid = False + message = PathChooser.REQUIRED_FIELD_MSG + elif not path_exists: + if self.model.pathMustExist(): + valid = False + message = PathChooser.PATH_DOES_NOT_EXIST_MSG + #todo: check if new (non-existing) file has directory or file format? + elif path_exists: + if self.model.pathMustBeExecutable() and is_file and not is_executable: + valid = False + message = PathChooser.FILE_IS_NOT_EXECUTABLE_MSG + elif self.model.pathMustBeADirectory() and not is_directory: + valid = False + message = PathChooser.PATH_IS_NOT_A_DIRECTORY_MSG + elif self.model.pathMustBeAbsolute() and not is_absolute: + valid = False + message = PathChooser.PATH_IS_NOT_ABSOLUTE_MSG + elif self.model.pathMustBeAFile() and not is_file: + valid = False + message = PathChooser.PATH_IS_NOT_A_FILE_MSG + + return valid, message - def getValidationTypeAndColor(self): - """Returns the type of validation message and the color that should be applied""" - if self.model.pathIsRequired(): - color = self.ERROR_COLOR - validity_type = self.WARNING - else: - color = self.INVALID_COLOR - validity_type = self.EXCLAMATION - return validity_type, color def validatePath(self): """Called whenever the path is modified""" palette = self.path_line.palette() - path = self.getPath().strip() - exists = os.path.exists(path) + valid, message = self.isPathValid(self.getPath()) - color = self.valid_color - message = "" validity_type = self.WARNING - self.valid = True - - if path == "" and self.model.pathIsRequired(): - message = self.required_field_msg + if not valid: color = self.ERROR_COLOR - self.valid = False - elif not exists: - if self.model.pathMustExist(): - message = self.file_does_not_exist_msg - self.valid = False - validity_type, color = self.getValidationTypeAndColor() - elif exists: - if self.model.pathMustBeExecutable() and os.path.isfile(path) and not os.access(path, os.X_OK): - validity_type, color = self.getValidationTypeAndColor() - message = self.file_is_not_executable_msg - self.valid = False - elif self.model.pathMustBeExecutable() and not os.path.isfile(path): - validity_type, color = self.getValidationTypeAndColor() - message = self.path_is_not_a_file_msg - self.valid = False - + else: + color = self.valid_color + + self.__valid = valid self.setValidationMessage(message, validity_type) self.path_line.setToolTip(message) @@ -122,7 +138,7 @@ def validatePath(self): def getPath(self): """Returns the path""" - return str(self.path_line.text()) + return str(self.path_line.text()).strip() def pathExists(self): """Returns True if the entered path exists""" @@ -130,30 +146,31 @@ def pathExists(self): def isValid(self): """Returns the validation value""" - return self.valid + return self.__valid - def selectDirectory(self): - """Pops up the 'select a directory' dialog""" + def selectPath(self): + """Pops up the 'select a file/directory' dialog""" + # todo: This probably needs some reworking to work properly with different scenarios... (file + dir) self.__editing = True - currentDirectory = self.getPath() + current_directory = self.getPath() #if not os.path.exists(currentDirectory): # currentDirectory = "~" if self.model.pathMustBeAFile(): - currentDirectory = QFileDialog.getOpenFileName(self, "Select a path", currentDirectory) + current_directory = QFileDialog.getOpenFileName(self, "Select a file path", current_directory) else: - currentDirectory = QFileDialog.getExistingDirectory(self, "Select a directory", currentDirectory) + current_directory = QFileDialog.getExistingDirectory(self, "Select a directory", current_directory) - if not currentDirectory == "": + if not current_directory == "": if not self.model.pathMustBeAbsolute(): cwd = os.getcwd() - match = re.match(cwd + "/(.*)", currentDirectory) + match = re.match(cwd + "/(.*)", current_directory) if match: - currentDirectory = match.group(1) + current_directory = match.group(1) - self.path_line.setText(currentDirectory) + self.path_line.setText(current_directory) self.model.setPath(self.getPath()) self.__editing = False @@ -161,15 +178,10 @@ def selectDirectory(self): def contentsChanged(self): """Called whenever the path is changed.""" - if not self.__editing: - if self.model.pathIsRequired() and (self.model.pathMustExist() and self.pathExists()): - # print("Pathchooser value set!") - self.model.setPath(self.getPath()) - - #todo: FIX!!!! + path_is_valid, message = self.isPathValid(self.getPath()) - # else: - # print("Pathchooser value not set!") + if not self.__editing and path_is_valid: + self.model.setPath(self.getPath()) def getPathFromModel(self): @@ -183,3 +195,7 @@ def getPathFromModel(self): self.path_line.setText("%s" % path) self.__editing = False + + def cleanup(self): + self.model.observable().detach(PathModelMixin.PATH_CHANGED_EVENT, self.getPathFromModel) + diff --git a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/string_box.py b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/string_box.py index 0c0f0c949a..c811be7e9a 100644 --- a/ThirdParty/Ert/devel/python/python/ert_gui/widgets/string_box.py +++ b/ThirdParty/Ert/devel/python/python/ert_gui/widgets/string_box.py @@ -34,6 +34,7 @@ def __init__(self, model, path_label="String", help_link="", defaultString=""): self.connect(self.box_string, QtCore.SIGNAL('textChanged(QString)'), self.validateString) self.addWidget(self.box_string) + self.valid_color = self.box_string.palette().color(self.box_string.backgroundRole()) self.box_string.setText(defaultString) self.__validator = None @@ -49,17 +50,15 @@ def validateString(self): if self.__validator is not None: status = self.__validator.validate(string_to_validate) + palette = QPalette() if not status: self.setValidationMessage(str(status), HelpedWidget.EXCLAMATION) - palette = QPalette() - palette.setColor(QPalette.Text, Qt.red) + palette.setColor(self.box_string.backgroundRole(), self.ERROR_COLOR) self.box_string.setPalette(palette) else: self.setValidationMessage("") - palette = QPalette() - palette.setColor(QPalette.Text, Qt.black) + palette.setColor(self.box_string.backgroundRole(), self.valid_color) self.box_string.setPalette(palette) - self.stringBoxChanged() def stringBoxChanged(self): diff --git a/ThirdParty/Ert/devel/python/test/CMakeLists.txt b/ThirdParty/Ert/devel/python/test/CMakeLists.txt deleted file mode 100644 index 9b21ce7155..0000000000 --- a/ThirdParty/Ert/devel/python/test/CMakeLists.txt +++ /dev/null @@ -1,660 +0,0 @@ -set(NFS_RUNPATH "" CACHE STRING "Disk area which is shared among cluster nodes and can be used as CWD for LSF/RSH jobs.") -set(RSH_SERVERS "" CACHE STRING "List of nodes which will be used to test the RSH driver") - -set(TEST_SOURCES - ert_tests/__init__.py - ert_tests/run_tests.py - ert_tests/test_ert_import.py - ert_tests/import_tester.py - - ert_tests/config/__init__.py - ert_tests/config/test_config.py - - ert_tests/cwrap/__init__.py - ert_tests/cwrap/test_cwrap.py - - ert_tests/ecl/__init__.py - ert_tests/ecl/test_deprecation.py - ert_tests/ecl/test_ecl_default.py - ert_tests/ecl/test_ecl_file.py - ert_tests/ecl/test_ecl_submit.py - ert_tests/ecl/test_fortio.py - ert_tests/ecl/test_grdecl.py - ert_tests/ecl/test_grid.py - ert_tests/ecl/test_kw.py - ert_tests/ecl/test_legacy_ecl.py - ert_tests/ecl/test_region.py - ert_tests/ecl/test_restart.py - ert_tests/ecl/test_rft.py - ert_tests/ecl/test_rft_cell.py - ert_tests/ecl/test_sum.py - ert_tests/ecl/test_ecl_sum_vector.py - ert_tests/ecl/test_faults.py - ert_tests/ecl/test_statoil_faults.py - ert_tests/ecl/test_fault_blocks.py - ert_tests/ecl/test_region_definition_statoil.py - ert_tests/ecl/test_region_definition.py - ert_tests/ecl/test_npv.py - ert_tests/ecl/test_indexed_read.py - - ert_tests/enkf/__init__.py - ert_tests/enkf/test_ert_context.py - ert_tests/enkf/test_enkf.py - ert_tests/enkf/test_enkf_fs.py - ert_tests/enkf/test_enkf_fs_manager1.py - ert_tests/enkf/test_enkf_fs_manager2.py - ert_tests/enkf/test_enkf_library.py - ert_tests/enkf/test_enkf_load_results_manually.py - ert_tests/enkf/test_analysis_config.py - ert_tests/enkf/test_analysis_iter_config.py - ert_tests/enkf/test_state_map.py - ert_tests/enkf/test_time_map.py - ert_tests/enkf/test_enkf_obs.py - ert_tests/enkf/test_run_arg.py - ert_tests/enkf/plot/test_plot_data.py - ert_tests/enkf/data/test_gen_data.py - ert_tests/enkf/data/test_gen_data_config.py - ert_tests/enkf/data/test_gen_kw.py - - ert_tests/analysis/__init__.py - ert_tests/analysis/test_options_enum.py - ert_tests/analysis/test_analysis_module.py - - ert_tests/job_queue/__init__.py - ert_tests/job_queue/test_ert_script.py - ert_tests/job_queue/test_function_ert_script.py - ert_tests/job_queue/test_job_queue.py - ert_tests/job_queue/test_workflow.py - ert_tests/job_queue/test_workflow_job.py - ert_tests/job_queue/test_workflow_joblist.py - ert_tests/job_queue/test_workflow_runner.py - ert_tests/job_queue/workflow_common.py - - ert_tests/sched/__init__.py - ert_tests/sched/test_sched.py - - ert_tests/util/__init__.py - ert_tests/util/test_ctime.py - ert_tests/util/test_hash.py - ert_tests/util/test_lookup_table.py - ert_tests/util/test_matrix.py - ert_tests/util/test_stat.py - ert_tests/util/test_string_list.py - ert_tests/util/test_vectors.py - ert_tests/util/test_ui_return.py - ert_tests/util/test_thread_pool.py - ert_tests/util/test_work_area.py - - ert_tests/gui/__init__.py - ert_tests/gui/test_model.py - ert_tests/gui/test_observable.py - - ert_tests/gui/plot/test_plot_metrics_tracker.py - - ert_tests/gui/ide/__init__.py - ert_tests/gui/ide/test_bool_argument.py - ert_tests/gui/ide/test_configuration_line.py - ert_tests/gui/ide/test_configuration_line_builder.py - ert_tests/gui/ide/test_configuration_line_definition.py - ert_tests/gui/ide/test_configuration_line_parser.py - ert_tests/gui/ide/test_ert_keywords.py - ert_tests/gui/ide/test_float_argument.py - ert_tests/gui/ide/test_integer_argument.py - ert_tests/gui/ide/test_percent_argument.py - ert_tests/gui/ide/test_path_argument.py - ert_tests/gui/ide/test_path_argument.py - ert_tests/gui/ide/test_proper_name_argument.py - ert_tests/gui/ide/test_proper_name_format_argument.py - ert_tests/gui/ide/test_proper_name_format_string_argument.py - ert_tests/gui/ide/test_range_string_argument.py - ert_tests/gui/ide/test_tokens.py - - ert_tests/gui/ide/wizards/__init__.py - ert_tests/gui/ide/wizards/test_tree_structure.py - - ert_tests/geometry/__init__.py - ert_tests/geometry/test_polyline.py - ert_tests/geometry/test_intersection.py - ert_tests/geometry/test_convex_hull.py - ert_tests/geometry/test_point_in_polygon.py - ert_tests/geometry/test_polygon_slicing.py - - - ert_tests/run/__init__.py - ert_tests/run/test_run.py - - ert_tests/server/test_server.py - ert_tests/server/test_socket.py - - ert_tests/well/test_ecl_well.py - ert_tests/well/test_ecl_well2.py - - ecl_isosurf.py - ens_config_test.py - grav_test.py - grid_test0.py - job_test.py - petrel_kw.py - poly_test.py - troll_test.py - ctest_run.py - ctest_import.py -) - -if (ERT_BUILD_GUI) - LIST(APPEND ${TEST_SOURCES} ert_tests/test_ert_gui_import.py) -endif() - -add_python_package("python.tests" "${PYTHON_INSTALL_PREFIX}/test" "${TEST_SOURCES}" False) - -# The test data is located in the current source directory; that is -# the reason we set that as the working directory for the test -# run. The module to import should then be in the default python -# module search path (i.e. current directory), whereas the location of -# the actual ert package is given by the first argument to ctest. - - -add_test( NAME python.tests.ert.import - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} - COMMAND python test/ctest_import.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} "ert") - - - -if (ERT_BUILD_GUI) - add_test( NAME python.tests.ert_gui.import - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} - COMMAND python test/ctest_import.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} "ert_gui") -endif() - - -#UTIL - -add_test( NAME python.tests.ert.util.stringlist - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_string_list.StringListTest ) - -add_test( NAME python.tests.ert.util.ui_return - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_ui_return.UIReturnTest ) - -add_test( NAME python.tests.ert.util.tvector - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_vectors.UtilTest ) - -add_test( NAME python.tests.ert.util.ctime - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_ctime.CTimeTest) - - -add_test( NAME python.tests.ert.util.hash - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_hash.HashTest) - -add_test( NAME python.tests.ert.util.work_area - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_work_area.WorkAreaTest) - -#add_test( NAME python.tests.ert.util.latex -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -# COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_latex.LatexTest ) - -add_test( NAME python.tests.ert.util.lookup_table - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_lookup_table.LookupTableTest ) - -add_test( NAME python.tests.ert.util.matrix - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_matrix.MatrixTest ) - -add_test( NAME python.tests.ert.util.stat - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.util.test_stat.StatTest ) - - -#ENKF -add_test( NAME python.tests.ert.enkf.enkf - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_enkf.EnKFTest) - -add_test( NAME python.tests.ert.enkf.enkf_obs - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_enkf_obs.EnKFObsTest) - -add_test( NAME python.tests.ert.enkf.enkf_load_results_manually - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_enkf_load_results_manually.LoadResultsManuallyTest) - -add_test( NAME python.tests.ert.enkf.enkf_fs - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_enkf_fs.EnKFFSTest) - -add_test( NAME python.tests.ert.enkf.ert_log - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_ert_log.ErtLogTest) - - -add_test( NAME python.tests.ert.enkf.enkf_fs_manager1 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_enkf_fs_manager1.EnKFFSManagerTest1) - -add_test( NAME python.tests.ert.enkf.enkf_fs_manager2 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_enkf_fs_manager2.EnKFFSManagerTest2) - -add_test( NAME python.tests.ert.enkf.enkf_library - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_enkf_library.EnKFLibraryTest) - -add_test( NAME python.tests.ert.enkf.analysis_config - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_analysis_config.AnalysisConfigTest) - -add_test( NAME python.tests.ert.enkf.analysis_iter_config - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_analysis_iter_config.AnalysisIterConfigTest) - -add_test( NAME python.tests.ert.enkf.state_map - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_state_map.StateMapTest) - -add_test( NAME python.tests.ert.enkf.time_map - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_time_map.TimeMapTest) - -add_test( NAME python.tests.ert.enkf.ecl_config - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_ecl_config.EclConfigTest) - -add_test( NAME python.tests.ert.enkf.plot.plot_block_data - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.plot.test_plot_data.PlotDataTest) - -add_test( NAME python.tests.ert.enkf.data.gen_data - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.data.test_gen_data.GenDataTest) - -add_test( NAME python.tests.ert.enkf.data.gen_data_config - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.data.test_gen_data_config.GenDataConfigTest) - -add_test( NAME python.tests.ert.enkf.data.gen_kw - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.data.test_gen_kw.GenKwTest) - -add_test( NAME python.tests.ert.enkf.ert_test_context - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_ert_context.ErtTestContextTest) - -add_test( NAME python.tests.ert.enkf.run_arg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.enkf.test_run_arg.RunArg) - - - - -#GUI -if (ERT_BUILD_GUI) - add_test( NAME python.tests.ert_gui.models - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.test_model.ModelTest) - - add_test( NAME python.tests.ert_gui.models.observable - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.test_observable.ObservableTest) - - add_test( NAME python.tests.ert_gui.plot.plot_metrics_tracker - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.plot.test_plot_metrics_tracker.PlotMetricTrackerTest) - - add_test( NAME python.tests.ert_gui.ide.bool_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_bool_argument.BoolArgumentTest) - - add_test( NAME python.tests.ert_gui.ide.integer_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_integer_argument.IntegerArgumentTest) - - add_test( NAME python.tests.ert_gui.ide.float_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_float_argument.FloatArgumentTest) - - add_test( NAME python.tests.ert_gui.ide.path_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_path_argument.PathArgumentTest) - - add_test( NAME python.tests.ert_gui.ide.proper_name_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_proper_name_argument.ProperNameArgumentTest) - - add_test( NAME python.tests.ert_gui.ide.proper_name_format_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_proper_name_format_argument.ProperNameFormatArgumentTest) - - add_test( NAME python.tests.ert_gui.ide.proper_name_format_string_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_proper_name_format_string_argument.ProperNameFormatStringArgumentTest) - - add_test( NAME python.tests.ert_gui.ide.range_string_argument - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_range_string_argument.RangeStringArgumentTest) - - - add_test( NAME python.tests.ert_gui.ide.test_configuration_line - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_configuration_line.ConfigurationLineTest) - - add_test( NAME python.tests.ert_gui.ide.test_configuration_line_builder - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_configuration_line_builder.ConfigurationLineBuilderTest) - - add_test( NAME python.tests.ert_gui.ide.test_configuration_line_definition - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_configuration_line_definition.ConfigurationLineDefinitionTest) - - add_test( NAME python.tests.ert_gui.ide.test_configuration_line_parser - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_configuration_line_parser.ConfigurationLineParserTest) - - - - add_test( NAME python.tests.ert_gui.ide.ert_keywords - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_ert_keywords.ErtKeywordTest) - - add_test( NAME python.tests.ert_gui.ide.tokens - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.test_tokens.TokenTest) - - add_test( NAME python.tests.ert_gui.ide.wizards.tree_structure - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.gui.ide.wizards.test_tree_structure.TreeStructureTest) - -endif() - -#ECL - - -add_test( NAME python.tests.ert.ecl.ecl_default - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_default.EclDefaultTest ) - -add_test( NAME python.tests.ert.ecl.ecl_file - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_file.EclFileTest) - -add_test( NAME python.tests.ert.ecl.ecl_queue_LOCAL - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_submit.LocalSubmitTest ) - -if (NOT ${NFS_RUNPATH} STREQUAL "") - add_test( NAME python.tests.ert.ecl.ecl_queue_LSF - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_submit.LSFSubmitTest ${NFS_RUNPATH} ) - set_property( TEST python.tests.ert.ecl.ecl_queue_LSF PROPERTY LABELS Python:StatoilData:Slow ) - - if (NOT ${RSH_SERVERS} STREQUAL "") - add_test( NAME python.tests.ert.ecl.ecl_queue_RSH - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_submit.RSHSubmitTest ${NFS_RUNPATH} ${RSH_SERVERS}) - set_property( TEST python.tests.ert.ecl.ecl_queue_RSH PROPERTY LABELS Python:StatoilData:Slow ) - endif() -endif() - - -add_test( NAME python.tests.ert.ecl.fortio - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_fortio.FortIOTest) - - -add_test( NAME python.tests.ert.ecl.ecl_grdecl - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_grdecl.GRDECLTest ) - -add_test( NAME python.tests.ert.ecl.ecl_grid - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_grid.GridTest ) - -add_test( NAME python.tests.ert.ecl.ecl_kw - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_kw.KWTest ) - -add_test( NAME python.tests.ert.ecl.legacy_ecl - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_legacy_ecl.LegacyEclTest) - -add_test( NAME python.tests.ert.ecl.ecl_restart - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_restart.RestartTest) - -add_test( NAME python.tests.ert.ecl.ecl_region - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_region.RegionTest) - -add_test( NAME python.tests.ert.ecl.ecl_rft - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_rft.RFTTest) - -add_test( NAME python.tests.ert.ecl.ecl_rft_cell - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_rft_cell.RFTCellTest) - -add_test( NAME python.tests.ert.ecl.ecl_sum - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_sum.SumTest) - -add_test( NAME python.tests.ert.ecl.ecl_sum_vector - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_sum_vector.EclSumVectorTest) - -add_test( NAME python.tests.ert.ecl.ecl_sum_time_range - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_ecl_sum.EclSumTest) - -add_test( NAME python.tests.ert.ecl.layer - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_layer.LayerTest ) - -add_test( NAME python.tests.ert.ecl.faults - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_faults.FaultTest ) - -add_test( NAME python.tests.ert.ecl.fault_blocks - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_fault_blocks.FaultBlockTest ) - -add_test( NAME python.tests.ert.ecl.region_definition_statoil - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_region_definition_statoil.RegionDefinitionTest ) - -add_test( NAME python.tests.ert.ecl.region_definition - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_region_definition.RegionDefinitionTest ) - -add_test( NAME python.tests.ert.ecl.fault_blocks_statoil - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_fault_blocks_statoil.FaultBlockTest ) - -add_test( NAME python.tests.ert.ecl.ecl_npv - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_npv.NPVTest) - -add_test( NAME python.tests.ert.ecl.statoil_faults - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_statoil_faults.StatoilFaultTest ) - -add_test( NAME python.tests.ert.ecl.ecl_deprecation - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_deprecation.DeprecationTest ) - -add_test( NAME python.tests.ert.ecl.indexed_read - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.ecl.test_indexed_read.EclIndexedReadTest ) - -#SCHED -add_test( NAME python.tests.ert.sched.sched - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.sched.test_sched.SchedFileTest) - -#JOB QUEUE -add_test( NAME python.tests.ert.job_queue.job_status_type_enum - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.job_queue.test_job_queue.JobQueueTest) - -add_test( NAME python.tests.ert.job_queue.workflow_job - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.job_queue.test_workflow_job.WorkflowJobTest) - -add_test( NAME python.tests.ert.job_queue.workflow - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.job_queue.test_workflow.WorkflowTest) - -add_test( NAME python.tests.ert.job_queue.workflow_joblist - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.job_queue.test_workflow_joblist.WorkflowJoblistTest) - -add_test( NAME python.tests.ert.job_queue.ert_script - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.job_queue.test_ert_script.ErtScriptTest) - -add_test( NAME python.tests.ert.job_queue.function_ert_script - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.job_queue.test_function_ert_script.FunctionErtScriptTest) - -add_test( NAME python.tests.ert.job_queue.workflow_runner - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.job_queue.test_workflow_runner.WorkflowRunnerTest) - - - -#CONFIG -add_test( NAME python.tests.ert.config - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.config.test_config.ConfigTest) - - -#CWRAP -add_test( NAME python.tests.ert.cwrap - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.cwrap.test_cwrap.CWRapTest) - -add_test( NAME python.tests.ert.cwrap.basecclass - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.cwrap.test_basecclass.BaseCClassTest) - -add_test( NAME python.tests.ert.cwrap.basecenum - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.cwrap.test_basecenum.BaseCEnumTest) - -add_test( NAME python.tests.ert.cwrap.basecvalue - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.cwrap.test_basecvalue.BaseCValueTest) - - -#TESTRUN -add_test( NAME python.tests.ert.test_run - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.run.test_run.RunTest ) - -#ANALYSIS -add_test( NAME python.tests.ert.analysis.enums - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.analysis.test_options_enum.AnalysisOptionsEnumTest) - -add_test( NAME python.tests.ert.analysis.analysis_module - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.analysis.test_analysis_module.AnalysisModuleTest) - - - -#GEOMETRY - -add_test( NAME python.tests.ert.geometry.polyline - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.geometry.test_polyline.PolylineTest) - -add_test( NAME python.tests.ert.geometry.intersection - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.geometry.test_intersection.IntersectionTest) - -add_test( NAME python.tests.ert.geometry.convex_hull - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.geometry.test_convex_hull.ConvexHullTest) - -add_test( NAME python.tests.ert.geometry.point_in_polygon - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.geometry.test_point_in_polygon.PointInPolygonTest) - -add_test( NAME python.tests.ert.geometry.polygon_slicing - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.geometry.test_polygon_slicing.PolygonSlicingTest) - - -#SERVER - -#add_test( NAME python.tests.ert.server.socket -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -# COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.server.test_socket.SocketTest) - -#add_test( NAME python.tests.ert.server.server -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -# COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.server.test_server.ServerTest) - - -# ECL_WELL -add_test( NAME python.tests.ert.well.ecl_well - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.well.test_ecl_well.EclWellTest) - - -add_test( NAME python.tests.ert.well.ecl_well2 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ert_tests.well.test_ecl_well2.EclWellTest2) - - -set_property( TEST python.tests.ert.sched.sched PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.fortio PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_grdecl PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_restart PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_region PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_file PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_queue_LOCAL PROPERTY LABELS Python:StatoilData:Slow ) -set_property( TEST python.tests.ert.ecl.ecl_sum PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_npv PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_kw PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_rft PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_sum_vector PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.indexed_read PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_grid PROPERTY LABELS Python:StatoilData:Slow ) -set_property( TEST python.tests.ert.ecl.ecl_deprecation PROPERTY LABELS Python ) -#set_property( TEST python.tests.import_local PROPERTY LABELS Python:StatoilBuild ) -set_property( TEST python.tests.ert.well.ecl_well PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.well.ecl_well2 PROPERTY LABELS Python:StatoilData ) - -set_property( TEST python.tests.ert.test_run PROPERTY LABELS Python) -set_property( TEST python.tests.ert.import PROPERTY LABELS Python) -set_property( TEST python.tests.ert.util.stringlist PROPERTY LABELS Python ) -set_property( TEST python.tests.ert.util.tvector PROPERTY LABELS Python ) -set_property( TEST python.tests.ert.ecl.faults PROPERTY LABELS Python ) - -set_property( TEST python.tests.ert.ecl.region_definition_statoil PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.fault_blocks_statoil PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.statoil_faults PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.enkf PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.ecl_config PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.enkf_fs PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.enkf_fs_manager1 PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.enkf_fs_manager2 PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.enkf_obs PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.enkf_load_results_manually PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.ert_test_context PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.plot.plot_block_data PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.data.gen_data_config PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.enkf.data.gen_data PROPERTY LABELS Python:StatoilData ) -set_property( TEST python.tests.ert.ecl.ecl_sum_time_range PROPERTY LABELS Python:StatoilData ) - -if (ERT_BUILD_GUI) - set_property( TEST python.tests.ert_gui.import PROPERTY ENVIRONMENT "ERT_SHARE_PATH=${PROJECT_SOURCE_PATH}/share") - set_property( TEST python.tests.ert_gui.import PROPERTY LABELS Python) - set_property( TEST python.tests.ert_gui.models PROPERTY LABELS Python) - set_property( TEST python.tests.ert_gui.models.observable PROPERTY LABELS Python) -endif() diff --git a/ThirdParty/Ert/devel/python/test/README b/ThirdParty/Ert/devel/python/test/README deleted file mode 100644 index 9fbf5a1619..0000000000 --- a/ThirdParty/Ert/devel/python/test/README +++ /dev/null @@ -1,27 +0,0 @@ -This directory contains some tests which can be used to test a local -ert-python installation before installing. To be certain that you are -actually testing the Python installation you are working on, and not -picking up previously installed versions you must make sure that: - - 1. The path $ERT-ROOT/devel/python/python is on the front of your - $PYTHONPATH environment variable. - - 2. That the python modules will find the shared libraries built as - part of your build process. This is achieved by adding a link - $ERT-ROOT/devel/python/lib64 pointing to the $ERT-BUILD/lib64 - area; where $ERT-BUILD is wherever you have compiled ert. - -The scripts local_bash and local_csh will update your environment with -a correct value of $PYTHONPATH: - - ps1> source local_xxx - -The lib64 link can not be made automagically, because your personal -build area could be anywhere. However the script will check that a -directory link lib64 exists and print a warning if not. - - - - - - diff --git a/ThirdParty/Ert/devel/python/test/ecl_isosurf.py b/ThirdParty/Ert/devel/python/test/ecl_isosurf.py deleted file mode 100644 index 287368ab6e..0000000000 --- a/ThirdParty/Ert/devel/python/test/ecl_isosurf.py +++ /dev/null @@ -1,227 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'ecl_isosurf.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - - -import sys -import os.path -import ert.ecl.ecl_util as ecl_util -import ert.ecl as ecl -import ert.util.tvector -from ert.util.lookup_table import LookupTable - - -# This function will scan the vertical column specified by (i,j) and -# collect the pairs ( value(kw) , depth ) in a lookuptable. When the -# full column has been scanned it will lookup the value @level in the -# lookuptable and return the corresponding depth, based on linear -# interpolation. -# -# If @level is out of bounds - i.e. it is above the highest value -# found in the column, or below the lowest value, the behaviour will -# depend on whether we are searching for gas levels or water levels, -# if we aware searching for gas the behaviour is as follows: -# -# o If @level is above the found maximum level we return reservoir -# top. -# o If @level is below the found minimum level we return reservoir -# bottom. -# -# When searching for water levels the behaviour os opposite. -# -# If the only one or zero active cells is founc in the column, the -# value None is returned. -# -# -# Caveat: Non unique depth profile - - - -def usage(): - print """ -The ecl_isosurf script can be used to extract isosurfaces of the SWAT -or SGAS keywords from a restart file. When using the program you must -give commandline arguments about: - - o Which restart file you want to use, and in case of unified restart - file which report_step you are interested in. The program will - look for a EGRID/GRID file with the same basename. - - o Which phase you are interested in - i.e. SWAT or SGAS. - - o The name of an output file where the surface will be - stored. Observe that this filename will be used a format - specifier, hence a float placeholder (i.e. something like %g / - %4.2f ) will be replaced with the level value when creating the - output file - that way you can create several iso surface with one - program invocation. - - o The iso levels you are interested in. - -Example 1: - - ecl_isosurf ECLIPSE.UNRST 25 SWAT surfaces/swat_%4.2f 0.50 0.6 0.70 0.80 0.90 - - This will look for a unified restart file "ECLIPSE.UNRST" in the - current directory, and load solution data from report step 25 in - that restart file. We will focus on water, i.e. the SWAT keyword, - and the output surfaces will be stored in files surfaces/swat_0.50, - surfaces/swat_0.60, surfaces/swat_0.70, ... the directory surfaces - will be created if it does not exist. - - -Example 2: - - ecl_isosurf /path/to/ECLIPSE.X0060 SGAS sgas_iso 0.50 - - In this case we give a non-unified restart filename, and then we - should not include a report number. Observe that we assume that the - grid is in the same directory as the restart file. In this case we - are interested the gas, and only at the iso level 0.50. Since we are - only interested in one level, we do not include any % formatting - characters in the output filename. -""" - sys.exit() - -def iso_level( grid , kw , level , i , j ): - depth_value = LookupTable() - klist = range(grid.nz) - if kw.name == "SGAS": - gas = True - else: - gas = False - - for k in klist: - if grid.active( ijk = (i,j,k) ): - depth_value.append( grid.grid_value( kw , i,j,k) , grid.depth( ijk = (i,j,k))) - - if depth_value.size > 1: - if depth_value.arg_max > level and depth_value.arg_min < level: - depth = depth_value.interp( level ) - k = grid.locate_depth( depth , i , j ) - return (depth , k) - else: - # The level we are searching is outside the [min,max] - # range present in this column. We return values - # corresponding to reservoir top / reservoir bottom - # depending on the phase we are seaking, and whether we - # are above the max or below the min value present. - if gas: - if depth_value.arg_max < level: - depth = grid.top( i , j) - k = 0 - else: - depth = grid.bottom( i , j ) - k = grid.nz - 1 - else: - if depth_value.arg_max < level: - depth = grid.bottom( i , j) - k = grid.nz - 1 - else: - depth = grid.top( i , j ) - k = 0 - return (depth , k) - else: - # The column zero or one active cells, not enough to determine - # a saturation-depth relationship. - return (None , 0) - - -# Creates a iso surface on the level @level of the phase found in @kw. - -def write_surface( grid , kw , output_fmt , level ): - if output_fmt.find("%") > -1: - output_file = output_fmt % level - else: - output_file = output_fmt - - (path , file) = os.path.split( output_file ) - if path: - if not os.path.exists( path ): - os.makedirs( path ) - print "Creating surface: %s" % output_file - fileH = open( output_file , "w") - for i in range(grid.nx): - for j in range(grid.ny): - (depth , k) = iso_level( grid , kw , level ,i,j) - if depth: - (utm_x , utm_y , tmp) = grid.get_xyz( ijk=(i,j,k) ) - fileH.write("%12.5f %12.5f %12.5f\n" % (utm_x , utm_y , depth)) - fileH.close() - - - -# The arguments to the ecl_isosurf script must be given on the -# commandline; the full list of commandline arguments is then sent up -# here for parsing and loading of files. -# -# The function will return a tuple of four elements: -# -# (grid , kw , output_fmt , level_list) - -def load_input( arglist ): - if len(arglist) < 3: - usage() - - input_file = arglist[0] - file_type = ecl_util.get_file_type( input_file ) - if file_type == ecl_util.ECL_UNIFIED_RESTART_FILE: - try: - report_step = int( arglist[1] ) - except: - usage() - - if os.path.exists( input_file ): - ecl_file = ecl.EclFile.restart_block( input_file , report_step = report_step ) - else: - usage() - arg_offset = 2 - elif file_type == ecl_util.ECL_RESTART_FILE: - if os.path.exists( input_file ): - ecl_file = ecl.EclFile( input_file ) - else: - usage() - arg_offset = 1 - else: - usage() - - (path_base , ext) = os.path.splitext( input_file ) - grid = ecl.EclGrid( path_base ) - if not grid: - usage() - - phase = arglist[ arg_offset ].upper() - if phase in ["SWAT" , "SGAS"]: - kw = ecl_file.iget_named_kw( phase , 0 ) - else: - sys.exit("Must give phase : SWAT / SGAS ") - - output_fmt = arglist[ arg_offset + 1 ] - level_list = [] - for level in arglist[arg_offset + 2:]: - level_list.append( float( level ) ) - - return (grid , kw , output_fmt , level_list ) - - -################################################################# -# Main program -################################################################# - -(grid , kw , output_fmt , level_list) = load_input( sys.argv[1:] ) - -for level in level_list: - write_surface( grid , kw , output_fmt , level ) diff --git a/ThirdParty/Ert/devel/python/test/ens_config_test.py b/ThirdParty/Ert/devel/python/test/ens_config_test.py deleted file mode 100644 index 642b52dd2a..0000000000 --- a/ThirdParty/Ert/devel/python/test/ens_config_test.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2012 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - -import datetime -import unittest -import ert -import ert.enkf.enkf as enkf -from test_util import approx_equal, approx_equalv -from ert.util.stringlist import StringList - -case = "/private/inmyr/ERT-Intro/testcase/ert_config" -site_conf_file = "/project/res/etc/ERT/site-config" -obs_config_file = "/private/inmyr/ERT-Intro/testcase/observations" - -class EnsConfigTest( unittest.TestCase ): - def setUp(self): - pass - - def test_key(self): - main = enkf.EnKFMain.bootstrap( case , site_conf_file) - conf = main.config - self.assertTrue( conf.hasKey("WWCT:OP_1" )) - self.assertFalse( conf.hasKey("WWCT:OP_1X" )) - - def test_enkf_conf_node(self): - main = enkf.EnKFMain.bootstrap( case , site_conf_file) - conf = main.config - s = StringList(initial = None, c_ptr=conf.alloc_keylist) - self.assertTrue( isinstance( conf.getNode("MULTFLT") , ert.enkf.enkf_config_node.EnkfConfigNode)) - self.assertTrue( isinstance( s , ert.util.stringlist.StringList)) - - - -unittest.main() diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/config/test_config.py b/ThirdParty/Ert/devel/python/test/ert_tests/config/test_config.py deleted file mode 100644 index 70747b2e2e..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/config/test_config.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2012 Statoil ASA, Norway. -# -# The file 'test_config.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - -from ert.config import ContentTypeEnum, UnrecognizedEnum, SchemaItem, ContentItem, ContentNode, ConfigParser -from ert.test import ExtendedTestCase - - -class ConfigTest(ExtendedTestCase): - def setUp( self ): - self.file_list = [] - - - def test_enums(self): - source_file_path = "libconfig/include/ert/config/config_schema_item.h" - self.assertEnumIsFullyDefined(ContentTypeEnum, "config_item_types", source_file_path) - - self.assertTrue(UnrecognizedEnum.CONFIG_UNRECOGNIZED_ERROR) - - - - - def test_parse(self): - conf = ConfigParser() - conf.add("FIELD", False) - schema_item = conf.add("RSH_HOST", False) - self.assertIsInstance(schema_item, SchemaItem) - test_path = self.createTestPath("local/config/simple_config") - self.assertTrue(conf.parse(test_path, unrecognized=UnrecognizedEnum.CONFIG_UNRECOGNIZED_IGNORE)) - - - content_item = conf["RSH_HOST"] - self.assertIsInstance(content_item, ContentItem) - self.assertIsNone(conf["BJARNE"]) - - self.assertEqual(len(content_item), 1) - self.assertRaises(ValueError, content_item.__getitem__, "BJARNE") - self.assertRaises(IndexError, content_item.__getitem__, 10) - - content_node = content_item[0] - self.assertIsInstance(content_node, ContentNode) - - self.assertEqual(len(content_node), 2) - self.assertRaises(ValueError, content_node.__getitem__, "BJARNE") - self.assertRaises(IndexError, content_node.__getitem__, 10) - self.assertEqual(content_node[1], "be-lx633214:2") - - self.assertEqual(content_node.content(sep=","), "be-lx655082:2,be-lx633214:2") - self.assertEqual(content_node.content(), "be-lx655082:2 be-lx633214:2") - - content_item = conf["FIELD"] - self.assertEqual(len(content_item), 5) - self.assertRaises(IOError, ConfigParser.parse, conf, "DoesNotExits") - - - def test_schema(self): - schema_item = SchemaItem("TestItem") - self.assertIsInstance(schema_item, SchemaItem) - self.assertEqual(schema_item.iget_type(6), ContentTypeEnum.CONFIG_STRING) - schema_item.iset_type(0, ContentTypeEnum.CONFIG_INT) - self.assertEqual(schema_item.iget_type(0), ContentTypeEnum.CONFIG_INT) - schema_item.set_argc_minmax(3, 6) - - del schema_item diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum.py deleted file mode 100644 index 65ed92a699..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum.py +++ /dev/null @@ -1,43 +0,0 @@ -# !/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -from ert.ecl import EclSum -from ert.test import ExtendedTestCase - -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -class EclSumTest(ExtendedTestCase): - def setUp(self): - self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") - self.ecl_sum = EclSum(self.test_file) - - def test_time_range_year(self): - real_range = self.ecl_sum.timeRange(interval="1y", extend_end = False) - extended_range = self.ecl_sum.timeRange(interval="1y", extend_end = True) - assert real_range[-1] < extended_range[-1] - - def test_time_range_day(self): - real_range = self.ecl_sum.timeRange(interval = "1d", extend_end = False) - extended_range = self.ecl_sum.timeRange(interval = "1d", extend_end = True) - assert real_range[-1] == extended_range[-1] - - def test_time_range_month(self): - real_range = self.ecl_sum.timeRange(interval = "1m", extend_end = False) - extended_range = self.ecl_sum.timeRange(interval = "1m", extend_end = True) - assert real_range[-1] < extended_range[-1] \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fault_blocks.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fault_blocks.py deleted file mode 100644 index f8c570da52..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fault_blocks.py +++ /dev/null @@ -1,233 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -from ert.ecl import EclGrid, EclTypeEnum , EclKW , EclRegion -from ert.test import ExtendedTestCase , TestAreaContext -from ert.ecl.faults import FaultBlock, FaultBlockLayer, FaultBlockCell - - -class FaultBlockTest(ExtendedTestCase): - def setUp(self): - self.grid = EclGrid.create_rectangular( (10,10,10) , (1,1,1) ) - self.kw = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_INT_TYPE ) - self.kw.assign( 1 ) - - reg = EclRegion( self.grid , False ) - - for k in range(self.grid.getNZ()): - reg.clear( ) - reg.select_kslice( k , k ) - self.kw.assign( k , mask = reg ) - self.kw[ k * self.grid.getNX() * self.grid.getNY() + 7] = 177 - - - - def test_fault_block(self): - grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) ) - kw = EclKW.create( "FAULTBLK" , grid.size , EclTypeEnum.ECL_INT_TYPE ) - kw.assign( 0 ) - for j in range(1,4): - for i in range(1,4): - g = i + j*grid.getNX() - kw[g] = 1 - - layer = FaultBlockLayer( grid , 0 ) - layer.scanKeyword( kw ) - block = layer[1] - - self.assertEqual( (2.50 , 2.50) , block.getCentroid() ) - self.assertEqual( len(block) , 9) - self.assertEqual( layer , block.getParentLayer() ) - - - def test_neighbours(self): - - with TestAreaContext("python/fault_block_layer/neighbour") as work_area: - with open("kw.grdecl","w") as fileH: - fileH.write("FAULTBLK \n") - fileH.write("1 1 1 0 0\n") - fileH.write("1 2 2 0 3\n") - fileH.write("4 2 2 3 3\n") - fileH.write("4 4 4 0 0\n") - fileH.write("4 4 4 0 5\n") - fileH.write("/\n") - - kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE) - - grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) ) - layer = FaultBlockLayer( grid , 0 ) - - layer.loadKeyword( kw ) - block1 = layer.getBlock( 1 ) - block2 = layer.getBlock( 2 ) - block3 = layer.getBlock( 3 ) - block4 = layer.getBlock( 4 ) - block5 = layer.getBlock( 5 ) - self.assertEqual( block1.getParentLayer() , layer ) - - #Expected: 1 -> {2,4}, 2 -> {1,3,4}, 3 -> {2}, 4 -> {1,2}, 5-> {} - - neighbours = block1.getNeighbours() - self.assertEqual( len(neighbours) , 2) - self.assertTrue( block2 in neighbours ) - self.assertTrue( block4 in neighbours ) - - neighbours = block2.getNeighbours() - self.assertEqual( len(neighbours) , 3) - self.assertTrue( block1 in neighbours ) - self.assertTrue( block3 in neighbours ) - self.assertTrue( block4 in neighbours ) - - neighbours = block3.getNeighbours() - self.assertEqual( len(neighbours) , 1) - self.assertTrue( block2 in neighbours ) - - neighbours = block4.getNeighbours() - self.assertEqual( len(neighbours) , 2) - self.assertTrue( block1 in neighbours ) - self.assertTrue( block2 in neighbours ) - - neighbours = block5.getNeighbours() - self.assertEqual( len(neighbours) , 0) - - - - - def test_fault_block_edge(self): - grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) ) - kw = EclKW.create( "FAULTBLK" , grid.size , EclTypeEnum.ECL_INT_TYPE ) - kw.assign( 0 ) - for j in range(1,4): - for i in range(1,4): - g = i + j*grid.getNX() - kw[g] = 1 - - layer = FaultBlockLayer( grid , 0 ) - #with self.assertRaises: - # layer.getEdgePolygon( ) - - - - def test_fault_block_layer(self): - with self.assertRaises(ValueError): - layer = FaultBlockLayer( self.grid , -1 ) - - with self.assertRaises(ValueError): - layer = FaultBlockLayer( self.grid , self.grid.size ) - - layer = FaultBlockLayer( self.grid , 1 ) - self.assertEqual( 1 , layer.getK() ) - - kw = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_FLOAT_TYPE ) - with self.assertRaises(ValueError): - layer.scanKeyword( kw ) - - layer.scanKeyword( self.kw ) - self.assertEqual( 2 , len(layer) ) - - with self.assertRaises(TypeError): - ls = layer["JJ"] - - l = [] - for blk in layer: - l.append( blk ) - self.assertEqual( len(l) , 2 ) - - l0 = layer[0] - l1 = layer[1] - self.assertTrue( isinstance(l1 , FaultBlock )) - l0.getCentroid() - l1.getBlockID() - - with self.assertRaises(IndexError): - l2 = layer[2] - - - self.assertEqual( True , 1 in layer) - self.assertEqual( True , 2 in layer) - self.assertEqual( False , 77 in layer) - self.assertEqual( False , 177 in layer) - - l1 = layer.getBlock( 1 ) - self.assertTrue( isinstance(l1 , FaultBlock )) - - with self.assertRaises(KeyError): - l =layer.getBlock(66) - - with self.assertRaises(KeyError): - layer.deleteBlock(66) - - layer.deleteBlock(2) - self.assertEqual( 1 , len(layer)) - blk = layer[0] - self.assertEqual( blk.getBlockID() , 1 ) - - with self.assertRaises(KeyError): - layer.addBlock(1) - - blk2 = layer.addBlock(2) - self.assertEqual( len(layer) , 2 ) - - blk3 = layer.addBlock() - self.assertEqual( len(layer) , 3 ) - - - layer.addBlock(100) - layer.addBlock(101) - layer.addBlock(102) - layer.addBlock(103) - - layer.deleteBlock(2) - blk1 = layer.getBlock( 103 ) - blk2 = layer[-1] - self.assertEqual( blk1.getBlockID() , blk2.getBlockID() ) - - fault_block = layer[0] - fault_block.assignToRegion( 2 ) - self.assertEqual( [2] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 2 ) - self.assertEqual( [2] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 3 ) - self.assertEqual( [2,3] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 1 ) - self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) - - fault_block.assignToRegion( 2 ) - self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) - - - - def test_fault_block_layer_export(self): - layer = FaultBlockLayer( self.grid , 1 ) - kw1 = EclKW.create( "FAULTBLK" , self.grid.size + 1 , EclTypeEnum.ECL_INT_TYPE ) - with self.assertRaises(ValueError): - layer.exportKeyword( kw1 ) - - kw2 = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_FLOAT_TYPE ) - with self.assertRaises(TypeError): - layer.exportKeyword(kw2) - - - - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_faults.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_faults.py deleted file mode 100644 index b3d68d674e..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_faults.py +++ /dev/null @@ -1,289 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ert.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment -from ert.ecl import EclGrid -from ert.test import ExtendedTestCase -from ert.geo import Polyline - -class FaultTest(ExtendedTestCase): - def setUp(self): - self.faults1 = self.createTestPath("local/ECLIPSE/FAULTS/fault1.grdecl") - self.faults2 = self.createTestPath("local/ECLIPSE/FAULTS/fault2.grdecl") - self.grid = EclGrid.create_rectangular( (151,100,50) , (1,1,1)) - - - def test_empty_collection(self): - faults = FaultCollection(self.grid) - self.assertEqual(0 , len(faults)) - - self.assertFalse( faults.hasFault("FX") ) - - with self.assertRaises(TypeError): - f = faults[ [] ] - - with self.assertRaises(KeyError): - f = faults["FX"] - - with self.assertRaises(IndexError): - f = faults[0] - - - def test_splitLine(self): - faults = FaultCollection(self.grid) - with self.assertRaises(ValueError): - # Not slash terminated - t = faults.splitLine("'F1' 149 149 29 29 1 43 'Y'") - - with self.assertRaises(ValueError): - # Not integer - t = faults.splitLine("'F1' 149 149 29 29 1 43X 'Y' /") - - with self.assertRaises(ValueError): - # Missing item - t = faults.splitLine("'F1' 149 29 29 1 43 'Y' /") - - with self.assertRaises(ValueError): - # Quote fuckup - t = faults.splitLine("'F1 149 149 29 29 1 43 'X' /") - - - def test_empty_fault( self ): - f = Fault(self.grid , "NAME") - self.assertEqual("NAME" , f.getName()) - - with self.assertRaises(KeyError): - g = f["Key"] - - with self.assertRaises(KeyError): - g = f[0] - - self.assertEqual( len(f) , 0 ) - - - def test_empty_faultLine(self): - fl = FaultLine(self.grid , 10) - self.assertEqual( 10 , fl.getK()) - self.assertEqual( 0 , len(fl) ) - - with self.assertRaises(TypeError): - f = fl[ "Test" ] - - with self.assertRaises(IndexError): - f = fl[0] - - - def test_faultLine(self): - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(0 , 10) - S2 = FaultSegment(10 , 20) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - fl.verify() - S3 = FaultSegment(20 , 30) - fl.tryAppend( S3 ) - fl.verify() - #--- - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(0 , 10) - S2 = FaultSegment(20 , 10) - fl.tryAppend( S1 ) - self.assertTrue( fl.tryAppend( S2 ) ) - fl.verify() - #--- - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(10 , 0) - S2 = FaultSegment(20 , 10) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - fl.verify() - #--- - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(10 , 0) - S2 = FaultSegment(10 , 20) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - fl.verify() - - fl = FaultLine(self.grid , 10) - S1 = FaultSegment(10 , 0) - S2 = FaultSegment(10 , 20) - fl.tryAppend( S1 ) - fl.tryAppend( S2 ) - S3 = FaultSegment(40 , 30) - self.assertTrue( fl.tryAppend(S3) == False ) - self.assertEqual( len(fl) , 2 ) - - pl = fl.getPolyline( ) - self.assertIsInstance( pl , Polyline ) - self.assertEqual( len(pl) , len(fl) + 1 ) - - S3 = FaultSegment(20 , 30) - fl.tryAppend( S3 ) - pl = fl.getPolyline( ) - self.assertIsInstance( pl , Polyline ) - self.assertEqual( len(pl) , len(fl) + 1 ) - - - - - def test_load(self): - faults = FaultCollection(self.grid , self.faults1) - self.assertEqual( 3 , len(faults)) - faults.load( self.faults2 ) - self.assertEqual( 7 , len(faults)) - fault1 = faults["F1"] - layer8 = fault1[8] - self.assertEqual( len(layer8) , 1 ) - - - def test_iter(self): - faults = FaultCollection(self.grid , self.faults1 , self.faults2) - self.assertEqual( 7 , len(faults)) - c = 0 - for f in faults: - c += 1 - self.assertEqual( c , len(faults)) - - - - def test_fault(self): - f = Fault(self.grid , "NAME") - - with self.assertRaises(ValueError): - # Invalid face - f.addRecord( 10 , 10 , 11 , 11 , 1 , 43 , "F") - - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( -1 , 10 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( 10000 , 10 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") - - - with self.assertRaises(ValueError): - # Invalid coordinates - f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates/face combination - f.addRecord( 10 , 11 , 11 , 11 , 1 , 43 , "X") - - with self.assertRaises(ValueError): - # Invalid coordinates/face combination - f.addRecord( 10 , 11 , 11 , 12 , 1 , 43 , "Y") - - f.addRecord(10 , 10 , 0 , 10 , 1 , 10 , "X") - - - def test_segment(self ): - s0 = FaultSegment(0 , 10) - self.assertEqual(s0.getC1() , 0 ) - self.assertEqual(s0.getC2() , 10 ) - - s0.swap() - self.assertEqual(s0.getC1() , 10 ) - self.assertEqual(s0.getC2() , 0 ) - - - - def test_fault_line(self ): - faults = FaultCollection(self.grid , self.faults1 , self.faults2) - for fault in faults: - for layer in fault: - for fl in layer: - fl.verify() - - - - - - def test_neighbour_cells(self): - nx = 10 - ny = 8 - nz = 7 - grid = EclGrid.create_rectangular( (nx , ny , nz) , (1,1,1) ) - faults_file = self.createTestPath("local/ECLIPSE/FAULTS/faults_nb.grdecl") - faults = FaultCollection( grid , faults_file ) - - fault = faults["FY"] - self.assertEqual(len(fault),1) - fault_layer = fault[0] - - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(0, nx) , (1,nx + 1), (2,nx+2) , (3,nx + 3) , (4,nx+4)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - fl2 = fault_layer[1] - nb_cells2 = fl2.getNeighborCells() - true_nb_cells2 = [(6, nx+6) , (7,nx + 7), (8 , nx+8) , (9,nx + 9)] - self.assertListEqual( nb_cells2 , true_nb_cells2 ) - - nb_cells = fault_layer.getNeighborCells() - self.assertListEqual( nb_cells , true_nb_cells1 + true_nb_cells2) - - - fault = faults["FY0"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(-1,0) , (-1,1), (-1,2)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - - fault = faults["FYNY"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(nx * (ny - 1) , -1), (nx * (ny - 1) + 1 , -1), (nx * (ny - 1) + 2, -1)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - fault = faults["FX"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(0,1) , (nx , nx+1) , (2*nx , 2*nx + 1)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - - fault = faults["FX0"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(-1 , 0) , (-1 , nx) , (-1 , 2*nx)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - - fault = faults["FXNX"] - fault_layer = fault[0] - fl1 = fault_layer[0] - nb_cells1 = fl1.getNeighborCells() - true_nb_cells1 = [(nx -1 , -1) , (2*nx -1 , -1) , (3*nx - 1 , -1)] - self.assertListEqual( nb_cells1 , true_nb_cells1 ) - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_layer.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_layer.py deleted file mode 100644 index 5cffccc51a..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_layer.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_layer.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ert.ecl.faults import Layer -from ert.test import ExtendedTestCase - -class LayerTest(ExtendedTestCase): - def setUp(self): - pass - - - def test_create_layer(self): - layer = Layer(10,10) - self.assertTrue( isinstance( layer , Layer )) - - - def test_add_cell(self): - layer = Layer(10,10) - with self.assertRaises(ValueError): - layer[100,100] = 199 - - with self.assertRaises(ValueError): - layer[100,"X"] = 199 - - with self.assertRaises(ValueError): - layer[100] = 199 - - layer[5,5] = 88 - self.assertEqual(layer[5,5] , 88) - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region_definition.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region_definition.py deleted file mode 100644 index f5ca78c8f4..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region_definition.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_region_definition.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ert.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment, RegionDefinition, FaultBlockLayer -from ert.ecl import EclGrid, EclKW, EclTypeEnum -from ert.test import ExtendedTestCase -from ert.geo import Polyline - - - -class RegionDefinitionTest(ExtendedTestCase): - def setUp(self): - self.grid = EclGrid.create_rectangular( (16,16,1) , (1,1,1) ) - self.poly1 = Polyline(init_points = [(0,0) , (0,4) , (5,5) , (0,5)]) - self.poly2 = Polyline(init_points = [(11,11) , (16,12) , (16,16) , (12,16)]) - self.fault_block_kw = EclKW.create( "FAULTBLK" , self.grid.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE ) - self.fault_block_kw.assign( 0 ) - self.faults = FaultCollection( self.grid ) - for j in range(4): - for i in range(4): - g1 = i + j*self.grid.getNX() - g2 = i + 12 + (j + 12)* self.grid.getNX() - - self.fault_block_kw[g1] = 1 - self.fault_block_kw[g2] = 2 - - self.fault_blocks = [] - for k in range(self.grid.getNZ()): - block = FaultBlockLayer( self.grid , k) - block.scanKeyword( self.fault_block_kw ) - self.fault_blocks.append( block ) - - - - def test_add_edge(self): - createRegion = RegionDefinition( 1 ) - with self.assertRaises(TypeError): - createRegion.addEdge("Poly1") - - with self.assertRaises(TypeError): - createRegion.addEdge(112) - - - def test_update(self): - reg1 = RegionDefinition( 1 ) - reg2 = RegionDefinition( 2 ) - - self.assertTrue( not reg1.hasPolygon() ) - - reg1.addEdge( self.poly1 ) - reg2.addEdge( self.poly2 ) - - self.assertTrue( reg1.hasPolygon() ) - - - region_kw = EclKW.create( "REGIONS" , self.grid.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE ) - region_kw.assign( 0 ) - block_list1 = [] - block_list2 = [] - - with self.assertRaises(NotImplementedError): - block_list1 = reg1.findInternalBlocks(self.grid , reg1.splitFaultBlocks(self.grid , self.fault_blocks[0])) - - with self.assertRaises(NotImplementedError): - block_list2 = reg2.findInternalBlocks(self.grid , reg2.splitFaultBlocks(self.grid , self.fault_blocks[0])) - - if block_list1: - for block in block_list1: - region_id = reg1.getRegionID() - block.assignToRegion( region_id ) - for g in block.getGlobalIndexList(): - region_kw[g] = region_id - - if block_list2: - for block in block_list2: - region_id = reg2.getRegionID() - block.assignToRegion( region_id ) - for g in block.getGlobalIndexList(): - region_kw[g] = region_id - - for j in range(4): - for i in range(4): - g1 = i + j*self.grid.getNX() - g2 = i + 12 + (j + 12)* self.grid.getNX() - - #self.assertEqual(region_kw[g1] , 1) - #self.assertEqual(region_kw[g2] , 2) - - #self.assertEqual( region_kw.sum() , 16 * 3 ) - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region_definition_statoil.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region_definition_statoil.py deleted file mode 100644 index 49ae20d480..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region_definition_statoil.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_region_definition_statoil.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ert.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment, RegionDefinition, FaultBlockLayer -from ert.ecl import EclGrid, EclKW, EclTypeEnum -from ert.test import ExtendedTestCase -from ert.geo import Polyline - - - -class RegionDefinitionTest(ExtendedTestCase): - def setUp(self): - self.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID")) - - with open( self.createTestPath("Statoil/ECLIPSE/Mariner/faultblock.grdecl") ) as fileH: - self.kw = EclKW.read_grdecl( fileH , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE ) - - self.faults = FaultCollection( self.grid , self.createTestPath("Statoil/ECLIPSE/Mariner/faults.grdecl")) - self.poly_file1 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol1.xyz") - self.poly_file2 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol2.xyz") - self.poly_file3 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol3.xyz") - self.poly_file4 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol4.xyz") - self.poly_file5 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol5.xyz") - self.poly_file6 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol6.xyz") - self.poly_file7 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol7.xyz") - self.poly_file8 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol8.xyz") - self.poly_file9 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol9.xyz") - self.poly_file10 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol10.xyz") - self.poly_file11 = self.createTestPath("Statoil/ECLIPSE/Mariner/pol11.xyz") - - self.fault_blocks = [] - for k in range(self.grid.getNZ()): - blocks = FaultBlockLayer( self.grid , k) - blocks.scanKeyword( self.kw ) - self.fault_blocks.append( blocks ) - - - def test_create(self): - with self.assertRaises(TypeError): - regionDef = RegionDefinition( "GG" ) - - with self.assertRaises(ValueError): - regionDef = RegionDefinition.create( 1 , self.faults , ["Test" , 1]) - - regionDef = RegionDefinition.create( 1 , self.faults , ["DF28_LC" , self.poly_file1 , self.poly_file2 ]) - - - - def test_create(self): - defRegion = RegionDefinition.create( 5 , self.faults , ["DF4_MC","DF15_MC","DF43_MC","DF25_LC","DF21_C","DF1_C",self.poly_file6, "DF26_MC","DF34_MCS","DF32_MC",self.poly_file5]) - region_kw = EclKW.create( "REGIONS" , self.grid.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE ) - region_kw.assign( 0 ) - - for k in range(self.grid.getNZ()): - with self.assertRaises(NotImplementedError): - block_list = defRegion.findInternalBlocks( self.grid , self.fault_blocks[k] ) - - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_statoil_faults.py b/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_statoil_faults.py deleted file mode 100644 index 6eb17eaefb..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_statoil_faults.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ert.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment -from ert.ecl import EclGrid,EclKW,EclTypeEnum -from ert.test import ExtendedTestCase - - - -class StatoilFaultTest(ExtendedTestCase): - def loadGrid(self): - grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl") - fileH = open(grid_file, "r") - specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False) - zcorn = EclKW.read_grdecl(fileH, "ZCORN") - coord = EclKW.read_grdecl(fileH, "COORD") - actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE) - - return EclGrid.create(specgrid, zcorn, coord, actnum) - - - - - def test_load(self): - grid = self.loadGrid() - faults_file = self.createTestPath("Statoil/ECLIPSE/Faults/faults.grdecl") - faults = FaultCollection( grid , faults_file ) - for fault in faults: - for layer in fault: - for fl in layer: - fl.verify() - - - - - - - - - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_obs.py b/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_obs.py deleted file mode 100644 index fead4bfcdd..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_obs.py +++ /dev/null @@ -1,36 +0,0 @@ -from ert.enkf import ObsVector -from ert.util import BoolVector -from ert.test import ErtTestContext -from ert.test import ExtendedTestCase - - -class EnKFObsTest(ExtendedTestCase): - def setUp(self): - self.config_file = self.createTestPath("Statoil/config/obs_testing/config") - - def testObs(self): - with ErtTestContext("obs_test", self.config_file) as test_context: - ert = test_context.getErt() - obs = ert.getObservations() - - self.assertEqual(31, len(obs)) - for v in obs: - self.assertTrue(isinstance(v, ObsVector)) - - with self.assertRaises(IndexError): - v = obs[-1] - - with self.assertRaises(IndexError): - v = obs[40] - - with self.assertRaises(KeyError): - v = obs["No-this-does-not-exist"] - - v1 = obs["WWCT:OP_3"] - v2 = obs["GOPT:OP"] - mask = BoolVector(True, ert.getEnsembleSize()) - current_fs = ert.getEnkfFsManager().getCurrentFileSystem() - - self.assertTrue(v1.hasData(mask, current_fs)) - self.assertFalse(v2.hasData(mask, current_fs)) - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/run_tests.py b/ThirdParty/Ert/devel/python/test/ert_tests/run_tests.py deleted file mode 100644 index 3b51a8ac17..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/run_tests.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -import sys -import os -from ert.test import ErtTestRunner - -sys.path.append( os.path.realpath( os.path.join(os.path.dirname( os.path.abspath( __file__)) , "../") )) - -if __name__ == '__main__': - ErtTestRunner.runTestsInDirectory(".") diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/server/test_client.py b/ThirdParty/Ert/devel/python/test/ert_tests/server/test_client.py deleted file mode 100644 index 2418376fcf..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/server/test_client.py +++ /dev/null @@ -1,22 +0,0 @@ -import socket - -class TestClient(object): - def __init__(self , port , host = "localhost"): - self.socket = socket.socket( socket.AF_INET , socket.SOCK_STREAM) - self.port = port - self.host = host - self.socket.connect((self.host , self.port)) - - - def send(self , data): - self.socket.sendall( data ) - - def recv(self): - data = self.socket.recv(1024) - return data - - @classmethod - def sendRecv(cls , port , data): - client = TestClient(port) - client.send( data ) - return client.recv() diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/server/test_socket.py b/ThirdParty/Ert/devel/python/test/ert_tests/server/test_socket.py deleted file mode 100644 index 5dbd8d9b5d..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/server/test_socket.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'test_socket.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - -import os -import time -import socket -import os -import signal -import json -import sys - -try: - from unittest2 import skipIf, skipUnless, skipIf -except ImportError: - from unittest import skipIf, skipUnless, skipIf - -from .test_client import TestClient -from ert.server import ErtSocket -from ert.util import StringList, TimeVector, DoubleVector - -from ert.test import ExtendedTestCase , TestAreaContext - - - - - - -class SocketTest(ExtendedTestCase): - def setUp(self): - self.config_path = self.createTestPath("local/resopt/config/simple") - self.config_file = "config" - self.port = 9125 - - - def sendRecv(self , send , expect): - recv = TestClient.sendRecv( self.port , json.dumps(send) + "\n") - self.assertEqual( json.loads(recv) , expect ) - - - def sendRecvRAW(self , send , expect): - recv = TestClient.sendRecv( self.port , send) - self.assertEqual( json.loads(recv) , expect ) - - - - def test_connect(self): - with TestAreaContext("server/socket") as work_area: - work_area.copy_directory_content(self.config_path) - pid = os.fork() - if pid == 0: - s = ErtSocket(self.config_file , self.port) - s.listen( ) - else: - time.sleep(0.50) - - self.sendRecv( ["ECHO" , "HEI"] , ["HEI"] ) - self.sendRecv( ["STATUS"] , ["OPEN"] ) - self.sendRecvRAW( "INVALID\n" , {"input" : "INVALID" , "ERROR" : "No JSON object could be decoded"}) - self.sendRecv( ["QUIT"] , ["QUIT"] ) - - diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_rng.py b/ThirdParty/Ert/devel/python/test/ert_tests/util/test_rng.py deleted file mode 100644 index a8e848e59e..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_rng.py +++ /dev/null @@ -1,14 +0,0 @@ -from ert.util.enums import RngAlgTypeEnum, RngInitModeEnum -from ert.util.rng import RandomNumberGenerator -from ert.test import ExtendedTestCase - - -class RngTest(ExtendedTestCase): - - def test_enums(self): - self.assertEnumIsFullyDefined(RngAlgTypeEnum, "rng_alg_type", "libert_util/include/ert/util/rng.h") - self.assertEnumIsFullyDefined(RngInitModeEnum, "rng_init_mode", "libert_util/include/ert/util/rng.h") - - def test_rng(self): - rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_CLOCK) - self.assertIsInstance(rng.getDouble(), float) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_stat.py b/ThirdParty/Ert/devel/python/test/ert_tests/util/test_stat.py deleted file mode 100644 index e2e0a944b8..0000000000 --- a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_stat.py +++ /dev/null @@ -1,21 +0,0 @@ -import random -from ert.util import DoubleVector, quantile, quantile_sorted -from ert.test import ExtendedTestCase - - -class StatTest(ExtendedTestCase): - def test_stat_quantiles(self): - v = DoubleVector() - for i in range(100000): - v.append(random.random()) - - self.assertAlmostEqual(quantile(v, 0.1), 0.1, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.2), 0.2, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.3), 0.3, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.4), 0.4, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.5), 0.5, 2) - # print quantile( v , 0.10 ) - # print quantile_sorted( v , 0.20 ) - # print quantile_sorted( v , 0.30 ) - # print quantile_sorted( v , 0.40 ) - # print quantile_sorted( v , 0.50 ) diff --git a/ThirdParty/Ert/devel/python/test/grav_test.py b/ThirdParty/Ert/devel/python/test/grav_test.py deleted file mode 100644 index b29e6fb6a0..0000000000 --- a/ThirdParty/Ert/devel/python/test/grav_test.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'grav_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - - -import datetime -import ert.ecl.ecl as ecl - - -# 1: We need the name of the GRID/EGRID file and the init file. Pass -# these two filenames to the EclGrav() constructor. -grid = ecl.EclGrid( "data/eclipse/grav/TROLL.EGRID" ) -init_file = ecl.EclFile( "data/eclipse/grav/TROLL.INIT" ) -grav = ecl.EclGrav( grid , init_file ) - - -# 2: We load the restart files for the times we are interested in, -# this can be done in two different ways: -# -# a) In the case of non unified restart files you can just use the -# EclFile() constructor to load the whole file: -# -# restart1 = ecl.EclFile("ECLIPSE.X0078") -# -# b) You can use the ecl.EclFile.restart_block() method to load -# only one block from a unified restart file. In that case you -# must use 'report_step = nnn' to specifiy which report_step you -# are interested in. Alternatively you can use 'dtime = -# datetime( year , month , day)' to specify which block are -# interested in. -# -# restart1 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , report_step = 88) -# restart2 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , dtime = datetime.datetime( 2008 , 12 , 1) ) - -restart1 = ecl.EclFile.restart_block("data/eclipse/grav/TROLL.UNRST" , report_step = 117 ) -restart2 = ecl.EclFile.restart_block("data/eclipse/grav/TROLL.UNRST" , report_step = 199 ) - - -# 3. Add the surveys - as loaded from restart files. Give them a -# sensible name as the first argument. You must add at least two -# surveys, but you can add as many as you like. - -grav.add_survey_PORMOD("PORMOD" , restart1 ) -grav.add_survey_RPORV("RPORV" , restart1 ) - -grav.new_std_density( ecl.ECL_GAS_PHASE , 0.77840 ) -grav.new_std_density( ecl.ECL_WATER_PHASE , 1045 ) -grav.add_survey_FIP("FIP" , restart1 ) - -# 4: Load the list of stations from file - this can of course be done -# any way you want. -stations = [] -fileH = open("data/eclipse/grav/gravity_stations_2002" , "r") -for line in fileH.readlines(): - tmp = line.split() - name = tmp[0] - pos = (float( tmp[1]) , float( tmp[2] ) , float( tmp[3] )) - stations.append( (name , pos) ) -fileH.close() - - -# 5. Evaluate the gravitational response for all the stations. -for (name, pos) in stations: - print "%-5s: %8.3f %8.3f" % (name , grav.eval( "PORMOD" , "FIP" , pos) , grav.eval( "RPORV" , None , pos) ) diff --git a/ThirdParty/Ert/devel/python/test/grid_test0.py b/ThirdParty/Ert/devel/python/test/grid_test0.py deleted file mode 100644 index 81d09732da..0000000000 --- a/ThirdParty/Ert/devel/python/test/grid_test0.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'grid_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - - -import ert -import ert.ecl.ecl as ecl - -from ert.ecl.ecl import * - -from ert.util.tvector import DoubleVector -from ert.util.tvector import DoubleVector - -def load_grid( grid_file ): - grid = ecl.EclGrid( grid_file ) - return grid - - -def load_egrid( egrid_file ): - grid = ecl.EclGrid( egrid_file ) - return grid - - -def load_grdecl( grdecl_file ): - fileH = open( grdecl_file , "r") - specgrid = EclKW.read_grdecl( fileH , "SPECGRID" , ecl_type = ecl.ECL_INT_TYPE , strict = False) - zcorn = EclKW.read_grdecl( fileH , "ZCORN" ) - coord = EclKW.read_grdecl( fileH , "COORD" ) - actnum = EclKW.read_grdecl( fileH , "ACTNUM" , ecl_type = ecl.ECL_INT_TYPE ) - - grid = ecl.EclGrid.create( specgrid , zcorn , coord , actnum ) - return grid - - -init_file = EclFile( "data/eclipse/case/ECLIPSE.INIT" ) -egrid_file = "data/eclipse/case/ECLIPSE.EGRID" -grid_file = "data/eclipse/case/ECLIPSE.GRID" -grdecl_file = "data/eclipse/case/include/example_grid_sim.GRDECL" - -grid = load_grdecl( grdecl_file ) -grid = load_grid( grid_file ) -grid = load_egrid( egrid_file ) - -print "Thickness(10,11,12): %g" % grid.cell_dz( ijk=(10,11,12) ) - -permx_column = DoubleVector( -999 ) -grid.load_column( init_file.iget_named_kw( "PERMX" , 0 ) , 5 , 5 , permx_column) -permx_column.printf() - -print "top2 : %g depth(10,10,0) : %g " % (grid.top( 10, 10) , grid.depth( ijk=(10,10,0))) -print "bottom2 : %g depth(10,10,nz-1) : %g " % (grid.bottom( 10 , 10 ) , grid.depth( ijk=(10,10,grid.nz - 1))) - -kw_list = init_file[1:7] -print kw_list diff --git a/ThirdParty/Ert/devel/python/test/job_test.py b/ThirdParty/Ert/devel/python/test/job_test.py deleted file mode 100644 index 5e20375cf9..0000000000 --- a/ThirdParty/Ert/devel/python/test/job_test.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'job_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - - -import os -import time -import sys -import shutil -import os.path -import ert.job_queue.driver as driver -import ert.ecl.ecl as ecl -import socket - -default = ecl.ecl_default.default - -server_list = { "be" : "lsf-be.no", - "st" : "lsf-st.no", - "tr" : "lsf-tr.no" } - -src_files = ["data/eclipse/case/ECLIPSE.DATA" , "data/eclipse/case/include"] -run_path_fmt = "tmp/simulations/run%d" - -default_driver_string = "LOCAL" -num_jobs = 10 -max_running = 2 - - -def copy_case( target_path , src_files): - if not os.path.exists( target_path ): - os.makedirs( target_path ) - - print "Creating simulation directory:%s" % target_path - for file in src_files: - if os.path.isfile( file ): - shutil.copy( file , target_path ) - elif os.path.isdir( file ): - (path , base) = os.path.split( file ) - if not os.path.exists( "%s/%s" % (target_path , base)): - shutil.copytree( file , "%s/%s" % (target_path , base) ) - else: - sys.exit("Error") - - - -def get_lsf_server(): - host = socket.gethostname() - site = host[:2] - lsf_server = server_list.get( site , False) - if not lsf_server: - print "Sorry - don't know what is the LSF server in:%s" % site - sys.exit() - return lsf_server - -################################################################# - -#lsf_driver = driver.LSFDriver( 1 ) -#local_driver = driver.LocalDriver( 3 ) -#rsh_driver = driver.RSHDriver( 1 , [("be-lx655082" , 2)]) - - -queue = ecl.EclQueue( driver_type = driver.LSF_DRIVER , max_running = 3) -joblist = [] -case_list = [] -for case_nr in range( num_jobs ): - copy_case( run_path_fmt % case_nr , src_files ) - case = ecl.EclCase( run_path_fmt % case_nr + "/ECLIPSE.DATA" ) - joblist.append(queue.submit( case.datafile )) - -while 1: - print "Waiting:%02d Running:%02d Complete:%02d" % (queue.num_waiting , queue.num_running , queue.num_complete), - for job in joblist: - print "[%02d] " % job.status, - print - time.sleep( 1 ) - - -queue.block_waiting() - -#while queue.running: - # print "Still running" - # time.sleep( 3 ) - - - diff --git a/ThirdParty/Ert/devel/python/test/local_bash b/ThirdParty/Ert/devel/python/test/local_bash deleted file mode 100644 index c96c5f856f..0000000000 --- a/ThirdParty/Ert/devel/python/test/local_bash +++ /dev/null @@ -1,15 +0,0 @@ -export PYTHONPATH=$PWD/../python:$PYTHONPATH -export PYTHONPATH=$PWD/../test:$PYTHONPATH -lib_path="../lib64"; - -if [ -d "$lib_path" ]; then - if [ -s "$lib_path" ]; then - target=$(readlink -f $lib_path) - echo "Using $lib_path -> $target for shared libraries." - else - echo "** Warning: $lib_path is not a symbolic link ??" - fi -else - echo "** Warning: can not find directory/link: $lib_path - will not find newly compiled shared libraries." -fi - \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/local_csh b/ThirdParty/Ert/devel/python/test/local_csh deleted file mode 100644 index 5eacc17a0b..0000000000 --- a/ThirdParty/Ert/devel/python/test/local_csh +++ /dev/null @@ -1,16 +0,0 @@ -setenv PYTHONPATH $PWD/../python:$PYTHONPATH -setenv PYTHONPATH $PWD/../test:$PYTHONPATH - -set lib_path="../lib64"; - -if ( -d "$lib_path") then - if ( -s "$lib_path") then - set target=`readlink -f $lib_path` - echo "Using $lib_path -> $target for shared libraries." - else - echo "** Warning: $lib_path is not a symbolic link ??" - endif -else - echo "** Warning: can not find directory/link: $lib_path - will not find newly compiled shared libraries." -endif - \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/petrel_kw.py b/ThirdParty/Ert/devel/python/test/petrel_kw.py deleted file mode 100644 index f5d0271a00..0000000000 --- a/ThirdParty/Ert/devel/python/test/petrel_kw.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -import ert.ecl.ecl as ecl - -file = "data/eclipse/Petrel/PERM.GRDECL" -grid = "data/eclipse/Petrel/GRID.GRDECL" - -kw = ecl.EclKW.grdecl_load( open(file) , "PERMX" ) - -gridH = open(grid) -coord = ecl.EclKW.grdecl_load( gridH , "COORD" ) -actnum = ecl.EclKW.grdecl_load( gridH , "ACTNUM" , ecl_type = ecl.ECL_INT_TYPE ) -zcorn = ecl.EclKW.grdecl_load( gridH , "ZCORN" ) - diff --git a/ThirdParty/Ert/devel/python/test/poly_test.py b/ThirdParty/Ert/devel/python/test/poly_test.py deleted file mode 100644 index 38a09dd38a..0000000000 --- a/ThirdParty/Ert/devel/python/test/poly_test.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -import ert.ecl.ecl as ecl - -g = ecl.EclGrid( "data/eclipse/case/ECLIPSE" ) -r = ecl.EclRegion( g , False ) - -ll = g.get_xyz( ijk = (0,0,0) ) -ur = g.get_xyz( ijk = (39,63,0) ) - -dx = 0.5*(ur[0] - ll[0]) -dy = 0.5*(ur[1] - ll[1]) - -x0 = ll[0] + dx*0.5 -y0 = ll[1] + dy*0.5 -x1 = x0 + dx -y1 = y0 + dy - - -points = [(x0,y0) , (x1,y0) , (x1,y1) , (x0,y1)] - - -print " X ----------------------------------- (%10.3f , %10.3f)" % (x1-x0,y1-y0) -print " | |" -print " | |" -print " | |" -print " | |" -print " | |" -print " | |" -print " | |" -print " | |" -print " | |" -print "(%10.3f , %10.3f) ---------------------------------- X\n\n" % (x0-x0,y0-y0) - -r.select_inside_polygon( points ) -for gi in r.global_list: - (x,y,z) = g.get_xyz( global_index = gi ) - (i,j,k) = g.get_ijk( global_index = gi ) - print "(ijk) = (%d,%d,%d) x,y = (%10.3f,%10.3f)" % (i,j,k,x-x0,y-y0) - -print "-------------------------" - -j = 15 -k = 0 -for i in (10,11,12): - (x,y,z) = g.get_xyz( ijk = (i,j,k) ) - print "(ijk) = (%d,%d,%d) x,y = (%10.3f,%10.3f)" % (i,j,k,x-x0,y-y0) - diff --git a/ThirdParty/Ert/devel/python/test/run_tests.py b/ThirdParty/Ert/devel/python/test/run_tests.py deleted file mode 100644 index 25266ff028..0000000000 --- a/ThirdParty/Ert/devel/python/test/run_tests.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -import sys -from ert_tests.run_tests import * - -from ert.test import ErtTestRunner - -#runTestsInClass("ert_tests.util.test_string_list.StringListTest") -ErtTestRunner.runTestsInClass("ert_tests.run.test_run.RunTest") diff --git a/ThirdParty/Ert/devel/python/test/troll_test.py b/ThirdParty/Ert/devel/python/test/troll_test.py deleted file mode 100644 index ccd99800c3..0000000000 --- a/ThirdParty/Ert/devel/python/test/troll_test.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'grid_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 <http://www.gnu.org/licenses/gpl.html> -# for more details. - -import os -import ert -import ert.ecl.ecl as ecl -import datetime -import time -import unittest -import ert -import ert.ecl.ecl as ecl -from ert.util.tvector import DoubleVector -from ert.util.tvector import DoubleVector - -from test_util import approx_equal, approx_equalv - -troll_case = "/d/proj/bg/restroll6/ressim/ff/2007a/e100/simu/O22/O22YH_UPDATE" -bprod_path = "/d/proj/bg/restroll6/bin/bprod.py" -dump_path = "/d/proj/bg/restroll6/bin/eclipse_dump.py" - -class TrollTest( unittest.TestCase ): - def setUp(self): - pass - - - def testBPROD(self): - os.system("%s %s" % (bprod_path , troll_case)) - self.assertTrue( True ) - - - def testDUMP( self ): - os.system("%s %s" % (dump_path , troll_case)) - self.assertTrue( True ) - - -def fast_suite(): - suite = unittest.TestSuite() - suite.addTest( TrollTest( 'testBPROD' )) - suite.addTest( TrollTest( 'testDUMP' )) - return suite - - -if __name__ == "__main__": - unittest.TextTestRunner().run( fast_suite() ) diff --git a/ThirdParty/Ert/devel/python/tests/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/CMakeLists.txt new file mode 100644 index 0000000000..23067e8a1f --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/CMakeLists.txt @@ -0,0 +1,51 @@ +set(TEST_SOURCES + __init__.py + ctest_import.py + ctest_run.py + import_tester.py +) + +set(TEST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) +set(INSTALL_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}) + +add_python_package("python.tests" "${PYTHON_INSTALL_PREFIX}/tests" "${TEST_SOURCES}" False) + +function (addPythonTest TEST_NAME TEST_CLASS) + set(oneValueArgs LABELS) + set(multiValueArgs ARGUMENTS ENVIRONMENT) + cmake_parse_arguments(TEST_OPTIONS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_test(NAME python.tests.${TEST_NAME} + WORKING_DIRECTORY ${INSTALL_DIRECTORY} + COMMAND tests/ctest_run.py ${INSTALL_DIRECTORY} ${TEST_CLASS} ${TEST_OPTIONS_ARGUMENTS}) + + if(TEST_OPTIONS_LABELS) + set_property(TEST python.tests.${TEST_NAME} PROPERTY LABELS "Python:${TEST_OPTIONS_LABELS}") + else() + set_property(TEST python.tests.${TEST_NAME} PROPERTY LABELS "Python") + endif() + + if(TEST_OPTIONS_ENVIRONMENT) + set_property(TEST python.tests.${TEST_NAME} PROPERTY ENVIRONMENT ${TEST_OPTIONS_ENVIRONMENT}) + endif() +endfunction(addPythonTest) + + +add_subdirectory(core) + +if(BUILD_ERT) + add_subdirectory(ert) + + add_test( NAME python.tests.ert.import + WORKING_DIRECTORY ${INSTALL_DIRECTORY} + COMMAND tests/ctest_import.py ${INSTALL_DIRECTORY} "ert") +endif() + +if (ERT_BUILD_GUI) + add_subdirectory(gui) + add_subdirectory(plugins) + + add_test( NAME python.tests.ert_gui.import + WORKING_DIRECTORY ${INSTALL_DIRECTORY} + COMMAND tests/ctest_import.py ${INSTALL_DIRECTORY} "ert_gui") +endif() diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/__init__.py b/ThirdParty/Ert/devel/python/tests/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/__init__.py rename to ThirdParty/Ert/devel/python/tests/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/core/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/core/CMakeLists.txt new file mode 100644 index 0000000000..62741f3c13 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/CMakeLists.txt @@ -0,0 +1,11 @@ +set(TEST_SOURCES + __init__.py +) + +add_python_package("python.tests.core" ${PYTHON_INSTALL_PREFIX}/tests/core "${TEST_SOURCES}" False) + +add_subdirectory(cwrap) +add_subdirectory(geometry) +add_subdirectory(util) +add_subdirectory(ecl) +add_subdirectory(well) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/analysis/__init__.py b/ThirdParty/Ert/devel/python/tests/core/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/analysis/__init__.py rename to ThirdParty/Ert/devel/python/tests/core/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/core/cwrap/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/core/cwrap/CMakeLists.txt new file mode 100644 index 0000000000..0be2053d56 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/cwrap/CMakeLists.txt @@ -0,0 +1,15 @@ +set(TEST_SOURCES + __init__.py + test_basecclass.py + test_basecenum.py + test_basecvalue.py + test_cwrap.py +) + +add_python_package("python.tests.core.cwrap" ${PYTHON_INSTALL_PREFIX}/tests/core/cwrap "${TEST_SOURCES}" False) + +addPythonTest(core.cwrap tests.core.cwrap.test_cwrap.CWrapTest) +addPythonTest(core.cwrap.basecclass tests.core.cwrap.test_basecclass.BaseCClassTest) +addPythonTest(core.cwrap.basecenum tests.core.cwrap.test_basecenum.BaseCEnumTest) +addPythonTest(core.cwrap.basecvalue tests.core.cwrap.test_basecvalue.BaseCValueTest) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/config/__init__.py b/ThirdParty/Ert/devel/python/tests/core/cwrap/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/config/__init__.py rename to ThirdParty/Ert/devel/python/tests/core/cwrap/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_basecclass.py b/ThirdParty/Ert/devel/python/tests/core/cwrap/test_basecclass.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_basecclass.py rename to ThirdParty/Ert/devel/python/tests/core/cwrap/test_basecclass.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_basecenum.py b/ThirdParty/Ert/devel/python/tests/core/cwrap/test_basecenum.py similarity index 69% rename from ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_basecenum.py rename to ThirdParty/Ert/devel/python/tests/core/cwrap/test_basecenum.py index 8aefcea9f8..33613e0ff0 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_basecenum.py +++ b/ThirdParty/Ert/devel/python/tests/core/cwrap/test_basecenum.py @@ -1,4 +1,3 @@ -from ert.config import CONFIG_LIB from ert.cwrap import BaseCEnum from ert.test import ExtendedTestCase @@ -76,25 +75,4 @@ class PowerOf2(BaseCEnum): self.assertNotIn(PowerOf2.FOUR, three) - def test_enum_populate_from_c(self): - class ContentTypeEnum(BaseCEnum): - pass - - ContentTypeEnum.populateEnum(CONFIG_LIB, "config_schema_item_type_enum_iget") - - # CONFIG_STRING = 1, - # CONFIG_INT = 2, - # CONFIG_FLOAT = 4, - # CONFIG_PATH = 8, - # CONFIG_EXISTING_PATH = 16, - # CONFIG_BOOL = 32, - # CONFIG_CONFIG = 64, - # CONFIG_BYTESIZE = 128, - # CONFIG_EXECUTABLE = 256 , - # CONFIG_INVALID = 512 - - self.assertEqual(ContentTypeEnum.CONFIG_STRING, 1) - self.assertEqual(ContentTypeEnum.CONFIG_EXISTING_PATH, 16) - self.assertEqual(ContentTypeEnum.CONFIG_BYTESIZE, 128) - self.assertEqual(ContentTypeEnum.CONFIG_INVALID, 512) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_basecvalue.py b/ThirdParty/Ert/devel/python/tests/core/cwrap/test_basecvalue.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_basecvalue.py rename to ThirdParty/Ert/devel/python/tests/core/cwrap/test_basecvalue.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_cwrap.py b/ThirdParty/Ert/devel/python/tests/core/cwrap/test_cwrap.py similarity index 84% rename from ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_cwrap.py rename to ThirdParty/Ert/devel/python/tests/core/cwrap/test_cwrap.py index f17a7be376..38020c80ff 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/cwrap/test_cwrap.py +++ b/ThirdParty/Ert/devel/python/tests/core/cwrap/test_cwrap.py @@ -1,4 +1,4 @@ -from ert.cwrap import CWrapper, BaseCClass, clib +from ert.cwrap import CWrapper, BaseCClass, clib, CWrapError from ert.test import ExtendedTestCase test_lib = clib.ert_load("libert_util") # create a local namespace (so we don't overwrite StringList) @@ -18,7 +18,7 @@ def free(self): StringListTest.cNamespace().free = cwrapper.prototype("void stringlist_free(stringlisttest )") -class CWRapTest(ExtendedTestCase): +class CWrapTest(ExtendedTestCase): def test_return_type(self): stringlist_alloc = cwrapper.prototype("c_void_p stringlist_alloc_new( )") @@ -61,6 +61,15 @@ def test_class_variables(self): self.assertEqual(StringListTest.cNamespace().pow, StringListTest.cNamespace()["pow"]) + def test_invalid_function(self): + with self.assertRaises(CWrapError): + func = cwrapper.prototype("void stringlist_missing_function( )") + + + def test_invalid_function(self): + with self.assertRaises(CWrapError): + stringlist_alloc = cwrapper.prototype("c_void_p stringlist_alloc_new( ") + diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/core/ecl/CMakeLists.txt new file mode 100644 index 0000000000..67cc33090b --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/CMakeLists.txt @@ -0,0 +1,77 @@ +set(NFS_RUNPATH "" CACHE STRING "Disk area which is shared among cluster nodes and can be used as CWD for LSF/RSH jobs.") +set(RSH_SERVERS "" CACHE STRING "List of nodes which will be used to test the RSH driver") + +set(TEST_SOURCES + __init__.py + test_deprecation.py + test_ecl_3dkw.py + test_ecl_default.py + test_ecl_file.py + test_ecl_init_file.py + test_ecl_restart_file.py + test_ecl_submit.py + test_ecl_sum.py + test_ecl_sum_vector.py + test_fault_blocks.py + test_fault_blocks_statoil.py + test_faults.py + test_fortio.py + test_grdecl.py + test_grid.py + test_grid_statoil.py + test_indexed_read.py + test_kw.py + test_kw_function.py + test_layer.py + test_legacy_ecl.py + test_npv.py + test_region.py + test_restart.py + test_rft.py + test_rft_cell.py + test_statoil_faults.py + test_sum.py +) + +add_python_package("python.tests.ecl" ${PYTHON_INSTALL_PREFIX}/tests/ecl "${TEST_SOURCES}" False) + +addPythonTest(ecl.ecl_default ecl.test_ecl_default.EclDefaultTest ) +addPythonTest(ecl.ecl_file ecl.test_ecl_file.EclFileTest LABELS StatoilData) +addPythonTest(ecl.ecl_queue_LOCAL ecl.test_ecl_submit.LocalSubmitTest LABELS StatoilData:Slow) +addPythonTest(ecl.fortio ecl.test_fortio.FortIOTest LABELS StatoilData) +addPythonTest(ecl.ecl_grdecl ecl.test_grdecl.GRDECLTest LABELS StatoilData) +addPythonTest(ecl.ecl_grid_statoil ecl.test_grid_statoil.GridTest LABELS StatoilData:Slow) +addPythonTest(ecl.ecl_grid ecl.test_grid.GridTest ) +addPythonTest(ecl.ecl_kw ecl.test_kw.KWTest LABELS StatoilData) +addPythonTest(ecl.ecl_kw_function ecl.test_kw_function.KWFunctionTest) +addPythonTest(ecl.ecl_3dkw ecl.test_ecl_3dkw.Ecl3DKWTest ) +addPythonTest(ecl.ecl_init_file ecl.test_ecl_init_file.InitFileTest LABELS StatoilData) +addPythonTest(ecl.ecl_restart_file ecl.test_ecl_restart_file.RestartFileTest LABELS StatoilData) +addPythonTest(ecl.legacy_ecl ecl.test_legacy_ecl.LegacyEclTest) +addPythonTest(ecl.ecl_restart ecl.test_restart.RestartTest LABELS StatoilData ) +addPythonTest(ecl.ecl_region ecl.test_region.RegionTest LABELS StatoilData) +addPythonTest(ecl.ecl_rft ecl.test_rft.RFTTest LABELS StatoilData) +addPythonTest(ecl.ecl_rft_cell ecl.test_rft_cell.RFTCellTest) +addPythonTest(ecl.ecl_sum ecl.test_sum.SumTest LABELS StatoilData) +addPythonTest(ecl.ecl_sum_vector ecl.test_ecl_sum_vector.EclSumVectorTest LABELS StatoilData) +addPythonTest(ecl.ecl_sum_time_range ecl.test_ecl_sum.EclSumTest LABELS StatoilData) +addPythonTest(ecl.layer ecl.test_layer.LayerTest ) +addPythonTest(ecl.faults ecl.test_faults.FaultTest ) +addPythonTest(ecl.statoil_faults ecl.test_statoil_faults.StatoilFaultTest LABELS StatoilData) +addPythonTest(ecl.fault_blocks ecl.test_fault_blocks.FaultBlockTest ) +addPythonTest(ecl.fault_blocks_statoil ecl.test_fault_blocks_statoil.FaultBlockTest LABELS StatoilData) +addPythonTest(ecl.ecl_npv ecl.test_npv.NPVTest LABELS StatoilData) +addPythonTest(ecl.ecl_deprecation ecl.test_deprecation.DeprecationTest ) +addPythonTest(ecl.indexed_read ecl.test_indexed_read.EclIndexedReadTest LABELS StatoilData) + + +if (NOT ${NFS_RUNPATH} STREQUAL "") + if (ERT_LSF_SUBMIT_TEST) + addPythonTest(ert.ecl.ecl_queue_LSF tests.ecl.test_ecl_submit.LSFSubmitTest ARGUMENTS ${NFS_RUNPATH} LABELS StatoilData:Slow) + endif() + + + if (NOT ${RSH_SERVERS} STREQUAL "") + addPythonTest(ert.ecl.ecl_queue_RSH tests.ecl.test_ecl_submit.RSHSubmitTest ARGUMENTS ${NFS_RUNPATH} ${RSH_SERVERS} LABELS StatoilData:Slow) + endif() +endif() \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/cwrap/__init__.py b/ThirdParty/Ert/devel/python/tests/core/ecl/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/cwrap/__init__.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_deprecation.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_deprecation.py new file mode 100644 index 0000000000..966ffce403 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_deprecation.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_deprecation.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +import warnings +import time + +from ert.test import ExtendedTestCase +from ert.ecl import EclGrid,EclKW,EclTypeEnum,EclGrid,EclRegion +from ert.util import BoolVector + + +class DeprecationTest(ExtendedTestCase): + + def test_EclGrid_get_corner_xyz(self): + grid = EclGrid.create_rectangular( (10,20,30) , (1,1,1) ) + with warnings.catch_warnings(): + grid.get_corner_xyz(0 , global_index = 10) + + def test_ecl_ecl_ecl(self): + with warnings.catch_warnings(): + import ert.ecl.ecl as ecl + + # Added in 1.8.x development + def test_EclGrid_dims_property(self): + grid = EclGrid.create_rectangular( (10,20,30) , (1,1,1) ) + with warnings.catch_warnings(): + d = grid.dims + + + + + # Added in 1.8.x development + def test_EclKW_min_max(self): + kw = EclKW.new("TEST", 3, EclTypeEnum.ECL_INT_TYPE) + with warnings.catch_warnings(): + kw.min + + with warnings.catch_warnings(): + kw.max + + with warnings.catch_warnings(): + kw.min_max + + # Added in 1.8.x development + def test_EclRegion_properties(self): + grid = EclGrid.create_rectangular( (10,10,10) , (1,1,1)) + region = EclRegion( grid , False ) + + with warnings.catch_warnings(): + region.active_size + + with warnings.catch_warnings(): + region.global_size + + with warnings.catch_warnings(): + region.global_list + + with warnings.catch_warnings(): + region.active_list + + + + # Deprecated method from 1.8.4 + def test_BoolVector_active_mask(self): + with warnings.catch_warnings(): + active_vector = BoolVector.active_mask("1,1,1,1,1,1") \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_3dkw.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_3dkw.py new file mode 100644 index 0000000000..5135dc5315 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_3dkw.py @@ -0,0 +1,202 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +import os +import random + +from ert.util import IntVector +from ert.ecl import Ecl3DKW , EclKW, EclTypeEnum, EclFile, FortIO, EclFileFlagEnum , EclGrid +from ert.test import ExtendedTestCase , TestAreaContext + + + +class Ecl3DKWTest(ExtendedTestCase): + + def test_create( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW.create( "KW" , grid , EclTypeEnum.ECL_FLOAT_TYPE ) + self.assertEqual( len(kw) , grid.getNumActive()) + + self.assertEqual( (10,10,10) , kw.dims() ) + + + def test_create_global_size( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW.create( "KW" , grid , EclTypeEnum.ECL_FLOAT_TYPE , global_active = True) + self.assertEqual( len(kw) , grid.getGlobalSize()) + + kw.assign(50) + self.assertEqual( kw[0,0,0] , 50 ) + + kw[0,0,0] = 45 + self.assertEqual( kw[0,0,0] , 45 ) + + + def test_fix_uninitialized(self): + nx = 10 + ny = 11 + nz = 12 + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) ) + kw = Ecl3DKW.create("REGIONS" , grid , EclTypeEnum.ECL_INT_TYPE , global_active = True) + kw.assign(3) + self.assertEqual( 3 * nx*ny*nz , sum(kw)) + + kw[1,1,1] = 0 + kw[3,3,3] = 0 + kw[6,6,6] = 0 + + self.assertEqual( 3 * nx*ny*nz - 9 , sum(kw)) + kw.fixUninitialized( grid ) + self.assertEqual( 3 * nx*ny*nz , sum(kw)) + + + + def test_getitem( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW.create( "KW" , grid , EclTypeEnum.ECL_FLOAT_TYPE , default_value = 77) + + with self.assertRaises(IndexError): + kw[1000] + + with self.assertRaises(IndexError): + kw[0,10,100] + + with self.assertRaises(ValueError): + kw[1,1] + + with self.assertRaises(ValueError): + kw[1,1,1,1] + + kw.assign(99) + + self.assertEqual( kw[0,0,0] , 77 ) + self.assertEqual( kw[0,0,1] , 99 ) + + + + def test_setitem( self ): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW.create( "KW" , grid , EclTypeEnum.ECL_FLOAT_TYPE , default_value = 77) + + with self.assertRaises(IndexError): + kw[1000] + + with self.assertRaises(IndexError): + kw[0,10,100] + + with self.assertRaises(ValueError): + kw[1,1] + + with self.assertRaises(ValueError): + kw[1,1,1,1] + + kw.assign(99) + self.assertEqual( kw[0,0,0] , 77 ) + self.assertEqual( kw[0,0,1] , 99 ) + + + with self.assertRaises(ValueError): + kw[0,0,0] = 88 + + kw[0,0,1] = 100 + self.assertEqual( kw[0,0,1] , 100 ) + + + + def test_cast(self): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(100): + actnum[i] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw_wrong_size = EclKW.create( "KW" , 27 , EclTypeEnum.ECL_FLOAT_TYPE ) + kw_global_size = EclKW.create( "KW" , grid.getGlobalSize() , EclTypeEnum.ECL_FLOAT_TYPE ) + kw_active_size = EclKW.create( "KW" , grid.getNumActive() , EclTypeEnum.ECL_FLOAT_TYPE ) + + with self.assertRaises(ValueError): + Ecl3DKW.castFromKW(kw_wrong_size , grid) + + Ecl3DKW.castFromKW(kw_global_size , grid) + self.assertTrue( isinstance( kw_global_size , Ecl3DKW)) + + Ecl3DKW.castFromKW(kw_active_size , grid , default_value = 66) + self.assertTrue( isinstance( kw_active_size , Ecl3DKW)) + + self.assertEqual( kw_active_size[0,0,0] , 66) + with self.assertRaises(ValueError): + kw_active_size[0,0,0] = 88 + + + def test_default(self): + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1)) + kw = Ecl3DKW.create( "KW" , grid , EclTypeEnum.ECL_FLOAT_TYPE ) + kw.setDefault(55) + self.assertTrue( 55 , kw.getDefault()) + + + def test_compressed_copy(self): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(500): + actnum[2*i + 1] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW.create( "KW" , grid , EclTypeEnum.ECL_INT_TYPE , global_active = True) + for i in range(len(kw)): + kw[i] = i + + kw_copy = kw.compressedCopy() + self.assertTrue( isinstance( kw_copy , EclKW ) ) + + self.assertEqual(len(kw_copy) , 500) + for i in range(len(kw_copy)): + self.assertEqual(kw_copy[i] , 2*i) + + + + def test_global_copy(self): + actnum = IntVector(default_value = 1 , initial_size = 1000) + for i in range(500): + actnum[2*i + 1] = 0 + + grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) , actnum = actnum) + kw = Ecl3DKW.create( "KW" , grid , EclTypeEnum.ECL_INT_TYPE , global_active = False) + for i in range(len(kw)): + kw[i] = i + + kw.setDefault( 177 ) + kw_copy = kw.globalCopy() + self.assertTrue( isinstance( kw_copy , EclKW ) ) + + self.assertEqual(len(kw_copy) , 1000) + for i in range(len(kw)): + self.assertEqual(kw_copy[2*i] , i) + self.assertEqual(kw_copy[2*i + 1] , kw.getDefault()) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_default.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_default.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_default.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_default.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_file.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_file.py similarity index 77% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_file.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_file.py index 1b3b7b1d0e..10dc2e59c4 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_file.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_file.py @@ -15,13 +15,11 @@ # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. import datetime -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf +import os.path +from unittest import skipIf -from ert.ecl import EclFile, FortIO -from ert.ecl.ecl_util import EclFileFlagEnum +from ert.ecl import EclFile, FortIO, EclKW , openFortIO , openEclFile +from ert.ecl import EclFileFlagEnum, EclTypeEnum from ert.test import ExtendedTestCase , TestAreaContext @@ -71,6 +69,22 @@ def test_fwrite( self ): self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file) + def test_context( self ): + with TestAreaContext("python/ecl_file/context"): + kw1 = EclKW.create( "KW1" , 100 , EclTypeEnum.ECL_INT_TYPE) + kw2 = EclKW.create( "KW2" , 100 , EclTypeEnum.ECL_INT_TYPE) + with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + kw2.fwrite( f ) + + with openEclFile("TEST") as ecl_file: + self.assertEqual( len(ecl_file) , 2 ) + self.assertTrue( ecl_file.has_kw("KW1")) + self.assertTrue( ecl_file.has_kw("KW2")) + + + + @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow file test skipped!") def test_save(self): #work_area = TestArea("python/ecl_file/save") @@ -127,4 +141,20 @@ def test_save_fmt(self): # Random failure .... self.assertFilesAreEqual("ECLIPSE.FUNRST", self.test_fmt_file) + + def test_truncated(self): + with TestAreaContext("python/ecl_file/truncated") as work_area: + work_area.copy_file(self.test_file) + size = os.path.getsize("ECLIPSE.UNRST") + with open("ECLIPSE.UNRST" , "r+") as f: + f.truncate( size / 2 ) + + with self.assertRaises(IOError): + rst_file = EclFile("ECLIPSE.UNRST") + + with self.assertRaises(IOError): + rst_file = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + + + diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_init_file.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_init_file.py new file mode 100644 index 0000000000..18b7511f3d --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_init_file.py @@ -0,0 +1,41 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +from ert.test import ExtendedTestCase +from ert.ecl import Ecl3DKW , EclKW, EclTypeEnum, EclInitFile , EclFile, FortIO, EclFileFlagEnum , EclGrid + +class InitFileTest(ExtendedTestCase): + def setUp(self): + self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + self.init_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT") + + + def test_load(self): + g = EclGrid( self.grid_file ) + f = EclInitFile( g , self.init_file ) + + head = f["INTEHEAD"][0] + self.assertTrue( isinstance( head , EclKW )) + + porv = f["PORV"][0] + self.assertTrue( isinstance( porv , Ecl3DKW )) + + poro = f["PORO"][0] + self.assertTrue( isinstance( poro , Ecl3DKW )) + + + diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_restart_file.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_restart_file.py new file mode 100644 index 0000000000..651e5ce4cc --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_restart_file.py @@ -0,0 +1,41 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +from ert.test import ExtendedTestCase +from ert.ecl import Ecl3DKW , EclKW, EclTypeEnum, EclRestartFile , EclFile, FortIO, EclFileFlagEnum , EclGrid + +class RestartFileTest(ExtendedTestCase): + def setUp(self): + self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + self.rst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + + + def test_load(self): + g = EclGrid( self.grid_file ) + f = EclRestartFile( g , self.rst_file ) + + head = f["INTEHEAD"][0] + self.assertTrue( isinstance( head , EclKW )) + + swat = f["SWAT"][0] + self.assertTrue( isinstance( swat , Ecl3DKW )) + + pressure = f["PRESSURE"][0] + self.assertTrue( isinstance( pressure , Ecl3DKW )) + + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_submit.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_submit.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_submit.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_submit.py diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_sum.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_sum.py new file mode 100644 index 0000000000..a68f7f07cf --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_sum.py @@ -0,0 +1,137 @@ +# !/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +import datetime +import os.path +from ert.cwrap import CFILE +from ert.ecl import EclSum, EclSumKeyWordVector, EclFile,FortIO, openFortIO,openEclFile,EclKW +from ert.test import ExtendedTestCase , TestAreaContext + + +class EclSumTest(ExtendedTestCase): + def setUp(self): + self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + self.ecl_sum = EclSum(self.test_file) + + def test_time_range_year(self): + real_range = self.ecl_sum.timeRange(interval="1y", extend_end = False) + extended_range = self.ecl_sum.timeRange(interval="1y", extend_end = True) + assert real_range[-1] < extended_range[-1] + + def test_time_range_day(self): + real_range = self.ecl_sum.timeRange(interval = "1d", extend_end = False) + extended_range = self.ecl_sum.timeRange(interval = "1d", extend_end = True) + assert real_range[-1] == extended_range[-1] + + def test_time_range_month(self): + real_range = self.ecl_sum.timeRange(interval = "1m", extend_end = False) + extended_range = self.ecl_sum.timeRange(interval = "1m", extend_end = True) + assert real_range[-1] < extended_range[-1] + + def test_dump_csv_line(self): + ecl_sum_vector = EclSumKeyWordVector(self.ecl_sum) + ecl_sum_vector.addKeywords("F*") + + with self.assertRaises(KeyError): + ecl_sum_vector.addKeyword("MISSING") + + dtime = datetime.datetime( 2002 , 01 , 01 , 0 , 0 , 0 ) + with TestAreaContext("EclSum/csv_dump"): + test_file_name = self.createTestPath("dump.csv") + outputH = open(test_file_name , "w") + self.ecl_sum.dumpCSVLine( dtime, ecl_sum_vector, outputH) + assert os.path.isfile(test_file_name) + + + def test_truncated_smspec(self): + with TestAreaContext("EclSum/truncated_smspec") as ta: + ta.copy_file( self.test_file ) + ta.copy_file( self.createTestPath( "Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY" )) + + file_size = os.path.getsize( "ECLIPSE.SMSPEC") + with open("ECLIPSE.SMSPEC","r+") as f: + f.truncate( file_size / 2 ) + + with self.assertRaises(IOError): + EclSum( "ECLIPSE" ) + + + def test_truncated_data(self): + with TestAreaContext("EclSum/truncated_data") as ta: + ta.copy_file( self.test_file ) + ta.copy_file( self.createTestPath( "Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY" )) + + + file_size = os.path.getsize( "ECLIPSE.UNSMRY") + with open("ECLIPSE.UNSMRY","r+") as f: + f.truncate( file_size / 2 ) + + with self.assertRaises(IOError): + EclSum( "ECLIPSE" ) + + + def test_missing_smspec_keyword(self): + with TestAreaContext("EclSum/truncated_data") as ta: + ta.copy_file( self.test_file ) + ta.copy_file( self.createTestPath( "Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY" )) + + with openEclFile("ECLIPSE.SMSPEC") as f: + kw_list = [] + for kw in f: + kw_list.append(EclKW.copy( kw ) ) + + with openFortIO("ECLIPSE.SMSPEC" , mode = FortIO.WRITE_MODE) as f: + for kw in kw_list: + if kw.getName() == "KEYWORDS": + continue + kw.fwrite(f) + + with self.assertRaises(IOError): + EclSum( "ECLIPSE" ) + + def test_missing_unsmry_keyword(self): + with TestAreaContext("EclSum/truncated_data") as ta: + ta.copy_file( self.test_file ) + ta.copy_file( self.createTestPath( "Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY" )) + + with openEclFile("ECLIPSE.UNSMRY") as f: + kw_list = [] + for kw in f: + kw_list.append(EclKW.copy( kw ) ) + + + with openFortIO("ECLIPSE.UNSMRY" , mode = FortIO.WRITE_MODE) as f: + c = 0 + for kw in kw_list: + if kw.getName() == "PARAMS": + if c % 5 == 0: + continue + c += 1 + kw.fwrite(f) + + with self.assertRaises(IOError): + EclSum( "ECLIPSE" ) + + + + + def test_labscale(self): + case = self.createTestPath("Statoil/ECLIPSE/LabScale/HDMODEL") + sum = EclSum( case ) + self.assertEqual( sum.getStartTime( ) , datetime.datetime(2013,1,1,0,0,0)) + self.assertEqual( sum.getEndTime( ) , datetime.datetime(2013,1,1,19,30,0)) + self.assertFloatEqual( sum.getSimulationLength() , 0.8125 ) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum_vector.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_sum_vector.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_ecl_sum_vector.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_ecl_sum_vector.py diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_fault_blocks.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_fault_blocks.py new file mode 100644 index 0000000000..862ba3b85c --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_fault_blocks.py @@ -0,0 +1,474 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +from unittest import skipIf + +from ert.ecl import EclGrid, EclTypeEnum , EclKW , EclRegion +from ert.ecl.faults import FaultBlock, FaultBlockLayer, FaultBlockCell,FaultCollection +from ert.geo import Polyline , CPolylineCollection +from ert.test import ExtendedTestCase , TestAreaContext + + +class FaultBlockTest(ExtendedTestCase): + def setUp(self): + self.grid = EclGrid.create_rectangular( (10,10,10) , (1,1,1) ) + self.kw = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_INT_TYPE ) + self.kw.assign( 1 ) + + reg = EclRegion( self.grid , False ) + + for k in range(self.grid.getNZ()): + reg.clear( ) + reg.select_kslice( k , k ) + self.kw.assign( k , mask = reg ) + self.kw[ k * self.grid.getNX() * self.grid.getNY() + 7] = 177 + + + + def test_fault_block(self): + grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) ) + kw = EclKW.create( "FAULTBLK" , grid.size , EclTypeEnum.ECL_INT_TYPE ) + kw.assign( 0 ) + for j in range(1,4): + for i in range(1,4): + g = i + j*grid.getNX() + kw[g] = 1 + + layer = FaultBlockLayer( grid , 0 ) + layer.scanKeyword( kw ) + block = layer[1] + + self.assertEqual( (2.50 , 2.50) , block.getCentroid() ) + self.assertEqual( len(block) , 9) + self.assertEqual( layer , block.getParentLayer() ) + + + def test_get_ijk(self): + with TestAreaContext("python/fault_block_layer/neighbour") as work_area: + with open("kw.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 0 0\n") + fileH.write("1 2 2 0 3\n") + fileH.write("4 2 2 3 3\n") + fileH.write("4 4 4 0 0\n") + fileH.write("4 4 4 0 5\n") + fileH.write("/\n") + + kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE) + + grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + layer.loadKeyword( kw ) + + block = layer[0,0] + self.assertEqual( block.getBlockID() , 1 ) + + block = layer[2,2] + self.assertEqual( block.getBlockID() , 2 ) + + with self.assertRaises(ValueError): + layer[3,3] + + with self.assertRaises(IndexError): + layer[5,5] + + + + def test_neighbours(self): + + with TestAreaContext("python/fault_block_layer/neighbour") as work_area: + with open("kw.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 0 0\n") + fileH.write("1 2 2 0 3\n") + fileH.write("4 2 2 3 3\n") + fileH.write("4 4 4 0 0\n") + fileH.write("4 4 4 0 5\n") + fileH.write("/\n") + + kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE) + + grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + + layer.loadKeyword( kw ) + block1 = layer.getBlock( 1 ) + block2 = layer.getBlock( 2 ) + block3 = layer.getBlock( 3 ) + block4 = layer.getBlock( 4 ) + block5 = layer.getBlock( 5 ) + self.assertEqual( block1.getParentLayer() , layer ) + + #Expected: 1 -> {2,4}, 2 -> {1,3,4}, 3 -> {2}, 4 -> {1,2}, 5-> {} + + neighbours = block1.getNeighbours() + self.assertEqual( len(neighbours) , 2) + self.assertTrue( block2 in neighbours ) + self.assertTrue( block4 in neighbours ) + + neighbours = block2.getNeighbours() + self.assertEqual( len(neighbours) , 3) + self.assertTrue( block1 in neighbours ) + self.assertTrue( block3 in neighbours ) + self.assertTrue( block4 in neighbours ) + + neighbours = block3.getNeighbours() + self.assertEqual( len(neighbours) , 1) + self.assertTrue( block2 in neighbours ) + + neighbours = block4.getNeighbours() + self.assertEqual( len(neighbours) , 2) + self.assertTrue( block1 in neighbours ) + self.assertTrue( block2 in neighbours ) + + neighbours = block5.getNeighbours() + self.assertEqual( len(neighbours) , 0) + + + + + def test_neighbours2(self): + nx = 8 + ny = 8 + nz = 1 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + with TestAreaContext("python/FaultBlocks/neighbours"): + with open("faultblock.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("3 3 3 3 2 2 2 2 \n") + fileH.write("/\n") + + kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE) + with open("faults.grdecl" , "w") as f: + f.write("FAULTS\n") + f.write("\'FY\' 1 4 4 4 1 1 'Y' /\n") + f.write("\'FX\' 4 4 1 8 1 1 'X' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + layer.loadKeyword( kw ) + b1 = layer.getBlock( 1 ) + b2 = layer.getBlock( 2 ) + b3 = layer.getBlock( 3 ) + + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + self.assertTrue( b3 in nb ) + + polylines1 = CPolylineCollection() + p1 = polylines1.createPolyline(name="P1") + p1.addPoint(4,0) + p1.addPoint(4,4) + p1.addPoint(4,8) + nb = b1.getNeighbours( polylines = polylines1 ) + self.assertFalse( b2 in nb ) + self.assertTrue( b3 in nb ) + + + polylines2 = CPolylineCollection() + p1 = polylines2.createPolyline(name="P2") + p1.addPoint(0,4) + p1.addPoint(4,4) + nb = b1.getNeighbours( polylines = polylines2 ) + self.assertTrue( b2 in nb ) + self.assertFalse( b3 in nb ) + + + + layer.addFaultBarrier( faults["FY"] ) + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + self.assertFalse( b3 in nb ) + + layer.addFaultBarrier( faults["FX"] ) + nb = b1.getNeighbours() + self.assertEqual( len(nb) , 0 ) + + + def test_neighbours3(self): + nx = 8 + ny = 8 + nz = 1 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + with TestAreaContext("python/FaultBlocks/neighbours"): + with open("faultblock.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("/\n") + + kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE) + with open("faults.grdecl" , "w") as f: + f.write("FAULTS\n") + f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") + f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + layer.loadKeyword( kw ) + b1 = layer.getBlock( 1 ) + b2 = layer.getBlock( 2 ) + + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + + layer.addFaultBarrier( faults["FX"] , link_segments = False) + nb = b1.getNeighbours() + self.assertTrue( b2 in nb ) + + + + + + + + def test_fault_block_edge(self): + grid = EclGrid.create_rectangular( (5,5,1) , (1,1,1) ) + kw = EclKW.create( "FAULTBLK" , grid.size , EclTypeEnum.ECL_INT_TYPE ) + kw.assign( 0 ) + for j in range(1,4): + for i in range(1,4): + g = i + j*grid.getNX() + kw[g] = 1 + + layer = FaultBlockLayer( grid , 0 ) + #with self.assertRaises: + # layer.getEdgePolygon( ) + + + + def test_fault_block_layer(self): + with self.assertRaises(ValueError): + layer = FaultBlockLayer( self.grid , -1 ) + + with self.assertRaises(ValueError): + layer = FaultBlockLayer( self.grid , self.grid.size ) + + layer = FaultBlockLayer( self.grid , 1 ) + self.assertEqual( 1 , layer.getK() ) + + kw = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_FLOAT_TYPE ) + with self.assertRaises(ValueError): + layer.scanKeyword( kw ) + + layer.scanKeyword( self.kw ) + self.assertEqual( 2 , len(layer) ) + + with self.assertRaises(TypeError): + ls = layer["JJ"] + + l = [] + for blk in layer: + l.append( blk ) + self.assertEqual( len(l) , 2 ) + + l0 = layer[0] + l1 = layer[1] + self.assertTrue( isinstance(l1 , FaultBlock )) + l0.getCentroid() + l1.getBlockID() + + with self.assertRaises(IndexError): + l2 = layer[2] + + + self.assertEqual( True , 1 in layer) + self.assertEqual( True , 2 in layer) + self.assertEqual( False , 77 in layer) + self.assertEqual( False , 177 in layer) + + l1 = layer.getBlock( 1 ) + self.assertTrue( isinstance(l1 , FaultBlock )) + + with self.assertRaises(KeyError): + l =layer.getBlock(66) + + with self.assertRaises(KeyError): + layer.deleteBlock(66) + + layer.deleteBlock(2) + self.assertEqual( 1 , len(layer)) + blk = layer[0] + self.assertEqual( blk.getBlockID() , 1 ) + + with self.assertRaises(KeyError): + layer.addBlock(1) + + blk2 = layer.addBlock(2) + self.assertEqual( len(layer) , 2 ) + + blk3 = layer.addBlock() + self.assertEqual( len(layer) , 3 ) + + + layer.addBlock(100) + layer.addBlock(101) + layer.addBlock(102) + layer.addBlock(103) + + layer.deleteBlock(2) + blk1 = layer.getBlock( 103 ) + blk2 = layer[-1] + self.assertEqual( blk1.getBlockID() , blk2.getBlockID() ) + + fault_block = layer[0] + fault_block.assignToRegion( 2 ) + self.assertEqual( [2] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 2 ) + self.assertEqual( [2] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 3 ) + self.assertEqual( [2,3] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 1 ) + self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) + + fault_block.assignToRegion( 2 ) + self.assertEqual( [1,2,3] , list(fault_block.getRegionList())) + + + def test_add_polyline_barrier1(self): + grid = EclGrid.create_rectangular( (4,1,1) , (1,1,1) ) + layer = FaultBlockLayer( self.grid , 0 ) + polyline = Polyline( init_points = [ (1.99 , 0.001) , (2.01 , 0.99)]) + + points = [((1,0) , (2,0))] + + geo_layer = layer.getGeoLayer() + for p1,p2 in points: + self.assertTrue(geo_layer.cellContact( p1 , p2 )) + + layer.addPolylineBarrier( polyline ) + for p1,p2 in points: + print p1,p2 + self.assertFalse(geo_layer.cellContact( p1 , p2 )) + + + + def test_add_polyline_barrier2(self): + grid = EclGrid.create_rectangular( (10,10,1) , (1,1,1) ) + layer = FaultBlockLayer( self.grid , 0 ) + polyline = Polyline( init_points = [ (0.1 , 0.9) , (8.9,0.9) , (8.9,8.9) ]) + + points = [((0,0) , (0,1)), + ((2,0) , (2,1)), + ((4,0) , (4,1)), + ((6,0) , (6,1)), + ((8,0) , (8,1)), + # + ((8,1) , (9,1)), + ((8,3) , (9,3)), + ((8,5) , (9,5)), + ((8,7) , (9,7))] + + geo_layer = layer.getGeoLayer() + for p1,p2 in points: + self.assertTrue(geo_layer.cellContact( p1 , p2 )) + + layer.addPolylineBarrier( polyline ) + for p1,p2 in points: + print p1,p2 + self.assertFalse(geo_layer.cellContact( p1 , p2 )) + + + + + + + def test_fault_block_layer_export(self): + layer = FaultBlockLayer( self.grid , 1 ) + kw1 = EclKW.create( "FAULTBLK" , self.grid.size + 1 , EclTypeEnum.ECL_INT_TYPE ) + with self.assertRaises(ValueError): + layer.exportKeyword( kw1 ) + + kw2 = EclKW.create( "FAULTBLK" , self.grid.size , EclTypeEnum.ECL_FLOAT_TYPE ) + with self.assertRaises(TypeError): + layer.exportKeyword(kw2) + + + def test_internal_blocks(self): + nx = 8 + ny = 8 + nz = 1 + grid = EclGrid.createRectangular( (nx , ny , nz) , (1,1,1) ) + layer = FaultBlockLayer( grid , 0 ) + with TestAreaContext("python/FaultBlocks/internal_blocks"): + with open("faultblock.grdecl","w") as fileH: + fileH.write("FAULTBLK \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 4 4 1 2 5 5 2 \n") + fileH.write("1 4 4 1 2 5 5 2 \n") + fileH.write("1 1 1 1 2 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 3 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("1 1 1 1 1 2 2 2 \n") + fileH.write("/\n") + + + kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclTypeEnum.ECL_INT_TYPE) + with open("faults.grdecl" , "w") as f: + f.write("FAULTS\n") + f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") + f.write("\'FX\' 5 5 4 4 1 1 'Y' /\n") + f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + + layer.loadKeyword( kw ) + layer.addFaultBarrier( faults["FX"] ) + b1 = layer.getBlock( 1 ) + b2 = layer.getBlock( 2 ) + b3 = layer.getBlock( 3 ) + b4 = layer.getBlock( 4 ) + b5 = layer.getBlock( 5 ) + + + nb = b1.getNeighbours() + for b in nb: + print "Block:%d" % b.getBlockID() + + self.assertTrue( len(nb) == 2 ) + self.assertTrue( b3 in nb ) + self.assertTrue( b4 in nb ) + + nb = b2.getNeighbours() + self.assertTrue( len(nb) == 1 ) + self.assertTrue( b5 in nb ) + + + + + + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fault_blocks_statoil.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_fault_blocks_statoil.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fault_blocks_statoil.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_fault_blocks_statoil.py diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_faults.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_faults.py new file mode 100644 index 0000000000..f0576dd69d --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_faults.py @@ -0,0 +1,793 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from unittest import skipIf +import time + +from ert.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment,FaultBlockLayer +from ert.ecl import EclGrid, EclKW, EclTypeEnum +from ert.test import ExtendedTestCase, TestAreaContext +from ert.geo import Polyline , CPolyline + +class FaultTest(ExtendedTestCase): + def setUp(self): + self.faults1 = self.createTestPath("local/ECLIPSE/FAULTS/fault1.grdecl") + self.faults2 = self.createTestPath("local/ECLIPSE/FAULTS/fault2.grdecl") + self.grid = EclGrid.create_rectangular( (151,100,50) , (1,1,1)) + + + def test_PolylineIJ(self): + nx = 10 + ny = 10 + nz = 10 + grid = EclGrid.create_rectangular( (nx,ny,nz) , (0.1,0.1,0.1)) + f = Fault(grid , "F") + f.addRecord(0 , 1 , 0 , 0 , 0,0 , "Y-") + f.addRecord(2 , 2 , 0 , 1 , 0,0 , "X-") + f.addRecord(2 , 2 , 1 , 1 , 0,0 , "Y") + + pl = f.getIJPolyline( 0 ) + self.assertEqual(pl , [(0,0) , (2,0) , (2,2) , (3,2)]) + + + def test_empty_collection(self): + faults = FaultCollection() + self.assertEqual(0 , len(faults)) + + self.assertFalse( faults.hasFault("FX") ) + + with self.assertRaises(TypeError): + f = faults[ [] ] + + with self.assertRaises(KeyError): + f = faults["FX"] + + with self.assertRaises(IndexError): + f = faults[0] + + self.assertFalse( "NAME" in faults ) + + def test_collection_invalid_arg(self): + with self.assertRaises(ValueError): + faults = FaultCollection(self.faults1) + + with self.assertRaises(ValueError): + faults = FaultCollection(self.faults1 , self.faults2) + + + + def test_splitLine(self): + faults = FaultCollection(self.grid) + with self.assertRaises(ValueError): + # Not slash terminated + t = faults.splitLine("'F1' 149 149 29 29 1 43 'Y'") + + with self.assertRaises(ValueError): + # Not integer + t = faults.splitLine("'F1' 149 149 29 29 1 43X 'Y' /") + + with self.assertRaises(ValueError): + # Missing item + t = faults.splitLine("'F1' 149 29 29 1 43 'Y' /") + + with self.assertRaises(ValueError): + # Quote fuckup + t = faults.splitLine("'F1 149 149 29 29 1 43 'X' /") + + + def test_empty_fault( self ): + f = Fault(self.grid , "NAME") + self.assertEqual("NAME" , f.getName()) + + with self.assertRaises(Exception): + g = f["Key"] + + + def test_empty_faultLine(self): + fl = FaultLine(self.grid , 10) + self.assertEqual( 10 , fl.getK()) + self.assertEqual( 0 , len(fl) ) + + with self.assertRaises(TypeError): + f = fl[ "Test" ] + + with self.assertRaises(IndexError): + f = fl[0] + + + + def test_faultLine_center(self): + nx = 10 + ny = 10 + nz = 2 + grid = EclGrid.create_rectangular( (nx,ny,nz) , (0.1,0.1,0.1)) + fl = FaultLine(grid , 0) + C1 = (nx + 1) * 5 + 3 + C2 = C1 + 2 + C3 = C2 + 2 + + s1 = FaultSegment( C1 , C2 ) + s2 = FaultSegment( C2 , C3 ) + + fl.tryAppend( s1 ) + fl.tryAppend( s2 ) + + self.assertEqual( len(fl) , 2 ) + self.assertEqual( fl.center() , (0.50 , 0.50) ) + + + + def test_faultLine(self): + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(0 , 10) + S2 = FaultSegment(10 , 20) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + fl.verify() + S3 = FaultSegment(20 , 30) + fl.tryAppend( S3 ) + fl.verify() + #--- + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(0 , 10) + S2 = FaultSegment(20 , 10) + fl.tryAppend( S1 ) + self.assertTrue( fl.tryAppend( S2 ) ) + fl.verify() + #--- + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(10 , 0) + S2 = FaultSegment(20 , 10) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + fl.verify() + #--- + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(10 , 0) + S2 = FaultSegment(10 , 20) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + fl.verify() + + fl = FaultLine(self.grid , 10) + S1 = FaultSegment(10 , 0) + S2 = FaultSegment(10 , 20) + fl.tryAppend( S1 ) + fl.tryAppend( S2 ) + S3 = FaultSegment(40 , 30) + self.assertTrue( fl.tryAppend(S3) == False ) + self.assertEqual( len(fl) , 2 ) + + pl = fl.getPolyline( ) + self.assertIsInstance( pl , CPolyline ) + self.assertEqual( len(pl) , len(fl) + 1 ) + + S3 = FaultSegment(20 , 30) + fl.tryAppend( S3 ) + pl = fl.getPolyline( ) + self.assertIsInstance( pl , CPolyline ) + self.assertEqual( len(pl) , len(fl) + 1 ) + + + + + def test_load(self): + faults = FaultCollection(self.grid , self.faults1) + self.assertEqual( 3 , len(faults)) + faults.load( self.grid , self.faults2 ) + self.assertEqual( 7 , len(faults)) + fault1 = faults["F1"] + layer8 = fault1[8] + self.assertEqual( len(layer8) , 1 ) + + with self.assertRaises(IOError): + faults.load(self.grid , "No/this/does/not/exist") + + + def test_connect_faults(self): + grid = EclGrid.create_rectangular( (100,100,10) , (1,1,1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ------- Fault2 | + # | | + # | | + # + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + + for other_fault in [fault2 , fault3,fault4]: + with self.assertRaises(ValueError): + fault1.extendToFault( other_fault ,0) + + with self.assertRaises(ValueError): + fault2.extendToFault( fault3 , 0) + + for other_fault in [fault1 , fault2,fault4]: + with self.assertRaises(ValueError): + fault3.extendToFault( other_fault ,0 ) + + for other_fault in [fault1 , fault2,fault3]: + with self.assertRaises(ValueError): + fault4.extendToFault( other_fault , 0) + + ext21 = fault2.extendToFault( fault1 , 0) + self.assertEqual(len(ext21) , 2) + p0 = ext21[0] + p1 = ext21[1] + self.assertEqual(p0 , (5 , 16)) + self.assertEqual(p1 , (2 , 16)) + + + ext24 = fault2.extendToFault( fault4,0 ) + self.assertEqual(len(ext24) , 2) + p0 = ext24[0] + p1 = ext24[1] + self.assertEqual(p0 , (11 , 16)) + self.assertEqual(p1 , (21 , 16)) + + + def test_intersect_intRays(self): + p1 = (0,0) + dir1 = (1,0) + p2 = (0,0) + dir2 = (0,1) + + line = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual( line , [] ) + + # Opposite direction + p3 = (-1,0) + dir3 = (-1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p3,dir3)) + + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p3,dir3),(p1,dir1)) + + # Parallell with offset + p4 = (0,1) + dir4 = (1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p4,dir4)) + + p5 = (0,1) + dir5 = (-1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p5,dir5)) + + p6 = (1,1) + dir6 = (1,0) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p6,dir6)) + + p2 = (-1,0) + dir2 = (-1,0) + join = Fault.intersectFaultRays(( p2,dir1),(p1,dir2)) + self.assertEqual( join , [p2 , p1]) + + join = Fault.intersectFaultRays(( p1,dir3),(p3,dir1)) + self.assertEqual( join , [p1 , p3]) + + p2 = (1,0) + dir2 = (1,0) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2)) + self.assertEqual( join , [p1 , p2]) + + # Orthogonal + p2 = (1,1) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (0,1) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (-1,0) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (-1,1) + dir2 = (0,1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (-1,1) + dir2 = (0,-1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (3,-1) + dir2 = (0,-1) + with self.assertRaises(ValueError): + Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + + p2 = (1,-1) + dir2 = (0,1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , (1,0) , p2]) + + p2 = (1,1) + dir2 = (0,-1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , (1,0) , p2]) + + p2 = (0,3) + dir2 = (0,-1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , p2]) + + p2 = (3,0) + dir2 = (0,-1) + join = Fault.intersectFaultRays(( p1,dir1),(p2,dir2 )) + self.assertEqual(join , [p1 , p2]) + + + def test_join_faults(self): + grid = EclGrid.create_rectangular( (100,100,10) , (1,1,1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ------- Fault2 | + # | | + # | | + # + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + rays = fault1.getEndRays(0) + self.assertEqual( rays[0] , [(2,10) , (0,-1)]) + self.assertEqual( rays[1] , [(2,100) , (0,1)]) + + extra = Fault.joinFaults( fault1 , fault3 , 0) + self.assertEqual( extra , [(2,10) , (2,6) , (5,6)] ) + + + def test_contact(self): + grid = EclGrid.create_rectangular( (100,100,10) , (1,1,1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ----------------------+-- Fault2 + # | | + # | | + # + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 30 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(2 , 10 , 9 , 9 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + #self.assertFalse( fault1.intersectsFault(fault2 , 0) ) + #self.assertFalse( fault2.intersectsFault(fault1 , 0) ) + + #self.assertTrue( fault2.intersectsFault(fault4 , 0) ) + #self.assertTrue( fault4.intersectsFault(fault2 , 0) ) + + self.assertTrue( fault1.intersectsFault(fault1 , 0) ) + #self.assertTrue( fault3.intersectsFault(fault3 , 0) ) + + + + def test_iter(self): + faults = FaultCollection(self.grid , self.faults1 , self.faults2) + self.assertEqual( 7 , len(faults)) + c = 0 + for f in faults: + c += 1 + self.assertEqual( c , len(faults)) + + for f in ["F1","F2","F3" ,"F4"]: + self.assertTrue( f in faults ) + + self.assertFalse("FX" in faults ) + + + + def test_fault(self): + f = Fault(self.grid , "NAME") + + with self.assertRaises(ValueError): + # Invalid face + f.addRecord( 10 , 10 , 11 , 11 , 1 , 43 , "F") + + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( -1 , 10 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( 10000 , 10 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") + + + with self.assertRaises(ValueError): + # Invalid coordinates + f.addRecord( 10 , 9 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates/face combination + f.addRecord( 10 , 11 , 11 , 11 , 1 , 43 , "X") + + with self.assertRaises(ValueError): + # Invalid coordinates/face combination + f.addRecord( 10 , 11 , 11 , 12 , 1 , 43 , "Y") + + f.addRecord(10 , 10 , 0 , 10 , 1 , 10 , "X") + + + def test_segment(self ): + s0 = FaultSegment(0 , 10) + self.assertEqual(s0.getC1() , 0 ) + self.assertEqual(s0.getC2() , 10 ) + + s0.swap() + self.assertEqual(s0.getC1() , 10 ) + self.assertEqual(s0.getC2() , 0 ) + + + + + def test_fault_line(self ): + faults = FaultCollection(self.grid , self.faults1 , self.faults2) + for fault in faults: + for layer in fault: + for fl in layer: + fl.verify() + + + def test_fault_line_order(self): + nx = 120 + ny = 60 + nz = 43 + grid = EclGrid.create_rectangular( (nx , ny , nz) , (1,1,1) ) + with TestAreaContext("python/faults/line_order"): + with open("faults.grdecl" , "w") as f: + f.write("""FAULTS +\'F\' 105 107 50 50 1 43 \'Y\' / +\'F\' 108 108 50 50 1 43 \'X\' / +\'F\' 108 108 50 50 22 43 \'Y\' / +\'F\' 109 109 49 49 1 43 \'Y\' / +\'F\' 110 110 49 49 1 43 \'X\' / +\'F\' 111 111 48 48 1 43 \'Y\' / +/ +""") + with open("faults.grdecl") as f: + faults = FaultCollection( grid , "faults.grdecl" ) + + fault = faults["F"] + layer = fault[29] + self.assertEqual(len(layer) , 2) + + line1 = layer[0] + line2 = layer[1] + self.assertEqual(len(line1) , 4) + self.assertEqual(len(line2) , 2) + + seg0 = line1[0] + seg1 = line1[1] + seg2 = line1[2] + seg3 = line1[3] + self.assertEqual( seg0.getCorners() , (50 * (nx + 1) + 104 , 50 * (nx + 1) + 107)) + self.assertEqual( seg1.getCorners() , (50 * (nx + 1) + 107 , 50 * (nx + 1) + 108)) + self.assertEqual( seg2.getCorners() , (50 * (nx + 1) + 108 , 49 * (nx + 1) + 108)) + self.assertEqual( seg3.getCorners() , (49 * (nx + 1) + 108 , 49 * (nx + 1) + 109)) + + + + + + def test_neighbour_cells(self): + nx = 10 + ny = 8 + nz = 7 + grid = EclGrid.create_rectangular( (nx , ny , nz) , (1,1,1) ) + faults_file = self.createTestPath("local/ECLIPSE/FAULTS/faults_nb.grdecl") + faults = FaultCollection( grid , faults_file ) + + fault = faults["FY"] + self.assertEqual(len(fault),1) + fault_layer = fault[0] + + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(0, nx) , (1,nx + 1), (2,nx+2) , (3,nx + 3) , (4,nx+4)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + fl2 = fault_layer[1] + nb_cells2 = fl2.getNeighborCells() + true_nb_cells2 = [(6, nx+6) , (7,nx + 7), (8 , nx+8) , (9,nx + 9)] + self.assertListEqual( nb_cells2 , true_nb_cells2 ) + + nb_cells = fault_layer.getNeighborCells() + self.assertListEqual( nb_cells , true_nb_cells1 + true_nb_cells2) + + + fault = faults["FY0"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(-1,0) , (-1,1), (-1,2)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + + fault = faults["FYNY"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(nx * (ny - 1) , -1), (nx * (ny - 1) + 1 , -1), (nx * (ny - 1) + 2, -1)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + fault = faults["FX"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(0,1) , (nx , nx+1) , (2*nx , 2*nx + 1)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + + fault = faults["FX0"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(-1 , 0) , (-1 , nx) , (-1 , 2*nx)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + fault = faults["FXNX"] + fault_layer = fault[0] + fl1 = fault_layer[0] + nb_cells1 = fl1.getNeighborCells() + true_nb_cells1 = [(nx -1 , -1) , (2*nx -1 , -1) , (3*nx - 1 , -1)] + self.assertListEqual( nb_cells1 , true_nb_cells1 ) + + + def test_polyline_intersection(self): + grid = EclGrid.create_rectangular( (100,100,10) , (0.25 , 0.25 , 1)) + + # Fault1 Fault4 + # | | + # | | + # | | + # | ------- Fault2 | + # | | + # | | + # (5 , 2.50) + # -------- Fault3 + # + + fault1 = Fault(grid , "Fault1") + fault2 = Fault(grid , "Fault2") + fault3 = Fault(grid , "Fault3") + fault4 = Fault(grid , "Fault4") + + fault1.addRecord(1 , 1 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + fault2.addRecord(5 , 10 , 15 , 15 , 0 , 0 , "Y") + fault3.addRecord(5 , 10 , 5 , 5 , 0 , 0 , "Y") + fault4.addRecord(20 , 20 , 10 , grid.getNY() - 1 , 0 , 0 , "X") + + + polyline = Polyline( init_points = [(4 , 4) , (8,4)]) + self.assertTrue( fault4.intersectsPolyline( polyline , 0)) + + cpolyline = CPolyline( init_points = [(4 , 4) , (8,4)]) + self.assertTrue( fault4.intersectsPolyline( cpolyline , 0)) + + polyline = Polyline( init_points = [(8 , 4) , (16,4)]) + self.assertFalse( fault4.intersectsPolyline( polyline , 0)) + + cpolyline = CPolyline( init_points = [(8 , 4) , (16,4)]) + self.assertFalse( fault4.intersectsPolyline( cpolyline , 0)) + + + def test_num_linesegment(self): + nx = 10 + ny = 10 + nz = 1 + grid = EclGrid.create_rectangular( (nx , ny , nz) , (1,1,1) ) + with TestAreaContext("python/faults/line_order"): + with open("faults.grdecl" , "w") as f: + f.write("""FAULTS +\'F1\' 1 4 2 2 1 1 \'Y\' / +\'F1\' 6 8 2 2 1 1 \'Y\' / +\'F2\' 1 8 2 2 1 1 \'Y\' / +/ +""") + with open("faults.grdecl") as f: + faults = FaultCollection( grid , "faults.grdecl" ) + + f1 = faults["F1"] + f2 = faults["F2"] + self.assertEqual( 2 , f1.numLines(0)) + self.assertEqual( 1 , f2.numLines(0)) + + + def test_extend_to_polyline(self): + grid = EclGrid.create_rectangular( (3,3,1) , (1 , 1 , 1)) + + # o o o o + # + # o---o---o---o + # + # o===+ o o + # | + # o o o o + + fault1 = Fault(grid , "Fault") + + fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "X-") + fault1.addRecord(0 , 0 , 0 , 0 , 0 , 0 , "Y") + + polyline = CPolyline( init_points = [(0,2) , (3,2)]) + points = fault1.extendToPolyline( polyline , 0 ) + self.assertEqual( points , [(1,1) , (2,2)]) + + end_join = fault1.endJoin( polyline , 0 ) + self.assertEqual( end_join, [(1,1) , (0,2)] ) + + polyline2 = CPolyline( init_points = [(0.8,2) , (0.8,0.8)]) + end_join = fault1.endJoin( polyline2 , 0 ) + self.assertIsNone( end_join ) + + + def test_extend_polyline_on(self): + grid = EclGrid.create_rectangular( (3,3,1) , (1 , 1 , 1)) + + # o o o o + # + # o---o---o---o + # + # o===o===o===o + # + # o o o o + + fault1 = Fault(grid , "Fault") + fault1.addRecord(0 , 2 , 0 , 0 , 0 , 0 , "Y") + + polyline0 = CPolyline( init_points = [(0,2)]) + polyline1 = CPolyline( init_points = [(0,2) , (3,2)]) + polyline2 = CPolyline( init_points = [(1,3) , (1,2)]) + polyline3 = CPolyline( init_points = [(1,3) , (1,0)]) + + with self.assertRaises(ValueError): + fault1.extendPolylineOnto( polyline0 , 0 ) + + points = fault1.extendPolylineOnto( polyline1 , 0 ) + self.assertIsNone( points ) + + points = fault1.extendPolylineOnto( polyline2 , 0) + self.assertEqual( points , [(1,2) , (1,1)]) + + points = fault1.extendPolylineOnto( polyline3 , 0) + self.assertIsNone( points ) + + + def test_stepped(self): + grid = EclGrid.create_rectangular( (6,1,4) , (1,1,1)) + f = Fault(grid , "F") + f.addRecord(4,4,0,0,0,1,"X") + f.addRecord(2,2,0,0,1,1,"Z") + f.addRecord(1,1,0,0,2,3,"X") + + block_kw = EclKW.create("FAULTBLK" , grid.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE) + block_kw.assign(1) + block_kw[5] = 2 + block_kw[11] = 2 + block_kw[14:18] = 2 + block_kw[14:18] = 2 + block_kw[20:23] = 2 + + layer0 = FaultBlockLayer( grid , 0 ) + layer0.scanKeyword( block_kw ) + layer0.addFaultBarrier( f ) + self.assertTrue( layer0.cellContact((0,0) , (1,0))) + self.assertFalse( layer0.cellContact((4,0) , (5,0))) + + layer1 = FaultBlockLayer( grid , 1 ) + layer1.scanKeyword( block_kw ) + layer1.addFaultBarrier( f ) + self.assertTrue( layer1.cellContact((0,0) , (1,0))) + self.assertFalse( layer1.cellContact((4,0) , (5,0))) + + layer2 = FaultBlockLayer( grid , 2 ) + layer2.scanKeyword( block_kw ) + layer2.addFaultBarrier( f ) + self.assertTrue( layer2.cellContact((0,0) , (1,0))) + self.assertFalse( layer2.cellContact((1,0) , (2,0))) + + layer3 = FaultBlockLayer( grid , 3 ) + layer3.scanKeyword( block_kw ) + layer3.addFaultBarrier( f ) + self.assertTrue( layer3.cellContact((0,0) , (1,0))) + self.assertFalse( layer3.cellContact((1,0) , (2,0))) + + + + def test_connectWithPolyline(self): + grid = EclGrid.create_rectangular( (4,4,1) , (1 , 1 , 1)) + + + # o o o o o + # + # o o o o o + # + # o---o---o---o---o + # + # o o o o o + # | + # o o o o o + + fault1 = Fault(grid , "Fault1") + fault1.addRecord(0 , 3 , 1 , 1 , 0 , 0 , "Y") + + fault2 = Fault(grid , "Fault2") + fault2.addRecord(1 , 1 , 0 , 0 , 0 , 0 , "X") + + fault3 = Fault(grid , "Fault3") + fault3.addRecord(1 , 1 , 0 , 2 , 0 , 0 , "X") + + self.assertIsNone( fault3.connect( fault1 , 0 )) + + + intersect = fault2.connect( fault1 , 0 ) + self.assertEqual( len(intersect) , 2 ) + p1 = intersect[0] + p2 = intersect[1] + + self.assertEqual( p1 , (2,1)) + self.assertEqual( p2 , (2,2)) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fortio.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_fortio.py similarity index 65% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fortio.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_fortio.py index dc667ec151..edfe01f9b2 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_fortio.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_fortio.py @@ -75,55 +75,7 @@ def test_fortio_creation(self): w.close() w.close() # should not fail - def test_fortio_read_and_write(self): - with TestAreaContext("python/fortio/read_and_write"): - f = FortIO("test", FortIO.WRITE_MODE) - - record_size = 4000 - - for i, c in enumerate("abcdefghijklmnopqrstuvwxyz"): - data = bytearray(c * record_size) - f.writeRecord(data) - position = f.getPosition() - self.assertEqual(position, (i + 1) * (record_size + 8)) - - f = FortIO("test", FortIO.READ_MODE) - - for c in "abcdefghijklmnopqrstuvwxyz": - record = f.readRecordAsString(record_size) - self.assertEqual(record, c * record_size) - - - def test_fortio_read_and_write_and_rewrite(self): - with TestAreaContext("python/fortio/read_and_write_and_rewrite"): - record_size = 4000 - - f = FortIO("complete", FortIO.WRITE_MODE) - for c in "abcdefghijklmnopqrstuvwxyz": - data = bytearray(c * record_size) - f.writeRecord(data) - - - f = FortIO("test", FortIO.WRITE_MODE) - - positions = {} - for c in "abcdefghij-lmnopqrstuvwxyz": - data = bytearray(c * record_size) - f.writeRecord(data) - positions[c] = f.getPosition() - - - f = FortIO("test", FortIO.READ_AND_WRITE_MODE) - - f.seek(positions["j"]) - - new_data = bytearray("k" * record_size) - f.writeRecord(new_data) - - f.close() - - self.assertFilesAreEqual("test", "complete") - + @@ -141,3 +93,15 @@ def test_context(self): self.assertTrue( kw1 == kw2 ) + + def test_is_fortran_file(self): + with TestAreaContext("python/fortio/guess"): + kw1 = EclKW.create("KW" , 12345 , EclTypeEnum.ECL_FLOAT_TYPE) + with openFortIO("fortran_file" , mode = FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + + with open("text_file" , "w") as f: + kw1.write_grdecl( f ) + + self.assertTrue( FortIO.isFortranFile( "fortran_file" )) + self.assertFalse( FortIO.isFortranFile( "text_file" )) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_grdecl.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_grdecl.py similarity index 94% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_grdecl.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_grdecl.py index cfda2feef1..3ff4f63b01 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_grdecl.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_grdecl.py @@ -16,7 +16,7 @@ # for more details. import os -from ert.ecl import EclKW +from ert.ecl import EclKW,EclGrid,Ecl3DKW from ert.test import ExtendedTestCase @@ -41,6 +41,11 @@ def test_Load( self ): kw = EclKW.read_grdecl(open(self.src_file, "r"), "PERMX") self.assertTrue(kw) + grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" )) + kw = Ecl3DKW.read_grdecl(grid , open(self.src_file, "r"), "PERMX") + self.assertTrue( isinstance( kw , Ecl3DKW )) + + def test_reload( self ): kw = EclKW.read_grdecl(open(self.src_file, "r"), "PERMX") diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_grid.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_grid.py new file mode 100644 index 0000000000..006fc8b747 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_grid.py @@ -0,0 +1,186 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +import os.path +from unittest import skipIf +import time + +from ert.util import IntVector +from ert.ecl import EclGrid,EclKW,EclTypeEnum +from ert.ecl.faults import Layer , FaultCollection +from ert.test import ExtendedTestCase , TestAreaContext + + +# This test class should only have test cases which do not require +# external test data. Tests involving Statoil test data are in the +# test_grid_statoil module. + +class GridTest(ExtendedTestCase): + + + def test_posXYEdge(self): + nx = 10 + ny = 11 + grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) + self.assertEqual( grid.findCellCornerXY(0,0,0) , 0 ) + self.assertEqual( grid.findCellCornerXY(nx,0,0) , nx) + self.assertEqual( grid.findCellCornerXY(0 , ny , 0) , (nx + 1 ) * ny ) + self.assertEqual( grid.findCellCornerXY(nx,ny,0) , (nx + 1 ) * (ny + 1) - 1) + + self.assertEqual( grid.findCellCornerXY(0.25,0,0) , 0 ) + self.assertEqual( grid.findCellCornerXY(0,0.25,0) , 0 ) + + self.assertEqual( grid.findCellCornerXY(nx - 0.25,0,0) , nx ) + self.assertEqual( grid.findCellCornerXY(nx , 0.25,0) , nx ) + + self.assertEqual( grid.findCellCornerXY(0 , ny - 0.25, 0) , (nx + 1 ) * ny ) + self.assertEqual( grid.findCellCornerXY(0.25 , ny , 0) , (nx + 1 ) * ny ) + + self.assertEqual( grid.findCellCornerXY(nx -0.25 ,ny,0) , (nx + 1 ) * (ny + 1) - 1) + self.assertEqual( grid.findCellCornerXY(nx , ny - 0.25,0) , (nx + 1 ) * (ny + 1) - 1) + + + def test_dims(self): + grid = EclGrid.createRectangular( (10,20,30) , (1,1,1) ) + self.assertEqual( grid.getNX() , 10 ) + self.assertEqual( grid.getNY() , 20 ) + self.assertEqual( grid.getNZ() , 30 ) + self.assertEqual( grid.getGlobalSize() , 30*10*20 ) + + self.assertEqual( grid.getDims() , (10,20,30,6000) ) + + + + def test_create(self): + with self.assertRaises(ValueError): + grid = EclGrid.createRectangular( (10,20,30) , (1,1,1) , actnum = [0,1,1,2]) + + with self.assertRaises(ValueError): + grid = EclGrid.createRectangular( (10,20,30) , (1,1,1) , actnum = IntVector(initial_size = 10)) + + actnum = IntVector(default_value = 1 , initial_size = 6000) + actnum[0] = 0 + actnum[1] = 0 + grid = EclGrid.createRectangular( (10,20,30) , (1,1,1) , actnum = actnum) + self.assertEqual( grid.getNumActive( ) , 30*20*10 - 2) + + + + + def test_node_pos(self): + grid = EclGrid.createRectangular( (10,20,30) , (1,1,1) ) + with self.assertRaises(IndexError): + grid.getNodePos(-1,0,0) + + with self.assertRaises(IndexError): + grid.getNodePos(11,0,0) + + p0 = grid.getNodePos(0,0,0) + self.assertEqual( p0 , (0,0,0)) + + p7 = grid.getNodePos(10,20,30) + self.assertEqual( p7 , (10,20,30)) + + + def test_truncated_file(self): + grid = EclGrid.createRectangular( (10,20,30) , (1,1,1) ) + with TestAreaContext("python/ecl_grid/truncated"): + grid.save_EGRID( "TEST.EGRID") + + size = os.path.getsize( "TEST.EGRID") + with open("TEST.EGRID" , "r+") as f: + f.truncate( size / 2 ) + + with self.assertRaises(IOError): + EclGrid("TEST.EGRID") + + def test_posXY1(self): + nx = 4 + ny = 1 + nz = 1 + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) ) + (i,j) = grid.findCellXY( 0.5 , 0.5, 0 ) + self.assertEqual(i , 0) + self.assertEqual(j , 0) + + (i,j) = grid.findCellXY( 3.5 , 0.5, 0 ) + self.assertEqual(i , 3) + self.assertEqual(j , 0) + + + def test_init_ACTNUM(self): + nx = 10 + ny = 23 + nz = 7 + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) ) + actnum = grid.exportACTNUM() + + self.assertEqual( len(actnum) , nx*ny*nz ) + self.assertEqual( actnum[0] , 1 ) + self.assertEqual( actnum[nx*ny*nz - 1] , 1 ) + + + + + def test_posXY(self): + nx = 10 + ny = 23 + nz = 7 + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) ) + with self.assertRaises(IndexError): + grid.findCellXY( 1 , 1, -1 ) + + with self.assertRaises(IndexError): + grid.findCellXY( 1 , 1, nz + 1 ) + + with self.assertRaises(ValueError): + grid.findCellXY(15 , 78 , 2) + + + i,j = grid.findCellXY( 1.5 , 1.5 , 2 ) + self.assertEqual(i , 1) + self.assertEqual(j , 1) + + + for i in range(nx): + for j in range(ny): + p = grid.findCellXY(i + 0.5 , j+ 0.5 , 0) + self.assertEqual( p[0] , i ) + self.assertEqual( p[1] , j ) + + c = grid.findCellCornerXY( 0.10 , 0.10 , 0 ) + self.assertEqual(c , 0) + + c = grid.findCellCornerXY( 0.90 , 0.90 , 0 ) + self.assertEqual( c , (nx + 1) + 1 ) + + c = grid.findCellCornerXY( 0.10 , 0.90 , 0 ) + self.assertEqual( c , (nx + 1) ) + + c = grid.findCellCornerXY( 0.90 , 0.90 , 0 ) + self.assertEqual( c , (nx + 1) + 1 ) + + c = grid.findCellCornerXY( 0.90 , 0.10 , 0 ) + self.assertEqual( c , 1 ) + + def test_compressed_copy(self): + nx = 10 + ny = 10 + nz = 10 + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) ) + kw1 = EclKW.create("KW" , 1001 , EclTypeEnum.ECL_INT_TYPE ) + with self.assertRaises(ValueError): + cp = grid.compressedKWCopy( kw1 ) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_grid.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_grid_statoil.py similarity index 80% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_grid.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_grid_statoil.py index b7f10a96ac..3ef13f178d 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_grid.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_grid_statoil.py @@ -22,8 +22,8 @@ from unittest import skipIf import time -from ert.ecl import EclTypeEnum, EclKW, EclGrid -from ert.util import DoubleVector +from ert.ecl import EclTypeEnum, EclKW, EclGrid, EclFile, openEclFile +from ert.util import DoubleVector, IntVector from ert.test import ExtendedTestCase , TestAreaContext @@ -39,34 +39,14 @@ def grid_file(self): def grdecl_file(self): return self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_grid_sim.GRDECL") - def test_dims(self): - grid = EclGrid.create_rectangular( (10,20,30) , (1,1,1) ) - self.assertEqual( grid.getNX() , 10 ) - self.assertEqual( grid.getNY() , 20 ) - self.assertEqual( grid.getNZ() , 30 ) - self.assertEqual( grid.getGlobalSize() , 30*10*20 ) + def test_loadFromFile(self): + g1 = EclGrid.loadFromFile( self.egrid_file() ) + g2 = EclGrid.loadFromFile( self.grdecl_file() ) + self.assertTrue( isinstance( g1 , EclGrid ) ) + self.assertTrue( isinstance( g2 , EclGrid ) ) - def test_node_pos(self): - grid = EclGrid.create_rectangular( (10,20,30) , (1,1,1) ) - with self.assertRaises(IndexError): - grid.getNodePos(-1,0,0) - - with self.assertRaises(IndexError): - grid.getNodePos(11,0,0) - - p0 = grid.getNodePos(0,0,0) - self.assertEqual( p0 , (0,0,0)) - - p7 = grid.getNodePos(10,20,30) - self.assertEqual( p7 , (10,20,30)) - - - - - - def test_corner(self): grid = EclGrid(self.egrid_file()) nx = grid.getNX() @@ -154,7 +134,7 @@ def test_rect(self): a1 = 1.0 a2 = 2.0 a3 = 3.0 - grid = EclGrid.create_rectangular((9, 9, 9), (a1, a2, a3)) + grid = EclGrid.createRectangular((9, 9, 9), (a1, a2, a3)) grid.save_EGRID("rect.EGRID") grid2 = EclGrid("rect.EGRID") self.assertTrue(grid) @@ -185,6 +165,42 @@ def test_create(self): self.assertTrue(grid) + def test_grdecl_load(self): + with self.assertRaises(IOError): + grid = EclGrid.loadFromGrdecl("/file/does/not/exists") + + with TestAreaContext("python/grid-test/grdeclLoad"): + with open("grid.grdecl","w") as f: + f.write("Hei ...") + + with self.assertRaises(ValueError): + grid = EclGrid.loadFromGrdecl("grid.grdecl") + + actnum = IntVector(default_value = 1 , initial_size = 1000) + actnum[0] = 0 + g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum ) + self.assertEqual( g1.getNumActive() , actnum.elementSum() ) + g1.save_EGRID("G.EGRID") + + with openEclFile("G.EGRID") as f: + with open("grid.grdecl" , "w") as f2: + f2.write("SPECGRID\n") + f2.write(" 10 10 10 \'F\' /\n") + + coord_kw = f["COORD"][0] + coord_kw.write_grdecl( f2 ) + + zcorn_kw = f["ZCORN"][0] + zcorn_kw.write_grdecl( f2 ) + + actnum_kw = f["ACTNUM"][0] + actnum_kw.write_grdecl( f2 ) + + g2 = EclGrid.loadFromGrdecl("grid.grdecl") + self.assertTrue( g1.equal( g2 )) + + + def test_ACTNUM(self): g1 = self.create(self.grdecl_file()) g2 = self.create(self.grdecl_file(), load_actnum=False) @@ -241,7 +257,7 @@ def test_raise_IO_error(self): g = EclGrid("/does/not/exist.EGRID") def test_boundingBox(self): - grid = EclGrid.create_rectangular((10,10,10) , (1,1,1)) + grid = EclGrid.createRectangular((10,10,10) , (1,1,1)) with self.assertRaises(ValueError): bbox = grid.getBoundingBox2D(layer = -1 ) @@ -252,6 +268,23 @@ def test_boundingBox(self): self.assertEqual( bbox , ((0,0) , (10, 0) , (10 , 10) , (0,10))) + with self.assertRaises(ValueError): + grid.getBoundingBox2D( lower_left = (-1,0) ) + + with self.assertRaises(ValueError): + grid.getBoundingBox2D( lower_left = (6,10) ) + + bbox = grid.getBoundingBox2D( lower_left = (3,3) ) + self.assertEqual( bbox , ((3,3) , (10,3) , (10,10) , (3,10))) + + with self.assertRaises(ValueError): + grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (2,2)) + + bbox = grid.getBoundingBox2D( lower_left = (3,3) , upper_right = (7,7)) + self.assertEqual( bbox , ((3,3) , (7,3) , (7,7) , (3,7))) + + + @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test of dual grid skipped!") @@ -327,4 +360,4 @@ def test_no_mapaxes_check_for_nan(self): xyz = grid.get_xyz(ijk=(1, 1, 1)) self.assertFalse(math.isnan(xyz[0])) self.assertFalse(math.isnan(xyz[1])) - self.assertFalse(math.isnan(xyz[2])) \ No newline at end of file + self.assertFalse(math.isnan(xyz[2])) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_indexed_read.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_indexed_read.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_indexed_read.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_indexed_read.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_kw.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_kw.py similarity index 87% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_kw.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_kw.py index 0d1f46483e..e29562f32d 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_kw.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_kw.py @@ -42,6 +42,17 @@ def test_fortio_size( self ): stat = os.stat(unrst_file_path) self.assertTrue(size == stat.st_size) + def test_min_max(self): + kw = EclKW.new("TEST", 3, EclTypeEnum.ECL_INT_TYPE) + kw[0] = 10 + kw[1] = 5 + kw[2] = 0 + + self.assertEqual( 10 , kw.getMax()) + self.assertEqual( 0 , kw.getMin()) + self.assertEqual( (0,10) , kw.getMinMax()) + + def test_equal(self): kw1 = EclKW.new("TEST", 3, EclTypeEnum.ECL_CHAR_TYPE) @@ -104,7 +115,12 @@ def kw_test( self, data_type, data, fmt ): self.assertFilesAreEqual(name1, name2) self.assertEqual( kw.getEclType() , data_type ) - + def test_create(self): + with self.assertRaises(ValueError): + EclKW.create( "ToGodDamnLong" , 100 , EclTypeEnum.ECL_CHAR_TYPE ) + + + def test_sum( self ): kw_string = EclKW.create( "STRING" , 100 , EclTypeEnum.ECL_CHAR_TYPE ) with self.assertRaises(ValueError): @@ -213,6 +229,38 @@ def test_kw_write(self): self.assertTrue(kw.equal(kw5)) + + def test_fprintf_data(self): + with TestAreaContext("kw_no_header"): + kw = EclKW.create("REGIONS" , 10 , EclTypeEnum.ECL_INT_TYPE) + for i in range(len(kw)): + kw[i] = i + + fileH = open("test" , "w") + kw.fprintf_data( fileH ) + fileH.close() + + fileH = open("test" , "r") + data = [] + for line in fileH.readlines(): + tmp = line.split() + for elm in tmp: + data.append( int(elm) ) + + for (v1,v2) in zip(data,kw): + self.assertEqual(v1,v2) + + + def test_sliced_set(self): + kw = EclKW.create("REGIONS" , 10 , EclTypeEnum.ECL_INT_TYPE) + kw.assign(99) + kw[0:5] = 66 + self.assertEqual(kw[0] , 66) + self.assertEqual(kw[4] , 66) + self.assertEqual(kw[5] , 99) + + + #def cutoff( x , arg ): # if x < arg: # return 0 diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_kw_function.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_kw_function.py new file mode 100644 index 0000000000..cd60c14f60 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_kw_function.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_kw_function.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +import os +import random +from ert.ecl import EclKW, EclTypeEnum, EclGrid , Ecl3DKW +from ert.util import IntVector +from ert.test import ExtendedTestCase + +class KWFunctionTest(ExtendedTestCase): + + def test_region_filter(self): + nx = 10 + ny = 10 + nz = 1 + actnum = IntVector( initial_size = nx*ny*nz , default_value = 1 ) + actnum[nx*ny - 1] = 0 + + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) , actnum = actnum) + self.assertEqual( grid.getNumActive() , nx*ny*nz - 1 ) + + kw = Ecl3DKW.create( "REGIONS" , grid , EclTypeEnum.ECL_INT_TYPE , global_active = True ) + kw.assign( 0 ) + kw[0:nx*ny/2] = 1 + kw[5,2,0] = 0 + kw[0,9,0] = 2 + + kw.fixUninitialized( grid ) + + # Not assigned because they are in contact with a '2'; these + # two are problem cells. + self.assertEqual( kw[0,ny - 2,0] , 0) + self.assertEqual( kw[1,ny - 1,0] , 0) + + # Not assigned because it is inactive + self.assertEqual( kw[nx - 1,ny - 1,0] , 0) + + self.assertEqual( kw[5,2,0] , 1 ) + for j in range(5,10): + self.assertEqual( kw[5,j,0] , 1 ) + + for i in range(10): + self.assertEqual( kw[i,7,0] , 1 ) + diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_layer.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_layer.py new file mode 100644 index 0000000000..713dac5a4f --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_layer.py @@ -0,0 +1,298 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_layer.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from unittest import skipIf +import time + +from ert.util import IntVector +from ert.ecl import EclGrid +from ert.geo import CPolyline +from ert.ecl.faults import Layer , FaultCollection +from ert.test import ExtendedTestCase , TestAreaContext + + +class LayerTest(ExtendedTestCase): + def setUp(self): + pass + + + def test_create_layer(self): + layer = Layer(10,10) + self.assertTrue( isinstance( layer , Layer )) + + + def test_add_cell(self): + layer = Layer(10,10) + with self.assertRaises(ValueError): + layer[100,100] = 199 + + with self.assertRaises(ValueError): + layer[100,"X"] = 199 + + with self.assertRaises(ValueError): + layer[100] = 199 + + layer[5,5] = 88 + self.assertEqual(layer[5,5] , 88) + + + + def test_contact(self): + nx = 20 + ny = 10 + layer = Layer(nx,ny) + grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) + + with self.assertRaises(IndexError): + layer.cellContact( (-1,0),(1,1) ) + + with self.assertRaises(IndexError): + layer.cellContact( (20,0),(1,1) ) + + + self.assertFalse( layer.cellContact((0,0) , (2,0)) ) + self.assertFalse( layer.cellContact((1,0) , (1,0)) ) + + self.assertTrue( layer.cellContact((0,0) , (1,0)) ) + self.assertTrue( layer.cellContact((1,0) , (0,0)) ) + + self.assertTrue( layer.cellContact((0,0) , (0,1)) ) + self.assertTrue( layer.cellContact((0,1) , (0,0)) ) + + self.assertFalse( layer.cellContact((0,0) , (1,1)) ) + self.assertFalse( layer.cellContact((1,1) , (0,0)) ) + + self.assertTrue( layer.cellContact((4,0) , (5,0)) ) + self.assertTrue( layer.cellContact((0,4) , (0,5)) ) + + with TestAreaContext("Layer/barrier"): + with open("faults.grdecl" , "w") as f: + f.write("FAULTS\n") + f.write("\'FX\' 5 5 1 10 1 1 'X' /\n") + f.write("\'FY\' 1 10 5 5 1 1 'Y' /\n") + f.write("/") + + faults = FaultCollection( grid , "faults.grdecl") + + layer.addFaultBarrier( faults["FX"] , 0 ) + self.assertFalse( layer.cellContact((4,0) , (5,0)) ) + + layer.addFaultBarrier( faults["FY"] , 0 ) + self.assertFalse( layer.cellContact((0,4) , (0,5)) ) + + self.assertFalse( layer.cellContact((9,4) , (9,5)) ) + self.assertTrue( layer.cellContact((10,4) , (10,5)) ) + + def test_get_barrier(self): + layer = Layer(10,10) + self.assertFalse( layer.leftBarrier(5,5) ) + self.assertFalse( layer.bottomBarrier(5,5) ) + + layer.addIJBarrier([(1,1),(2,1),(2,2)]) + self.assertTrue( layer.bottomBarrier(1,1) ) + self.assertTrue( layer.leftBarrier(2,1) ) + + + + def test_fault_barrier(self): + nx = 120 + ny = 60 + nz = 43 + grid = EclGrid.create_rectangular( (nx , ny , nz) , (1,1,1) ) + with TestAreaContext("python/faults/line_order"): + with open("faults.grdecl" , "w") as f: + f.write("""FAULTS +\'F\' 105 107 50 50 1 43 \'Y\' / +\'F\' 108 108 50 50 1 43 \'X\' / +\'F\' 108 108 50 50 22 43 \'Y\' / +\'F\' 109 109 49 49 1 43 \'Y\' / +\'F\' 110 110 49 49 1 43 \'X\' / +\'F\' 111 111 48 48 1 43 \'Y\' / +/ +""") + with open("faults.grdecl") as f: + faults = FaultCollection( grid , "faults.grdecl" ) + + + # Fault layout: + # + # +---+---+---+---+ + # | + # +---+ + + # | + # +---+ + + + fault = faults["F"] + layer = Layer(nx,ny) + fault_pairs = [((104,49),(104,50)), + ((105,49),(105,50)), + ((106,49),(106,50)), + ((107,49),(108,49)), + ((107,49),(107,50)), + ((108,48),(108,49)), + ((109,48),(110,48)), + ((110,47),(110,48))] + gap_pair = ((109,48),(109,49)) + + + for p1,p2 in fault_pairs: + self.assertTrue(layer.cellContact( p1 , p2 )) + + p1,p2 = gap_pair + self.assertTrue(layer.cellContact( p1 , p2 )) + + + layer.addFaultBarrier(fault , 30 , link_segments = False) + for p1,p2 in fault_pairs: + self.assertFalse(layer.cellContact( p1 , p2 )) + p1,p2 = gap_pair + self.assertTrue(layer.cellContact( p1 , p2 )) + + layer.addFaultBarrier(fault , 30) + p1,p2 = gap_pair + self.assertFalse(layer.cellContact( p1 , p2 )) + + + def test_contact2(self): + nx = 10 + ny = 10 + layer = Layer(nx,ny) + grid = EclGrid.createRectangular( (nx,ny,1) , (1,1,1) ) + + # Too short + with self.assertRaises(ValueError): + layer.addIJBarrier( [(1,5)] ) + + # Out of range + with self.assertRaises(ValueError): + layer.addIJBarrier( [(10,15),(5,5)] ) + + # Out of range + with self.assertRaises(ValueError): + layer.addIJBarrier( [(7,7),(-5,5)] ) + + # Must have either i1 == i2 or j1 == j2 + with self.assertRaises(ValueError): + layer.addIJBarrier( [(7,8),(6,5)] ) + + p1 = (0 , 4) + p2 = (0 , 5) + self.assertTrue(layer.cellContact( p1 , p2 )) + layer.addIJBarrier( [(0,5) , (nx , 5)] ) + self.assertFalse(layer.cellContact( p1 , p2 )) + + + + def test_update_connected(self): + nx = 10 + ny = 10 + layer = Layer(nx,ny) + + layer[0,0] = 100 + self.assertEqual( layer[0,0], 100 ) + layer.clearCells() + self.assertEqual( layer[0,0], 0 ) + self.assertEqual( layer.cellSum( ) , 0 ) + + with self.assertRaises(ValueError): + layer.updateConnected( (10,10) , 10 ) + + layer[0,0] = 77 + with self.assertRaises(ValueError): + layer.updateConnected( (0,0) , 10 , org_value = 0) + + layer.updateConnected( (0,0) , 10 ) + self.assertEqual( 10 , layer.cellSum() ) + + layer[0,0] = 0 + layer.updateConnected( (0,0) , 3 ) + self.assertEqual( nx*ny*3 , layer.cellSum() ) + + layer.addIJBarrier( [(5,0), (5,10)] ) + layer.clearCells( ) + self.assertEqual( 0 , layer.cellSum( ) ) + layer.updateConnected( (0,0) , 1 ) + + self.assertEqual( 50 , layer.cellSum( ) ) + self.assertEqual( layer[4,0] , 1 ) + self.assertEqual( layer[5,0] , 0 ) + + layer = Layer(nx,ny) + layer.addIJBarrier( [(5,0), (5,5)] ) + layer.updateConnected( (0,0) , 1 ) + self.assertEqual( 100 , layer.cellSum( ) ) + + + def test_matching(self): + d = 10 + layer = Layer(d,d) + + for i in range(d): + layer[i,i] = 10 + + cell_list = layer.cellsEqual( 1 ) + self.assertEqual( cell_list , [] ) + + cell_list = layer.cellsEqual( 10 ) + self.assertEqual( cell_list , [ (i,i) for i in range(d)] ) + + + def test_add_polyline_barrier(self): + d = 10 + layer = Layer(d,d) + grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) ) + pl = CPolyline( init_points = [(0 , 0) , (d/2 , d/2) , (d,d)]) + layer.addPolylineBarrier( pl , grid , 0) + for i in range(d): + print i + self.assertTrue( layer.bottomBarrier(i,i) ) + if i < (d - 1): + self.assertTrue( layer.leftBarrier(i+1,i) ) + + + def test_active(self): + d = 10 + layer = Layer(d,d) + with self.assertRaises( ValueError ): + layer.activeCell(d+1,d+2) + + self.assertTrue( layer.activeCell(1,2) ) + + grid = EclGrid.createRectangular( (d,d+1,1) , (1,1,1) ) + with self.assertRaises( ValueError ): + layer.updateActive( grid , 0 ) + + grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) ) + with self.assertRaises( ValueError ): + layer.updateActive( grid , 10 ) + + actnum = IntVector( initial_size = d*d*1 , default_value = 1) + actnum[0] = 0 + grid = EclGrid.createRectangular( (d,d,1) , (1,1,1) , actnum = actnum) + layer.updateActive( grid , 0 ) + self.assertTrue( layer.activeCell(1,2) ) + self.assertFalse( layer.activeCell(0,0) ) + + + def test_assign(self): + layer = Layer(10,5) + self.assertEqual( layer.cellSum() , 0 ) + + layer.assign(10) + self.assertEqual( layer.cellSum() , 500 ) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_legacy_ecl.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_legacy_ecl.py similarity index 93% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_legacy_ecl.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_legacy_ecl.py index c07b53f689..8b50138ddb 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_legacy_ecl.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_legacy_ecl.py @@ -50,9 +50,15 @@ def test_classes(self): with self.assertRaises(NotImplementedError): ecl.ecl_default.default.ecl_version new_ecl.EclDefault.ecl_version() + + def test_queues(self): + try: + from ert.job_queue import JOB_QUEUE_LIB + self.assertEqual(ecl.EclQueue, new_ecl.ecl_queue.EclQueue) + except ImportError: + pass - self.assertEqual(ecl.EclQueue, new_ecl.ecl_queue.EclQueue) - + def test_enums(self): self.assertEqual(ecl.ECL_FLOAT_TYPE, EclTypeEnum.ECL_FLOAT_TYPE) self.assertEqual(ecl.ECL_CHAR_TYPE, EclTypeEnum.ECL_CHAR_TYPE) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_npv.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_npv.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_npv.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_npv.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_region.py similarity index 84% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_region.py index 20a6fd231e..caf9616b6e 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_region.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_region.py @@ -15,6 +15,7 @@ # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. from ert.ecl import EclFile, EclGrid, EclRegion +from ert.ecl.faults import Layer from ert.test import ExtendedTestCase @@ -141,7 +142,7 @@ def test_slice(self): OK = False self.assertTrue(OK) - self.assertTrue(2 * 3 * 6 == len(reg.global_list)) + self.assertTrue(2 * 3 * 6 == len(reg.getGlobalList())) @@ -159,7 +160,7 @@ def test_polygon(self): dx = 0.1 dy = 0.1 reg.select_inside_polygon( [(x-dx,y-dy) , (x-dx,y+dy) , (x+dx,y+dy) , (x+dx,y-dy)] ) - self.assertTrue( self.grid.nz == len(reg.global_list)) + self.assertTrue( self.grid.nz == len(reg.getGlobalList())) def test_heidrun(self): @@ -176,4 +177,29 @@ def test_heidrun(self): reg = EclRegion( grid , False ) reg.select_inside_polygon( polygon ) self.assertEqual( 0 , len(reg.global_list) % grid.nz) + + + def test_layer(self): + region = EclRegion(self.grid, False) + layer = Layer( self.grid.getNX() , self.grid.getNY() + 1) + with self.assertRaises(ValueError): + region.selectFromLayer( layer , 0 , 1 ) + + layer = Layer( self.grid.getNX() , self.grid.getNY() ) + layer[0,0] = 1 + layer[1,1] = 1 + layer[2,2] = 1 + + with self.assertRaises(ValueError): + region.selectFromLayer( layer , -1 , 1 ) + + with self.assertRaises(ValueError): + region.selectFromLayer( layer , self.grid.getNZ() , 1 ) + region.selectFromLayer( layer , 0 , 2 ) + glist = region.getGlobalList() + self.assertEqual(0 , len(glist)) + + region.selectFromLayer( layer , 0 , 1 ) + glist = region.getGlobalList() + self.assertEqual(3 , len(glist)) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_restart.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_restart.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_restart.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_restart.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_rft.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_rft.py similarity index 72% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_rft.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_rft.py index 9cefb40f23..35106fe25b 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_rft.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_rft.py @@ -18,6 +18,7 @@ import datetime from ert.ecl import EclRFTFile, EclRFTCell, EclPLTCell +from ert.ecl.rft import WellTrajectory from ert.test import ExtendedTestCase @@ -77,3 +78,30 @@ def test_exceptions( self ): with self.assertRaises(IndexError): rftFile = EclRFTFile(self.RFT_file) rft = rftFile[100] + + + def test_trajectory(self): + with self.assertRaises(IOError): + WellTrajectory("/does/no/exist") + + with self.assertRaises(UserWarning): + WellTrajectory( self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/invalid_float.txt") ) + + with self.assertRaises(UserWarning): + WellTrajectory( self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/missing_item.txt") ) + + wt = WellTrajectory( self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/E-3H.txt") ) + self.assertEqual( len(wt) , 38) + + with self.assertRaises(IndexError): + p = wt[38] + + p0 = wt[0] + self.assertEqual( p0.utm_x , 458920.671 ) + self.assertEqual( p0.utm_y , 7324939.077 ) + self.assertEqual( p0.measured_depth , 2707.5000 ) + + pm1 = wt[-1] + p37 = wt[37] + self.assertEqual( p37 , pm1) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_rft_cell.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_rft_cell.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_rft_cell.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_rft_cell.py diff --git a/ThirdParty/Ert/devel/python/tests/core/ecl/test_statoil_faults.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_statoil_faults.py new file mode 100644 index 0000000000..e436985e18 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_statoil_faults.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. +try: + from unittest2 import skipIf +except ImportError: + from unittest import skipIf + +import time +from ert.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment +from ert.ecl import EclGrid,EclKW,EclTypeEnum +from ert.test import ExtendedTestCase + + + +class StatoilFaultTest(ExtendedTestCase): + def loadGrid(self): + grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl") + fileH = open(grid_file, "r") + specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False) + zcorn = EclKW.read_grdecl(fileH, "ZCORN") + coord = EclKW.read_grdecl(fileH, "COORD") + actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclTypeEnum.ECL_INT_TYPE) + + return EclGrid.create(specgrid, zcorn, coord, actnum) + + + + + def test_load(self): + grid = self.loadGrid() + faults_file = self.createTestPath("Statoil/ECLIPSE/Faults/faults.grdecl") + faults = FaultCollection( grid , faults_file ) + for fault in faults: + for layer in fault: + for fl in layer: + fl.verify() + + + + def test_splitLine2(self): + grid = self.loadGrid( ) + f = Fault(grid , "DF41_C") + +# 179 180 181 +# o o o o o o o o o o o o o o +# | +# 78 | +# o o o o o o o o o o o o o o +# | +# 77 | +# o o o o o o o o o o o o o o +# | +# 76 | +# o o o o o o o o o o o o o o +# | +# 75 | +# o o o o o o o o o o o o o o +# +# 74 +# o o o o o o o o o o o o o o +# +# 73 +# o o o o-----o o o o o o o o o o +# | +# 72 | +# o o o o-----o o o o o o o o o o +# +# 71 +# o o o o-----o o o o o o o o o o +# | +# 70 | +# o o o o o o o o o o o o o o +# | +# 69 | +# o o o o o o o o o o o o o o +# +# 68 +# o o o o o o o o o o o o o o +# +# 67 +# o o o o o o o o o o o o o o +# +# 66 +# o o o o o o o o o o o o o o +# | +# 65 | +# o o o o-----o o o o o o o o o o + + + f.addRecord( 179, 179 , 77 , 78 , 0 , 42 , 'X' ) + f.addRecord( 179, 179 , 75 , 76 , 0 , 41 , 'X' ) + f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'X' ) + f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y' ) + f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y-' ) + + f.addRecord( 180, 180 , 70 , 70 , 0 , 42 , 'Y' ) + f.addRecord( 180, 180 , 69 , 70 , 0 , 42 , 'X' ) + f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'X' ) + f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'Y-' ) + + + ij_polyline = f.getIJPolyline( 19 ) + ij_list = [(180, 79), (180, 77), (180, 75), + (180, 73), (181, 73), (181, 72), (180, 72), + (180, 71), (181, 71), (181, 69), + (181, 66), (181, 65), (180, 65)] + + self.assertEqual(ij_polyline , ij_list) + + + + + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_sum.py b/ThirdParty/Ert/devel/python/tests/core/ecl/test_sum.py similarity index 98% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_sum.py rename to ThirdParty/Ert/devel/python/tests/core/ecl/test_sum.py index d88f681a56..0d5c78a5e3 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_sum.py +++ b/ThirdParty/Ert/devel/python/tests/core/ecl/test_sum.py @@ -18,10 +18,7 @@ import os import datetime -try: - from unittest2 import skipIf, skipUnless, skipIf -except ImportError: - from unittest import skipIf, skipUnless, skipIf +from unittest import skipIf, skipUnless, skipIf from ert.ecl import EclSum @@ -56,7 +53,7 @@ def test_load(self): def test_invalid(self): - with self.assertRaises(AssertionError): + with self.assertRaises(IOError): sum = EclSum("Does/not/exist") diff --git a/ThirdParty/Ert/devel/python/tests/core/geometry/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/core/geometry/CMakeLists.txt new file mode 100644 index 0000000000..48bd491898 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/geometry/CMakeLists.txt @@ -0,0 +1,22 @@ +set(TEST_SOURCES + __init__.py + test_convex_hull.py + test_cpolyline.py + test_cpolyline_collection.py + test_geometry_tools.py + test_intersection.py + test_point_in_polygon.py + test_polygon_slicing.py + test_polyline.py +) + +add_python_package("python.tests.core.geometry" ${PYTHON_INSTALL_PREFIX}/tests/core/geometry "${TEST_SOURCES}" True) + +addPythonTest(core.geometry.polyline tests.core.geometry.test_polyline.PolylineTest) +addPythonTest(core.geometry.intersection tests.core.geometry.test_intersection.IntersectionTest) +addPythonTest(core.geometry.convex_hull tests.core.geometry.test_convex_hull.ConvexHullTest) +addPythonTest(core.geometry.point_in_polygon tests.core.geometry.test_point_in_polygon.PointInPolygonTest) +addPythonTest(core.geometry.polygon_slicing tests.core.geometry.test_polygon_slicing.PolygonSlicingTest) +addPythonTest(core.geometry.cpolyline tests.core.geometry.test_cpolyline.CPolylineTest) +addPythonTest(core.geometry.cpolyline_collection tests.core.geometry.test_cpolyline_collection.CPolylineCollectionTest) +addPythonTest(core.geometry.geometry_tools tests.core.geometry.test_geometry_tools.GeometryToolsTest ) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/__init__.py b/ThirdParty/Ert/devel/python/tests/core/geometry/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/__init__.py rename to ThirdParty/Ert/devel/python/tests/core/geometry/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_convex_hull.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_convex_hull.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_convex_hull.py rename to ThirdParty/Ert/devel/python/tests/core/geometry/test_convex_hull.py diff --git a/ThirdParty/Ert/devel/python/tests/core/geometry/test_cpolyline.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_cpolyline.py new file mode 100644 index 0000000000..cb517af936 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/geometry/test_cpolyline.py @@ -0,0 +1,171 @@ +import math + +from ert.geo import CPolyline , Polyline +from ert.geo.xyz_io import XYZIo +from ert.test import ExtendedTestCase , TestAreaContext + + +class CPolylineTest(ExtendedTestCase): + def setUp(self): + self.polyline1 = self.createTestPath("local/geometry/pol11.xyz") + self.polyline2 = self.createTestPath("local/geometry/pol8.xyz") + self.polyline3 = self.createTestPath("local/geometry/pol8_noend.xyz") + + + + def test_construction(self): + polyline = CPolyline() + self.assertEqual( len(polyline) , 0 ) + + with self.assertRaises(IOError): + CPolyline.createFromXYZFile( "Does/not/exist" ) + + p1 = CPolyline.createFromXYZFile( self.polyline1 ) + self.assertEqual( len(p1) , 13 ) + x,y = p1[-1] + self.assertEqual(x , 389789.263184) + self.assertEqual(y , 6605784.945099) + + p2 = CPolyline.createFromXYZFile( self.polyline2 ) + self.assertEqual( len(p2) , 20 ) + x,y = p2[-1] + self.assertEqual(x , 396056.314697) + self.assertEqual(y , 6605835.119461) + + p3 = CPolyline.createFromXYZFile( self.polyline3 ) + self.assertEqual( len(p3) , 20 ) + x,y = p3[-1] + self.assertEqual(x , 396056.314697) + self.assertEqual(y , 6605835.119461) + + + + def test_front(self): + polyline = CPolyline() + polyline.addPoint( 1 , 1 ) + polyline.addPoint( 0 , 0 , front = True ) + self.assertEqual( len(polyline) , 2 ) + + x,y = polyline[0] + self.assertEqual(x,0) + self.assertEqual(y,0) + + x,y = polyline[1] + self.assertEqual(x,1) + self.assertEqual(y,1) + + + def test_equal(self): + pl1 = CPolyline(name = "Poly1" , init_points = [(0,0) , (1,1) , (2,2)]) + pl2 = CPolyline(name = "Poly2" , init_points = [(0,0) , (1,1) , (2,2)]) + pl3 = CPolyline(init_points = [(0,0) , (1,1) , (2,3)]) + + self.assertEqual( pl1 , pl1 ) + self.assertEqual( pl1 , pl2 ) + self.assertFalse( pl1 == pl3 ) + + + def test_length(self): + polyline = CPolyline( init_points = [(0,1)]) + self.assertEqual( polyline.segmentLength() , 0 ) + + polyline = CPolyline( init_points = [(0,0) , (1,0) , (1,1) , (2,2)]) + self.assertEqual( polyline.segmentLength() , 2 + math.sqrt(2)) + + + def test_extend_to_bbox(self): + bbox = [(0,0) , (10,0) , (10,10) , (0,10)] + + polyline = CPolyline( init_points = [(11,11) , (13,13)]) + with self.assertRaises(ValueError): + polyline.extendToBBox( bbox , start = False ) + + + polyline = CPolyline( init_points = [(1,1) , (3,3)]) + + line1 = polyline.extendToBBox( bbox , start = True ) + self.assertEqual( line1 , CPolyline( init_points = [(1,1) , (0,0)])) + + line1 = polyline.extendToBBox( bbox , start = False ) + self.assertEqual( line1 , CPolyline( init_points = [(3,3) , (10,10)])) + + + + + def test_item(self): + polyline = CPolyline() + polyline.addPoint( 10 , 20 ) + self.assertEqual( len(polyline) , 1 ) + + with self.assertRaises(TypeError): + (x,y) = polyline["KEY"] + + with self.assertRaises(IndexError): + (x,y) = polyline[10] + + (x,y) = polyline[0] + self.assertEqual( x , 10 ) + self.assertEqual( y , 20 ) + + polyline.addPoint(20,20) + (x,y) = polyline[-1] + self.assertEqual( x , 20 ) + self.assertEqual( y , 20 ) + + + def test_cross_segment(self): + polyline = CPolyline( init_points = [(0,0), (1,0) , (1,1)]) + # + # x + # | + # | + # | + # x-------x + # + + self.assertTrue(polyline.segmentIntersects( (0.5 , 0.5) , (0.5 , -0.5))) + self.assertTrue(polyline.segmentIntersects( (0.5 , 0.5) , (1.5 , 0.5))) + + self.assertFalse(polyline.segmentIntersects( (0.5 , 0.5) , ( 0.5 , 1.5))) + self.assertFalse(polyline.segmentIntersects( (0.5 , 0.5) , (-0.5 , 0.5))) + self.assertFalse(polyline.segmentIntersects( (0.5 , 1.5) , ( 1.5 , 1.5))) + + self.assertTrue( polyline.segmentIntersects( (1.0 , 1.0) , ( 1.5 , 1.5))) + self.assertTrue( polyline.segmentIntersects( ( 1.5 , 1.5) , (1.0 , 1.0))) + self.assertTrue( polyline.segmentIntersects( ( 1 , 0) , (1.0 , 1.0))) + + + + def test_intersects(self): + polyline1 = CPolyline( init_points = [(0,0), (1,0) , (1,1)]) + polyline2 = CPolyline( init_points = [(0.50,0.50) , (1.50,0.50)]) + polyline3 = Polyline( init_points = [(0.50,0.50) , (1.50,0.50)]) + polyline4 = CPolyline( init_points = [(0.50,1.50) , (1.50,1.50)]) + + self.assertTrue( polyline1.intersects( polyline2 )) + self.assertTrue( polyline1.intersects( polyline3 )) + self.assertFalse( polyline1.intersects( polyline4 )) + + + def test_intersects2(self): + polyline = CPolyline( init_points = [(2,10),(2,100)]) + self.assertTrue( polyline.intersects( polyline )) + + + + def test_name(self): + p1 = CPolyline() + self.assertTrue( p1.getName() is None ) + + p2 = CPolyline( name = "Poly2" ) + self.assertEqual( p2.getName() , "Poly2") + + + def test_unzip(self): + pl = CPolyline( init_points = [(0,3) , (1,4) , (2,5)] ) + x,y = pl.unzip() + self.assertEqual(x , [0,1,2]) + self.assertEqual(y , [3,4,5]) + + + diff --git a/ThirdParty/Ert/devel/python/tests/core/geometry/test_cpolyline_collection.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_cpolyline_collection.py new file mode 100644 index 0000000000..08fc345bce --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/geometry/test_cpolyline_collection.py @@ -0,0 +1,133 @@ +import gc + +from ert.geo import CPolylineCollection , CPolyline +from ert.geo.xyz_io import XYZIo +from ert.test import ExtendedTestCase , TestAreaContext +from ert.util import DoubleVector + +class CPolylineCollectionTest(ExtendedTestCase): + + def test_construction(self): + pc = CPolylineCollection() + self.assertEqual(len(pc) , 0) + + + def test_add_polyline(self): + pc = CPolylineCollection() + pl = pc.createPolyline( name = "TestP" ) + self.assertTrue( isinstance(pl , CPolyline)) + self.assertEqual(len(pc) , 1) + self.assertTrue( "TestP" in pc ) + + with self.assertRaises(IndexError): + pl = pc[2] + + p0 = pc[0] + self.assertTrue( p0 == pl ) + + with self.assertRaises(KeyError): + pn = pc["missing"] + + pn = pc["TestP"] + self.assertTrue( pn == pl ) + + px = CPolyline( name = "TestP") + with self.assertRaises(KeyError): + pc.addPolyline( px ) + self.assertEqual(len(pc) , 1) + + + p2 = CPolyline( name = "Poly2") + pc.addPolyline( p2 ) + + self.assertEqual( len(pc) , 2 ) + self.assertTrue( "Poly2" in pc ) + + l = [] + for p in pc: + l.append(p) + self.assertEqual( len(pc) , 2 ) + + + points = [(0,1) , (1,1)] + pc.addPolyline( points , name = "XYZ") + self.assertTrue( "XYZ" in pc ) + + + + + def create_collection(self): + collection = CPolylineCollection() + p1 = CPolyline( name = "POLY1" , init_points = [(0,10) , (1,11) , (2,12)]) + p2 = CPolyline( name = "POLY2" , init_points = [(0,100) , (10,110) , (20,120)]) + collection.addPolyline( p1 ) + collection.addPolyline( p2 ) + + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual(p1.getName() , "POLY1") + + tail = p2[-1] + self.assertEqual( tail , (20,120)) + self.assertEqual(p2.getName() , "POLY2") + + return collection + + + def test_gc_polyline(self): + # This should test that the elements in the collection can be + # safely accessed, even after the polyline objects p1 and p2 + # from create_collection() have gone out of scope. + c = self.create_collection() + v = DoubleVector(initial_size = 10000) + + p1 = c[0] + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual(p1.getName() , "POLY1") + + p2 = c[1] + tail = p2[-1] + self.assertEqual( tail , (20,120)) + self.assertEqual(p2.getName() , "POLY2") + + + def get_polyline(self): + collection = self.create_collection() + return collection[0] + + + def test_gc_collection(self): + p1 = self.get_polyline() + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual( p1.getName() , "POLY1") + + def create_coll2(self): + coll1 = self.create_collection() + coll2 = coll1.shallowCopy() + coll1.addPolyline( CPolyline( name = "POLY3" , init_points = [(1,1) , (2,2) , (1,3) , (1,1)])) + + self.assertEqual(len(coll1) , 3) + self.assertTrue( "POLY3" in coll1 ) + + self.assertEqual(len(coll2) , 2) + self.assertFalse( "POLY3" in coll2 ) + + return coll2 + + + def test_shallow_copy(self): + coll2 = self.create_coll2() + self.assertEqual(len(coll2) , 2) + + p1 = coll2["POLY1"] + tail = p1[-1] + self.assertEqual( tail , (2,12)) + self.assertEqual(p1.getName() , "POLY1") + + p2 = coll2["POLY2"] + tail = p2[-1] + self.assertEqual( tail , (20,120)) + self.assertEqual(p2.getName() , "POLY2") + diff --git a/ThirdParty/Ert/devel/python/tests/core/geometry/test_geometry_tools.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_geometry_tools.py new file mode 100644 index 0000000000..80f0eb8489 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/geometry/test_geometry_tools.py @@ -0,0 +1,80 @@ +import math + +from ert.geo import Polyline, GeometryTools , CPolyline +from ert.geo.xyz_io import XYZIo +from ert.test import ExtendedTestCase , TestAreaContext + + +class GeometryToolsTest(ExtendedTestCase): + + def test_distance(self): + p1 = (1,1) + p2 = (1,2,3) + with self.assertRaises(ValueError): + GeometryTools.distance( p1 , p2) + + with self.assertRaises(TypeError): + GeometryTools.distance( 1 , p2 ) + + p2 = (2,2) + self.assertEqual( GeometryTools.distance( p1 , p2) , math.sqrt(2)) + + p1 = (1,1,1) + p2 = (2,2,2) + self.assertEqual( GeometryTools.distance( p1 , p2) , math.sqrt(3)) + + + def test_join__polylines(self): + l1 = Polyline( init_points = [(0,1) , (1,1)]) + l2 = CPolyline( init_points = [(2,-1) , (2,0)]) + l3 = CPolyline( init_points = [(2,2) , (2,3)]) + l4 = Polyline( ) + l5 = CPolyline( init_points = [(0.5,0),(0.5,2)] ) + + with self.assertRaises( ValueError ): + GeometryTools.joinPolylines( l1 , l4 ) + + with self.assertRaises( ValueError ): + GeometryTools.joinPolylines( l4 , l1 ) + + self.assertIsNone( GeometryTools.joinPolylines( l1 , l5 )) + + self.assertEqual( GeometryTools.joinPolylines( l1 , l2 ) , [(1,1) , (2,0)] ) + + + def test_join_extend_polylines_onto(self): + l1 = Polyline( init_points = [(0,1) , (1,1)]) + l2 = CPolyline( init_points = [(2,0) , (2,2)]) + l3 = CPolyline( init_points = [(0.5 , 0) , (0.5 , 2)]) + l4 = Polyline( init_points = [(0,5) , (1,5)]) + l5 = Polyline( init_points = [(0,5)]) + + self.assertIsNone( GeometryTools.connectPolylines( l1 , l3 )) + + with self.assertRaises( ValueError ): + GeometryTools.connectPolylines( l1 , l5 ) + + with self.assertRaises( ValueError ): + GeometryTools.connectPolylines( l1 , l4 ) + + self.assertEqual( GeometryTools.connectPolylines( l1 , l2 ) , [(1,1) , (2,1)]) + + def test_ray_line_intersection(self): + p = GeometryTools.rayLineIntersection((0,0) , (1,0) , (5,-1),(5,1)) + self.assertEqual( p , (5,0)) + + self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (-1,0) , (5,-1),(5,1)) ) + self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (0,1) , (5,-1),(5,1)) ) + self.assertIsNone( GeometryTools.rayLineIntersection((0,0) , (0,-1) , (5,-1),(5,1)) ) + + p = GeometryTools.rayLineIntersection((0,0) , (1,1) , (5,-6),(5,6)) + self.assertEqual( p , (5,5)) + + + def test_nearest_point(self): + l1 = Polyline( init_points = [(0,0) , (10,0)]) + + p = GeometryTools.nearestPointOnPolyline( (5 , 5) , l1 ) + self.assertEqual( p , (5 , 0) ) + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_intersection.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_intersection.py similarity index 91% rename from ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_intersection.py rename to ThirdParty/Ert/devel/python/tests/core/geometry/test_intersection.py index 527c80667e..2e36c59aaf 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_intersection.py +++ b/ThirdParty/Ert/devel/python/tests/core/geometry/test_intersection.py @@ -24,8 +24,8 @@ def test_coincident(self): p1 = (0.0, 0.0) p2 = (10.0, 10.0) - self.assertEqual(GeometryTools.lineIntersection(p1, p2, p1, p2), (5.0, 5.0)) - + self.assertIsNone( GeometryTools.lineIntersection(p1, p2, p1, p2) ) + def test_parallel(self): p1 = (0.0, 0.0) @@ -44,4 +44,4 @@ def test_intersection_outside_segments(self): p3 = (-1.0, -1.0) p4 = (-1.0, 1.0) - self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4)) \ No newline at end of file + self.assertIsNone(GeometryTools.lineIntersection(p1, p2, p3, p4)) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_point_in_polygon.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_point_in_polygon.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_point_in_polygon.py rename to ThirdParty/Ert/devel/python/tests/core/geometry/test_point_in_polygon.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_polygon_slicing.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_polygon_slicing.py similarity index 75% rename from ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_polygon_slicing.py rename to ThirdParty/Ert/devel/python/tests/core/geometry/test_polygon_slicing.py index 9ea39d22f0..ad7c1780ac 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_polygon_slicing.py +++ b/ThirdParty/Ert/devel/python/tests/core/geometry/test_polygon_slicing.py @@ -5,6 +5,16 @@ class PolygonSlicingTest(ExtendedTestCase): + def test_slicing_internal_hull(self): + polygon = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4)] + edge = [(0,0) , (10,0) , (10,10), (0,10) , (0,0)] + + sliced = GeometryTools.slicePolygon(edge , polygon) + expected = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4),(2.0,4.0),(2,2)] + self.assertEqual(sliced, expected) + + + def test_line_to_ray(self): p0 = (0.0, 0.0) p1 = (1.0, 1.0) @@ -39,6 +49,7 @@ def test_ray_line_intersection(self): + def test_slicing_short_line_segment(self): p0 = (0.0, 0.0) p1 = (0.0, 1.0) @@ -48,11 +59,11 @@ def test_slicing_short_line_segment(self): lp0 = (0.2, 0.5) lp1 = (0.4, 0.5) line = [lp0, lp1] - + result = GeometryTools.slicePolygon(polygon, line) - + expected = [(0.0, 0.5), p1, p2, (1.0, 0.5), lp1, lp0, (0.0, 0.5)] - + self.assertEqual(result, expected) @@ -102,12 +113,27 @@ def test_slicing_same_segment(self): def test_ray_polyline_intersections(self): - p0 = (0.5, 0.0) - ray = (0.0, 1.0) - + # /.\ + # . + # . + # (4)---------+----(3) + # /________:_____:_________ + # \ . | + # (1)--+----(2) + # | . + # | . + # (0) . + + polygon = [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 2.0), (-1.0, 2.0)] - intersections = GeometryTools.rayPolygonIntersections(p0, ray, polygon) + p0 = (0.5, 0.0) + ray0 = (0.0, 1.0) + intersections0 = GeometryTools.rayPolygonIntersections(p0, ray0, polygon) + self.assertEqual(intersections0, [(1, (0.5, 1.0)), (3, (0.5, 2.0))]) - self.assertEqual(intersections, [(1, (0.5, 1.0)), (3, (0.5, 2.0))]) + p1 = (1.5, 1.5) + ray1 = (-1.0, 0.0) + intersections1 = GeometryTools.rayPolygonIntersections(p1, ray1, polygon) + self.assertEqual(intersections1, [(2, (1, 1.5))]) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_polyline.py b/ThirdParty/Ert/devel/python/tests/core/geometry/test_polyline.py similarity index 75% rename from ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_polyline.py rename to ThirdParty/Ert/devel/python/tests/core/geometry/test_polyline.py index 864c42b24f..8674e75460 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/test_polyline.py +++ b/ThirdParty/Ert/devel/python/tests/core/geometry/test_polyline.py @@ -15,7 +15,7 @@ def test_construction(self): with self.assertRaises(IndexError): polyline.isClosed() - self.assertEqual(polyline.name(), "test line") + self.assertEqual(polyline.getName(), "test line") self.assertEqual(len(polyline), 0) @@ -70,12 +70,12 @@ def test_iteration(self): def test_read_xyz_from_file(self): - with self.assertRaises(ValueError): + with self.assertRaises(IOError): XYZIo.readXYZFile("does/not/exist.xyz") polyline = XYZIo.readXYZFile(self.polyline) - self.assertEqual(polyline.name(), "pol11.xyz") + self.assertEqual(polyline.getName(), "pol11.xyz") self.assertEqual(len(polyline), 13) self.assertFalse(polyline.isClosed()) self.assertEqual(polyline[0], (390271.843750, 6606121.334396, 1441.942627)) # first point @@ -83,7 +83,7 @@ def test_read_xyz_from_file(self): polyline = XYZIo.readXYZFile(self.closed_polyline) - self.assertEqual(polyline.name(), "pol8.xyz") + self.assertEqual(polyline.getName(), "pol8.xyz") self.assertEqual(len(polyline), 21) self.assertTrue(polyline.isClosed()) self.assertEqual(polyline[0], (396202.413086, 6606091.935028, 1542.620972)) # first point @@ -152,3 +152,42 @@ def test_intersection(self): self.assertTrue( not p3.intersects(p1) ) + def test_add(self): + l1 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) + l2 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) + + l3 = l1 + l2 + self.assertEqual( len(l3) , 4 ) + self.assertEqual( l1[0] , l3[0] ) + self.assertEqual( l1[1] , l3[1] ) + self.assertEqual( l1[0] , l3[2] ) + self.assertEqual( l1[1] , l3[3] ) + + l4 = l1 + l4 += l2 + self.assertEqual(l3 , l4) + + + + def test_extend_to_edge(self): + bound = Polyline( init_points = [(0,0) , (1,0) , (1,1) , (0,1)] ) + l1 = Polyline( init_points = [(-1,0.5) , (0.5, 0.5)]) + l2 = Polyline( init_points = [(0.25,0.25) , (0.75, 0.75)]) + + # Bound is not closed + with self.assertRaises(AssertionError): + GeometryTools.extendToEdge( bound , l1 ) + + bound.assertClosed() + # l1 is not fully contained in bound + with self.assertRaises(ValueError): + GeometryTools.extendToEdge( bound , l1 ) + + l3 = GeometryTools.extendToEdge( bound , l2 ) + self.assertEqual( l3[0] , (0.00,0.00)) + self.assertEqual( l3[1] , (0.25,0.25)) + self.assertEqual( l3[2] , (0.75,0.75)) + self.assertEqual( l3[3] , (1.00,1.00)) + self.assertEqual( len(l3) , 4) + + diff --git a/ThirdParty/Ert/devel/python/tests/core/util/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/core/util/CMakeLists.txt new file mode 100644 index 0000000000..962c7bf8f8 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/util/CMakeLists.txt @@ -0,0 +1,35 @@ +set(TEST_SOURCES + __init__.py + test_ctime.py + test_hash.py + #test_latex.py + test_lookup_table.py + test_matrix.py + test_rng.py + test_stat.py + test_string_list.py + test_substitution_list.py + test_thread_pool.py + test_ui_return.py + test_vectors.py + test_version.py + test_work_area.py +) + +add_python_package("python.tests.core.util" ${PYTHON_INSTALL_PREFIX}/tests/core/util "${TEST_SOURCES}" False) + +addPythonTest(core.util.ctime core.util.test_ctime.CTimeTest) +addPythonTest(core.util.hash core.util.test_hash.HashTest) +addPythonTest(core.util.lookup_table core.util.test_lookup_table.LookupTableTest ) +addPythonTest(core.util.matrix core.util.test_matrix.MatrixTest ) +addPythonTest(core.util.rng core.util.test_rng.RngTest ) +addPythonTest(core.util.stat core.util.test_stat.StatTest ) +addPythonTest(core.util.stringlist core.util.test_string_list.StringListTest) +addPythonTest(core.util.tvector core.util.test_vectors.UtilTest) +addPythonTest(core.util.ui_return core.util.test_ui_return.UIReturnTest) +addPythonTest(core.util.work_area core.util.test_work_area.WorkAreaTest) +addPythonTest(core.util.version core.util.test_version.VersionTest) + +#add_test( NAME python.tests.ert.util.latex +# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +# COMMAND ctest_run.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} core.util.test_latex.LatexTest ) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/__init__.py b/ThirdParty/Ert/devel/python/tests/core/util/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/__init__.py rename to ThirdParty/Ert/devel/python/tests/core/util/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_ctime.py b/ThirdParty/Ert/devel/python/tests/core/util/test_ctime.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_ctime.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_ctime.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_hash.py b/ThirdParty/Ert/devel/python/tests/core/util/test_hash.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_hash.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_hash.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_latex.py b/ThirdParty/Ert/devel/python/tests/core/util/test_latex.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_latex.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_latex.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_lookup_table.py b/ThirdParty/Ert/devel/python/tests/core/util/test_lookup_table.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_lookup_table.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_lookup_table.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_matrix.py b/ThirdParty/Ert/devel/python/tests/core/util/test_matrix.py similarity index 66% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_matrix.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_matrix.py index c1bae1d8fe..cb89458323 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_matrix.py +++ b/ThirdParty/Ert/devel/python/tests/core/util/test_matrix.py @@ -1,4 +1,5 @@ -from ert.util import Matrix +from ert.util import Matrix , RandomNumberGenerator +from ert.util.enums import RngAlgTypeEnum, RngInitModeEnum from ert.test import ExtendedTestCase class MatrixTest(ExtendedTestCase): @@ -33,6 +34,30 @@ def test_matrix_set(self): m2 = Matrix(2,2 , value = 99) self.assertEqual(m1,m2) + + def test_matrix_random_init(self): + m = Matrix(10,10) + rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) + m.randomInit( rng ) + + def test_matrix_copy_column(self): + m = Matrix(10,2) + rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) + m.randomInit( rng ) + + with self.assertRaises(ValueError): + m.copyColumn(0,2) + + with self.assertRaises(ValueError): + m.copyColumn(2,0) + + with self.assertRaises(ValueError): + m.copyColumn(-2,0) + + m.copyColumn(1, 0) + for i in range(m.rows()): + self.assertEqual( m[i,0] , m[i,1] ) + def test_matrix_scale(self): m = Matrix(2,2 , value = 1) @@ -76,4 +101,3 @@ def test_matrix_equality(self): self.assertEqual(m, r) - diff --git a/ThirdParty/Ert/devel/python/tests/core/util/test_rng.py b/ThirdParty/Ert/devel/python/tests/core/util/test_rng.py new file mode 100644 index 0000000000..d7c49403d6 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/util/test_rng.py @@ -0,0 +1,29 @@ +from ert.util.enums import RngAlgTypeEnum, RngInitModeEnum +from ert.util.rng import RandomNumberGenerator +from ert.test import ExtendedTestCase + + +class RngTest(ExtendedTestCase): + + def test_enums(self): + self.assertEnumIsFullyDefined(RngAlgTypeEnum, "rng_alg_type", "libert_util/include/ert/util/rng.h") + self.assertEnumIsFullyDefined(RngInitModeEnum, "rng_init_mode", "libert_util/include/ert/util/rng.h") + + def test_rng_default(self): + rng = RandomNumberGenerator() + self.assertIsInstance(rng.getDouble(), float) + + def test_rng_state(self): + rng = RandomNumberGenerator() + with self.assertRaises(ValueError): + rng.setState("12") + + rng.setState("0123456789ABCDEF") + val1 = rng.getInt() + val2 = rng.getInt() + + self.assertFalse( val1 == val2 ) + rng.setState("0123456789ABCDEF") + self.assertEqual( rng.getInt() , val1) + self.assertEqual( rng.getInt() , val2) + diff --git a/ThirdParty/Ert/devel/python/tests/core/util/test_stat.py b/ThirdParty/Ert/devel/python/tests/core/util/test_stat.py new file mode 100644 index 0000000000..e719902921 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/util/test_stat.py @@ -0,0 +1,44 @@ +import random +from ert.util import DoubleVector, quantile, quantile_sorted , polyfit +from ert.test import ExtendedTestCase + + +class StatTest(ExtendedTestCase): + def test_stat_quantiles(self): + v = DoubleVector() + for i in range(100000): + v.append(random.random()) + + self.assertAlmostEqual(quantile(v, 0.1), 0.1, 2) + self.assertAlmostEqual(quantile_sorted(v, 0.2), 0.2, 2) + self.assertAlmostEqual(quantile_sorted(v, 0.3), 0.3, 2) + self.assertAlmostEqual(quantile_sorted(v, 0.4), 0.4, 2) + self.assertAlmostEqual(quantile_sorted(v, 0.5), 0.5, 2) + + + + def test_polyfit(self): + x_list = DoubleVector() + y_list = DoubleVector() + S = DoubleVector() + + A = 7.25 + B = -4 + C = 0.025 + + x = 0 + dx = 0.1 + for i in range(100): + y = A + B*x + C*x*x + x_list.append(x) + y_list.append(y) + + x += dx + S.append( 1.0 ) + + beta = polyfit(3 , x_list , y_list , None) + + self.assertAlmostEqual( A , beta[0] ) + self.assertAlmostEqual( B , beta[1] ) + self.assertAlmostEqual( C , beta[2] ) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_string_list.py b/ThirdParty/Ert/devel/python/tests/core/util/test_string_list.py similarity index 94% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_string_list.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_string_list.py index 469b303fd1..95796c1e27 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_string_list.py +++ b/ThirdParty/Ert/devel/python/tests/core/util/test_string_list.py @@ -78,6 +78,13 @@ def test_append(self): s.append("C") self.assertEqual(list(s), ["A", "B", "C"]) + def test_append_not_string(self): + s = StringList() + s.append(10) + self.assertEqual( len(s) , 1) + self.assertEqual(s[0] , "10") + + def test_negative_index(self): s = StringList(["A", "B", "C"]) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_substitution_list.py b/ThirdParty/Ert/devel/python/tests/core/util/test_substitution_list.py similarity index 76% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_substitution_list.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_substitution_list.py index 41d82cbcfc..a51be76ffd 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_substitution_list.py +++ b/ThirdParty/Ert/devel/python/tests/core/util/test_substitution_list.py @@ -22,3 +22,9 @@ def test_substitution_list(self): self.assertEqual(value, "Value") self.assertEqual(doc_string, "Doc String") + self.assertTrue("Key" in subst_list) + self.assertEqual(subst_list.indexForKey("Key"), 0) + + with self.assertRaises(KeyError): + subst_list.indexForKey("AnotherKey") + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_thread_pool.py b/ThirdParty/Ert/devel/python/tests/core/util/test_thread_pool.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_thread_pool.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_thread_pool.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_ui_return.py b/ThirdParty/Ert/devel/python/tests/core/util/test_ui_return.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_ui_return.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_ui_return.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_vectors.py b/ThirdParty/Ert/devel/python/tests/core/util/test_vectors.py similarity index 88% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_vectors.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_vectors.py index 24fc71732f..7762b9827f 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_vectors.py +++ b/ThirdParty/Ert/devel/python/tests/core/util/test_vectors.py @@ -145,7 +145,7 @@ def test_contains_int(self): def test_activeMask(self): - active_list = BoolVector.active_mask("1 , 4 - 7 , 10") + active_list = BoolVector.createActiveMask("1 , 4 - 7 , 10") self.assertTrue(len(active_list) == 11) self.assertTrue(active_list[1]) self.assertTrue(active_list[4]) @@ -155,7 +155,7 @@ def test_activeMask(self): self.assertEqual(6, active_list.count(True)) - active_list = BoolVector.active_mask("1,4-7,10X") + active_list = BoolVector.createActiveMask("1,4-7,10X") self.assertFalse(active_list) @@ -374,6 +374,18 @@ def test_unique(self): + def test_element_sum(self): + dv = DoubleVector() + iv = IntVector() + for i in range(10): + dv.append(i+1) + iv.append(i+1) + + self.assertEqual( dv.elementSum() , 55 ) + self.assertEqual( iv.elementSum() , 55 ) + + + def test_time_vector_regular(self): start = datetime.datetime(2010 , 1 , 1 , 0,0,0) end = datetime.datetime(2010 , 2 , 1 , 0,0,0) @@ -436,3 +448,54 @@ def test_asList(self): l = v.asList() self.assertListEqual( l , [100,10,1] ) + + + def test_true_false(self): + v = IntVector(default_value = 77) + self.assertFalse( v ) + v[10] = 77 + self.assertTrue( v ) + + v = DoubleVector(default_value = 77) + self.assertFalse( v ) + v[10] = 77 + self.assertTrue( v ) + + + + + def test_count_equal(self): + v = IntVector(default_value = 77) + v[0] = 1 + v[10] = 1 + v[20] = 1 + self.assertEqual( v.countEqual(1) , 3 ) + + + v = DoubleVector(default_value = 77) + v[0] = 1 + v[10] = 1 + v[20] = 1 + self.assertEqual( v.countEqual(1) , 3 ) + + + def range_test(self,v,a,b,d): + v.initRange(a,b,d) + r = range(a,b,d) + + self.assertEqual(len(v) , len(r)) + for a,b in zip(v,r): + self.assertEqual(a,b) + + + + def test_range(self): + v = IntVector( ) + v[10] = 99 + + with self.assertRaises(ValueError): + v.initRange(1,2,0) + + self.range_test(v , 0 , 5 , 1) + self.range_test(v , 0,100,3) + self.range_test(v,0,100,-3) diff --git a/ThirdParty/Ert/devel/python/tests/core/util/test_version.py b/ThirdParty/Ert/devel/python/tests/core/util/test_version.py new file mode 100644 index 0000000000..515257ac04 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/util/test_version.py @@ -0,0 +1,100 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_version.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import os.path +from ert.test import ExtendedTestCase , TestAreaContext +from ert.util import Version + +class VersionTest(ExtendedTestCase): + def setUp(self): + pass + + + def test_create(self): + v1 = Version(1,8,6) + self.assertFalse( v1.isDevelVersion() ) + + self.assertEqual( v1.versionString() , "1.8.6" ) + self.assertEqual( v1.versionTuple() , (1,8,6) ) + + v2 = Version(2,0,"X") + self.assertTrue( v2.isDevelVersion() ) + + def test_eq(self): + v1 = Version(1,2,3) + v2 = Version(1,2,3) + + self.assertTrue( v1 == v2 ) + self.assertFalse( v1 != v2 ) + + v1 = Version(1,2,"X") + v2 = Version(1,2,"Y") + self.assertTrue( v1 != v2 ) + self.assertFalse( v1 == v2 ) + + v1 = Version(1,2,"X") + v2 = Version(1,2,0) + self.assertTrue( v1 != v2 ) + self.assertFalse( v1 == v2 ) + + v1 = Version(1,2,"X") + v2 = Version(1,3,"X") + self.assertTrue( v1 != v2 ) + self.assertFalse( v1 == v2 ) + + + v1 = Version(1,2,"X") + v2 = (1,3,"X") + self.assertTrue( v1 != v2 ) + self.assertFalse( v1 == v2 ) + + + + def test_ge(self): + v1 = Version(1,2,3) + v2 = Version(1,2,3) + v3 = (1,2,2) + + self.assertTrue( v1 >= v2 ) + self.assertFalse( v1 < v2 ) + + self.assertTrue( v1 >= v3 ) + self.assertFalse( v1 < v3 ) + + v1 = Version(1,2,"X") + v2 = Version(1,1,9) + self.assertTrue( v1 > v2 ) + + + v2 = Version(1,2,"X") + self.assertTrue( v1 >= v2 ) + + v2 = Version(1,2,0) + self.assertFalse( v1 >= v2 ) + + + def test_current(self): + current = Version.currentVersion() + self.assertTrue( current > (0,0,0) ) + + + + def test_import(self): + from ert import Version as globalVersion + v1 = globalVersion(1,1,2) + v2 = Version(1,1,2) + + self.assertTrue( v1 == v2 ) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/test_work_area.py b/ThirdParty/Ert/devel/python/tests/core/util/test_work_area.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/test_work_area.py rename to ThirdParty/Ert/devel/python/tests/core/util/test_work_area.py diff --git a/ThirdParty/Ert/devel/python/tests/core/well/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/core/well/CMakeLists.txt new file mode 100644 index 0000000000..1b2b2cdf2d --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/core/well/CMakeLists.txt @@ -0,0 +1,10 @@ +set(TEST_SOURCES + __init__.py + test_ecl_well.py + test_ecl_well2.py +) + +add_python_package("python.tests.core.well" ${PYTHON_INSTALL_PREFIX}/tests/core/well "${TEST_SOURCES}" False) + +addPythonTest(core.well.ecl_well core.well.test_ecl_well.EclWellTest LABELS StatoilData) +addPythonTest(core.well.ecl_well2 core.well.test_ecl_well2.EclWellTest2 LABELS StatoilData) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/geometry/__init__.py b/ThirdParty/Ert/devel/python/tests/core/well/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/geometry/__init__.py rename to ThirdParty/Ert/devel/python/tests/core/well/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well.py b/ThirdParty/Ert/devel/python/tests/core/well/test_ecl_well.py similarity index 97% rename from ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well.py rename to ThirdParty/Ert/devel/python/tests/core/well/test_ecl_well.py index eec34e2468..8310d18d88 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well.py +++ b/ThirdParty/Ert/devel/python/tests/core/well/test_ecl_well.py @@ -173,11 +173,11 @@ def test_well_state(self): sim_time = CTime(datetime.date(2000, 1, 1)) open_states = {True: 0, False: 0} msw_states = {True: 0, False: 0} - well_types = {WellTypeEnum.UNDOCUMENTED_ZERO: 0, - WellTypeEnum.PRODUCER: 0, - WellTypeEnum.GAS_INJECTOR: 0, - WellTypeEnum.OIL_INJECTOR: 0, - WellTypeEnum.WATER_INJECTOR: 0} + well_types = {WellTypeEnum.ERT_UNDOCUMENTED_ZERO: 0, + WellTypeEnum.ERT_PRODUCER: 0, + WellTypeEnum.ERT_GAS_INJECTOR: 0, + WellTypeEnum.ERT_OIL_INJECTOR: 0, + WellTypeEnum.ERT_WATER_INJECTOR: 0} segments = set() branches = set() @@ -214,11 +214,11 @@ def test_well_state(self): self.assertEqual(msw_states[True], 169) self.assertEqual(msw_states[False], 53) - self.assertEqual(well_types[WellTypeEnum.UNDOCUMENTED_ZERO], 0) - self.assertEqual(well_types[WellTypeEnum.WATER_INJECTOR], 0) - self.assertEqual(well_types[WellTypeEnum.OIL_INJECTOR], 0) - self.assertEqual(well_types[WellTypeEnum.GAS_INJECTOR], 1) - self.assertEqual(well_types[WellTypeEnum.PRODUCER], 221) + self.assertEqual(well_types[WellTypeEnum.ERT_UNDOCUMENTED_ZERO], 0) + self.assertEqual(well_types[WellTypeEnum.ERT_WATER_INJECTOR], 0) + self.assertEqual(well_types[WellTypeEnum.ERT_OIL_INJECTOR], 0) + self.assertEqual(well_types[WellTypeEnum.ERT_GAS_INJECTOR], 1) + self.assertEqual(well_types[WellTypeEnum.ERT_PRODUCER], 221) self.assertEqual(len(connections), connections_count) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well2.py b/ThirdParty/Ert/devel/python/tests/core/well/test_ecl_well2.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/well/test_ecl_well2.py rename to ThirdParty/Ert/devel/python/tests/core/well/test_ecl_well2.py diff --git a/ThirdParty/Ert/devel/python/test/ctest_import.py b/ThirdParty/Ert/devel/python/tests/ctest_import.py similarity index 81% rename from ThirdParty/Ert/devel/python/test/ctest_import.py rename to ThirdParty/Ert/devel/python/tests/ctest_import.py index fb64e2845d..c7892a0ec3 100644 --- a/ThirdParty/Ert/devel/python/test/ctest_import.py +++ b/ThirdParty/Ert/devel/python/tests/ctest_import.py @@ -1,10 +1,11 @@ +#!/usr/bin/env python import os import sys PYTHONPATH = sys.argv[1] sys.path.insert(0, PYTHONPATH) -from ert_tests.import_tester import ImportTester +from import_tester import ImportTester package_name = sys.argv[2] package_path = os.path.join(PYTHONPATH, package_name) diff --git a/ThirdParty/Ert/devel/python/test/ctest_run.py b/ThirdParty/Ert/devel/python/tests/ctest_run.py similarity index 68% rename from ThirdParty/Ert/devel/python/test/ctest_run.py rename to ThirdParty/Ert/devel/python/tests/ctest_run.py index f1007fcef3..ceeafa47bf 100644 --- a/ThirdParty/Ert/devel/python/test/ctest_run.py +++ b/ThirdParty/Ert/devel/python/tests/ctest_run.py @@ -6,11 +6,6 @@ except ImportError: from unittest import TextTestRunner -PYTHONPATH = sys.argv[1] -sys.path.insert(0, PYTHONPATH) - -from ert.test import ErtTestRunner - def runTestCase(tests): test_result = TextTestRunner(verbosity=0).run(tests) @@ -30,18 +25,22 @@ def runTestCase(tests): return True -test_class_path = sys.argv[2] -argv = [] +if __name__ == '__main__': + PYTHONPATH = sys.argv[1] + sys.path.insert(0, PYTHONPATH) + test_class_path = sys.argv[2] + argv = [] -try: - argv = sys.argv[3:] -except IndexError: - pass + try: + argv = sys.argv[3:] + except IndexError: + pass -tests = ErtTestRunner.getTestsFromTestClass(test_class_path, argv) + from ert.test import ErtTestRunner + tests = ErtTestRunner.getTestsFromTestClass(test_class_path, argv) -if runTestCase(tests): - sys.exit(0) -else: - sys.exit(1) + if runTestCase(tests): + sys.exit(0) + else: + sys.exit(1) diff --git a/ThirdParty/Ert/devel/python/tests/ert/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/CMakeLists.txt new file mode 100644 index 0000000000..892b16a645 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/CMakeLists.txt @@ -0,0 +1,14 @@ +set(TEST_SOURCES + __init__.py +) + +add_python_package("python.tests.ert" ${PYTHON_INSTALL_PREFIX}/tests/ert "${TEST_SOURCES}" False) + +add_subdirectory(analysis) +add_subdirectory(config) +add_subdirectory(enkf) +add_subdirectory(job_queue) +add_subdirectory(run) +add_subdirectory(sched) +add_subdirectory(server) +add_subdirectory(testcase) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/analysis/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/analysis/CMakeLists.txt new file mode 100644 index 0000000000..31940dc2d0 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/analysis/CMakeLists.txt @@ -0,0 +1,14 @@ +set(TEST_SOURCES + __init__.py + test_analysis_module.py + test_linalg.py + test_options_enum.py + test_rml.py +) + +add_python_package("python.tests.ert.analysis" ${PYTHON_INSTALL_PREFIX}/tests/ert/analysis "${TEST_SOURCES}" False) + +addPythonTest(ert.analysis.analysis_module tests.ert.analysis.test_analysis_module.AnalysisModuleTest) +addPythonTest(ert.analysis.enums tests.ert.analysis.test_options_enum.AnalysisOptionsEnumTest) +addPythonTest(ert.analysis.linalg tests.ert.analysis.test_linalg.LinalgTest) +addPythonTest(ert.analysis.rml tests.ert.analysis.test_rml.RMLTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/analysis/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/analysis/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/analysis/test_analysis_module.py b/ThirdParty/Ert/devel/python/tests/ert/analysis/test_analysis_module.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/analysis/test_analysis_module.py rename to ThirdParty/Ert/devel/python/tests/ert/analysis/test_analysis_module.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/analysis/test_linalg.py b/ThirdParty/Ert/devel/python/tests/ert/analysis/test_linalg.py new file mode 100644 index 0000000000..8ccef6e91c --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/analysis/test_linalg.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_labscale.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +from ert.enkf import ObsVector +from ert.util import Matrix +from ert.analysis import Linalg +from ert.test import ExtendedTestCase + +class LinalgTest(ExtendedTestCase): + + def test_num_PC(self): + S = Matrix(3,3) + S[0,0] = 1 + S[1,1] = 1 + S[2,2] = 1 + + with self.assertRaises(ValueError): + num_pc = Linalg.numPC( S , 0 ) + + with self.assertRaises(ValueError): + num_pc = Linalg.numPC( S , 1.5 ) + + num_pc = Linalg.numPC( S , 0.20 ) + self.assertEqual( num_pc , 1 ) + + num_pc = Linalg.numPC( S , 0.50 ) + self.assertEqual( num_pc , 2 ) + + num_pc = Linalg.numPC( S , 0.80 ) + self.assertEqual( num_pc , 3 ) + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/analysis/test_options_enum.py b/ThirdParty/Ert/devel/python/tests/ert/analysis/test_options_enum.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/analysis/test_options_enum.py rename to ThirdParty/Ert/devel/python/tests/ert/analysis/test_options_enum.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/analysis/test_rml.py b/ThirdParty/Ert/devel/python/tests/ert/analysis/test_rml.py new file mode 100644 index 0000000000..2a2fc6e635 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/analysis/test_rml.py @@ -0,0 +1,129 @@ +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_analysis_module.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import random + +from ert.test import ExtendedTestCase +from ert.util.enums import RngAlgTypeEnum, RngInitModeEnum +from ert.util import Matrix, BoolVector , RandomNumberGenerator +from ert.analysis import AnalysisModule, AnalysisModuleLoadStatusEnum, AnalysisModuleOptionsEnum +from ert.enkf import MeasData , ObsData + +import ert.cwrap.clib as clib + + +def forward_model(params , model_error = False): + # Y = A*p[0] + B*p[1] + A = 2 + B = -1 + C = 1 + D = 0.1 + state = [A*params[0] + B*params[1] , C*params[0] - D*params[1]*params[0]] + return state + + +def measure(state): + return 0.25*state[0] - 0.1*state[1]*state[1] + + +def init_matrices(ens , mask , obs , rng): + state_size = 2 + report_step = 5 + meas_data = MeasData( mask ) + meas_block = meas_data.addBlock("OBS" , report_step , len(obs) ) + + A = Matrix( state_size , mask.countEqual( True )) + active_iens = 0 + for iens,params in enumerate( ens ): + if mask[iens]: + state = forward_model( params ) + meas_block[0,iens] = measure( state ) + + A[0 , active_iens] = params[0] + A[1 , active_iens] = params[1] + + active_iens += 1 + + + S = meas_data.createS() + + obs_data = ObsData() + obs_block = obs_data.addBlock("OBS" , 1) + for iobs,obs_value in enumerate(obs): + obs_block[iobs] = obs_value + + + R = obs_data.createR() + dObs = obs_data.createDObs() + E = obs_data.createE( rng , meas_data.getActiveEnsSize() ) + D = obs_data.createD(E , S) + + obs_data.scale(S , E = E , D = D , R = R , D_obs = dObs) + return (A , S , E , D , R , dObs) + + + +class RMLTest(ExtendedTestCase): + def setUp(self): + self.libname = clib.ert_lib_path + "/rml_enkf.so" + self.user = "TEST" + + def createAnalysisModule(self): + rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) + return AnalysisModule(rng, self.user, self.libname) + + def test_load_status_enum(self): + source_file_path = "libanalysis/include/ert/analysis/analysis_module.h" + self.assertEnumIsFullyDefined(AnalysisModuleLoadStatusEnum, "analysis_module_load_status_enum", source_file_path) + + + + + def test_analysis_module(self): + rng = RandomNumberGenerator( ) + module = self.createAnalysisModule() + ens_size = 12 + obs_size = 1 + state_size = 2 + + true_params = [1.25 , 0.75] + true_state = forward_model( true_params ) + obs = [(measure( true_state ) , 0.75)] + A = Matrix( state_size , ens_size ) + + ens = [] + for iens in range(ens_size): + param = [ random.gauss( 1.00 , 1.00 ) , random.gauss(1.00 , 1.00)] + ens.append( param ) + + mask = BoolVector(default_value = True , initial_size = ens_size) + mask[2] = False + (A , S , E , D , R , dObs) = init_matrices( ens , mask , obs , rng ) + + module.initUpdate( mask , S , R , dObs , E , D ) + module.updateA( A , S , R , dObs , E , D ) + + + mask[10] = False + mask[5] = False + (A , S , E , D , R , dObs) = init_matrices( ens , mask , obs , rng ) + self.assertEqual( S.dims() , (obs_size , mask.countEqual( True ))) + self.assertEqual( E.dims() , (obs_size , mask.countEqual( True ))) + self.assertEqual( D.dims() , (obs_size , mask.countEqual( True ))) + + module.initUpdate( mask , S , R , dObs , E , D ) + module.updateA( A , S , R , dObs , E , D ) + diff --git a/ThirdParty/Ert/devel/python/tests/ert/config/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/config/CMakeLists.txt new file mode 100644 index 0000000000..06443963eb --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/config/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_config.py +) + +add_python_package("python.tests.ert.config" ${PYTHON_INSTALL_PREFIX}/tests/ert/config "${TEST_SOURCES}" True) + +addPythonTest(ert.config tests.ert.config.test_config.ConfigTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/wizards/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/config/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/wizards/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/config/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/config/test_config.py b/ThirdParty/Ert/devel/python/tests/ert/config/test_config.py new file mode 100644 index 0000000000..a348289dc7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/config/test_config.py @@ -0,0 +1,187 @@ +#!/usr/bin/env python +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'test_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from ert.config import ContentTypeEnum, UnrecognizedEnum, SchemaItem, ContentItem, ContentNode, ConfigParser, ConfigContent +from ert.test import ExtendedTestCase, TestAreaContext + +from ert.config.config_content import cwrapper + +# Adding extra functions to the ConfigContent object for the ability +# to test low level C functions which are not exposed in Python. +ConfigContent.cNamespace().safe_iget = cwrapper.prototype("char* config_content_safe_iget( config_content , char* , int , int)") +ConfigContent.cNamespace().iget = cwrapper.prototype("char* config_content_iget( config_content , char* , int , int)") +ConfigContent.cNamespace().iget_as_int = cwrapper.prototype("int config_content_iget_as_int( config_content , char* , int , int)") +ConfigContent.cNamespace().iget_as_bool = cwrapper.prototype("bool config_content_iget_as_bool( config_content , char* , int , int)") +ConfigContent.cNamespace().iget_as_double = cwrapper.prototype("double config_content_iget_as_double( config_content , char* , int , int)") +ConfigContent.cNamespace().get_occurences = cwrapper.prototype("int config_content_get_occurences( config_content , char* )") + + +class ConfigTest(ExtendedTestCase): + def setUp( self ): + self.file_list = [] + + + def test_enums(self): + source_file_path = "libconfig/include/ert/config/config_schema_item.h" + self.assertEnumIsFullyDefined(ContentTypeEnum, "config_item_types", source_file_path) + + self.assertTrue(UnrecognizedEnum.CONFIG_UNRECOGNIZED_ERROR) + + + def test_item_types(self): + with TestAreaContext("config/types") as test_area: + with open("config" , "w") as f: + f.write("TYPE_ITEM 10 3.14 TruE String file\n") + + conf = ConfigParser() + schema_item = conf.add("TYPE_ITEM", False) + schema_item.iset_type(0 , ContentTypeEnum.CONFIG_INT ) + schema_item.iset_type(1 , ContentTypeEnum.CONFIG_FLOAT ) + schema_item.iset_type(2 , ContentTypeEnum.CONFIG_BOOL ) + schema_item.iset_type(3 , ContentTypeEnum.CONFIG_STRING ) + schema_item.iset_type(4 , ContentTypeEnum.CONFIG_PATH ) + self.assertFalse( "TYPE_XX" in conf ) + self.assertTrue( "TYPE_ITEM" in conf ) + + content = conf.parse("config") + type_item = content["TYPE_ITEM"][0] + int_value = type_item[0] + self.assertEqual( int_value , 10 ) + self.assertEqual( type_item.igetString(0) , "10") + + float_value = type_item[1] + self.assertEqual( float_value , 3.14 ) + self.assertEqual( type_item.igetString(1) , "3.14") + + bool_value = type_item[2] + self.assertEqual( bool_value , True) + self.assertEqual( type_item.igetString(2) , "TruE") + + string_value = type_item[3] + self.assertEqual( string_value , "String") + self.assertEqual( type_item.igetString(3) , "String") + + path_value = type_item[4] + self.assertEqual( path_value , "file") + self.assertEqual( type_item.igetString(4) , "file") + + + + + + def test_parse(self): + conf = ConfigParser() + conf.add("FIELD", False) + schema_item = conf.add("RSH_HOST", False) + self.assertIsInstance(schema_item, SchemaItem) + test_path = self.createTestPath("local/config/simple_config") + content = conf.parse(test_path, unrecognized=UnrecognizedEnum.CONFIG_UNRECOGNIZED_IGNORE) + self.assertTrue( content.isValid() ) + + + content_item = content["RSH_HOST"] + self.assertIsInstance(content_item, ContentItem) + self.assertEqual(len(content_item), 1) + with self.assertRaises(TypeError): + content_item["BJARNE"] + + with self.assertRaises(IndexError): + content_item[10] + + content_node = content_item[0] + self.assertIsInstance(content_node, ContentNode) + self.assertEqual(len(content_node), 2) + self.assertEqual(content_node[1], "be-lx633214:2") + self.assertEqual(content_node.content(sep=","), "be-lx655082:2,be-lx633214:2") + self.assertEqual(content_node.content(), "be-lx655082:2 be-lx633214:2") + + + content_item = content["FIELD"] + self.assertEqual(len(content_item), 5) + with self.assertRaises(IOError): + conf.parse("DoesNotExits") + + + def test_parser_content(self): + conf = ConfigParser() + conf.add("KEY2", False) + schema_item = conf.add("KEY", False) + schema_item.iset_type(2 , ContentTypeEnum.CONFIG_INT ) + schema_item.iset_type(3 , ContentTypeEnum.CONFIG_BOOL ) + schema_item.iset_type(4 , ContentTypeEnum.CONFIG_FLOAT ) + + with TestAreaContext("config/parse2"): + with open("config","w") as fileH: + fileH.write("KEY VALUE1 VALUE2 100 True 3.14\n") + + content = conf.parse("config") + self.assertTrue( content.isValid() ) + self.assertTrue( "KEY" in content ) + self.assertFalse( "NOKEY" in content ) + + with self.assertRaises(KeyError): + content["Nokey"] + + item = content["KEY"] + self.assertEqual(len(item) , 1) + + with self.assertRaises(IndexError): + item[10] + + node = item[0] + self.assertEqual(len(node) , 5) + with self.assertRaises(IndexError): + node[6] + + self.assertEqual( node[0] , "VALUE1" ) + self.assertEqual( node[1] , "VALUE2" ) + self.assertEqual( node[2] , 100 ) + self.assertEqual( node[3] , True ) + self.assertEqual( node[4] , 3.14) + + self.assertEqual( content.getValue( "KEY" , 0 , 1 ) , "VALUE2" ) + self.assertEqual( content.cNamespace().iget( content , "KEY" , 0 , 1) , "VALUE2") + + self.assertEqual( content.getValue( "KEY" , 0 , 2 ) , 100 ) + self.assertEqual( content.cNamespace().iget_as_int( content , "KEY" , 0 , 2) , 100) + + self.assertEqual( content.getValue( "KEY" , 0 , 3 ) , True ) + self.assertEqual( content.cNamespace().iget_as_bool( content , "KEY" , 0 , 3) , True) + + self.assertEqual( content.getValue( "KEY" , 0 , 4 ) , 3.14 ) + self.assertEqual( content.cNamespace().iget_as_double( content , "KEY" , 0 , 4) , 3.14) + + self.assertIsNone( content.cNamespace().safe_iget( content , "KEY2" , 0 , 0)) + + self.assertEqual( content.cNamespace().get_occurences( content , "KEY2" ) , 0) + self.assertEqual( content.cNamespace().get_occurences( content , "KEY" ) , 1) + self.assertEqual( content.cNamespace().get_occurences( content , "MISSING-KEY" ) , 0) + + + + def test_schema(self): + schema_item = SchemaItem("TestItem") + self.assertIsInstance(schema_item, SchemaItem) + self.assertEqual(schema_item.iget_type(6), ContentTypeEnum.CONFIG_STRING) + schema_item.iset_type(0, ContentTypeEnum.CONFIG_INT) + self.assertEqual(schema_item.iget_type(0), ContentTypeEnum.CONFIG_INT) + schema_item.set_argc_minmax(3, 6) + + del schema_item + + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/enkf/CMakeLists.txt new file mode 100644 index 0000000000..2fe35a5ac7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/CMakeLists.txt @@ -0,0 +1,73 @@ +set(TEST_SOURCES + __init__.py + test_active_list.py + test_analysis_config.py + test_analysis_iter_config.py + test_block_obs.py + test_custom_kw_config_set.py + test_ecl_config.py + test_enkf.py + test_enkf_fs.py + test_enkf_fs_manager1.py + test_enkf_fs_manager2.py + test_enkf_library.py + test_enkf_load_results_manually.py + test_enkf_obs.py + test_ert_context.py + test_ert_log.py + test_gen_obs.py + test_labscale.py + test_linalg.py + test_local_obsdata_node.py + test_meas_block.py + test_meas_data.py + test_obs_block.py + test_obs_data.py + test_run_arg.py + test_runpath_list.py + test_state_map.py + test_summary_key_matcher.py + test_summary_key_set.py + test_summary_obs.py + test_time_map.py + test_update.py + test_ensemble_config.py +) + +add_python_package("python.tests.ert.enkf" ${PYTHON_INSTALL_PREFIX}/tests/ert/enkf "${TEST_SOURCES}" False) + +addPythonTest(ert.enkf.enkf tests.ert.enkf.test_enkf.EnKFTest LABELS StatoilData) +addPythonTest(ert.enkf.enkf_obs tests.ert.enkf.test_enkf_obs.EnKFObsTest LABELS StatoilData) +addPythonTest(ert.enkf.meas_block tests.ert.enkf.test_meas_block.MeasBlockTest) +addPythonTest(ert.enkf.meas_data tests.ert.enkf.test_meas_data.MeasDataTest) +addPythonTest(ert.enkf.obs_data tests.ert.enkf.test_obs_data.ObsDataTest) +addPythonTest(ert.enkf.gen_obs tests.ert.enkf.test_gen_obs.GenObsTest) +addPythonTest(ert.enkf.summary_obs tests.ert.enkf.test_summary_obs.SummaryObsTest) +addPythonTest(ert.enkf.block_obs tests.ert.enkf.test_block_obs.BlockObsTest) +addPythonTest(ert.enkf.obs_block tests.ert.enkf.test_obs_block.ObsBlockTest) +addPythonTest(ert.enkf.enkf_load_results_manually tests.ert.enkf.test_enkf_load_results_manually.LoadResultsManuallyTest LABELS StatoilData) +addPythonTest(ert.enkf.enkf_fs tests.ert.enkf.test_enkf_fs.EnKFFSTest LABELS StatoilData) +addPythonTest(ert.enkf.ert_log tests.ert.enkf.test_ert_log.ErtLogTest) +addPythonTest(ert.enkf.enkf_fs_manager1 tests.ert.enkf.test_enkf_fs_manager1.EnKFFSManagerTest1 LABELS StatoilData) +addPythonTest(ert.enkf.enkf_fs_manager2 tests.ert.enkf.test_enkf_fs_manager2.EnKFFSManagerTest2 LABELS StatoilData) +addPythonTest(ert.enkf.enkf_library tests.ert.enkf.test_enkf_library.EnKFLibraryTest) +addPythonTest(ert.enkf.analysis_config tests.ert.enkf.test_analysis_config.AnalysisConfigTest) +addPythonTest(ert.enkf.analysis_iter_config tests.ert.enkf.test_analysis_iter_config.AnalysisIterConfigTest) +addPythonTest(ert.enkf.state_map tests.ert.enkf.test_state_map.StateMapTest) +addPythonTest(ert.enkf.summary_key_set tests.ert.enkf.test_summary_key_set.SummaryKeySetTest LABELS StatoilData) +addPythonTest(ert.enkf.custom_kw_config_set tests.ert.enkf.test_custom_kw_config_set.CustomKWConfigSetTest) +addPythonTest(ert.enkf.summary_key_matcher tests.ert.enkf.test_summary_key_matcher.SummaryKeyMatcherTest) +addPythonTest(ert.enkf.time_map tests.ert.enkf.test_time_map.TimeMapTest) +addPythonTest(ert.enkf.ecl_config tests.ert.enkf.test_ecl_config.EclConfigTest LABELS StatoilData) +addPythonTest(ert.enkf.ert_test_context tests.ert.enkf.test_ert_context.ErtTestContextTest LABELS StatoilData) +addPythonTest(ert.enkf.run_arg tests.ert.enkf.test_run_arg.RunArg) +addPythonTest(ert.enkf.runpath_list tests.ert.enkf.test_runpath_list.RunpathListTest) +addPythonTest(ert.enkf.update tests.ert.enkf.test_update.UpdateTest LABELS StatoilData) +addPythonTest(ert.enkf.labscale tests.ert.enkf.test_labscale.LabScaleTest LABELS StatoilData) +addPythonTest(ert.enkf.active_list tests.ert.enkf.test_active_list.ActiveListTest) +addPythonTest(ert.enkf.local_obsdata_node tests.ert.enkf.test_local_obsdata_node.LocalObsdataNodeTest) +addPythonTest(ert.enkf.ensemble_config tests.ert.enkf.test_ensemble_config.EnsembleConfigTest) + +add_subdirectory(data) +add_subdirectory(export) +add_subdirectory(plot) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/data/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/CMakeLists.txt new file mode 100644 index 0000000000..2f2a072448 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/CMakeLists.txt @@ -0,0 +1,20 @@ +set(TEST_SOURCES + __init__.py + test_custom_kw.py + test_custom_kw_config.py + test_field_config.py + test_gen_data.py + test_gen_data_config.py + test_gen_kw.py + test_gen_kw_config.py +) + +add_python_package("python.tests.ert.enkf.data" ${PYTHON_INSTALL_PREFIX}/tests/ert/enkf/data "${TEST_SOURCES}" False) + +addPythonTest(ert.enkf.data.custom_kw tests.ert.enkf.data.test_custom_kw.CustomKWTest) +addPythonTest(ert.enkf.data.custom_kw_config tests.ert.enkf.data.test_custom_kw_config.CustomKWConfigTest) +addPythonTest(ert.enkf.data.gen_data tests.ert.enkf.data.test_gen_data.GenDataTest LABELS StatoilData) +addPythonTest(ert.enkf.data.gen_data_config tests.ert.enkf.data.test_gen_data_config.GenDataConfigTest LABELS StatoilData) +addPythonTest(ert.enkf.data.gen_kw tests.ert.enkf.data.test_gen_kw.GenKwTest) +addPythonTest(ert.enkf.data.gen_kw_config tests.ert.enkf.data.test_gen_kw_config.GenKwConfigTest LABELS StatoilData) +addPythonTest(ert.enkf.data.field_config tests.ert.enkf.data.test_field_config.FieldConfigTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/data/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_custom_kw.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_custom_kw.py new file mode 100644 index 0000000000..42b5285746 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_custom_kw.py @@ -0,0 +1,96 @@ +import os +from ert.enkf.data import CustomKW, CustomKWConfig +from ert.enkf.enkf_simulation_runner import EnkfSimulationRunner +from ert.enkf.export import custom_kw_collector +from ert.enkf.export.custom_kw_collector import CustomKWCollector +from ert.test.ert_test_context import ErtTestContext +from ert.test.extended_testcase import ExtendedTestCase +from ert.test.test_area import TestAreaContext +from ert.util import StringList + + +class CustomKWTest(ExtendedTestCase): + + def createResultFile(self, filename, data): + with open(filename, "w") as output_file: + for key in data: + output_file.write("%s %s\n" % (key, data[key])) + + def test_custom_kw_creation(self): + data = {"VALUE_1": 2345.234, + "VALUE_2": 0.001234, + "VALUE_3": "string_1", + "VALUE_4": "string_2"} + + with TestAreaContext("python/enkf/data/custom_kw_creation") as test_area: + + self.createResultFile("result_file", data) + + custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") + + self.assertEqual(len(custom_kw_config), 0) + + custom_kw = CustomKW(custom_kw_config) + + custom_kw.fload("result_file") + self.assertEqual(len(custom_kw_config), 4) + + for key in data: + index = custom_kw_config.indexOfKey(key) + self.assertEqual(data[key], custom_kw[key]) + + with self.assertRaises(KeyError): + value = custom_kw["VALUE_5"] + + + + def test_custom_kw_config_data_is_null(self): + data_1 = {"VALUE_1": 123453.3, + "VALUE_2": 0.234234} + + data_2 = {"VALUE_1": 965689, + "VALUE_3": 1.1222} + + with TestAreaContext("python/enkf/data/custom_kw_null_element") as test_area: + + self.createResultFile("result_file_1", data_1) + self.createResultFile("result_file_2", data_2) + + custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") + + custom_kw_1 = CustomKW(custom_kw_config) + custom_kw_1.fload("result_file_1") + + custom_kw_2 = CustomKW(custom_kw_config) + custom_kw_2.fload("result_file_2") + + index_1 = custom_kw_config.indexOfKey("VALUE_1") + index_2 = custom_kw_config.indexOfKey("VALUE_2") + + self.assertEqual(custom_kw_1["VALUE_1"], data_1["VALUE_1"]) + self.assertEqual(custom_kw_2["VALUE_1"], data_2["VALUE_1"]) + + self.assertIsNone(custom_kw_2["VALUE_2"]) + self.assertFalse( "VALUE_3" in custom_kw_config ) + + + + def test_simulated_custom_kw(self): + config = self.createTestPath("local/custom_kw/mini_config") + with ErtTestContext("python/enkf/data/custom_kw_simulated", config) as context: + ert = context.getErt() + + ensemble_config = ert.ensembleConfig() + self.assertTrue("AGGREGATED" in ensemble_config) + + config = ensemble_config.getNode("AGGREGATED").getCustomKeywordModelConfig() + + self.assertEqual(len(config.getKeys()), 0) + + simulation_runner = EnkfSimulationRunner(ert) + simulation_runner.runEnsembleExperiment() + + config = ensemble_config.getNode("AGGREGATED").getCustomKeywordModelConfig() + + self.assertEqual(len(config.getKeys()), 4) + self.assertItemsEqual(config.getKeys(), ["PERLIN_1", "PERLIN_2", "PERLIN_3", "STATE"]) diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_custom_kw_config.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_custom_kw_config.py new file mode 100644 index 0000000000..d6708ffb2c --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_custom_kw_config.py @@ -0,0 +1,114 @@ +from ert.enkf.data.custom_kw_config import CustomKWConfig +from ert.test.extended_testcase import ExtendedTestCase +from ert.test.test_area import TestAreaContext +from ert.util import StringList + + +class CustomKWConfigTest(ExtendedTestCase): + + def createResultFile(self, filename, data): + with open(filename, "w") as output_file: + for key in data: + output_file.write("%s %s\n" % (key, data[key])) + + def test_custom_kw_config_creation(self): + data = {"VALUE_1": 2345.234, + "VALUE_2": 0.001234, + "VALUE_3": "string_1", + "VALUE_4": "string_2"} + + with TestAreaContext("python/enkf/data/custom_kw_config") as test_area: + + self.createResultFile("result_file", data) + + custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file", "output_file") + + self.assertEqual(custom_kw_config.getName(), "CUSTOM_KW") + self.assertEqual(custom_kw_config.getResultFile(), "result_file") + self.assertEqual(custom_kw_config.getOutputFile(), "output_file") + + self.assertEqual(len(custom_kw_config), 0) + + result = StringList() + success = custom_kw_config.parseResultFile("result_file", result) + self.assertTrue(success) + + self.assertEqual(len(custom_kw_config), 4) + + for index, key in enumerate(data): + self.assertTrue(key in custom_kw_config) + + key_is_string = isinstance(data[key], str) + self.assertTrue(custom_kw_config.keyIsDouble(key) != key_is_string) + self.assertEqual(index, custom_kw_config.indexOfKey(key)) + + self.assertEqual(result[index], str(data[key])) + + self.assertTrue(len(custom_kw_config.getKeys()) == 4) + + for key in custom_kw_config: + self.assertTrue(key in data) + + + def test_custom_kw_config_multiple_identical_keys(self): + data = {"VALUE_1": 2345.234, + "VALUE_2": 0.001234, + "VALUE_3": "string_1", + "VALUE_4": "string_2 VALUE_4 repeat_of_value_4"} + + with TestAreaContext("python/enkf/data/custom_kw_config_multiple_identical_keys") as test_area: + + self.createResultFile("result_file", data) + + custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") + + result = StringList() + success = custom_kw_config.parseResultFile("result_file", result) + self.assertTrue(success) + + index_of_value_4 = custom_kw_config.indexOfKey("VALUE_4") + self.assertEqual(result[index_of_value_4], "repeat_of_value_4") + + + + def test_custom_kw_config_define_and_read(self): + data_1 = {"VALUE_1": 123453.3, + "VALUE_2": 0.234234} + + data_2 = {"VALUE_1": 965689, + "VALUE_3": 1.1222} + + with TestAreaContext("python/enkf/data/custom_kw_config") as test_area: + + self.createResultFile("result_file_1", data_1) + self.createResultFile("result_file_2", data_2) + + custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") + + result_1 = StringList() + success = custom_kw_config.parseResultFile("result_file_1", result_1) + self.assertTrue(success) + + result_2 = StringList() + success = custom_kw_config.parseResultFile("result_file_2", result_2) + self.assertFalse(success) + + for key in custom_kw_config: + self.assertTrue(key in data_1) + + self.assertFalse("VALUE_3" in custom_kw_config) + + + + + def test_custom_kw_config_parse_fail(self): + data = {"KEY_1": "Value Key_2"} + + with TestAreaContext("python/enkf/data/custom_kw_config_fail") as test_area: + + self.createResultFile("result_file", data) + + custom_kw_config = CustomKWConfig("CUSTOM_KW_FAIL", "result_file") + self.assertIsNone(custom_kw_config.getOutputFile()) + + self.assertFalse(custom_kw_config.parseResultFile("result_file", StringList())) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/test_ert_gui_import.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_field_config.py similarity index 51% rename from ThirdParty/Ert/devel/python/test/ert_tests/test_ert_gui_import.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_field_config.py index cfed3f41f2..04ba9303c9 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/test_ert_gui_import.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_field_config.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python -# Copyright (C) 2013 Statoil ASA, Norway. +# Copyright (C) 2015 Statoil ASA, Norway. # -# The file 'test_ert_gui_import.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'test_field_config.py' is part of ERT - Ensemble based Reservoir Tool. # # ERT is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,17 +13,19 @@ # # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. -import os - -from ert.test.extended_testcase import ExtendedTestCase -from ert_tests.import_tester import ImportTester +import os -class ErtGuiImportTest(ExtendedTestCase): +from ert.enkf import FieldConfig +from ert.enkf import ActiveList +from ert.test import ExtendedTestCase +from ert.ecl import EclGrid - def test_ert_gui(self): - module = __import__("ert_gui") - path = os.path.abspath(module.__file__) - path = os.path.dirname(path) +class FieldConfigTest(ExtendedTestCase): - self.assertTrue(ImportTester.importRecursively(path, "ert_gui")) + def test_create(self): + grid = EclGrid.createRectangular( (10,10,5) , (1,1,1) ) + field_config = FieldConfig("SWAT" , grid) + + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/test_gen_data.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_data.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/test_gen_data.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_data.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/test_gen_data_config.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_data_config.py similarity index 96% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/test_gen_data_config.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_data_config.py index f8748b3984..73e2b3f5bb 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/test_gen_data_config.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_data_config.py @@ -1,5 +1,6 @@ from ert.cwrap import clib, CWrapper from ert.enkf.data.enkf_node import EnkfNode +from ert.enkf.data import GenDataConfig from ert.enkf.enums.enkf_state_type_enum import EnkfStateType from ert.enkf.node_id import NodeId from ert.test import ErtTestContext @@ -68,7 +69,9 @@ def test_loading_two_cases_with_and_without_active_file(self): - + def test_create(self): + conf = GenDataConfig("KEY") + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/test_gen_kw.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_kw.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/data/test_gen_kw.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_kw.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_kw_config.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_kw_config.py new file mode 100644 index 0000000000..f32ad7a1e2 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/data/test_gen_kw_config.py @@ -0,0 +1,55 @@ +from ert.enkf import ErtImplType, GenKwConfig +from ert.test import ErtTestContext, ExtendedTestCase + +class GenKwConfigTest(ExtendedTestCase): + + def setUp(self): + self.config = self.createTestPath("Statoil/config/with_data/config") + + + def test_gen_kw_config(self): + + with ErtTestContext("python/enkf/data/gen_kw_config", self.config) as context: + + ert = context.getErt() + + gen_kw_keys = ert.ensembleConfig().getKeylistFromImplType(ErtImplType.GEN_KW) + + self.assertEqual(gen_kw_keys[0], "GRID_PARAMS") + + node = ert.ensembleConfig().getNode(gen_kw_keys[0]) + gen_kw_config = node.getModelConfig() + self.assertIsInstance(gen_kw_config, GenKwConfig) + + self.assertEqual(gen_kw_config.getKey(), "GRID_PARAMS") + self.assertEqual(len(gen_kw_config), 2) + + self.assertEqual(gen_kw_config[0], "MULTPV2") + self.assertEqual(gen_kw_config[1], "MULTPV3") + + self.assertFalse(gen_kw_config.shouldUseLogScale(0)) + self.assertFalse(gen_kw_config.shouldUseLogScale(1)) + + + node = ert.ensembleConfig().getNode(gen_kw_keys[1]) + gen_kw_config = node.getModelConfig() + self.assertIsInstance(gen_kw_config, GenKwConfig) + + self.assertEqual(gen_kw_config.getKey(), "MULTFLT") + + self.assertTrue(gen_kw_config.shouldUseLogScale(0)) + + + node = ert.ensembleConfig().getNode(gen_kw_keys[2]) + gen_kw_config = node.getModelConfig() + self.assertIsInstance(gen_kw_config, GenKwConfig) + + self.assertEqual(gen_kw_config.getKey(), "FLUID_PARAMS") + + self.assertFalse(gen_kw_config.shouldUseLogScale(0)) + self.assertFalse(gen_kw_config.shouldUseLogScale(1)) + + expected = ["SWCR", "SGCR"] + + for index, keyword in enumerate(gen_kw_config): + self.assertEqual(keyword, expected[index]) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/CMakeLists.txt new file mode 100644 index 0000000000..da216557aa --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/CMakeLists.txt @@ -0,0 +1,28 @@ +set(TEST_SOURCES + __init__.py + test_arg_loader.py + test_custom_kw_collector.py + test_design_matrix.py + test_export_join.py + test_gen_data_collector.py + test_gen_data_observation_collector.py + test_gen_kw_collector.py + test_misfit_collector.py + test_numpy_and_pandas.py + test_summary_collector.py + test_summary_observation_collector.py +) + +add_python_package("python.tests.ert.enkf.export" ${PYTHON_INSTALL_PREFIX}/tests/ert/enkf/export "${TEST_SOURCES}" False) + +addPythonTest(ert.enkf.export.arg_loader tests.ert.enkf.export.test_arg_loader.ArgLoaderTest LABELS StatoilData) +addPythonTest(ert.enkf.export.custom_kw_collector tests.ert.enkf.export.test_custom_kw_collector.CustomKwCollectorTest) +addPythonTest(ert.enkf.export.design_matrix tests.ert.enkf.export.test_design_matrix.DesignMatrixTest LABELS StatoilData) +addPythonTest(ert.enkf.export.export_join tests.ert.enkf.export.test_export_join.ExportJoinTest LABELS StatoilData) +addPythonTest(ert.enkf.export.gen_data_collector tests.ert.enkf.export.test_gen_data_collector.GenDataCollectorTest LABELS StatoilData) +addPythonTest(ert.enkf.export.gen_data_observation_collector tests.ert.enkf.export.test_gen_data_observation_collector.GenDataObservationCollectorTest) +addPythonTest(ert.enkf.export.gen_kw_collector tests.ert.enkf.export.test_gen_kw_collector.GenKwCollectorTest LABELS StatoilData) +addPythonTest(ert.enkf.export.numpy_and_pandas tests.ert.enkf.export.test_numpy_and_pandas.NumpyAndPandasTest) +addPythonTest(ert.enkf.export.misfit_collector tests.ert.enkf.export.test_misfit_collector.MisfitCollectorTest LABELS StatoilData) +addPythonTest(ert.enkf.export.summary_collector tests.ert.enkf.export.test_summary_collector.SummaryCollectorTest LABELS StatoilData) +addPythonTest(ert.enkf.export.summary_observation_collector tests.ert.enkf.export.test_summary_observation_collector.SummaryObservationCollectorTest LABELS StatoilData) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/run/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/run/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/export/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_arg_loader.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_arg_loader.py new file mode 100644 index 0000000000..58e510271c --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_arg_loader.py @@ -0,0 +1,24 @@ +import math + +from ert.enkf.export import ArgLoader +from ert.test import ErtTestContext, ExtendedTestCase + +class ArgLoaderTest(ExtendedTestCase): + + + def test_arg_loader(self): + + with self.assertRaises(IOError): + arg = ArgLoader.load("arg1X") + + arg_file = self.createTestPath("Statoil/config/with_GEN_DATA_RFT/wellpath/WI_1.txt") + + with self.assertRaises(ValueError): + arg = ArgLoader.load(arg_file , column_names = ["Col1" , "Col2" , "Col3" ,"COl5" , "Col6"]) + + arg = ArgLoader.load(arg_file , column_names = ["utm_x" , "utm_y" , "md" , "tvd"]) + self.assertFloatEqual( arg["utm_x"][0] , 461317.620646) + + + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_custom_kw_collector.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_custom_kw_collector.py new file mode 100644 index 0000000000..dba81ea80b --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_custom_kw_collector.py @@ -0,0 +1,40 @@ +from ert.enkf.export import CustomKWCollector +from ert.test import ErtTestContext, ExtendedTestCase + +class CustomKwCollectorTest(ExtendedTestCase): + + def test_custom_kw_collector_non_current_fs(self): + config = self.createTestPath("local/custom_kw/mini_config") + + with ErtTestContext("python/enkf/export/custom_kw_collector_from_fs", config) as context: + ert = context.getErt() + + data = CustomKWCollector.loadAllCustomKWData(ert, "test_run") + + self.assertTrue(len(data.columns) == 0) + + + def test_custom_kw_collector_current_fs(self): + config = self.createTestPath("local/custom_kw/mini_config") + + with ErtTestContext("python/enkf/export/custom_kw_collector_from_current_fs", config) as context: + ert = context.getErt() + fs = ert.getEnkfFsManager().getFileSystem("test_run") + ert.getEnkfFsManager().switchFileSystem(fs) + data = CustomKWCollector.loadAllCustomKWData(ert, "test_run") + + self.assertFloatEqual(data["AGGREGATED:PERLIN_1"][0], -0.167794) + self.assertFloatEqual(data["AGGREGATED:PERLIN_1"][8], -1.276058) + self.assertFloatEqual(data["AGGREGATED:PERLIN_1"][9], -0.137903) + + self.assertFloatEqual(data["AGGREGATED:PERLIN_2"][0], 1.00263) + self.assertFloatEqual(data["AGGREGATED:PERLIN_2"][8], -0.105634) + self.assertFloatEqual(data["AGGREGATED:PERLIN_2"][9], 1.032522) + + self.assertFloatEqual(data["AGGREGATED:PERLIN_3"][0], 0.190479) + self.assertFloatEqual(data["AGGREGATED:PERLIN_3"][8], -0.917785) + self.assertFloatEqual(data["AGGREGATED:PERLIN_3"][9], 0.220371) + + self.assertEqual(data["AGGREGATED:STATE"][0], "Positive") + self.assertEqual(data["AGGREGATED:STATE"][8], "Negative") + self.assertEqual(data["AGGREGATED:STATE"][9], "Positive") diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_design_matrix.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_design_matrix.py new file mode 100644 index 0000000000..8c513a63fa --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_design_matrix.py @@ -0,0 +1,94 @@ +from ert.enkf.export import DesignMatrixReader +from ert.test import ExtendedTestCase +from ert.test.test_area import TestAreaContext + +def dumpDesignMatrix1(path): + with open(path, "w") as dm: + dm.write("Case CORR_SEIS_HEIMDAL VOL_FRAC_HEIMDAL AZIM_IND_HEIMDAL VARIO_PARAL_HEIMDAL VARIO_NORM_HEIMDAL VARIO_VERT_HEIMDAL SEIS_COND_HEIMDAL\n") + dm.write("0 0.8 0.08 125 1000 500 25 ON\n") + dm.write("1 0.8 0.15 125 2000 1000 25 ON\n") + dm.write("2 0.8 0.20 125 4000 2000 25 ON\n") + + +def dumpDesignMatrix2(path): + with open(path, "w") as dm: + dm.write("Case CORR_SEIS_HEIMDAL VOL_FRAC_HEIMDAL AZIM_IND_HEIMDAL VARIO_PARAL_HEIMDAL VARIO_NORM_HEIMDAL VARIO_VERT_HEIMDAL SEIS_COND_HEIMDAL\n") + dm.write("0 0.8 0.08 125 1000 500 25 ON\n") + dm.write("1 0.8 0.15 125 2000 1000 25 ON\n") + dm.write("2 0.8 0.20 125 4000 2000 25 ON\n") + dm.write("4 0.8 0.30 125 16000 8000 25 ON\n") + + + +class DesignMatrixTest(ExtendedTestCase): + + def test_read_design_matrix(self): + with TestAreaContext("python/enkf/export/design_matrix"): + dumpDesignMatrix1("DesignMatrix.txt") + dm = DesignMatrixReader.loadDesignMatrix("DesignMatrix.txt") + + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][0], 0.8) + self.assertEqual(dm["VOL_FRAC_HEIMDAL"][0], 0.08) + self.assertEqual(dm["AZIM_IND_HEIMDAL"][0], 125) + self.assertEqual(dm["VARIO_PARAL_HEIMDAL"][0], 1000) + self.assertEqual(dm["VARIO_NORM_HEIMDAL"][0], 500) + self.assertEqual(dm["VARIO_VERT_HEIMDAL"][0], 25) + self.assertEqual(dm["SEIS_COND_HEIMDAL"][0], "ON") + + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][1], 0.8) + self.assertEqual(dm["VOL_FRAC_HEIMDAL"][1], 0.15) + self.assertEqual(dm["AZIM_IND_HEIMDAL"][1], 125) + self.assertEqual(dm["VARIO_PARAL_HEIMDAL"][1], 2000) + self.assertEqual(dm["VARIO_NORM_HEIMDAL"][1], 1000) + self.assertEqual(dm["VARIO_VERT_HEIMDAL"][1], 25) + self.assertEqual(dm["SEIS_COND_HEIMDAL"][1], "ON") + + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][2], 0.8) + self.assertEqual(dm["VOL_FRAC_HEIMDAL"][2], 0.20) + self.assertEqual(dm["AZIM_IND_HEIMDAL"][2], 125) + self.assertEqual(dm["VARIO_PARAL_HEIMDAL"][2], 4000) + self.assertEqual(dm["VARIO_NORM_HEIMDAL"][2], 2000) + self.assertEqual(dm["VARIO_VERT_HEIMDAL"][2], 25) + self.assertEqual(dm["SEIS_COND_HEIMDAL"][2], "ON") + + + def test_read_design_matrix_2(self): + with TestAreaContext("python/enkf/export/design_matrix_2"): + dumpDesignMatrix2("DesignMatrix2.txt") + dm = DesignMatrixReader.loadDesignMatrix("DesignMatrix2.txt") + + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][0], 0.8) + self.assertEqual(dm["VOL_FRAC_HEIMDAL"][0], 0.08) + self.assertEqual(dm["AZIM_IND_HEIMDAL"][0], 125) + self.assertEqual(dm["VARIO_PARAL_HEIMDAL"][0], 1000) + self.assertEqual(dm["VARIO_NORM_HEIMDAL"][0], 500) + self.assertEqual(dm["VARIO_VERT_HEIMDAL"][0], 25) + self.assertEqual(dm["SEIS_COND_HEIMDAL"][0], "ON") + + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][1], 0.8) + self.assertEqual(dm["VOL_FRAC_HEIMDAL"][1], 0.15) + self.assertEqual(dm["AZIM_IND_HEIMDAL"][1], 125) + self.assertEqual(dm["VARIO_PARAL_HEIMDAL"][1], 2000) + self.assertEqual(dm["VARIO_NORM_HEIMDAL"][1], 1000) + self.assertEqual(dm["VARIO_VERT_HEIMDAL"][1], 25) + self.assertEqual(dm["SEIS_COND_HEIMDAL"][1], "ON") + + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][2], 0.8) + self.assertEqual(dm["VOL_FRAC_HEIMDAL"][2], 0.20) + self.assertEqual(dm["AZIM_IND_HEIMDAL"][2], 125) + self.assertEqual(dm["VARIO_PARAL_HEIMDAL"][2], 4000) + self.assertEqual(dm["VARIO_NORM_HEIMDAL"][2], 2000) + self.assertEqual(dm["VARIO_VERT_HEIMDAL"][2], 25) + self.assertEqual(dm["SEIS_COND_HEIMDAL"][2], "ON") + + + with self.assertRaises(KeyError): + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][3], 0.8) + + self.assertEqual(dm["CORR_SEIS_HEIMDAL"][4], 0.8) + self.assertEqual(dm["VOL_FRAC_HEIMDAL"][4], 0.30) + self.assertEqual(dm["AZIM_IND_HEIMDAL"][4], 125) + self.assertEqual(dm["VARIO_PARAL_HEIMDAL"][4], 16000) + self.assertEqual(dm["VARIO_NORM_HEIMDAL"][4], 8000) + self.assertEqual(dm["VARIO_VERT_HEIMDAL"][4], 25) + self.assertEqual(dm["SEIS_COND_HEIMDAL"][4], "ON") diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_export_join.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_export_join.py new file mode 100644 index 0000000000..21b863ba93 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_export_join.py @@ -0,0 +1,85 @@ +from ert.enkf.export import DesignMatrixReader, SummaryCollector, GenKwCollector, MisfitCollector +from ert.test import ExtendedTestCase, ErtTestContext +import pandas +import numpy + +def dumpDesignMatrix(path): + with open(path, "w") as dm: + dm.write("REALIZATION EXTRA_FLOAT_COLUMN EXTRA_INT_COLUMN EXTRA_STRING_COLUMN\n") + dm.write("0 0.08 125 ON\n") + dm.write("1 0.07 225 OFF\n") + dm.write("2 0.08 325 ON\n") + dm.write("3 0.06 425 ON\n") + dm.write("4 0.08 525 OFF\n") + dm.write("5 0.08 625 ON\n") + dm.write("6 0.09 725 ON\n") + dm.write("7 0.08 825 OFF\n") + dm.write("8 0.02 925 ON\n") + dm.write("9 0.08 125 ON\n") + dm.write("10 0.08 225 ON\n") + dm.write("11 0.05 325 OFF\n") + dm.write("12 0.08 425 ON\n") + dm.write("13 0.07 525 ON\n") + dm.write("14 0.08 625 UNKNOWN\n") + dm.write("15 0.08 725 ON\n") + dm.write("16 0.08 825 ON\n") + dm.write("17 0.08 925 OFF\n") + dm.write("18 0.09 125 ON\n") + dm.write("19 0.08 225 ON\n") + dm.write("20 0.06 325 OFF\n") + dm.write("21 0.08 425 ON\n") + dm.write("22 0.07 525 ON\n") + dm.write("23 0.08 625 OFF\n") + dm.write("24 0.08 725 ON\n") + +class ExportJoinTest(ExtendedTestCase): + + def setUp(self): + self.config = self.createTestPath("Statoil/config/with_data/config") + + def test_join(self): + + with ErtTestContext("python/enkf/export/export_join", self.config) as context: + dumpDesignMatrix("DesignMatrix.txt") + ert = context.getErt() + + summary_data = SummaryCollector.loadAllSummaryData(ert, "default") + gen_kw_data = GenKwCollector.loadAllGenKwData(ert, "default") + misfit = MisfitCollector.loadAllMisfitData(ert, "default") + dm = DesignMatrixReader.loadDesignMatrix("DesignMatrix.txt") + + result = summary_data.join(gen_kw_data, how='inner') + result = result.join(misfit, how='inner') + result = result.join(dm, how='inner') + + self.assertFloatEqual(result["FLUID_PARAMS:SGCR"][0]["2000-02-01"], 0.018466) + self.assertFloatEqual(result["FLUID_PARAMS:SGCR"][24]["2000-02-01"], 0.221049 ) + self.assertFloatEqual(result["FLUID_PARAMS:SGCR"][24]["2004-12-01"], 0.221049) + + self.assertFloatEqual(result["EXTRA_FLOAT_COLUMN"][0]["2000-02-01"], 0.08) + self.assertEqual(result["EXTRA_INT_COLUMN"][0]["2000-02-01"], 125) + self.assertEqual(result["EXTRA_STRING_COLUMN"][0]["2000-02-01"], "ON") + + self.assertFloatEqual(result["EXTRA_FLOAT_COLUMN"][0]["2004-12-01"], 0.08) + self.assertEqual(result["EXTRA_INT_COLUMN"][0]["2004-12-01"], 125) + self.assertEqual(result["EXTRA_STRING_COLUMN"][0]["2004-12-01"], "ON") + + self.assertFloatEqual(result["EXTRA_FLOAT_COLUMN"][1]["2004-12-01"], 0.07) + self.assertEqual(result["EXTRA_INT_COLUMN"][1]["2004-12-01"], 225) + self.assertEqual(result["EXTRA_STRING_COLUMN"][1]["2004-12-01"], "OFF") + + self.assertFloatEqual(result["MISFIT:WWCT:OP_2"][0]["2004-12-01"], 0.617793) + self.assertFloatEqual(result["MISFIT:WWCT:OP_2"][24]["2004-12-01"], 0.256436) + + self.assertFloatEqual(result["MISFIT:TOTAL"][0]["2000-02-01"], 7236.322836) + self.assertFloatEqual(result["MISFIT:TOTAL"][0]["2004-12-01"], 7236.322836) + self.assertFloatEqual(result["MISFIT:TOTAL"][24]["2004-12-01"], 2261.726621) + + + with self.assertRaises(KeyError): + realization_13 = result.loc[60] + + column_count = len(result.columns) + self.assertEqual(result.dtypes[0], numpy.float64) + self.assertEqual(result.dtypes[column_count - 1], numpy.object) + self.assertEqual(result.dtypes[column_count - 2], numpy.int64) diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_data_collector.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_data_collector.py new file mode 100644 index 0000000000..f23af07a9f --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_data_collector.py @@ -0,0 +1,27 @@ +import math + +from ert.enkf.export import GenDataCollector +from ert.test import ErtTestContext, ExtendedTestCase + +class GenDataCollectorTest(ExtendedTestCase): + + + def test_gen_data_collector(self): + config = self.createTestPath("Statoil/config/with_GEN_DATA_RFT/config") + with ErtTestContext("python/enkf/export/gen_data_collector", config) as context: + ert = context.getErt() + + with self.assertRaises(KeyError): + data = GenDataCollector.loadGenData(ert, "default" , "RFT_XX" , 5) + + with self.assertRaises(ValueError): + data = GenDataCollector.loadGenData(ert, "default" , "RFT_WI_1" , 90) + + data1 = GenDataCollector.loadGenData(ert, "default" , "RFT_WI_1" , 9) + data2 = GenDataCollector.loadGenData(ert, "default" , "RFT_WI_2" , 5) + + self.assertFloatEqual( data1[0][0] , 346.088074) + self.assertFloatEqual( data1[24][1] , 364.461090) + self.assertFloatEqual( data2[0][1] , 263.419434) + + self.assertTrue( math.isnan( data2[0][0] ) ) diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_data_observation_collector.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_data_observation_collector.py new file mode 100644 index 0000000000..465188b25e --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_data_observation_collector.py @@ -0,0 +1,33 @@ +from ert.enkf.export import GenDataObservationCollector +from ert.test import ErtTestContext, ExtendedTestCase + + +class GenDataObservationCollectorTest(ExtendedTestCase): + + def test_gen_data_collector(self): + config = self.createTestPath("local/custom_kw/mini_config") + with ErtTestContext("python/enkf/export/gen_data_observation_collector", config) as context: + ert = context.getErt() + + obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 1) + self.assertEqual(obs_key, "GEN_PERLIN_1") + + obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 2) + self.assertEqual(obs_key, "GEN_PERLIN_2") + + obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 3) + self.assertEqual(obs_key, "GEN_PERLIN_3") + + obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLIN", 4) + self.assertIsNone(obs_key) + + obs_key = GenDataObservationCollector.getObservationKeyForDataKey(ert, "PERLINk", 1) + self.assertIsNone(obs_key) + + data = GenDataObservationCollector.loadGenDataObservations(ert, "default", ["GEN_PERLIN_1", "GEN_PERLIN_3"]) + + self.assertFloatEqual(data["GEN_PERLIN_1"][0], -0.616789) + self.assertFloatEqual(data["STD_GEN_PERLIN_1"][0], 0.2) + + with self.assertRaises(KeyError): + data["GEN_PERLIN_2"] \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_kw_collector.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_kw_collector.py new file mode 100644 index 0000000000..8d09c65318 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_gen_kw_collector.py @@ -0,0 +1,39 @@ +from ert.enkf.export import GenKwCollector +from ert.test import ErtTestContext, ExtendedTestCase + +class GenKwCollectorTest(ExtendedTestCase): + + def setUp(self): + self.config = self.createTestPath("Statoil/config/with_data/config") + + + def test_gen_kw_collector(self): + + with ErtTestContext("python/enkf/export/gen_kw_collector", self.config) as context: + ert = context.getErt() + + data = GenKwCollector.loadAllGenKwData(ert, "default") + + self.assertFloatEqual(data["FLUID_PARAMS:SGCR"][0], 0.018466) + self.assertFloatEqual(data["FLUID_PARAMS:SGCR"][24], 0.221049) + + self.assertFloatEqual(data["GRID_PARAMS:MULTPV3"][0], 2.227307) + self.assertFloatEqual(data["GRID_PARAMS:MULTPV3"][12], 5.899703) + + self.assertFloatEqual(data["LOG10_MULTFLT:F3"][0], -3.008949) + self.assertFloatEqual(data["LOG10_MULTFLT:F3"][24], -1.051446) + + realization_20 = data.loc[20] + + with self.assertRaises(KeyError): + realization_60 = data.loc[60] + + + + data = GenKwCollector.loadAllGenKwData(ert, "default", ["FLUID_PARAMS:SGCR", "LOG10_MULTFLT:F3"]) + + self.assertFloatEqual(data["FLUID_PARAMS:SGCR"][0], 0.018466) + self.assertFloatEqual(data["LOG10_MULTFLT:F3"][0], -3.008949) + + with self.assertRaises(KeyError): + data["GRID_PARAMS:MULTPV3"] diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_misfit_collector.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_misfit_collector.py new file mode 100644 index 0000000000..69b28e8032 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_misfit_collector.py @@ -0,0 +1,26 @@ +from ert.enkf.export import MisfitCollector +from ert.test import ErtTestContext, ExtendedTestCase + +class MisfitCollectorTest(ExtendedTestCase): + + def setUp(self): + self.config = self.createTestPath("Statoil/config/with_data/config") + + def test_misfit_collector(self): + + with ErtTestContext("python/enkf/export/misfit_collector", self.config) as context: + ert = context.getErt() + data = MisfitCollector.loadAllMisfitData(ert, "default") + + self.assertFloatEqual(data["MISFIT:WWCT:OP_2"][0], 0.617793) + self.assertFloatEqual(data["MISFIT:WWCT:OP_2"][24], 0.256436) + + self.assertFloatEqual(data["MISFIT:TOTAL"][0],7236.322836) + self.assertFloatEqual(data["MISFIT:TOTAL"][24], 2261.726621) + + + realization_20 = data.loc[20] + + with self.assertRaises(KeyError): + realization_60 = data.loc[60] + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_numpy_and_pandas.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_numpy_and_pandas.py new file mode 100644 index 0000000000..f83ddfcfcb --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_numpy_and_pandas.py @@ -0,0 +1,81 @@ +import numpy +from pandas import MultiIndex, DataFrame, pandas +from ert.test import ExtendedTestCase + + +class NumpyAndPandasTest(ExtendedTestCase): + + def test_numpy(self): + data = numpy.empty(shape=(10, 10), dtype=numpy.float64) + data.fill(numpy.nan) + + self.assertTrue(numpy.isnan(data[0][0])) + self.assertTrue(numpy.isnan(data[9][9])) + + with self.assertRaises(IndexError): + v = data[10][9] + + data[5][5] = 1.0 + + self.assertEqual(data[5][5], 1.0) + + data[0] = 5.0 + + test_data = numpy.empty(shape=10) + test_data.fill(5.0) + + self.assertTrue(numpy.array_equal(data[0], test_data)) + + data = numpy.transpose(data) + + self.assertTrue(numpy.array_equal(data[:,0], test_data)) + + row = data[0] + row[5] = 11 + self.assertEqual(data[0][5], 11) + + + def test_pandas_join(self): + + multi_index = MultiIndex.from_product([[1, 2], ["A", "B", "C"]], names=["REALIZATION", "LABEL"]) + + data = DataFrame(data=[[1, 2, 3], [2, 4, 6], [4, 8, 12]] * 2, index=multi_index, columns=["C1", "C2", "C3"]) + + new_column = DataFrame(data=[4.0, 4.4, 4.8], index=[1, 2, 3], columns=["C4"]) + new_column.index.name = "REALIZATION" + + result = data.join(new_column, how='inner') + + self.assertFloatEqual(result["C4"][1]["A"], 4.0) + self.assertFloatEqual(result["C4"][1]["B"], 4.0) + self.assertFloatEqual(result["C4"][1]["C"], 4.0) + + self.assertFloatEqual(result["C4"][2]["A"], 4.4) + self.assertFloatEqual(result["C4"][2]["B"], 4.4) + self.assertFloatEqual(result["C4"][2]["C"], 4.4) + + + + def test_pandas_concatenate(self): + + d1 = DataFrame(data=[2, 4, 6, 8], columns=["A"], index=[1, 2, 3, 4]) + d2 = DataFrame(data=[[1, 1.1], [3, 3.3], [5, 5.5], [7, 7.7], [9, 9.9]], columns=["A", "B"], index=[1, 2, 3, 4, 5]) + + result = pandas.concat([d1, d2], keys=[1, 2]) + + self.assertEqual(result["A"][1][2], 4) + self.assertEqual(result["A"][2][2], 3) + self.assertTrue(numpy.isnan(result["B"][1][1])) + self.assertFloatEqual(result["B"][2][4], 7.7) + + + def test_pandas_extend_index(self): + d1 = DataFrame(data=[2, 4, 6, 8], columns=["A"], index=[1, 2, 3, 4]) + d1.index.name = "first" + + d1["second"] = "default" + d1.set_index(["second"], append=True, inplace=True) + self.assertEqual(d1.index.names, ["first", "second"]) + + d1 = d1.reorder_levels(["second", "first"]) + self.assertEqual(d1.index.names, ["second", "first"]) diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_summary_collector.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_summary_collector.py new file mode 100644 index 0000000000..85c9f8e01d --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_summary_collector.py @@ -0,0 +1,37 @@ +from ert.enkf.export import SummaryCollector +from ert.test import ErtTestContext, ExtendedTestCase + +class SummaryCollectorTest(ExtendedTestCase): + + def setUp(self): + self.config = self.createTestPath("Statoil/config/with_data/config") + + + def test_summary_collector(self): + + with ErtTestContext("python/enkf/export/summary_collector", self.config) as context: + + ert = context.getErt() + + data = SummaryCollector.loadAllSummaryData(ert, "default") + + self.assertFloatEqual(data["WWCT:OP_2"][0]["2000-02-01"], 0.000389) + self.assertFloatEqual(data["WWCT:OP_2"][24]["2000-02-01"], 0.000279) + + self.assertFloatEqual(data["FOPR"][0]["2000-02-01"], 19997.0) + self.assertFloatEqual(data["FOPR"][0]["2004-12-01"], 6563.947266) + + + realization_20 = data.loc[20] + + with self.assertRaises(KeyError): + realization_60 = data.loc[60] + + + data = SummaryCollector.loadAllSummaryData(ert, "default", ["WWCT:OP_2", "WWCT:OP_3"]) + + self.assertFloatEqual(data["WWCT:OP_2"][0]["2000-02-01"], 0.000389) + self.assertFloatEqual(data["WWCT:OP_3"][0]["2000-02-01"], 0.000188) + + with self.assertRaises(KeyError): + data["FOPR"] diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_summary_observation_collector.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_summary_observation_collector.py new file mode 100644 index 0000000000..607f36d760 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/export/test_summary_observation_collector.py @@ -0,0 +1,42 @@ +from ert.enkf.export import SummaryObservationCollector +from ert.test import ErtTestContext, ExtendedTestCase + +class SummaryObservationCollectorTest(ExtendedTestCase): + + def setUp(self): + self.config = self.createTestPath("Statoil/config/with_data/config") + + + def test_summary_observation_collector(self): + + with ErtTestContext("python/enkf/export/summary_observation_collector", self.config) as context: + + ert = context.getErt() + + self.assertTrue(SummaryObservationCollector.summaryKeyHasObservations(ert, "FOPT")) + self.assertFalse(SummaryObservationCollector.summaryKeyHasObservations(ert, "FGIR")) + + keys = SummaryObservationCollector.getAllObservationKeys(ert) + self.assertTrue("FOPT" in keys) + self.assertTrue("RPR:2" in keys) + + data = SummaryObservationCollector.loadObservationData(ert, "default") + + self.assertFloatEqual(data["RPR:2"]["2001-01-01"], 278) + self.assertFloatEqual(data["STD_RPR:2"]["2001-01-01"], 41.7) + + self.assertFloatEqual(data["FOPT"]["2000-02-01"], 619907.0) + self.assertFloatEqual(data["STD_FOPT"]["2000-02-01"], 61990.7) + + + with self.assertRaises(KeyError): + fgir = data["FGIR"] + + + data = SummaryObservationCollector.loadObservationData(ert, "default", ["RPR:3"]) + + self.assertFloatEqual(data["RPR:3"]["2001-01-01"], 283.5) + self.assertFloatEqual(data["STD_RPR:3"]["2001-01-01"], 2) + + with self.assertRaises(KeyError): + data["FOPR"] diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/plot/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/enkf/plot/CMakeLists.txt new file mode 100644 index 0000000000..556c734166 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/plot/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_plot_data.py +) + +add_python_package("python.tests.ert.enkf.plot" ${PYTHON_INSTALL_PREFIX}/tests/ert/enkf/plot "${TEST_SOURCES}" False) + +addPythonTest(ert.enkf.plot.plot_block_data tests.ert.enkf.plot.test_plot_data.PlotDataTest LABELS StatoilData) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/plot/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/plot/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/plot/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/plot/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/plot/test_plot_data.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/plot/test_plot_data.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/plot/test_plot_data.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/plot/test_plot_data.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_active_list.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_active_list.py new file mode 100644 index 0000000000..53a3c089a2 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_active_list.py @@ -0,0 +1,30 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_active_list.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +from ert.enkf import ActiveList +from ert.enkf import ActiveMode +from ert.test import ExtendedTestCase + + + +class ActiveListTest(ExtendedTestCase): + + def test_create(self): + active_list = ActiveList() + self.assertEqual( active_list.getMode() , ActiveMode.ALL_ACTIVE ) + active_list.addActiveIndex( 10 ) + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_analysis_config.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_analysis_config.py similarity index 84% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_analysis_config.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_analysis_config.py index 201f858173..c6cd103e48 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_analysis_config.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_analysis_config.py @@ -38,3 +38,9 @@ def test_analysis_modules(self): ac = AnalysisConfig() self.assertIsNone( ac.activeModuleName() ) self.assertIsNotNone( ac.getModuleList() ) + + def test_analysis_config_global_std_scaling(self): + ac = AnalysisConfig() + self.assertFloatEqual(ac.getGlobalStdScaling(), 1.0) + ac.setGlobalStdScaling(0.77) + self.assertFloatEqual(ac.getGlobalStdScaling(), 0.77) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_analysis_iter_config.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_analysis_iter_config.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_analysis_iter_config.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_analysis_iter_config.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_block_obs.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_block_obs.py new file mode 100644 index 0000000000..9363c204fe --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_block_obs.py @@ -0,0 +1,55 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_block_obs.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import os + +from ert.enkf import BlockObservation +from ert.enkf import ActiveList, FieldConfig +from ert.test import ExtendedTestCase +from ert.ecl import EclGrid + + +class BlockObsTest(ExtendedTestCase): + + def test_create(self): + grid = EclGrid.createRectangular( (10,20,5) , (1,1,1) ) + field_config = FieldConfig("PRESSURE" , grid) + block_obs = BlockObservation("P-CONFIG" , field_config , grid) + + self.assertEqual( len(block_obs) , 0 ) + + block_obs.addPoint(1,2,3,100,25) + self.assertEqual( len(block_obs) , 1 ) + self.assertEqual( block_obs.getValue(0) , 100 ) + self.assertEqual( block_obs.getStd(0) , 25 ) + self.assertEqual( block_obs.getStdScaling(0) , 1 ) + + block_obs.addPoint(1,2,4,200,50) + self.assertEqual( len(block_obs) , 2 ) + self.assertEqual( block_obs.getValue(1) , 200 ) + self.assertEqual( block_obs.getStd(1) , 50 ) + self.assertEqual( block_obs.getStdScaling(1) , 1 ) + + active_list = ActiveList( ) + block_obs.updateStdScaling( 0.50 , active_list ) + self.assertEqual( block_obs.getStdScaling(0) , 0.50 ) + self.assertEqual( block_obs.getStdScaling(1) , 0.50 ) + + active_list.addActiveIndex( 1 ) + block_obs.updateStdScaling( 2.00 , active_list ) + self.assertEqual( block_obs.getStdScaling(0) , 0.50 ) + self.assertEqual( block_obs.getStdScaling(1) , 2.00 ) + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_custom_kw_config_set.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_custom_kw_config_set.py new file mode 100644 index 0000000000..a39931d404 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_custom_kw_config_set.py @@ -0,0 +1,80 @@ +import os +from ert.enkf import CustomKWConfigSet +from ert.enkf.data import CustomKWConfig +from ert.enkf.enkf_fs import EnkfFs +from ert.enkf.enkf_main import EnKFMain +from ert.test import ExtendedTestCase +from ert.test.ert_test_context import ErtTestContext +from ert.test.test_area import TestAreaContext +from ert.util.stringlist import StringList + + +class CustomKWConfigSetTest(ExtendedTestCase): + + def createCustomKWConfig(self, name, data): + with TestAreaContext("python/enkf/custom_kw_config_set_config") as test_area: + self.createResultFile("result_file", data) + + config = CustomKWConfig(name, "") + config.parseResultFile("result_file", StringList()) + + return config + + def createResultFile(self, filename, data): + with open(filename, "w") as output_file: + for key in data: + output_file.write("%s %s\n" % (key, data[key])) + + + def test_creation(self): + config_set = CustomKWConfigSet() + + config = self.createCustomKWConfig("TEST", {"VALUE_1": 0.5, "VALUE_2": 5, "VALUE_3": "string", "VALUE_4": "true"}) + self.assertItemsEqual(config.getKeys(), ["VALUE_1", "VALUE_2", "VALUE_3", "VALUE_4"]) + + config_set.addConfig(config) + keys = config_set.getStoredConfigKeys() + self.assertItemsEqual(keys, ["TEST"]) + + config_set.reset() + self.assertTrue(len(config_set.getStoredConfigKeys()) == 0) + + + def test_fwrite_and_fread(self): + with TestAreaContext("python/enkf/custom_kw_config_set_fwrite") as test_area: + trees_config = self.createCustomKWConfig("TREES", {"OAK": 0.1, "SPRUCE": 5, "FIR": "pines", "PALM": "coconut"}) + insects_config = self.createCustomKWConfig("INSECTS", {"MOSQUITO": "annoying", "FLY": 3.14, "BEETLE": 0.5}) + + config_set = CustomKWConfigSet() + config_set.addConfig(trees_config) + config_set.addConfig(insects_config) + + self.assertItemsEqual(config_set.getStoredConfigKeys(), ["TREES", "INSECTS"]) + + config_set.fwrite("config_set") + + self.assertTrue(os.path.exists("config_set")) + + config_set = CustomKWConfigSet("config_set") + + self.assertItemsEqual(config_set.getStoredConfigKeys(), ["TREES", "INSECTS"]) + + trees_config_from_file = CustomKWConfig("TREES", None) + config_set.updateConfig(trees_config_from_file) + + for key in ["OAK", "SPRUCE", "FIR", "PALM"]: + self.assertEqual(trees_config_from_file.indexOfKey(key), trees_config.indexOfKey(key)) + self.assertTrue(trees_config_from_file.keyIsDouble(key) == trees_config.keyIsDouble(key)) + + + insects_config_from_file = CustomKWConfig("INSECTS", None) + config_set.updateConfig(insects_config_from_file) + + for key in ["MOSQUITO", "FLY", "BEETLE"]: + self.assertEqual(insects_config_from_file.indexOfKey(key), insects_config.indexOfKey(key)) + self.assertTrue(insects_config_from_file.keyIsDouble(key) == insects_config.keyIsDouble(key)) + + + + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_ecl_config.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_ecl_config.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_ecl_config.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_ecl_config.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf.py similarity index 85% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf.py index 58a512d3de..b553ece252 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (C) 2012 Statoil ASA, Norway. # # The file 'test_enkf.py' is part of ERT - Ensemble based Reservoir Tool. @@ -19,12 +18,10 @@ from ert.util import BoolVector -from ert.enkf import EnsConfig, AnalysisConfig, ModelConfig, SiteConfig, EclConfig, PlotConfig, EnkfObs, ErtTemplates, EnkfFs, EnKFState, EnkfStateType, EnkfVarType, ObsVector , RunArg +from ert.enkf import EnsembleConfig, AnalysisConfig, ModelConfig, SiteConfig, EclConfig, PlotConfig, EnkfObs, ErtTemplates, EnkfFs, EnKFState, EnkfStateType, EnkfVarType, ObsVector , RunArg from ert.enkf.data import EnkfConfigNode from ert.enkf.enkf_main import EnKFMain -from ert.enkf.enums import EnkfObservationImplementationType, LoadFailTypeEnum, EnkfInitModeEnum, ErtImplType, RealizationStateEnum , EnkfRunType -from ert.enkf.enums.enkf_field_file_format_enum import EnkfFieldFileFormatEnum -from ert.enkf.enums.enkf_truncation_type import EnkfTruncationType +from ert.enkf.enums import EnkfObservationImplementationType, LoadFailTypeEnum, EnkfInitModeEnum, ErtImplType, RealizationStateEnum , EnkfRunType, EnkfFieldFileFormatEnum, EnkfTruncationType, ActiveMode from ert.enkf.observations.summary_observation import SummaryObservation from ert.test import ExtendedTestCase , TestAreaContext @@ -33,19 +30,22 @@ class EnKFTest(ExtendedTestCase): def setUp(self): self.case_directory = self.createTestPath("local/simple_config/") - self.site_config_file = os.getenv("ERT_SITE_CONFIG") def test_bootstrap( self ): with TestAreaContext("enkf_test", store_area=True) as work_area: work_area.copy_directory(self.case_directory) - main = EnKFMain("simple_config/minimum_config", self.site_config_file) + main = EnKFMain("simple_config/minimum_config") self.assertTrue(main, "Load failed") main.free() - def test_enum(self): + def test_site_bootstrap( self ): + with TestAreaContext("enkf_test", store_area=True) as work_area: + EnKFMain.loadSiteConfig() + + def test_enum(self): self.assertEnumIsFullyDefined(EnkfVarType, "enkf_var_type", "libenkf/include/ert/enkf/enkf_types.h") self.assertEnumIsFullyDefined(EnkfStateType, "state_enum", "libenkf/include/ert/enkf/enkf_types.h") self.assertEnumIsFullyDefined(ErtImplType, "ert_impl_type", "libenkf/include/ert/enkf/enkf_types.h") @@ -57,13 +57,14 @@ def test_enum(self): self.assertEnumIsFullyDefined(EnkfObservationImplementationType, "obs_impl_type", "libenkf/include/ert/enkf/obs_vector.h") self.assertEnumIsFullyDefined(LoadFailTypeEnum, "load_fail_type", "libenkf/include/ert/enkf/summary_config.h") self.assertEnumIsFullyDefined(EnkfFieldFileFormatEnum, "field_file_format_type", "libenkf/include/ert/enkf/field_config.h" ) - + self.assertEnumIsFullyDefined(ActiveMode , "active_mode_type" , "libenkf/include/ert/enkf/enkf_types.h") + def test_observations(self): with TestAreaContext("enkf_test") as work_area: work_area.copy_directory(self.case_directory) - main = EnKFMain("simple_config/minimum_config", self.site_config_file) + main = EnKFMain("simple_config/minimum_config") count = 10 summary_key = "test_key" @@ -71,7 +72,7 @@ def test_observations(self): summary_observation_node = EnkfConfigNode.createSummaryConfigNode(summary_key, LoadFailTypeEnum.LOAD_FAIL_EXIT) observation_vector = ObsVector(EnkfObservationImplementationType.SUMMARY_OBS, observation_key, summary_observation_node, count) - main.getObservations().addObservationVector(observation_key, observation_vector) + main.getObservations().addObservationVector(observation_vector) values = [] for index in range(0, count): @@ -82,13 +83,18 @@ def test_observations(self): self.assertEqual(observation_vector.getNode(index), summary_observation_node) self.assertEqual(value, summary_observation_node.getValue()) values.append((index, value, std)) + observations = main.getObservations() test_vector = observations[observation_key] + index = 0 + for node in test_vector: + self.assertTrue( isinstance( node , SummaryObservation )) + self.assertEqual( node.getValue( ) , index * 10.5 ) + index += 1 - self.assertListEqual(range(10), [report_step for report_step in test_vector]) - + self.assertEqual(observation_vector, test_vector) for index, value, std in values: self.assertTrue(test_vector.isActive(index)) @@ -103,15 +109,15 @@ def test_observations(self): main.free() - + def test_config( self ): with TestAreaContext("enkf_test") as work_area: work_area.copy_directory(self.case_directory) - main = EnKFMain("simple_config/minimum_config", self.site_config_file) + main = EnKFMain("simple_config/minimum_config") - self.assertIsInstance(main.ensembleConfig(), EnsConfig) + self.assertIsInstance(main.ensembleConfig(), EnsembleConfig) self.assertIsInstance(main.analysisConfig(), AnalysisConfig) self.assertIsInstance(main.getModelConfig(), ModelConfig) #self.assertIsInstance(main.local_config(), LocalConfig) #warn: Should this be None? @@ -138,14 +144,14 @@ def test_enkf_create_config_file(self): with TestAreaContext("python/ens_condif/create_config" , store_area = True) as ta: EnKFMain.createNewConfig(config_file, "storage" , firste_case_name, dbase_type, num_realizations) - main = EnKFMain(config_file, self.site_config_file) + main = EnKFMain(config_file) self.assertEqual(main.getEnsembleSize(), num_realizations) def test_run_context(self): with TestAreaContext("enkf_test") as work_area: work_area.copy_directory(self.case_directory) - main = EnKFMain("simple_config/minimum_config", self.site_config_file) + main = EnKFMain("simple_config/minimum_config") fs_manager = main.getEnkfFsManager() fs = fs_manager.getCurrentFileSystem( ) iactive = BoolVector(initial_size = 10 , default_value = True) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_fs.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_fs.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_fs.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_fs.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_fs_manager1.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_fs_manager1.py similarity index 61% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_fs_manager1.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_fs_manager1.py index 3f3bbd4047..03c8ca6b12 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_fs_manager1.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_fs_manager1.py @@ -20,11 +20,26 @@ def test_create(self): ert = testContext.getErt() fsm = ert.getEnkfFsManager() + self.assertTrue(fsm.isCaseMounted("default")) + self.assertTrue(fsm.caseExists("default")) + self.assertTrue(fsm.caseHasData("default")) + self.assertFalse(fsm.isCaseRunning("default")) + fs = fsm.getCurrentFileSystem() self.assertEqual(2, fs.refCount()) self.assertEqual(1, fsm.getFileSystemCount()) + self.assertFalse(fsm.isCaseMounted("newFS")) + self.assertFalse(fsm.caseExists("newFS")) + self.assertFalse(fsm.caseHasData("newFS")) + self.assertFalse(fsm.isCaseRunning("newFS")) + fs2 = fsm.getFileSystem("newFS") self.assertEqual(2, fsm.getFileSystemCount()) self.assertEqual(1, fs2.refCount()) + self.assertTrue(fsm.isCaseMounted("newFS")) + self.assertTrue(fsm.caseExists("newFS")) + self.assertFalse(fsm.caseHasData("newFS")) + self.assertFalse(fsm.isCaseRunning("newFS")) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_fs_manager2.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_fs_manager2.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_fs_manager2.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_fs_manager2.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_library.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_library.py similarity index 72% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_library.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_library.py index 97955629a9..689cf2de4a 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_library.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_library.py @@ -1,7 +1,7 @@ import os from ert.ecl import EclSum from ert.enkf import AnalysisConfig, EclConfig, GenKwConfig, EnkfConfigNode, SiteConfig, ObsVector -from ert.enkf import GenDataConfig, FieldConfig, EnkfFs, EnkfObs, EnKFState, EnsConfig +from ert.enkf import GenDataConfig, FieldConfig, EnkfFs, EnkfObs, EnKFState, EnsembleConfig from ert.enkf import ErtTemplate, ErtTemplates, LocalConfig, ModelConfig, PlotConfig from ert.enkf.enkf_main import EnKFMain @@ -12,12 +12,9 @@ class EnKFLibraryTest(ExtendedTestCase): def setUp(self): self.case_directory = self.createTestPath("local/simple_config/") - self.site_config = os.getenv("ERT_SITE_CONFIG") - def test_failed_class_creation(self): - classes = [FieldConfig, GenDataConfig, - EnkfConfigNode, EnkfObs, EnKFState, EnsConfig, + classes = [EnkfConfigNode, EnKFState, ErtTemplate, ErtTemplates, LocalConfig, ModelConfig, PlotConfig, SiteConfig] for cls in classes: @@ -29,7 +26,7 @@ def test_ecl_config_creation(self): with TestAreaContext("enkf_library_test") as work_area: work_area.copy_directory(self.case_directory) - main = EnKFMain("simple_config/minimum_config", self.site_config) + main = EnKFMain("simple_config/minimum_config") self.assertIsInstance(main.analysisConfig(), AnalysisConfig) self.assertIsInstance(main.eclConfig(), EclConfig) @@ -45,4 +42,15 @@ def test_ecl_config_creation(self): main.free() + def test_enkf_state(self): + with TestAreaContext("enkf_library_test") as work_area: + work_area.copy_directory(self.case_directory) + main = EnKFMain("simple_config/minimum_config") + state = main.getRealisation( 0 ) + + with self.assertRaises(TypeError): + state.addSubstKeyword( "GEO_ID" , 45) + + state.addSubstKeyword("GEO_ID" , "45") + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_load_results_manually.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_load_results_manually.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_enkf_load_results_manually.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_load_results_manually.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_obs.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_obs.py new file mode 100644 index 0000000000..f647aadc1f --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_enkf_obs.py @@ -0,0 +1,137 @@ +from ert.test import ErtTestContext +from ert.test import ExtendedTestCase + +from ert.ecl import EclGrid, EclSum +from ert.sched import History + +from ert.util import BoolVector,IntVector +from ert.enkf import ActiveMode, EnsembleConfig +from ert.enkf import ObsVector , LocalObsdata, EnkfObs, TimeMap + + +class EnKFObsTest(ExtendedTestCase): + def setUp(self): + self.config_file = self.createTestPath("Statoil/config/obs_testing/config") + self.obs_config = self.createTestPath("Statoil/config/obs_testing/observations") + self.obs_config2 = self.createTestPath("Statoil/config/obs_testing/observations2") + self.refcase = self.createTestPath("Statoil/config/obs_testing/EXAMPLE_01_BASE") + self.grid = self.createTestPath("Statoil/config/obs_testing/EXAMPLE_01_BASE.EGRID") + + + def testObs(self): + with ErtTestContext("obs_test", self.config_file) as test_context: + ert = test_context.getErt() + obs = ert.getObservations() + + self.assertEqual(31, len(obs)) + for v in obs: + self.assertTrue(isinstance(v, ObsVector)) + + with self.assertRaises(IndexError): + v = obs[-1] + + with self.assertRaises(IndexError): + v = obs[40] + + with self.assertRaises(KeyError): + v = obs["No-this-does-not-exist"] + + v1 = obs["WWCT:OP_3"] + v2 = obs["GOPT:OP"] + mask = BoolVector(True, ert.getEnsembleSize()) + current_fs = ert.getEnkfFsManager().getCurrentFileSystem() + + self.assertTrue(v1.hasData(mask, current_fs)) + self.assertFalse(v2.hasData(mask, current_fs)) + + local_node = v1.createLocalObs( ) + self.assertEqual( len(local_node.getStepList()) , len(v1.getStepList())) + for t1,t2 in zip( local_node.getStepList() , v1.getStepList()): + self.assertEqual( t1 , t2 ) + + + + def test_obs_block_scale_std(self): + with ErtTestContext("obs_test_scale", self.config_file) as test_context: + ert = test_context.getErt() + fs = ert.getEnkfFsManager().getCurrentFileSystem() + active_list = IntVector( ) + active_list.initRange(0 , ert.getEnsembleSize() , 1 ) + + obs = ert.getObservations() + obs_data = LocalObsdata( "OBSxx" ) + obs_vector = obs["WWCT:OP_1"] + obs_data.addObsVector( obs_vector ) + scale_factor = obs.scaleCorrelatedStd( fs , obs_data , active_list ) + + for obs_node in obs_vector: + for index in range(len(obs_node)): + self.assertEqual( scale_factor , obs_node.getStdScaling( index )) + + + + + def test_obs_block_all_active_local(self): + with ErtTestContext("obs_test_all_active", self.config_file) as test_context: + ert = test_context.getErt() + obs = ert.getObservations() + obs_data = obs.getAllActiveLocalObsdata( ) + + self.assertEqual( len(obs_data) , len(obs) ) + for obs_vector in obs: + self.assertTrue( obs_vector.getObservationKey() in obs_data ) + + tstep_list1 = obs_vector.getStepList() + local_node = obs_data[ obs_vector.getObservationKey() ] + + self.assertTrue( tstep_list1 , local_node.getStepList()) + active_list = local_node.getActiveList() + self.assertEqual( active_list.getMode() , ActiveMode.ALL_ACTIVE ) + + + + def test_create(self): + ensemble_config = EnsembleConfig() + obs = EnkfObs(ensemble_config) + self.assertEqual( len(obs) , 0 ) + self.assertFalse( obs.load(self.obs_config) ) + self.assertEqual( len(obs) , 0 ) + + + time_map = TimeMap() + obs = EnkfObs(ensemble_config , external_time_map = time_map) + self.assertEqual( len(obs) , 0 ) + + grid = EclGrid(self.grid) + refcase = EclSum(self.refcase) + + history = History.alloc_from_refcase( refcase , False ) + obs = EnkfObs( ensemble_config , grid = grid , history = history ) + with self.assertRaises(IOError): + obs.load("/does/not/exist") + + self.assertTrue( obs.load(self.obs_config) ) + self.assertEqual( len(obs) , 32 ) + obs.clear() + self.assertEqual( len(obs) , 0 ) + + obs.load(self.obs_config) + self.assertEqual( len(obs) , 32 ) + self.assertFalse( "RFT2" in obs ) + obs.load(self.obs_config2) + self.assertEqual( len(obs) , 33 ) + self.assertTrue( "RFT2" in obs ) + + + + def test_ert_obs_reload(self): + with ErtTestContext("obs_test_reload", self.config_file) as test_context: + ert = test_context.getErt() + obs = ert.getObservations() + self.assertEqual( len(obs) , 31 ) + ert.loadObservations("observations2") + self.assertEqual( len(obs) , 1 ) + + ert.loadObservations("observations" , clear = False) + self.assertEqual( len(obs) , 32 ) + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_ensemble_config.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_ensemble_config.py new file mode 100644 index 0000000000..e5f64250e2 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_ensemble_config.py @@ -0,0 +1,17 @@ +from ert.test import ErtTestContext +from ert.test import ExtendedTestCase + +from ert.util import BoolVector,IntVector +from ert.enkf import ActiveMode, EnsembleConfig +from ert.enkf import ObsVector , LocalObsdata + + +class EnsembleConfigTest(ExtendedTestCase): + + def test_create(self): + conf = EnsembleConfig( ) + self.assertEqual( len(conf) , 0 ) + self.assertFalse( "XYZ" in conf ) + + with self.assertRaises(KeyError): + node = conf["KEY"] diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_ert_context.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_ert_context.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_ert_context.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_ert_context.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_ert_log.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_ert_log.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_ert_log.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_ert_log.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_gen_obs.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_gen_obs.py new file mode 100644 index 0000000000..429a3852cc --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_gen_obs.py @@ -0,0 +1,52 @@ +import os.path + +from ert.test import ExtendedTestCase, TestAreaContext + +from ert.enkf import GenObservation,GenDataConfig,ActiveList + + + + +class GenObsTest(ExtendedTestCase): + def setUp(self): + pass + + + def test_create(self): + data_config = GenDataConfig("KEY") + with self.assertRaises(ValueError): + gen_obs = GenObservation("KEY" , data_config ) + + with TestAreaContext("gen_obs/create"): + with open("obs1.txt","w") as f: + f.write("10 5 12 6\n") + + with self.assertRaises(ValueError): + gen_obs = GenObservation("KEY" , data_config , scalar_value = (1,2) , obs_file = "obs1.txt") + + with self.assertRaises(TypeError): + gen_obs = GenObservation("KEY" , data_config , scalar_value = 1 ) + + with self.assertRaises(IOError): + gen_obs = GenObservation("KEY" , data_config , obs_file = "does/not/exist" ) + + gen_obs = GenObservation("KEY" , data_config , obs_file = "obs1.txt" , data_index = "10,20") + self.assertEqual( len(gen_obs) , 2 ) + self.assertEqual( gen_obs[0] , (10,5) ) + self.assertEqual( gen_obs[1] , (12,6) ) + + self.assertEqual( gen_obs.getValue(0) , 10 ) + self.assertEqual( gen_obs.getDataIndex(1) , 20 ) + self.assertEqual( gen_obs.getStdScaling(0) , 1 ) + self.assertEqual( gen_obs.getStdScaling(1) , 1 ) + + active_list = ActiveList( ) + gen_obs.updateStdScaling( 0.25 , active_list ) + self.assertEqual( gen_obs.getStdScaling(0) , 0.25 ) + self.assertEqual( gen_obs.getStdScaling(1) , 0.25 ) + + active_list.addActiveIndex( 1 ) + gen_obs.updateStdScaling( 2.00 , active_list ) + self.assertEqual( gen_obs.getStdScaling(0) , 0.25 ) + self.assertEqual( gen_obs.getStdScaling(1) , 2.00 ) + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_labscale.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_labscale.py new file mode 100644 index 0000000000..38db80bce9 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_labscale.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_labscale.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +from ert.enkf import ObsVector +from ert.test import ExtendedTestCase , ErtTestContext + + + +class LabScaleTest(ExtendedTestCase): + + + def testObs(self): + config_file = self.createTestPath("Statoil/config/labscale/config") + with ErtTestContext("labscale", config_file) as test_context: + ert = test_context.getErt() + obs = ert.getObservations() + + self.assertEqual(4, len(obs)) + for v in obs: + self.assertTrue(isinstance(v, ObsVector)) + + v1 = obs["WWCT_1"] + self.assertEqual( v1.activeStep() , 5 ) + node = v1.getNode( 5 ) + self.assertFloatEqual( node.getValue() , 0.00) + + v2 = obs["WWCT_2"] + self.assertEqual( v2.activeStep() , 31 ) + node = v2.getNode( 31 ) + self.assertFloatEqual( node.getValue() , 0.575828) + + v3 = obs["WWCT_3"] + self.assertEqual( v3.activeStep() , 73 ) + node = v3.getNode( 73 ) + self.assertFloatEqual( node.getValue() , 1.00) + + + bpr = obs["BPR"] + self.assertEqual( bpr.activeStep() , 31 ) + node = bpr.getNode( 31 ) + self.assertFloatEqual( node.getValue(0) , 10.284) + + + + def testObs_beijing(self): + config_file = self.createTestPath("Statoil/config/lab-beijing/labunits/config") + with ErtTestContext("labscale-beijing", config_file) as test_context: + ert = test_context.getErt() + obs = ert.getObservations() + + + v0 = obs["WCT0"] + self.assertEqual( v0.activeStep() , 18 ) + node = v0.getNode( 18 ) + self.assertEqual( node.getValue() , 0.12345 ) + + + v1 = obs["WCT1"] + self.assertEqual( v1.activeStep() , 18 ) + node = v1.getNode( 18 ) + self.assertEqual( node.getValue() , 0.12345 ) diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_linalg.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_linalg.py new file mode 100644 index 0000000000..0106b60c6e --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_linalg.py @@ -0,0 +1,39 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_labscale.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + + +from ert.enkf import ObsVector +from ert.util import Matrix +from ert.enkf.linalg import * + + +class LinalgTest(ExtendedTestCase): + + def test_num_PC(self): + S = Matrix(3,3) + s[0,0] = 1 + s[1,1] = 0.25 + s[2,2] = 0.125 + + with self.assertRaises(ValueError): + num_pc = numPC( S , -1 ) + + + with self.assertRaises(ValueError): + num_pc = numPC( S , 1.5 ) + + num_pc = numPC( S , 0.80 ) + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_local_obsdata_node.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_local_obsdata_node.py new file mode 100644 index 0000000000..3f6e922d55 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_local_obsdata_node.py @@ -0,0 +1,24 @@ +from ert.enkf import LocalObsdataNode +from ert.test import ExtendedTestCase + + +class LocalObsdataNodeTest(ExtendedTestCase): + def setUp(self): + pass + + def test_tstep(self): + node = LocalObsdataNode("KEY") + self.assertTrue( node.allTimeStepActive() ) + + with self.assertRaises(ValueError): + tstep_list = node.getStepList() + + node.addTimeStep(10) + self.assertFalse( node.allTimeStepActive() ) + + tstep_list = node.getStepList() + self.assertEqual( len(tstep_list) , 1 ) + self.assertEqual( tstep_list[0] , 10) + + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_meas_block.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_meas_block.py new file mode 100644 index 0000000000..cff889fdab --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_meas_block.py @@ -0,0 +1,103 @@ +import datetime + +from ert.test import TestAreaContext +from ert.test import ExtendedTestCase +from ert.util import BoolVector +from ert.enkf import MeasBlock + + + +class MeasBlockTest(ExtendedTestCase): + + + def test_create(self): + key = "OBS" + ens_size = 100 + obs_size = 77 + ens_mask = BoolVector( default_value = True , initial_size = ens_size ) + + ens_mask[67] = False + block = MeasBlock( key , obs_size , ens_mask) + self.assertEqual( block.getObsSize() , obs_size ) + self.assertEqual( block.getActiveEnsSize() , ens_size - 1) + self.assertEqual( block.getTotalEnsSize() , ens_size ) + + self.assertTrue( block.iensActive( 66 ) ) + self.assertFalse( block.iensActive( 67 ) ) + + + + + def test_update(self): + key = "OBS" + obs_size = 4 + ens_size = 10 + ens_mask = BoolVector( default_value = True , initial_size = ens_size ) + block = MeasBlock( key , obs_size , ens_mask) + + with self.assertRaises(TypeError): + block["String"] = 10 + + with self.assertRaises(TypeError): + block[10] = 10 + + with self.assertRaises(IndexError): + block[obs_size,0] = 10 + + with self.assertRaises(IndexError): + block[0,ens_size] = 10 + + #----------------------------------------------------------------- + + with self.assertRaises(TypeError): + a = block["String"] + + with self.assertRaises(TypeError): + a = block[10] + + with self.assertRaises(IndexError): + val = block[obs_size,0] + + with self.assertRaises(IndexError): + val = block[0,ens_size] + + block[1,2] = 3 + self.assertEqual( 3 , block[1,2] ) + + + + def test_inactive(self): + key = "OBS" + obs_size = 2 + ens_size = 10 + ens_mask = BoolVector( default_value = True , initial_size = ens_size ) + ens_mask[5] = False + block = MeasBlock( key , obs_size , ens_mask) + + self.assertFalse( block.iensActive( 5 )) + + with self.assertRaises(ValueError): + block[0,5] = 10 + + + + + def test_stat(self): + key = "OBS" + obs_size = 2 + ens_size = 10 + ens_mask = BoolVector( default_value = True , initial_size = ens_size ) + block = MeasBlock( key , obs_size , ens_mask) + + for iens in range(ens_size): + block[0,iens] = iens + block[1,iens] = iens + 1 + + self.assertEqual( 4.5 , block.igetMean( 0 )) + self.assertEqual( 5.5 , block.igetMean( 1 )) + + self.assertFloatEqual( 2.872281 , block.igetStd( 0 )) + self.assertFloatEqual( 2.872281 , block.igetStd( 1 )) + + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_meas_data.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_meas_data.py new file mode 100644 index 0000000000..eb0d85e3ef --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_meas_data.py @@ -0,0 +1,75 @@ +import datetime + +from ert.util import BoolVector +from ert.test import TestAreaContext +from ert.test import ExtendedTestCase +from ert.enkf import MeasBlock,MeasData + + + +class MeasDataTest(ExtendedTestCase): + + + def test_create(self): + ens_size = 10 + ens_mask = BoolVector( default_value = True , initial_size = ens_size ) + data = MeasData( ens_mask ) + self.assertEqual( len(data) , 0) + self.assertTrue( isinstance( data , MeasData )) + + block1 = data.addBlock( "OBS1" , 10 , 5 ) + block2 = data.addBlock( "OBS2" , 27 , 10 ) + + with self.assertRaises(TypeError): + data[1.782] + + with self.assertRaises(KeyError): + data["NO-this-does-not-exist"] + + with self.assertRaises(IndexError): + data[2] + + last0 = data[-1] + last1 = data[1] + self.assertEqual( last0 , last1 ) + + self.assertTrue( "OBS1-10" in data ) + self.assertTrue( "OBS2-27" in data ) + self.assertEqual( len(data) , 2) + + self.assertTrue( isinstance( block1 , MeasBlock )) + self.assertTrue( isinstance( block2 , MeasBlock )) + + self.assertEqual( block1.getObsSize() , 5 ) + self.assertEqual( block2.getObsSize() , 10 ) + + l = [] + for b in data: + l.append(b) + + self.assertEqual(len(l) , 2) + self.assertEqual(l[0] , block1) + self.assertEqual(l[1] , block2) + + + with self.assertRaises(ValueError): + S = data.createS() + + for iens in range(ens_size): + block1[0,iens] = 5 + block2[0,iens] = 10 + block2[1,iens] = 15 + + self.assertEqual( 3 , data.activeObsSize() ) + S = data.createS() + + self.assertEqual( S.dims() , (3 , ens_size) ) + + for iens in range(ens_size): + self.assertEqual( S[0,iens] , 5 ) + self.assertEqual( S[1,iens] , 10 ) + self.assertEqual( S[2,iens] , 15 ) + + + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_obs_block.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_obs_block.py new file mode 100644 index 0000000000..0cbea7eae4 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_obs_block.py @@ -0,0 +1,55 @@ +import datetime + +from ert.util import BoolVector +from ert.test import TestAreaContext +from ert.test import ExtendedTestCase +from ert.enkf import ObsBlock + + + +class ObsBlockTest(ExtendedTestCase): + + + def test_create(self): + block = ObsBlock("OBS" , 1000) + self.assertTrue( isinstance( block , ObsBlock )) + self.assertEqual( 1000 , block.totalSize()) + self.assertEqual( 0 , block.activeSize()) + + + + def test_access(self): + obs_size = 10 + block = ObsBlock("OBS" , obs_size) + + with self.assertRaises(IndexError): + block[100] = (1,1) + + with self.assertRaises(IndexError): + block[-1] = (1,1) + + with self.assertRaises(TypeError): + block[4] = 10 + + with self.assertRaises(TypeError): + block[4] = (1,1,9) + + #------ + + with self.assertRaises(IndexError): + v = block[100] + + with self.assertRaises(IndexError): + v = block[-1] + + block[0] = (10,1) + v = block[0] + self.assertEqual( v , (10,1)) + self.assertEqual( 1 , block.activeSize()) + + + + + + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_obs_data.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_obs_data.py new file mode 100644 index 0000000000..85dc2ff6f7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_obs_data.py @@ -0,0 +1,39 @@ +import datetime + +from ert.util import BoolVector , Matrix +from ert.test import TestAreaContext +from ert.test import ExtendedTestCase +from ert.enkf import ObsData , ObsBlock + + + + +class ObsDataTest(ExtendedTestCase): + + + def test_create(self): + obs_data = ObsData() + obs_size = 10 + block = obs_data.addBlock("OBS" , obs_size) + self.assertTrue( isinstance( block , ObsBlock )) + + block[0] = (10,10) + block[1] = (12,12) + D = obs_data.createDObs() + self.assertTrue( isinstance(D , Matrix )) + self.assertEqual( D.dims() , (2,1)) + + self.assertEqual( D[0,0] , 10 ) + self.assertEqual( D[1,0] , 12 ) + + obs_data.scaleMatrix( D ) + self.assertEqual( D[0,0] , 1 ) + self.assertEqual( D[1,0] , 1 ) + + R = obs_data.createR() + self.assertEqual( (2,2) , R.dims() ) + + + + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_run_arg.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_run_arg.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_run_arg.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_run_arg.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_runpath_list.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_runpath_list.py new file mode 100644 index 0000000000..bcc1d9ea01 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_runpath_list.py @@ -0,0 +1,39 @@ +from ert.cwrap import clib, CWrapper +from ert.test import ExtendedTestCase +from ert.enkf import RunpathList, RunpathNode + + +test_lib = clib.ert_load("libenkf") # create a local namespace +cwrapper = CWrapper(test_lib) + +runpath_list_alloc = cwrapper.prototype("runpath_list_obj runpath_list_alloc(char*)") + +class RunpathListTest(ExtendedTestCase): + + def test_runpath_list(self): + runpath_list = runpath_list_alloc("") + """ @type runpath_list: RunpathList """ + + self.assertEqual(len(runpath_list), 0) + + test_runpath_nodes = [RunpathNode(0, 0, "runpath0", "basename0"), RunpathNode(1, 0, "runpath1", "basename0")] + + runpath_node = test_runpath_nodes[0] + runpath_list.add(runpath_node.realization, runpath_node.iteration, runpath_node.runpath, runpath_node.basename) + + self.assertEqual(len(runpath_list), 1) + self.assertEqual(runpath_list[0], test_runpath_nodes[0]) + + runpath_node = test_runpath_nodes[1] + runpath_list.add(runpath_node.realization, runpath_node.iteration, runpath_node.runpath, runpath_node.basename) + + self.assertEqual(len(runpath_list), 2) + self.assertEqual(runpath_list[1], test_runpath_nodes[1]) + + for index, runpath_node in enumerate(runpath_list): + self.assertEqual(runpath_node, test_runpath_nodes[index]) + + + runpath_list.clear() + + self.assertEqual(len(runpath_list), 0) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_state_map.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_state_map.py similarity index 85% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_state_map.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_state_map.py index 12ae3238fe..e6d5c1cc5c 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_state_map.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_state_map.py @@ -89,3 +89,17 @@ def test_state_map_transitions(self): StateMap.isLegalTransition("error", "exception") + def test_active_list(self): + state_map = StateMap() + state_map[0] = RealizationStateEnum.STATE_INITIALIZED + state_map[2] = RealizationStateEnum.STATE_INITIALIZED + state_map[2] = RealizationStateEnum.STATE_HAS_DATA + + initialized = state_map.realizationList( RealizationStateEnum.STATE_INITIALIZED ) + self.assertEqual( len(initialized) , 1 ) + self.assertEqual( initialized[0] , 0 ) + + has_data = state_map.realizationList( RealizationStateEnum.STATE_HAS_DATA ) + self.assertEqual( len(has_data) , 1 ) + self.assertEqual( has_data[0] , 2) + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_key_matcher.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_key_matcher.py new file mode 100644 index 0000000000..fcd783fdc3 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_key_matcher.py @@ -0,0 +1,28 @@ +from ert.enkf import SummaryKeyMatcher +from ert.test import ExtendedTestCase + +class SummaryKeyMatcherTest(ExtendedTestCase): + + def test_creation(self): + matcher = SummaryKeyMatcher() + + self.assertTrue(len(matcher) == 0) + + matcher.addSummaryKey("F*") + self.assertTrue(len(matcher) == 1) + + matcher.addSummaryKey("F*") + self.assertTrue(len(matcher) == 1) + + matcher.addSummaryKey("FOPT") + self.assertTrue(len(matcher) == 2) + + self.assertItemsEqual(["F*", "FOPT"], matcher.keys()) + + self.assertTrue("FGIR" in matcher) + self.assertTrue("FOPT" in matcher) + self.assertFalse("TCPU" in matcher) + + self.assertTrue(matcher.isRequired("FOPT")) + self.assertFalse(matcher.isRequired("FGIR")) + self.assertFalse(matcher.isRequired("TCPU")) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_key_set.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_key_set.py new file mode 100644 index 0000000000..4c3a44e9ee --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_key_set.py @@ -0,0 +1,99 @@ +import os +from ert.enkf import SummaryKeySet +from ert.enkf.enkf_fs import EnkfFs +from ert.enkf.enkf_main import EnKFMain +from ert.test import ExtendedTestCase +from ert.test.ert_test_context import ErtTestContext +from ert.test.test_area import TestAreaContext + + +class SummaryKeySetTest(ExtendedTestCase): + + def test_creation(self): + + keys = SummaryKeySet() + + self.assertEqual(len(keys), 0) + + self.assertTrue(keys.addSummaryKey("FOPT")) + + self.assertEqual(len(keys), 1) + + self.assertTrue("FOPT" in keys) + + self.assertItemsEqual(["FOPT"], keys.keys()) + + self.assertTrue(keys.addSummaryKey("WWCT")) + + self.assertEqual(len(keys), 2) + + self.assertTrue("WWCT" in keys) + + self.assertItemsEqual(["WWCT", "FOPT"], keys.keys()) + + + + def test_read_only_creation(self): + with TestAreaContext("enkf/summary_key_set/read_only_write_test"): + keys = SummaryKeySet() + + keys.addSummaryKey("FOPT") + keys.addSummaryKey("WWCT") + + filename = "test.txt" + keys.writeToFile(filename) + + keys_from_file = SummaryKeySet(filename, read_only=True) + self.assertItemsEqual(keys.keys(), keys_from_file.keys()) + + self.assertTrue(keys_from_file.isReadOnly()) + self.assertFalse(keys_from_file.addSummaryKey("WOPR")) + + + def test_write_to_and_read_from_file(self): + with TestAreaContext("enkf/summary_key_set/write_test"): + keys = SummaryKeySet() + + keys.addSummaryKey("FOPT") + keys.addSummaryKey("WWCT") + + filename = "test.txt" + + self.assertFalse(os.path.exists(filename)) + + keys.writeToFile(filename) + + self.assertTrue(os.path.exists(filename)) + + keys_from_file = SummaryKeySet(filename) + self.assertItemsEqual(keys.keys(), keys_from_file.keys()) + + + def test_with_enkf_fs(self): + config_file = self.createTestPath("Statoil/config/with_data/config") + + with TestAreaContext("enkf/summary_key_set/enkf_fs", store_area=True) as context: + context.copy_parent_content(config_file) + + fs = EnkfFs("storage/default") + summary_key_set = fs.getSummaryKeySet() + summary_key_set.addSummaryKey("FOPT") + summary_key_set.addSummaryKey("WWCT") + summary_key_set.addSummaryKey("WOPR") + fs.umount() + + ert = EnKFMain("config") + fs = ert.getEnkfFsManager().getCurrentFileSystem() + summary_key_set = fs.getSummaryKeySet() + self.assertTrue("FOPT" in summary_key_set) + self.assertTrue("WWCT" in summary_key_set) + self.assertTrue("WOPR" in summary_key_set) + + ensemble_config = ert.ensembleConfig() + + self.assertTrue("FOPT" in ensemble_config) + self.assertTrue("WWCT" in ensemble_config) + self.assertTrue("WOPR" in ensemble_config) + self.assertFalse("TCPU" in ensemble_config) + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_obs.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_obs.py new file mode 100644 index 0000000000..981ce73f91 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_summary_obs.py @@ -0,0 +1,41 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_summary_obs.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import os + +from ert.enkf import SummaryObservation +from ert.enkf import ActiveList +from ert.test import ExtendedTestCase + + + +class SummaryObsTest(ExtendedTestCase): + + def test_create(self): + sum_obs = SummaryObservation("WWCT:OP_X" , "WWCT:OP_X" , 0.25 , 0.12) + + self.assertEqual( sum_obs.getValue() , 0.25 ) + self.assertEqual( sum_obs.getStandardDeviation() , 0.12 ) + self.assertEqual( sum_obs.getStdScaling() , 1.0 ) + + + def test_std_scaling(self): + sum_obs = SummaryObservation("WWCT:OP_X" , "WWCT:OP_X" , 0.25 , 0.12) + + active_list = ActiveList() + sum_obs.updateStdScaling(0.50 , active_list) + sum_obs.updateStdScaling(0.125 , active_list) + self.assertEqual( sum_obs.getStdScaling() , 0.125 ) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_time_map.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_time_map.py similarity index 72% rename from ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_time_map.py rename to ThirdParty/Ert/devel/python/tests/ert/enkf/test_time_map.py index 7b67abd156..57a3106e00 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/enkf/test_time_map.py +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_time_map.py @@ -117,6 +117,7 @@ def test_lookupDate(self): tm.lookupTime( datetime.date(1999,10,10)) + def test_lookupDays(self): tm = TimeMap() @@ -130,7 +131,7 @@ def test_lookupDays(self): self.assertEqual( 0 , tm.lookupDays( 0 )) self.assertEqual( 1 , tm.lookupDays( 1 )) self.assertEqual( 2 , tm.lookupDays( 2 )) - + with self.assertRaises(ValueError): tm.lookupDays( -1 ) @@ -139,8 +140,40 @@ def test_lookupDays(self): with self.assertRaises(ValueError): tm.lookupDays( 3 ) + + def test_nearest_date_lookup(self): + tm = TimeMap() + with self.assertRaises(ValueError): + tm.lookupTime(datetime.date( 1999 , 1 , 1)) - + with self.assertRaises(ValueError): + tm.lookupTime(datetime.date( 1999 , 1 , 1) , tolerance_seconds_before = 10 , tolerance_seconds_after = 10) + + tm[0] = datetime.date(2000,1,1) + tm[1] = datetime.date(2000,2,1) + tm[2] = datetime.date(2000,3,1) + # Outside of total range will raise an exception, irrespective of + # the tolerances used. + with self.assertRaises(ValueError): + tm.lookupTime(datetime.date( 1999 , 1 , 1) , tolerance_seconds_before = -1 , tolerance_seconds_after = -1) + + with self.assertRaises(ValueError): + tm.lookupTime(datetime.date( 2001 , 1 , 1) , tolerance_seconds_before = -1 , tolerance_seconds_after = -1) + + self.assertEqual(0 , tm.lookupTime( datetime.datetime(2000 , 1 , 1 , 0 , 0 , 10) , tolerance_seconds_after = 15)) + self.assertEqual(1 , tm.lookupTime( datetime.datetime(2000 , 1 , 1 , 0 , 0 , 10) , tolerance_seconds_before = 3600*24*40)) + + self.assertEqual(0 , tm.lookupTime( datetime.date( 2000 , 1 , 10) , tolerance_seconds_before = -1 , tolerance_seconds_after = -1)) + self.assertEqual(1 , tm.lookupTime( datetime.date( 2000 , 1 , 20) , tolerance_seconds_before = -1 , tolerance_seconds_after = -1)) + + with self.assertRaises(ValueError): + tm.lookupTime(datetime.date( 2001 , 10 , 1) , tolerance_seconds_before = 10 , tolerance_seconds_after = 10) + + + def test_empty(self): + tm = TimeMap() + last_step = tm.getLastStep( ) + self.assertEqual( last_step , -1 ) diff --git a/ThirdParty/Ert/devel/python/tests/ert/enkf/test_update.py b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_update.py new file mode 100644 index 0000000000..357a191067 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/enkf/test_update.py @@ -0,0 +1,83 @@ +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_update.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import random + +from ert.test import ExtendedTestCase, ErtTestContext +from ert.util.enums import RngAlgTypeEnum, RngInitModeEnum +from ert.util import Matrix, BoolVector , RandomNumberGenerator +from ert.analysis import AnalysisModule, AnalysisModuleLoadStatusEnum, AnalysisModuleOptionsEnum +from ert.enkf import MeasData , ObsData , LocalObsdata, EnkfStateType + +import ert.cwrap.clib as clib + + +def update(rng , mask , module , ert , meas_data , obs_data , state_size): + S = meas_data.createS() + R = obs_data.createR() + dObs = obs_data.createDObs() + E = obs_data.createE( rng , meas_data.getActiveEnsSize() ) + D = obs_data.createD(E , S) + obs_data.scale(S , E = E , D = D , R = R , D_obs = dObs) + + A = Matrix(state_size , meas_data.getActiveEnsSize()) + A.randomInit( rng ) + + module.initUpdate( mask , S , R , dObs , E , D ) + module.updateA( A , S , R , dObs , E , D ) + + + + +class UpdateTest(ExtendedTestCase): + def setUp(self): + self.libname = clib.ert_lib_path + "/rml_enkf.so" + self.user = "TEST" + self.config_file = self.createTestPath("Statoil/config/obs_testing2/config") + self.rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) + + + def createAnalysisModule(self): + return AnalysisModule(self.rng, self.user, self.libname) + + + def test_it(self): + state_size = 10 + with ErtTestContext("update" , self.config_file) as tc: + analysis = self.createAnalysisModule() + ert = tc.getErt() + obs = ert.getObservations() + local_obsdata = obs.getAllActiveLocalObsdata( ) + + fs = ert.getEnkfFsManager().getCurrentFileSystem() + state = EnkfStateType.FORECAST + + + mask = BoolVector( initial_size = ert.getEnsembleSize() , default_value = True) + meas_data = MeasData(mask) + obs_data = ObsData() + obs.getObservationAndMeasureData( fs , local_obsdata , state , mask.createActiveList() , meas_data , obs_data ) + update( self.rng , mask , analysis , ert , meas_data , obs_data , state_size) + + + mask[0] = False + mask[4] = False + meas_data = MeasData(mask) + obs_data = ObsData() + obs.getObservationAndMeasureData( fs , local_obsdata , state , mask.createActiveList() , meas_data , obs_data ) + update( self.rng , mask , analysis , ert , meas_data , obs_data , state_size) + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/job_queue/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/job_queue/CMakeLists.txt new file mode 100644 index 0000000000..f7d30a8f04 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/CMakeLists.txt @@ -0,0 +1,23 @@ +set(TEST_SOURCES + __init__.py + test_ert_plugin.py + test_ert_script.py + test_function_ert_script.py + test_job_queue.py + test_workflow.py + test_workflow_job.py + test_workflow_joblist.py + test_workflow_runner.py + workflow_common.py +) + +add_python_package("python.tests.ert.job_queue" ${PYTHON_INSTALL_PREFIX}/tests/ert/job_queue "${TEST_SOURCES}" False) + +addPythonTest(ert.job_queue.job_status_type_enum tests.ert.job_queue.test_job_queue.JobQueueTest) +addPythonTest(ert.job_queue.workflow_job tests.ert.job_queue.test_workflow_job.WorkflowJobTest) +addPythonTest(ert.job_queue.workflow tests.ert.job_queue.test_workflow.WorkflowTest) +addPythonTest(ert.job_queue.workflow_joblist tests.ert.job_queue.test_workflow_joblist.WorkflowJoblistTest) +addPythonTest(ert.job_queue.ert_plugin tests.ert.job_queue.test_ert_plugin.ErtPluginTest) +addPythonTest(ert.job_queue.ert_script tests.ert.job_queue.test_ert_script.ErtScriptTest) +addPythonTest(ert.job_queue.function_ert_script tests.ert.job_queue.test_function_ert_script.FunctionErtScriptTest) +addPythonTest(ert.job_queue.workflow_runner tests.ert.job_queue.test_workflow_runner.WorkflowRunnerTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/sched/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/sched/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/__init__.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_ert_plugin.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_ert_plugin.py new file mode 100644 index 0000000000..96fbef4fd7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_ert_plugin.py @@ -0,0 +1,86 @@ +from ert.enkf import ErtPlugin, CancelPluginException +from ert.test.extended_testcase import ExtendedTestCase + + +class SimplePlugin(ErtPlugin): + def run(self, parameter1, parameter2): + assert parameter1 == "one" + assert parameter2 == 2 + + def getArguments(self, parent=None): + return ["one", 2] + + +class FullPlugin(ErtPlugin): + def getName(self): + return "FullPlugin" + + def getDescription(self): + return "Fully described!" + + def run(self, arg1, arg2, arg3=None): + assert arg1 == 5 + assert arg2 == "No" + assert arg3 is None + + def getArguments(self, parent=None): + return [5, "No"] + + +class CanceledPlugin(ErtPlugin): + def run(self, arg1): + pass + + def getArguments(self, parent=None): + raise CancelPluginException("Cancel test!") + +# class GUIPlugin(ErtPlugin): +# def getArguments(self, parent=None): +# value1 = QInputDialog.getInt(parent, "Enter a number!", "Enter a nice number (nothing else than 5):", value=0, min=0, max=10) +# value2 = QInputDialog.getInt(parent, "Enter a number!", "Enter a nice number (nothing else than 6):", value=0, min=0, max=10) +# print(value1, value2) +# return [value1[0], value2[0]] +# +# def run(self, arg1, arg2, arg3=None): +# assert arg1 == 5 +# assert arg2 == 6 + + +class ErtPluginTest(ExtendedTestCase): + + def test_simple_ert_plugin(self): + + simple_plugin = SimplePlugin("ert") + + arguments = simple_plugin.getArguments() + + self.assertTrue("SimplePlugin" in simple_plugin.getName()) + self.assertEqual("No description provided!", simple_plugin.getDescription()) + + simple_plugin.initializeAndRun([str, int], arguments) + + + def test_full_ert_plugin(self): + plugin = FullPlugin("ert") + + self.assertEqual(plugin.getName(), "FullPlugin") + self.assertEqual(plugin.getDescription(), "Fully described!") + + arguments = plugin.getArguments() + + plugin.initializeAndRun([int, str, float], arguments) + + + def test_cancel_plugin(self): + plugin = CanceledPlugin("ert") + + with self.assertRaises(CancelPluginException): + plugin.getArguments() + + # def test_gui_ert_plugin(self): + # app = QApplication([]) + # plugin = GUIPlugin("ert") + # + # arguments = plugin.getArguments() + # plugin.initializeAndRun([int, int], arguments) + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_ert_script.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_ert_script.py similarity index 86% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_ert_script.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/test_ert_script.py index 42dbe7647b..5b99e414df 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_ert_script.py +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_ert_script.py @@ -1,6 +1,6 @@ from ert.job_queue import ErtScript from ert.test import TestAreaContext, ExtendedTestCase -from ert_tests.job_queue.workflow_common import WorkflowCommon +from .workflow_common import WorkflowCommon class ReturnErtScript(ErtScript): @@ -15,6 +15,10 @@ class FailScript(ErtScript): def rum(self): pass +class NoneScript(ErtScript): + def run(self, arg): + assert arg is None + class ErtScriptTest(ExtendedTestCase): @@ -68,4 +72,11 @@ def test_ert_script_from_file(self): # with self.assertRaises(ErtScriptError): self.assertIsNone(ErtScript.loadScriptFromFile("syntax_error_script.py")) self.assertIsNone(ErtScript.loadScriptFromFile("import_error_script.py")) - self.assertIsNone(ErtScript.loadScriptFromFile("empty_script.py")) \ No newline at end of file + self.assertIsNone(ErtScript.loadScriptFromFile("empty_script.py")) + + + def test_none_ert_script(self): + #Check if None is not converted to string "None" + script = NoneScript("ert") + + script.initializeAndRun([str], [None]) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_function_ert_script.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_function_ert_script.py similarity index 94% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_function_ert_script.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/test_function_ert_script.py index ce6527feed..c85295efc4 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_function_ert_script.py +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_function_ert_script.py @@ -1,7 +1,7 @@ import ctypes from ert.cwrap import clib, CWrapper from ert.test import ExtendedTestCase, TestAreaContext -from ert_tests.job_queue.workflow_common import WorkflowCommon +from .workflow_common import WorkflowCommon test_lib = clib.ert_load("libjob_queue") # create a local namespace cwrapper = CWrapper(test_lib) diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_job_queue.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_job_queue.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_job_queue.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/test_job_queue.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow.py similarity index 96% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow.py index fa48e19445..a21228fc30 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow.py +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow.py @@ -1,7 +1,7 @@ from ert.job_queue import Workflow, WorkflowJoblist from ert.test import ExtendedTestCase, TestAreaContext from ert.util import SubstitutionList -from ert_tests.job_queue.workflow_common import WorkflowCommon +from .workflow_common import WorkflowCommon class WorkflowTest(ExtendedTestCase): diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_job.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_job.py similarity index 96% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_job.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_job.py index 8609f7e5c3..1bf6725406 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_job.py +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_job.py @@ -1,7 +1,7 @@ from ert.cwrap import clib, CWrapper from ert.job_queue import WorkflowJob from ert.test import TestAreaContext, ExtendedTestCase -from ert_tests.job_queue.workflow_common import WorkflowCommon +from .workflow_common import WorkflowCommon test_lib = clib.ert_load("libjob_queue") # create a local namespace cwrapper = CWrapper(test_lib) @@ -55,7 +55,7 @@ def test_arguments(self): self.assertEqual(job.maximumArgumentCount(), 5) self.assertEqual(job.argumentTypes(), [str, int, float, bool, str]) - self.assertTrue(job.run(None, ["x %d %f %d %s", 1, 2.5, True])) + self.assertTrue(job.run(None, ["x %d %f %d", 1, 2.5, True])) self.assertTrue(job.run(None, ["x %d %f %d %s", 1, 2.5, True, "y"])) with self.assertRaises(UserWarning): # Too few arguments diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_joblist.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_joblist.py similarity index 95% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_joblist.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_joblist.py index b6aa459c31..a8a8a83db1 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_joblist.py +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_joblist.py @@ -1,6 +1,6 @@ from ert.job_queue import WorkflowJoblist, WorkflowJob from ert.test import ExtendedTestCase, TestAreaContext -from ert_tests.job_queue.workflow_common import WorkflowCommon +from .workflow_common import WorkflowCommon class WorkflowJoblistTest(ExtendedTestCase): diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_runner.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_runner.py similarity index 98% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_runner.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_runner.py index 67b8297a0d..e45a084ed1 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/test_workflow_runner.py +++ b/ThirdParty/Ert/devel/python/tests/ert/job_queue/test_workflow_runner.py @@ -3,7 +3,7 @@ from ert.job_queue import WorkflowJoblist, Workflow, WorkflowRunner from ert.test import TestAreaContext, ExtendedTestCase from ert.util.substitution_list import SubstitutionList -from ert_tests.job_queue.workflow_common import WorkflowCommon +from .workflow_common import WorkflowCommon class WorkflowRunnerTest(ExtendedTestCase): diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/job_queue/workflow_common.py b/ThirdParty/Ert/devel/python/tests/ert/job_queue/workflow_common.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/job_queue/workflow_common.py rename to ThirdParty/Ert/devel/python/tests/ert/job_queue/workflow_common.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/run/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/run/CMakeLists.txt new file mode 100644 index 0000000000..01114973d2 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/run/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_run.py +) + +add_python_package("python.tests.ert.run" ${PYTHON_INSTALL_PREFIX}/tests/ert/run "${TEST_SOURCES}" False) + +addPythonTest(ert.test_run tests.ert.run.test_run.RunTest ) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/server/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/run/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/server/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/run/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/run/test_run.py b/ThirdParty/Ert/devel/python/tests/ert/run/test_run.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/run/test_run.py rename to ThirdParty/Ert/devel/python/tests/ert/run/test_run.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/sched/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/sched/CMakeLists.txt new file mode 100644 index 0000000000..d22c944528 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/sched/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_sched.py +) + +add_python_package("python.tests.ert.sched" ${PYTHON_INSTALL_PREFIX}/tests/ert/sched "${TEST_SOURCES}" False) + +addPythonTest(ert.sched.sched tests.ert.sched.test_sched.SchedFileTest LABELS StatoilData) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/util/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/sched/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/util/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/sched/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/sched/test_sched.py b/ThirdParty/Ert/devel/python/tests/ert/sched/test_sched.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/sched/test_sched.py rename to ThirdParty/Ert/devel/python/tests/ert/sched/test_sched.py diff --git a/ThirdParty/Ert/devel/python/tests/ert/server/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/server/CMakeLists.txt new file mode 100644 index 0000000000..69bd72bf01 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/server/CMakeLists.txt @@ -0,0 +1,10 @@ +set(TEST_SOURCES + __init__.py + test_server.py + test_socket.py +) + +add_python_package("python.tests.ert.server" ${PYTHON_INSTALL_PREFIX}/tests/ert/server "${TEST_SOURCES}" False) + +addPythonTest(ert.server.socket tests.ert.server.test_socket.SocketTest LABELS StatoilData) +addPythonTest(ert.server.server tests.ert.server.test_server.ServerTest LABELS StatoilData) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/well/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/server/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/well/__init__.py rename to ThirdParty/Ert/devel/python/tests/ert/server/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/server/test_server.py b/ThirdParty/Ert/devel/python/tests/ert/server/test_server.py similarity index 57% rename from ThirdParty/Ert/devel/python/test/ert_tests/server/test_server.py rename to ThirdParty/Ert/devel/python/tests/ert/server/test_server.py index d6e3d6d3ad..71be7384dd 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/server/test_server.py +++ b/ThirdParty/Ert/devel/python/tests/ert/server/test_server.py @@ -21,13 +21,14 @@ import signal import json import sys +import logging try: from unittest2 import skipIf, skipUnless, skipIf except ImportError: from unittest import skipIf, skipUnless, skipIf -from ert.server import ErtServer,ErtCmdError +from ert.server import ErtServer from ert.util import StringList, TimeVector, DoubleVector from ert.test import ExtendedTestCase , TestAreaContext @@ -38,6 +39,8 @@ class ServerTest(ExtendedTestCase): def setUp(self): self.config_path = self.createTestPath("local/resopt/config/simple") self.config_file = "config" + self.logger = logging.getLogger("test") + self.logger.addHandler( logging.NullHandler ) def testCreate(self): @@ -45,24 +48,16 @@ def testCreate(self): work_area.copy_directory_content(self.config_path) with self.assertRaises(IOError): - ert_server = ErtServer( "Does/not/exist" ) + ert_server = ErtServer( "Does/not/exist" , self.logger) - ert_server = ErtServer(self.config_file) + ert_server = ErtServer(self.config_file , self.logger) self.assertTrue( ert_server.isConnected() ) + with self.assertRaises(KeyError): + res = ert_server.evalCmd( ["UNKNWON-COMMAND"]) + ert_server.close() self.assertTrue( not ert_server.isConnected() ) - ert_server = ErtServer() - self.assertTrue( not ert_server.isConnected() ) - ert_server.open( self.config_file ) - self.assertTrue( ert_server.isConnected() ) - - cmd = ["STATUS"] - res = ert_server.evalCmd( cmd ) - self.assertEqual( res , ["READY"] ) - - with self.assertRaises(ErtCmdError): - res = ert_server.evalCmd( ["UNKNWON-COMMAND"]) def testSimulations(self): @@ -70,17 +65,36 @@ def testSimulations(self): work_area.copy_directory_content(self.config_path) - ert_server = ErtServer(self.config_file) + ert_server = ErtServer(self.config_file , self.logger) cmd = ["INIT_SIMULATIONS"] - with self.assertRaises(ErtCmdError): + with self.assertRaises(IndexError): + res = ert_server.evalCmd( cmd ) + + cmd = ["UNKNOWN_COMMAND"] + with self.assertRaises(KeyError): + res = ert_server.evalCmd( cmd ) + + cmd = ["GET_RESULT"] # Missing arguments + with self.assertRaises(IndexError): + res = ert_server.evalCmd( cmd ) + + cmd = ["GET_RESULT" , 1 , 1 , "KW"] #Missing keyword + with self.assertRaises(KeyError): res = ert_server.evalCmd( cmd ) - cmd = ["INIT_SIMULATIONS" , 100 , "Init_case"] - res = ert_server.evalCmd( cmd ) - cmd = ["STATUS"] - res = ert_server.evalCmd( cmd ) - self.assertEqual( res , ["RUNNING" , 0 , 0 ]) - - cmd = ["START_SIMULATION" , "0"] - + def testTIMESTEP(self): + config_path = self.createTestPath("Statoil/config/with_data") + with TestAreaContext("server/server") as work_area: + work_area.copy_directory_content(config_path) + + ert_server = ErtServer(self.config_file, self.logger) + cmd = ["TIME_STEP"] + + res = ert_server.evalCmd(cmd) + + data = json.dumps(res) + + result = json.loads(data) + self.assertEqual( res[0] , "OK") + diff --git a/ThirdParty/Ert/devel/python/tests/ert/server/test_socket.py b/ThirdParty/Ert/devel/python/tests/ert/server/test_socket.py new file mode 100644 index 0000000000..0cc865d40e --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/server/test_socket.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'test_socket.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 <http://www.gnu.org/licenses/gpl.html> +# for more details. + +import os +import random +import time +import socket +import os +import signal +import json +import sys +import logging +import datetime + +try: + from unittest2 import skipIf, skipUnless, skipIf +except ImportError: + from unittest import skipIf, skipUnless, skipIf + +from ert.server import ErtSocket, ErtClient +from ert.util import StringList, TimeVector, DoubleVector + +from ert.test import ExtendedTestCase , TestAreaContext + + + + + + +class SocketTest(ExtendedTestCase): + def setUp(self): + self.base_port = random.randint( 1024 , 1024 * 30 ) + self.host = "localhost" + self.pid = 0 + + self.logger = logging.Logger("ert-server-test") + self.logger.addHandler( logging.NullHandler() ) + + + + def runCommand(self , send , port , expected = None): + result = ErtClient.runCommand(send , port , self.host ) + if expected: + self.assertEqual( result , expected ) + return result + + + # If the client sends ["QUIT"] the server listen() method should + # return, and the whole server process should terminate with + # os._exit(0). If the client does not send ["QUIT"] the tearDown() + # method should kill the server process. + + def startServer(self , config_file , port): + self.pid = os.fork() + if self.pid == 0: + s = ErtSocket.connect(config_file , port , self.host , self.logger) + s.listen( ) + os._exit(0) + else: + time.sleep(0.50) + return + + def tearDown(self): + if self.pid != 0: + os.kill(self.pid, signal.SIGKILL) + + + def test_connect(self): + port = self.base_port + config_path = self.createTestPath("local/resopt/config/simple") + with TestAreaContext("server/socket1") as work_area: + work_area.copy_directory_content(config_path) + self.startServer( "config" , port ) + + self.runCommand( ["STATUS"] , port , expected = ["READY"] ) + + with self.assertRaises(Exception): + self.runCommand( "INVALID" , port ) + + with self.assertRaises(Exception): + self.runCommand( ["MISSING_COMMAND"] , port ) + + self.runCommand( ["QUIT"] , port , expected = ["QUIT"] ) + + # Server is closed + with self.assertRaises(Exception): + self.runCommand( ["STATUS"] , port ) + + + + def test_time_map(self): + port = self.base_port + 1 + config_path = self.createTestPath("Statoil/config/with_data") + with TestAreaContext("server/socket2") as work_area: + work_area.copy_directory_content(config_path) + self.startServer( "config" , port ) + + data = self.runCommand(["TIME_STEP"] , port ) + self.assertTrue( isinstance( data[0] , datetime.datetime )) + self.assertEqual( data[0] , datetime.datetime(2000 , 1 , 1, 0,0,0)) + + self.runCommand( ["QUIT"] , port , expected = ["QUIT"] ) + + + diff --git a/ThirdParty/Ert/devel/python/tests/ert/testcase/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/ert/testcase/CMakeLists.txt new file mode 100644 index 0000000000..328614835f --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/testcase/CMakeLists.txt @@ -0,0 +1,10 @@ +set(TEST_SOURCES + __init__.py + test_testcase.py + test_mini_config.py +) + +add_python_package("python.tests.ert.testcase" ${PYTHON_INSTALL_PREFIX}/tests/ert/testcase "${TEST_SOURCES}" False) + +addPythonTest(ert.testcase.testcase tests.ert.testcase.test_testcase.TestTestCase) +addPythonTest(ert.testcase.mini_config tests.ert.testcase.test_mini_config.MiniConfigTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/ert/testcase/__init__.py b/ThirdParty/Ert/devel/python/tests/ert/testcase/__init__.py new file mode 100644 index 0000000000..5e08e797f5 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/testcase/__init__.py @@ -0,0 +1 @@ + diff --git a/ThirdParty/Ert/devel/python/tests/ert/testcase/test_mini_config.py b/ThirdParty/Ert/devel/python/tests/ert/testcase/test_mini_config.py new file mode 100644 index 0000000000..33f388578b --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/ert/testcase/test_mini_config.py @@ -0,0 +1,49 @@ +from ert.enkf.enums.realization_state_enum import RealizationStateEnum +from ert.test import ErtTestContext +from ert.test.extended_testcase import ExtendedTestCase + + +class MiniConfigTest(ExtendedTestCase): + + def test_failed_realizations(self): + + # mini_fail_config has the following realization success/failures: + # + # 0 OK + # 1 GenData report step 1 missing + # 2 GenData report step 2 missing, Forward Model Component Target File not found. + # 3 GenData report step 3 missing, Forward Model Component Target File not found. + # 4 GenData report step 1 missing + # 5 GenData report step 2 missing, Forward Model Component Target File not found. + # 6 GenData report step 3 missing + # 7 Forward Model Target File not found. + # 8 OK + # 9 OK + + + config = self.createTestPath("local/custom_kw/mini_fail_config") + with ErtTestContext("python/enkf/data/custom_kw_simulated", config) as context: + ert = context.getErt() + + fs = ert.getEnkfFsManager().getCurrentFileSystem() + + realizations_list = fs.realizationList(RealizationStateEnum.STATE_HAS_DATA) + self.assertTrue(0 in realizations_list) + self.assertTrue(8 in realizations_list) + self.assertTrue(9 in realizations_list) + + realizations_list = fs.realizationList(RealizationStateEnum.STATE_LOAD_FAILURE) + self.assertTrue(1 in realizations_list) + self.assertTrue(2 in realizations_list) + self.assertTrue(3 in realizations_list) + self.assertTrue(4 in realizations_list) + self.assertTrue(5 in realizations_list) + self.assertTrue(6 in realizations_list) + self.assertTrue(7 in realizations_list) + + + + + + + diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_deprecation.py b/ThirdParty/Ert/devel/python/tests/ert/testcase/test_testcase.py similarity index 51% rename from ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_deprecation.py rename to ThirdParty/Ert/devel/python/tests/ert/testcase/test_testcase.py index d2610d9491..6308d54264 100644 --- a/ThirdParty/Ert/devel/python/test/ert_tests/ecl/test_deprecation.py +++ b/ThirdParty/Ert/devel/python/tests/ert/testcase/test_testcase.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2015 Statoil ASA, Norway. # -# The file 'test_deprecation.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'test_testcase.py' is part of ERT - Ensemble based Reservoir Tool. # # ERT is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,23 +13,14 @@ # # See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> # for more details. -import warnings -try: - from unittest2 import skipIf -except ImportError: - from unittest import skipIf - -import time -from ert.ecl import EclGrid +import functools +import math from ert.test import ExtendedTestCase - -class DeprecationTest(ExtendedTestCase): - - def test_EclGrid_get_corner_xyz(self): - grid = EclGrid.create_rectangular( (10,20,30) , (1,1,1) ) - with warnings.catch_warnings(): - grid.get_corner_xyz(0 , global_index = 10) - - +class TestTestCase(ExtendedTestCase): + + def test_not_raises(self): + call_sin = functools.partial( math.sin , 0.5*math.pi ) + self.assertNotRaises( call_sin ) + diff --git a/ThirdParty/Ert/devel/python/tests/gui/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/gui/CMakeLists.txt new file mode 100644 index 0000000000..61c7dfc1da --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/CMakeLists.txt @@ -0,0 +1,15 @@ +set(TEST_SOURCES + __init__.py + test_model.py + test_observable.py +) + +add_python_package("python.tests.gui" ${PYTHON_INSTALL_PREFIX}/tests/gui "${TEST_SOURCES}" False) + +addPythonTest(gui.model tests.gui.test_model.ModelTest) +addPythonTest(gui.observable tests.gui.test_observable.ObservableTest) + +add_subdirectory(ertshell) +add_subdirectory(ide) +add_subdirectory(plot) + diff --git a/ThirdParty/Ert/devel/python/tests/gui/__init__.py b/ThirdParty/Ert/devel/python/tests/gui/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/python/tests/gui/ertshell/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/gui/ertshell/CMakeLists.txt new file mode 100644 index 0000000000..5ee0319ec9 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ertshell/CMakeLists.txt @@ -0,0 +1,15 @@ +set(TEST_SOURCES + __init__.py + ert_shell_test_context.py + test_ertshell_analysis.py + test_ertshell_context.py + test_ertshell_observations.py + test_ertshell_smoother.py +) + +add_python_package("python.tests.gui.ertshell" ${PYTHON_INSTALL_PREFIX}/tests/gui/ertshell "${TEST_SOURCES}" False) + +addPythonTest(gui.ertshell.ertshell_analysis gui.ertshell.test_ertshell_analysis.ErtShellAnalysisModuleTest) +addPythonTest(gui.ertshell.ertshell_context gui.ertshell.test_ertshell_context.ErtShellContextTest) +addPythonTest(gui.ertshell.ertshell_observations gui.ertshell.test_ertshell_observations.ErtShellObservationsTest) +addPythonTest(gui.ertshell.ertshell_smoother gui.ertshell.test_ertshell_smoother.ErtShellSmootherTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/gui/ertshell/__init__.py b/ThirdParty/Ert/devel/python/tests/gui/ertshell/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/python/tests/gui/ertshell/ert_shell_test_context.py b/ThirdParty/Ert/devel/python/tests/gui/ertshell/ert_shell_test_context.py new file mode 100644 index 0000000000..da1ff544e1 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ertshell/ert_shell_test_context.py @@ -0,0 +1,50 @@ +from StringIO import StringIO +import os +import sys +from ert.test import TestAreaContext +from ert_gui.shell import ErtShell + +class ShellCapturing(list): + + def __init__(self, shell): + self.shell = shell + + def __enter__(self): + self._stdout = sys.stdout + self._shell_stdout = self.shell.stdout + sys.stdout = self.shell.stdout = self._stringio = StringIO() + return self + + def __exit__(self, *args): + self.extend(self._stringio.getvalue().splitlines()) + sys.stdout = self._stdout + self.shell.stdout = self._shell_stdout + + + +class ErtShellTestContext(object): + + def __init__(self, test_name, config_file, load_config=True, prefix=None, store_area=False): + self.config_file = config_file + self.load_config = load_config + self.test_area_context = TestAreaContext(test_name, prefix=prefix, store_area=store_area) + + + def __enter__(self): + """ :rtype: ErtShell """ + test_area = self.test_area_context.__enter__() + test_area.copy_parent_content(self.config_file) + self.shell = ErtShell(forget_history=True) + + config_file = os.path.basename(self.config_file) + + if self.load_config: + self.shell.onecmd("load_config %s" % config_file) + + return self.shell + + + def __exit__(self, exc_type, exc_val, exc_tb): + self.shell.do_exit("") + self.test_area_context.__exit__(exc_type, exc_val, exc_tb) + return False \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_analysis.py b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_analysis.py new file mode 100644 index 0000000000..ed0e33339b --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_analysis.py @@ -0,0 +1,46 @@ +from ert.test.extended_testcase import ExtendedTestCase +from .ert_shell_test_context import ErtShellTestContext + + +class ErtShellAnalysisModuleTest(ExtendedTestCase): + + def test_analysis_module(self): + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtShellTestContext("python/ertshell/analysis_module", test_config) as shell: + + self.assertTrue(shell.invokeCommand("analysis_module current")) + self.assertTrue(shell.invokeCommand("analysis_module list")) + + modules = shell.shellContext().ert().analysisConfig().getModuleList() + + for analysis_module in modules: + self.assertTrue(shell.invokeCommand("analysis_module select %s" % analysis_module)) + active_module_name = shell.shellContext().ert().analysisConfig().activeModuleName() + self.assertEqual(analysis_module, active_module_name) + + self.assertTrue(shell.invokeCommand("analysis_module variables")) + + analysis_module = shell.shellContext().ert().analysisConfig().getActiveModule() + variable_names = analysis_module.getVariableNames() + + for variable_name in variable_names: + value = analysis_module.getVariableValue(variable_name) + + variable_type = analysis_module.getVariableType(variable_name) + + if variable_type is float: + new_value = value + 0.5 + elif variable_type is int: + new_value = value + 2 + elif variable_type is str: + new_value = "New String Value" + else: + new_value = not value + + self.assertTrue(shell.invokeCommand("analysis_module set %s %s" % (variable_name, new_value))) + + updated_value = analysis_module.getVariableValue(variable_name) + + self.assertEqual(new_value, updated_value) + diff --git a/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_context.py b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_context.py new file mode 100644 index 0000000000..9bfe7567d5 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_context.py @@ -0,0 +1,34 @@ +import os +from ert.test import ExtendedTestCase +from .ert_shell_test_context import ErtShellTestContext, ShellCapturing + + +class ErtShellContextTest(ExtendedTestCase): + + def test_ertshell_context(self): + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtShellTestContext("python/ertshell/ert_shell_context", config_file=test_config, load_config=False) as shell: + + self.assertIsNone(shell.shellContext().ert()) + + self.assertTrue(shell.invokeCommand("load_config mini_config")) + + self.assertIsNotNone(shell.shellContext().ert()) + + + def test_std_out_capture(self): + + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtShellTestContext("python/ertshell/ert_shell_context", config_file=test_config, load_config=False) as shell: + + with ShellCapturing(shell) as out: + shell.onecmd("cwd") + + cwd = out[0] + prefix = "Current directory: " + self.assertTrue(cwd.startswith(prefix)) + + self.assertEqual(os.getcwd(), cwd[len(prefix):]) + diff --git a/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_observations.py b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_observations.py new file mode 100644 index 0000000000..be5ff0e061 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_observations.py @@ -0,0 +1,25 @@ +from ert.test import ExtendedTestCase +from tests.gui.ertshell.ert_shell_test_context import ErtShellTestContext + +class ErtShellObservationsTest(ExtendedTestCase): + + def test_load_observations(self): + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtShellTestContext("python/ertshell/observations", test_config) as shell: + ert = shell.shellContext().ert() + original_observation_count = len(ert.getObservations()) + + self.assertTrue(shell.invokeCommand("observations list")) + + self.assertTrue(shell.invokeCommand("observations clear")) + self.assertEqual(0, len(ert.getObservations())) + + self.assertTrue(shell.invokeCommand("observations load Observations/observation_1")) + self.assertEqual(1, len(ert.getObservations())) + + self.assertTrue(shell.invokeCommand("observations load Observations/observation_2")) + self.assertEqual(2, len(ert.getObservations())) + + self.assertTrue(shell.invokeCommand("observations load Observations/observation_3")) + self.assertEqual(original_observation_count, len(ert.getObservations())) diff --git a/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_smoother.py b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_smoother.py new file mode 100644 index 0000000000..394d0c3ec7 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ertshell/test_ertshell_smoother.py @@ -0,0 +1,46 @@ +from ert.enkf.export import GenKwCollector +from ert.test.extended_testcase import ExtendedTestCase +from tests.gui.ertshell.ert_shell_test_context import ErtShellTestContext + +class ErtShellSmootherTest(ExtendedTestCase): + + def test_smoother(self): + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtShellTestContext("python/ertshell/smoother", test_config) as shell: + shell.invokeCommand("case select test_run") + + self.assertTrue(shell.invokeCommand("smoother update test_run_update")) + + shell.invokeCommand("case select test_run_update") + + ert = shell.shellContext().ert() + data = GenKwCollector.loadAllGenKwData(ert, "test_run", keys=["PERLIN_PARAM:SCALE"]) + update_data = GenKwCollector.loadAllGenKwData(ert, "test_run_update", keys=["PERLIN_PARAM:SCALE"]) + + self.assertTrue(data["PERLIN_PARAM:SCALE"].std() > update_data["PERLIN_PARAM:SCALE"].std()) + + + def test_config(self): + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtShellTestContext("python/ertshell/smoother_config", test_config) as shell: + + analysis_config = shell.shellContext().ert().analysisConfig() + + self.assertTrue(shell.invokeCommand("smoother overlap_alpha")) + self.assertTrue(shell.invokeCommand("smoother overlap_alpha 3.1415")) + self.assertAlmostEqual(3.1415, analysis_config.getEnkfAlpha()) + self.assertFalse(shell.invokeCommand("smoother overlap_alpha threepointfourteen")) + + self.assertTrue(shell.invokeCommand("smoother std_cutoff")) + self.assertTrue(shell.invokeCommand("smoother std_cutoff 0.1")) + self.assertAlmostEqual(0.1, analysis_config.getStdCutoff()) + self.assertFalse(shell.invokeCommand("smoother std_cutoff zeropointthreefourteen")) + + + self.assertTrue(shell.invokeCommand("smoother global_std_scaling")) + self.assertTrue(shell.invokeCommand("smoother global_std_scaling 0.5")) + self.assertAlmostEqual(0.5, analysis_config.getGlobalStdScaling()) + self.assertFalse(shell.invokeCommand("smoother global_std_scaling zeropointfour")) + diff --git a/ThirdParty/Ert/devel/python/tests/gui/ide/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/gui/ide/CMakeLists.txt new file mode 100644 index 0000000000..64135b2519 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ide/CMakeLists.txt @@ -0,0 +1,37 @@ +set(PYTHON_SOURCES + __init__.py + test_bool_argument.py + test_configuration_line.py + test_configuration_line_builder.py + test_configuration_line_definition.py + test_configuration_line_parser.py + test_ert_keywords.py + test_float_argument.py + test_integer_argument.py + test_path_argument.py + test_percent_argument.py + test_proper_name_argument.py + test_proper_name_format_argument.py + test_proper_name_format_string_argument.py + test_range_string_argument.py + test_tokens.py +) + +add_python_package("python.tests.gui.ide" ${PYTHON_INSTALL_PREFIX}/tests/gui/ide "${PYTHON_SOURCES}" True) + +addPythonTest(gui.ide.bool_argument tests.gui.ide.test_bool_argument.BoolArgumentTest) +addPythonTest(gui.ide.integer_argument tests.gui.ide.test_integer_argument.IntegerArgumentTest) +addPythonTest(gui.ide.float_argument tests.gui.ide.test_float_argument.FloatArgumentTest) +addPythonTest(gui.ide.path_argument tests.gui.ide.test_path_argument.PathArgumentTest) +addPythonTest(gui.ide.proper_name_argument tests.gui.ide.test_proper_name_argument.ProperNameArgumentTest) +addPythonTest(gui.ide.proper_name_format_argument tests.gui.ide.test_proper_name_format_argument.ProperNameFormatArgumentTest) +addPythonTest(gui.ide.proper_name_format_string_argument tests.gui.ide.test_proper_name_format_string_argument.ProperNameFormatStringArgumentTest) +addPythonTest(gui.ide.range_string_argument tests.gui.ide.test_range_string_argument.RangeStringArgumentTest) +addPythonTest(gui.ide.test_configuration_line tests.gui.ide.test_configuration_line.ConfigurationLineTest) +addPythonTest(gui.ide.test_configuration_line_builder tests.gui.ide.test_configuration_line_builder.ConfigurationLineBuilderTest) +addPythonTest(gui.ide.test_configuration_line_definition tests.gui.ide.test_configuration_line_definition.ConfigurationLineDefinitionTest) +addPythonTest(gui.ide.test_configuration_line_parser tests.gui.ide.test_configuration_line_parser.ConfigurationLineParserTest) +addPythonTest(gui.ide.ert_keywords tests.gui.ide.test_ert_keywords.ErtKeywordTest) +addPythonTest(gui.ide.tokens tests.gui.ide.test_tokens.TokenTest) + +add_subdirectory(wizards) diff --git a/ThirdParty/Ert/devel/python/tests/gui/ide/__init__.py b/ThirdParty/Ert/devel/python/tests/gui/ide/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_bool_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_bool_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_bool_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_bool_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line_builder.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line_builder.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line_builder.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line_builder.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line_definition.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line_definition.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line_definition.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line_definition.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line_parser.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line_parser.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_configuration_line_parser.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_configuration_line_parser.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_ert_keywords.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_ert_keywords.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_ert_keywords.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_ert_keywords.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_float_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_float_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_float_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_float_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_integer_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_integer_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_integer_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_integer_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_path_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_path_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_path_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_path_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_percent_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_percent_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_percent_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_percent_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_proper_name_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_proper_name_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_proper_name_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_proper_name_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_proper_name_format_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_proper_name_format_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_proper_name_format_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_proper_name_format_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_proper_name_format_string_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_proper_name_format_string_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_proper_name_format_string_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_proper_name_format_string_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_range_string_argument.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_range_string_argument.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_range_string_argument.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_range_string_argument.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_tokens.py b/ThirdParty/Ert/devel/python/tests/gui/ide/test_tokens.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/test_tokens.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/test_tokens.py diff --git a/ThirdParty/Ert/devel/python/tests/gui/ide/wizards/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/gui/ide/wizards/CMakeLists.txt new file mode 100644 index 0000000000..3125ba406f --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/ide/wizards/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_tree_structure.py +) + +add_python_package("python.tests.gui.ide.wizards" ${PYTHON_INSTALL_PREFIX}/tests/gui/ide/wizards "${TEST_SOURCES}" False) + +addPythonTest(gui.ide.wizards.tree_structure tests.gui.ide.wizards.test_tree_structure.TreeStructureTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/gui/ide/wizards/__init__.py b/ThirdParty/Ert/devel/python/tests/gui/ide/wizards/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/wizards/test_tree_structure.py b/ThirdParty/Ert/devel/python/tests/gui/ide/wizards/test_tree_structure.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/ide/wizards/test_tree_structure.py rename to ThirdParty/Ert/devel/python/tests/gui/ide/wizards/test_tree_structure.py diff --git a/ThirdParty/Ert/devel/python/tests/gui/plot/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/gui/plot/CMakeLists.txt new file mode 100644 index 0000000000..dc5af18069 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/gui/plot/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_plot_metrics_tracker.py +) + +add_python_package("python.tests.gui.plot" ${PYTHON_INSTALL_PREFIX}/tests/gui/plot "${TEST_SOURCES}" False) + +addPythonTest(gui.plot.plot_metrics_tracker tests.gui.plot.test_plot_metrics_tracker.PlotMetricTrackerTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/plot/__init__.py b/ThirdParty/Ert/devel/python/tests/gui/plot/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/plot/__init__.py rename to ThirdParty/Ert/devel/python/tests/gui/plot/__init__.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/plot/test_plot_metrics_tracker.py b/ThirdParty/Ert/devel/python/tests/gui/plot/test_plot_metrics_tracker.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/plot/test_plot_metrics_tracker.py rename to ThirdParty/Ert/devel/python/tests/gui/plot/test_plot_metrics_tracker.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/test_model.py b/ThirdParty/Ert/devel/python/tests/gui/test_model.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/test_model.py rename to ThirdParty/Ert/devel/python/tests/gui/test_model.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/gui/test_observable.py b/ThirdParty/Ert/devel/python/tests/gui/test_observable.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/gui/test_observable.py rename to ThirdParty/Ert/devel/python/tests/gui/test_observable.py diff --git a/ThirdParty/Ert/devel/python/test/ert_tests/import_tester.py b/ThirdParty/Ert/devel/python/tests/import_tester.py similarity index 100% rename from ThirdParty/Ert/devel/python/test/ert_tests/import_tester.py rename to ThirdParty/Ert/devel/python/tests/import_tester.py diff --git a/ThirdParty/Ert/devel/python/tests/plugins/CMakeLists.txt b/ThirdParty/Ert/devel/python/tests/plugins/CMakeLists.txt new file mode 100644 index 0000000000..ef45056262 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/plugins/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_mda_es_plugin.py +) + +add_python_package("python.tests.plugins" ${PYTHON_INSTALL_PREFIX}/tests/plugins "${TEST_SOURCES}" False) + +addPythonTest(plugins.mda_es plugins.test_mda_es_plugin.MDAEnsembleSmootherPluginTest) \ No newline at end of file diff --git a/ThirdParty/Ert/devel/python/tests/plugins/__init__.py b/ThirdParty/Ert/devel/python/tests/plugins/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/python/tests/plugins/test_mda_es_plugin.py b/ThirdParty/Ert/devel/python/tests/plugins/test_mda_es_plugin.py new file mode 100644 index 0000000000..1acff16629 --- /dev/null +++ b/ThirdParty/Ert/devel/python/tests/plugins/test_mda_es_plugin.py @@ -0,0 +1,67 @@ +from ert.job_queue import ErtScript +from ert.test import ErtTestContext, ExtendedTestCase + + +class MDAEnsembleSmootherPluginTest(ExtendedTestCase): + def getPlugin(self, ert, job_name): + mda_es = self.createSharePath("workflows/jobs/internal-gui/config/%s" % job_name) + + ert.getWorkflowList().addJob("TEST_MDA_ES", mda_es) + plugin_job = ert.getWorkflowList().getJob("TEST_MDA_ES") + + self.assertIsNotNone(plugin_job) + + script_obj = ErtScript.loadScriptFromFile(plugin_job.getInternalScriptPath()) + script = script_obj(ert) + return script + + + def test_weights(self): + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtTestContext("python/workflow_jobs/mda_es_weights", test_config) as test_context: + ert = test_context.getErt() + plugin = self.getPlugin(ert, "MDA_ES") + + weights = plugin.parseWeights("iteration_weights/constant_4") + self.assertAlmostEqualList([2, 2, 2, 2], weights) + + weights = plugin.parseWeights("iteration_weights/constant_2") + self.assertAlmostEqualList([1.414213562373095, 1.414213562373095], weights) + + with self.assertRaises(ValueError): + plugin.parseWeights("iteration_weights/error_in_weights") + + with self.assertRaises(ValueError): + plugin.parseWeights("") + + weights = plugin.parseWeights("2, 2, 2, 2") + self.assertAlmostEqualList([2, 2, 2, 2], weights) + + weights = plugin.parseWeights("1.414213562373095, 1.414213562373095") + self.assertAlmostEqualList([1.414213562373095, 1.414213562373095], weights) + + with self.assertRaises(ValueError): + plugin.parseWeights("2, error, 2, 2") + + + def test_normalized_weights(self): + test_config = self.createTestPath("local/custom_kw/mini_config") + + with ErtTestContext("python/workflow_jobs/mda_es_weights_normalized", test_config) as test_context: + ert = test_context.getErt() + plugin = self.getPlugin(ert, "MDA_ES") + weights = plugin.normalizeWeights([1]) + self.assertAlmostEqualList([1.0], weights) + + weights = plugin.normalizeWeights([1, 1]) + self.assertAlmostEqualList([1.414214, 1.414214], weights) + + weights = plugin.normalizeWeights([1, 1, 1]) + self.assertAlmostEqualList([1.732051, 1.732051, 1.732051], weights) + + weights = plugin.normalizeWeights([8, 4, 2, 1]) + self.assertAlmostEqualList([9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109], weights) + + weights = plugin.normalizeWeights([9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109]) + self.assertAlmostEqualList([9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109], weights) diff --git a/ThirdParty/Ert/devel/redhat/ert.ecl.spec b/ThirdParty/Ert/devel/redhat/ert.ecl.spec index f058ee8964..e50ca7a0fe 100644 --- a/ThirdParty/Ert/devel/redhat/ert.ecl.spec +++ b/ThirdParty/Ert/devel/redhat/ert.ecl.spec @@ -51,7 +51,7 @@ This package contains the development and header files for ert.ecl %build cd devel -cmake28 -DSHARED_LIB=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_ECL_SUMMARY=1 +cmake28 -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_ECL_SUMMARY=1 make %install diff --git a/ThirdParty/Ert/devel/share/gui/img/ide/plugin.png b/ThirdParty/Ert/devel/share/gui/img/ide/plugin.png new file mode 100644 index 0000000000..c1ee68def0 Binary files /dev/null and b/ThirdParty/Ert/devel/share/gui/img/ide/plugin.png differ diff --git a/ThirdParty/Ert/devel/share/gui/img/ide/small/folder.png b/ThirdParty/Ert/devel/share/gui/img/ide/small/folder.png new file mode 100644 index 0000000000..f1ed9abe03 Binary files /dev/null and b/ThirdParty/Ert/devel/share/gui/img/ide/small/folder.png differ diff --git a/ThirdParty/Ert/devel/share/viewer/shaders/texturing.fp b/ThirdParty/Ert/devel/share/viewer/shaders/texturing.fp index b54cf81e72..298cff2c63 100644 --- a/ThirdParty/Ert/devel/share/viewer/shaders/texturing.fp +++ b/ThirdParty/Ert/devel/share/viewer/shaders/texturing.fp @@ -8,6 +8,9 @@ uniform bool lighting; uniform bool region_scaling; uniform float data_range; +// From python code: self.__shader.setUniformi("grid_size", texture.getWidth(), texture.getHeight(), texture.getDepth()) + + varying vec3 normal; @@ -20,9 +23,13 @@ void main() { float color_pos = texture3D(grid_data, gl_TexCoord[0].xyz).a; + if (color_pos < 0.001) { + discard; + } + if(region_scaling) { // data_range + 1 because [0-9] count = 10 - color_pos = color_pos * (data_range + 1) / 12.0; + color_pos = color_pos * (data_range + 1) / 16.0; } vec3 color = texture1D(color_scale, color_pos).rgb; @@ -39,4 +46,4 @@ void main() { gl_FragColor.rgb = color; gl_FragColor.a = 1.0; -} \ No newline at end of file +} diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/CSV_EXPORT b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/CSV_EXPORT new file mode 100644 index 0000000000..abef52b476 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/CSV_EXPORT @@ -0,0 +1,9 @@ +INTERNAL True +SCRIPT ../scripts/csv_export.py +MIN_ARG 1 +MAX_ARG 4 +ARG_TYPE 0 STRING +ARG_TYPE 1 STRING +ARG_TYPE 2 STRING +ARG_TYPE 3 BOOL + diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/EXPORT_MISFIT_DATA b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/EXPORT_MISFIT_DATA new file mode 100644 index 0000000000..c4aac369aa --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/EXPORT_MISFIT_DATA @@ -0,0 +1,6 @@ +INTERNAL True +SCRIPT ../scripts/export_misfit_data.py +MIN_ARG 0 +MAX_ARG 1 +ARG_TYPE 0 STRING + diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/GEN_DATA_RFT_CSV_EXPORT b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/GEN_DATA_RFT_CSV_EXPORT new file mode 100644 index 0000000000..e6ca1dcc58 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/GEN_DATA_RFT_CSV_EXPORT @@ -0,0 +1,8 @@ +INTERNAL True +SCRIPT ../scripts/gen_data_rft_export.py +MIN_ARG 2 +MAX_ARG 4 +ARG_TYPE 0 STRING +ARG_TYPE 1 STRING +ARG_TYPE 2 STRING +ARG_TYPE 3 BOOL diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/MDA_ES b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/MDA_ES new file mode 100644 index 0000000000..fe31710c57 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/MDA_ES @@ -0,0 +1,7 @@ +INTERNAL True +SCRIPT ../scripts/mda_es.py +MIN_ARG 2 +MAX_ARG 2 +ARG_TYPE 0 STRING +ARG_TYPE 1 STRING + diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/UPDATE_RUNPATH_LIST b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/UPDATE_RUNPATH_LIST new file mode 100644 index 0000000000..dbaa256d05 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/config/UPDATE_RUNPATH_LIST @@ -0,0 +1,6 @@ +INTERNAL True +SCRIPT ../scripts/update_runpath_list.py +MIN_ARG 0 +MAX_ARG 1 +ARG_TYPE 0 STRING + diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/csv_export.py b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/csv_export.py new file mode 100644 index 0000000000..f971aa2f6b --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/csv_export.py @@ -0,0 +1,189 @@ +import os +import re +import pandas +from ert.enkf import ErtPlugin, CancelPluginException +from ert.enkf.export import SummaryCollector, GenKwCollector, MisfitCollector, DesignMatrixReader, CustomKWCollector +from ert.util import Profiler +from ert_gui.models.mixins.connectorless import DefaultPathModel, DefaultBooleanModel +from ert_gui.widgets.checkbox import CheckBox +from ert_gui.widgets.custom_dialog import CustomDialog +from ert_gui.widgets.list_edit_box import ListEditBox +from ert_gui.widgets.path_chooser import PathChooser + + +class CSVExportJob(ErtPlugin): + """ + Export of summary, custom_kw, misfit, design matrix data and gen kw into a single CSV file. + + The script expects a single argument: + + output_file: this is the path to the file to output the CSV data to + + Optional arguments: + + case_list: a comma separated list of cases to export (no spaces allowed) + if no list is provided the current case is exported + a single * can be used to export all cases + + design_matrix: a path to a file containing the design matrix + + infer_iteration: If True the script will try to infer the iteration number by looking at the suffix of the case name + (i.e. default_2 = iteration 2) + If False the script will use the ordering of the case list: the first item will be iteration 0, + the second item will be iteration 1... + + The script also looks for default values for output path and design matrix path to present in the GUI. These can + be specified with DATA_KW keyword in the config file: + DATA_KW CSV_OUTPUT_PATH <some path> + DATA_KW DESIGN_MATRIX_PATH <some path> + """ + + INFER_HELP = ("<html>" + "If this is checked the iteration number will be inferred from the name i.e.:" + "<ul>" + "<li>case_name -> iteration: 0</li>" + "<li>case_name_0 -> iteration: 0</li>" + "<li>case_name_2 -> iteration: 2</li>" + "<li>case_0, case_2, case_5 -> iterations: 0, 2, 5</li>" + "</ul>" + "Leave this unchecked to set iteration number to the order of the listed cases:" + "<ul><li>case_0, case_2, case_5 -> iterations: 0, 1, 2</li></ul>" + "<br/>" + "</html>") + + def getName(self): + return "CSV Export" + + def getDescription(self): + return "Export GenKW, CustomKW, design matrix, misfit data and summary data into a single CSV file." + + def inferIterationNumber(self, case_name): + pattern = re.compile("_([0-9]+$)") + match = pattern.search(case_name) + + if match is not None: + return int(match.group(1)) + return 0 + + + def run(self, output_file, case_list=None, design_matrix_path=None, infer_iteration=True): + cases = [] + + if case_list is not None: + if case_list.strip() == "*": + cases = self.getAllCaseList() + else: + cases = case_list.split(",") + + if case_list is None or len(cases) == 0: + cases = [self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName()] + + if design_matrix_path is not None: + if not os.path.exists(design_matrix_path): + raise UserWarning("The design matrix file does not exists!") + + if not os.path.isfile(design_matrix_path): + raise UserWarning("The design matrix is not a file!") + + data = pandas.DataFrame() + + for index, case in enumerate(cases): + case = case.strip() + + if not self.ert().getEnkfFsManager().caseExists(case): + raise UserWarning("The case '%s' does not exist!" % case) + + if not self.ert().getEnkfFsManager().caseHasData(case): + raise UserWarning("The case '%s' does not have any data!" % case) + + if infer_iteration: + iteration_number = self.inferIterationNumber(case) + else: + iteration_number = index + + case_data = GenKwCollector.loadAllGenKwData(self.ert(), case) + + custom_kw_data = CustomKWCollector.loadAllCustomKWData(self.ert(), case) + if not custom_kw_data.empty: + case_data = case_data.join(custom_kw_data, how='outer') + + if design_matrix_path is not None: + design_matrix_data = DesignMatrixReader.loadDesignMatrix(design_matrix_path) + if not design_matrix_data.empty: + case_data = case_data.join(design_matrix_data, how='outer') + + misfit_data = MisfitCollector.loadAllMisfitData(self.ert(), case) + if not misfit_data.empty: + case_data = case_data.join(misfit_data, how='outer') + + summary_data = SummaryCollector.loadAllSummaryData(self.ert(), case) + if not summary_data.empty: + case_data = case_data.join(summary_data, how='outer') + else: + case_data["Date"] = None + case_data.set_index(["Date"], append=True, inplace=True) + + case_data["Iteration"] = iteration_number + case_data["Case"] = case + case_data.set_index(["Case", "Iteration"], append=True, inplace=True) + + data = pandas.concat([data, case_data]) + + data = data.reorder_levels(["Realization", "Iteration", "Date", "Case"]) + data.to_csv(output_file) + + export_info = "Exported %d rows and %d columns to %s." % (len(data.index), len(data.columns), output_file) + return export_info + + + def getArguments(self, parent=None): + description = "The CSV export requires some information before it starts:" + dialog = CustomDialog("CSV Export", description, parent) + + default_csv_output_path = self.getDataKWValue("CSV_OUTPUT_PATH", default="output.csv") + output_path_model = DefaultPathModel(default_csv_output_path) + output_path_chooser = PathChooser(output_path_model, path_label="Output file path") + + design_matrix_default = self.getDataKWValue("DESIGN_MATRIX_PATH", default="") + design_matrix_path_model = DefaultPathModel(design_matrix_default, is_required=False, must_exist=True) + design_matrix_path_chooser = PathChooser(design_matrix_path_model, path_label="Design Matrix path") + + all_case_list = self.getAllCaseList() + list_edit = ListEditBox(all_case_list, "List of cases to export") + + infer_iteration_model = DefaultBooleanModel() + infer_iteration_checkbox = CheckBox(infer_iteration_model, label="Infer iteration number", show_label=False) + infer_iteration_checkbox.setToolTip(CSVExportJob.INFER_HELP) + + dialog.addOption(output_path_chooser) + dialog.addOption(design_matrix_path_chooser) + dialog.addOption(list_edit) + dialog.addOption(infer_iteration_checkbox) + + dialog.addButtons() + + success = dialog.showAndTell() + + if success: + design_matrix_path = design_matrix_path_model.getPath() + if design_matrix_path.strip() == "": + design_matrix_path = None + + case_list = ",".join(list_edit.getItems()) + + return [output_path_model.getPath(), case_list, design_matrix_path, infer_iteration_model.isTrue()] + + raise CancelPluginException("User cancelled!") + + + def getDataKWValue(self, name, default): + data_kw = self.ert().getDataKW() + if name in data_kw: + return data_kw[data_kw.indexForKey(name)][1] + return default + + def getAllCaseList(self): + fs_manager = self.ert().getEnkfFsManager() + all_case_list = fs_manager.getCaseList() + all_case_list = [case for case in all_case_list if fs_manager.caseHasData(case)] + return all_case_list \ No newline at end of file diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/export_misfit_data.py b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/export_misfit_data.py new file mode 100644 index 0000000000..6887314834 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/export_misfit_data.py @@ -0,0 +1,78 @@ +from collections import OrderedDict +import os +from ert.enkf import ErtScript, RealizationStateEnum, EnkfStateType +from ert.util import BoolVector + +""" +This job exports misfit data into a chosen file or to the default gen_kw export file (parameters.txt) +""" + +class ExportMisfitDataJob(ErtScript): + + def run(self, target_file=None): + ert = self.ert() + fs = ert.getEnkfFsManager().getCurrentFileSystem() + + if target_file is None: + target_file = ert.getModelConfig().getGenKWExportFile() + + runpath_list = ert.getPostSimulationHook().getRunpathList() + + active_list = self.createActiveList(fs) + + for runpath_node in runpath_list: + if runpath_node.realization in active_list: + + if not os.path.exists(runpath_node.runpath): + os.makedirs(runpath_node.runpath) + + target_path = os.path.join(runpath_node.runpath, target_file) + + parameters = self.parseTargetFile(target_path) + + misfit_sum = 0.0 + for obs_vector in ert.getObservations(): + misfit = obs_vector.getTotalChi2(fs, runpath_node.realization, EnkfStateType.FORECAST) + + key = "MISFIT:%s" % obs_vector.getObservationKey() + parameters[key] = misfit + + misfit_sum += misfit + + parameters["MISFIT:TOTAL"] = misfit_sum + + self.dumpParametersToTargetFile(parameters, target_path) + + + + def parseTargetFile(self, target_path): + parameters = OrderedDict() + + if os.path.exists(target_path) and os.path.isfile(target_path): + with open(target_path, "r") as input_file: + lines = input_file.readlines() + + for line in lines: + tokens = line.split() + + if len(tokens) == 2: + parameters[tokens[0]] = tokens[1] + else: + raise UserWarning("The file '%s' contains errors. Expected format for each line: KEY VALUE" % target_path) + + return parameters + + + def dumpParametersToTargetFile(self, parameters, target_path): + with open(target_path, "w") as output: + for key in parameters: + output.write("%s %s\n" % (key, parameters[key])) + + + def createActiveList(self, fs): + state_map = fs.getStateMap() + ens_mask = BoolVector(False, self.ert().getEnsembleSize()) + state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA) + active_list = BoolVector.createActiveList(ens_mask) + + return active_list \ No newline at end of file diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/gen_data_rft_export.py b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/gen_data_rft_export.py new file mode 100644 index 0000000000..52f2bebec5 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/gen_data_rft_export.py @@ -0,0 +1,211 @@ +import os +import re +import pandas +import numpy + +from ert.ecl.rft import WellTrajectory + + +from ert.enkf import ErtPlugin, CancelPluginException +from ert.enkf import RealizationStateEnum +from ert.enkf.enums import EnkfObservationImplementationType +from ert.enkf.export import GenDataCollector, SummaryCollector, GenKwCollector, MisfitCollector, DesignMatrixReader,ArgLoader + +from ert_gui.models.mixins.connectorless import DefaultPathModel , DefaultBooleanModel, StringModel +from ert_gui.widgets.string_box import StringBox +from ert_gui.widgets.checkbox import CheckBox +from ert_gui.widgets.custom_dialog import CustomDialog +from ert_gui.widgets.list_edit_box import ListEditBox +from ert_gui.widgets.path_chooser import PathChooser + + +class GenDataRFTCSVExportJob(ErtPlugin): + """Export of GEN_DATA based rfts to a CSV file. The csv file will in + addition contain the depth as duplicated seperate row. + + The script expects four arguments: + + output_file: this is the path to the file to output the CSV data to + + key: this is the ert GEN_DATA key used for this particular RFT. + + report_step: This is the report step configured in the ert + configuration file for this RFT. + + trajectory_file: This is the the file containing the + + Optional arguments: + + case_list: a comma separated list of cases to export (no spaces allowed) + if no list is provided the current case is exported + + infer_iteration: If True the script will try to infer the iteration number by looking at the suffix of the case name + (i.e. default_2 = iteration 2) + If False the script will use the ordering of the case list: the first item will be iteration 0, + the second item will be iteration 1... + """ + + INFER_HELP = ("<html>" + "If this is checked the iteration number will be inferred from the name i.e.:" + "<ul>" + "<li>case_name -> iteration: 0</li>" + "<li>case_name_0 -> iteration: 0</li>" + "<li>case_name_2 -> iteration: 2</li>" + "<li>case_0, case_2, case_5 -> iterations: 0, 2, 5</li>" + "</ul>" + "Leave this unchecked to set iteration number to the order of the listed cases:" + "<ul><li>case_0, case_2, case_5 -> iterations: 0, 1, 2</li></ul>" + "<br/>" + "</html>") + + def getName(self): + return "GEN_DATA RFT CSV Export" + + def getDescription(self): + return "Export gen_data RFT results into a single CSV file." + + def inferIterationNumber(self, case_name): + pattern = re.compile("_([0-9]+$)") + match = pattern.search(case_name) + + if match is not None: + return int(match.group(1)) + return 0 + + + def run(self, output_file, trajectory_path , case_list=None, infer_iteration=True): + """The run method will export the RFT's for all wells and all cases. + + The successfull operation of this method hinges on two naming + conventions: + + 1. All the GEN_DATA RFT observations have key RFT_$WELL + 2. The trajectory files are in $trajectory_path/$WELL.txt + + """ + + + wells = set() + obs_pattern = "RFT_*" + enkf_obs = self.ert().getObservations() + obs_keys = enkf_obs.getMatchingKeys(obs_pattern , obs_type = EnkfObservationImplementationType.GEN_OBS) + + cases = [] + if case_list is not None: + cases = case_list.split(",") + + if case_list is None or len(cases) == 0: + cases = [self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName()] + + data_frame = pandas.DataFrame() + for index, case in enumerate(cases): + case = case.strip() + case_frame = pandas.DataFrame() + + if not self.ert().getEnkfFsManager().caseExists(case): + raise UserWarning("The case '%s' does not exist!" % case) + + if not self.ert().getEnkfFsManager().caseHasData(case): + raise UserWarning("The case '%s' does not have any data!" % case) + + if infer_iteration: + iteration_number = self.inferIterationNumber(case) + else: + iteration_number = index + + for obs_key in obs_keys: + well = obs_key.replace("RFT_","") + wells.add( well ) + obs_vector = enkf_obs[obs_key] + data_key = obs_vector.getDataKey() + report_step = obs_vector.activeStep() + obs_node = obs_vector.getNode( report_step ) + + rft_data = GenDataCollector.loadGenData( self.ert() , case , data_key , report_step ) + fs = self.ert().getEnkfFsManager().getFileSystem( case ) + realizations = fs.realizationList( RealizationStateEnum.STATE_HAS_DATA ) + + # Trajectory + trajectory_file = os.path.join( trajectory_path , "%s.txt" % well) + if not os.path.isfile(trajectory_file): + trajectory_file = os.path.join( trajectory_path , "%s_R.txt" % well) + + trajectory = WellTrajectory( trajectory_file ) + arg = ArgLoader.load( trajectory_file , column_names = ["utm_x" , "utm_y" , "md" , "tvd"]) + tvd_arg = arg["tvd"] + data_size = len(tvd_arg) + + + # Observations + obs = numpy.empty(shape = (data_size , 2 ) , dtype=numpy.float64) + obs.fill( numpy.nan ) + for obs_index in range(len(obs_node)): + data_index = obs_node.getDataIndex( obs_index ) + value = obs_node.getValue( obs_index ) + std = obs_node.getStandardDeviation( obs_index ) + obs[data_index,0] = value + obs[data_index,1] = std + + + real_data = pandas.DataFrame( index = ["Realization","Well"]) + for iens in realizations: + realization_frame = pandas.DataFrame( data = {"TVD" : tvd_arg , + "Pressure" : rft_data[iens], + "ObsValue" : obs[:,0], + "ObsStd" : obs[:,1]}, + columns = ["TVD" , "Pressure" , "ObsValue" , "ObsStd"]) + + realization_frame["Realization"] = iens + realization_frame["Well"] = well + realization_frame["Case"] = case + realization_frame["Iteration"] = iteration_number + + case_frame = pandas.concat( [case_frame , realization_frame] ) + + data_frame = pandas.concat([data_frame, case_frame]) + + data_frame.set_index(["Realization" , "Well" , "Case" , "Iteration"] , inplace = True) + data_frame.to_csv(output_file) + export_info = "Exported RFT information for wells: %s to: %s " % (", ".join(list(wells)) , output_file) + return export_info + + + def getArguments(self, parent=None): + description = "The GEN_DATA RFT CSV export requires some information before it starts:" + dialog = CustomDialog("Robust CSV Export", description, parent) + + output_path_model = DefaultPathModel("output.csv") + output_path_chooser = PathChooser(output_path_model, path_label="Output file path") + + trajectory_model = DefaultPathModel("wellpath" , must_be_a_directory=True , must_be_a_file = False , must_exist = True) + trajectory_chooser = PathChooser(trajectory_model, path_label="Trajectory file") + + fs_manager = self.ert().getEnkfFsManager() + all_case_list = fs_manager.getCaseList() + all_case_list = [case for case in all_case_list if fs_manager.caseHasData(case)] + list_edit = ListEditBox(all_case_list, "List of cases to export") + + + infer_iteration_model = DefaultBooleanModel() + infer_iteration_checkbox = CheckBox(infer_iteration_model, label="Infer iteration number", show_label=False) + infer_iteration_checkbox.setToolTip(GenDataRFTCSVExportJob.INFER_HELP) + + dialog.addOption(output_path_chooser) + dialog.addOption(trajectory_chooser) + dialog.addOption(list_edit) + dialog.addOption(infer_iteration_checkbox) + + dialog.addButtons() + + success = dialog.showAndTell() + + if success: + case_list = ",".join(list_edit.getItems()) + try: + return [output_path_model.getPath(), trajectory_model.getPath() , case_list, infer_iteration_model.isTrue()] + except ValueError: + pass + + raise CancelPluginException("User cancelled!") + + diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/mda_es.py b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/mda_es.py new file mode 100644 index 0000000000..98323c0515 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/mda_es.py @@ -0,0 +1,172 @@ +from math import sqrt +import os + +from ert.enkf import ErtPlugin, CancelPluginException, EnkfInitModeEnum, EnkfStateType +from ert.util import BoolVector +from ert_gui.ide.keywords.definitions import ProperNameFormatArgument, NumberListStringArgument +from ert_gui.models.mixins.connectorless import DefaultPathModel, DefaultNameFormatModel, StringModel +from ert_gui.widgets.custom_dialog import CustomDialog +from ert_gui.widgets.option_widget import OptionWidget +from ert_gui.widgets.path_chooser import PathChooser +from ert_gui.widgets.string_box import StringBox + + +class MDAEnsembleSmootherJob(ErtPlugin): + """ + This plugin runs Multiple Data Assimilation Ensemble Smoother (MDA ES) with custom weights. + """ + + def getName(self): + return "MDA Ensemble Smoother" + + def getDescription(self): + return "Run Multiple Data Assimilation Ensemble Smoother (MDA ES) with custom iteration weights." + + def parseWeights(self, weights): + """ :rtype: list of float """ + if os.path.exists(weights) and os.path.isfile(weights): + return self.parseWeightsFromFile(weights) + else: + return self.parseWeightsFromString(weights) + + def run(self, target_case_format, weights): + if not "%d" in target_case_format: + raise UserWarning("The target case format requires a %d. For example: default_%d") + + weights = self.parseWeights(weights) + weights = self.normalizeWeights(weights) + + iteration_count = len(weights) + + print("Running MDA ES for %d iterations with the following normalized weights: %s" % (iteration_count, ", ".join(str(weight) for weight in weights))) + + source_fs = self.ert().getEnkfFsManager().getCurrentFileSystem() + target_case_name = target_case_format % 0 + target_fs = self.ert().getEnkfFsManager().getFileSystem(target_case_name) + + if not source_fs == target_fs: + self.ert().getEnkfFsManager().switchFileSystem(target_fs) + self.ert().getEnkfFsManager().initializeCurrentCaseFromExisting(source_fs, 0, EnkfStateType.ANALYZED) + + active_realization_mask = BoolVector(True, self.ert().getEnsembleSize()) + + for iteration, weight in enumerate(weights): + self.simulateAndPostProcess(target_case_format, active_realization_mask, iteration) + self.update(target_case_format, iteration, weights[iteration]) + + self.simulateAndPostProcess(target_case_format, active_realization_mask, iteration_count) + + return "MDA ES completed successfully!" + + def update(self, target_case_format, iteration, weight): + self.checkIfCancelled() + + next_iteration = (iteration + 1) + next_target_case_name = target_case_format % next_iteration + target_fs = self.ert().getEnkfFsManager().getFileSystem(next_target_case_name) + + print("[%s] Analyzing iteration: %d with weight %f" % (next_target_case_name, next_iteration, weight)) + self.ert().analysisConfig().setGlobalStdScaling(weight) + success = self.ert().getEnkfSimulationRunner().smootherUpdate(target_fs) + + if not success: + raise UserWarning("[%s] Analysis of simulation failed for iteration: %d!" % (next_target_case_name, next_iteration)) + + + def simulateAndPostProcess(self, target_case_format, active_realization_mask, iteration): + self.checkIfCancelled() + + target_case_name = target_case_format % iteration + + target_fs = self.ert().getEnkfFsManager().getFileSystem(target_case_name) + self.ert().getEnkfFsManager().switchFileSystem(target_fs) + + print("[%s] Running simulation for iteration: %d" % (target_case_name, iteration)) + success = self.ert().getEnkfSimulationRunner().runSimpleStep(active_realization_mask, EnkfInitModeEnum.INIT_CONDITIONAL, iteration) + + if not success: + self.checkSuccessCount(active_realization_mask) + + self.checkIfCancelled() + + print("[%s] Post processing for iteration: %d" % (target_case_name, iteration)) + self.ert().getEnkfSimulationRunner().runPostWorkflow() + + + def checkSuccessCount(self, active_realization_mask): + min_realization_count = self.ert().analysisConfig().getMinRealisations() + success_count = active_realization_mask.count() + + if min_realization_count > success_count: + raise UserWarning("Simulation failed! Number of successful realizations less than MIN_REALIZATIONS %d < %d" % (success_count, min_realization_count)) + elif success_count == 0: + raise UserWarning("Simulation failed! All realizations failed!") + + + def getArguments(self, parent=None): + description = "The MDA Ensemble Smoother requires some information before running:" + dialog = CustomDialog("MDA Ensemble Smoother", description, parent) + + iterated_target_case_format_model = DefaultNameFormatModel(self.getDefaultTargetCaseFormat()) + iterated_target_case_format_box = StringBox(iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format") + iterated_target_case_format_box.setValidator(ProperNameFormatArgument()) + + iteration_weights_path_model = DefaultPathModel("", must_exist=True) + iteration_weights_path_chooser = PathChooser(iteration_weights_path_model, path_label="Iteration weights file") + + custom_iteration_weights_model = StringModel("1") + custom_iteration_weights_box = StringBox(custom_iteration_weights_model, "Custom iteration weights", "config/simulation/iteration_weights") + custom_iteration_weights_box.setValidator(NumberListStringArgument()) + + option_widget = OptionWidget("Iteration Weights") + option_widget.addHelpedWidget("Custom", custom_iteration_weights_box) + option_widget.addHelpedWidget("File", iteration_weights_path_chooser) + + dialog.addOption(iterated_target_case_format_box) + dialog.addOption(option_widget) + + dialog.addButtons() + + success = dialog.showAndTell() + + if success: + optioned_widget = option_widget.getCurrentWidget() + + if optioned_widget == iteration_weights_path_chooser: + weights = iteration_weights_path_model.getPath() + elif optioned_widget == custom_iteration_weights_box: + weights = custom_iteration_weights_model.getValue() + else: + weights = "1" + + return [iterated_target_case_format_model.getValue(), weights] + + raise CancelPluginException("User cancelled!") + + def getDefaultTargetCaseFormat(self): + if self.ert().analysisConfig().getAnalysisIterConfig().caseFormatSet(): + return self.ert().analysisConfig().getAnalysisIterConfig().getCaseFormat() + else: + case_name = self.ert().getEnkfFsManager().getCurrentFileSystem().getCaseName() + return "%s_%%d" % case_name + + def parseWeightsFromFile(self, weights): + result = [] + with open(weights, "r") as f: + for line in f: + result.append(float(line)) + return result + + def parseWeightsFromString(self, weights): + elements = weights.split(",") + result = [] + for element in elements: + element = element.strip() + result.append(float(element)) + + return result + + def normalizeWeights(self, weights): + """ :rtype: list of float """ + length = sqrt(sum((1.0 / x) * (1.0 / x) for x in weights)) + return [x * length for x in weights] diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/update_runpath_list.py b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/update_runpath_list.py new file mode 100644 index 0000000000..fc5b6c469a --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal-gui/scripts/update_runpath_list.py @@ -0,0 +1,37 @@ +from ert.enkf import ErtScript + +""" +This job is useful if you are running a workflow that requires the qc_module runpath_list +to be populated but your are not running any simulations. +""" + +class UpdateRunpathListJob(ErtScript): + def run(self): + ert = self.ert() + + realization_count = ert.getEnsembleSize() + iteration = 0 + + ecl_config = ert.eclConfig() + model_config = ert.getModelConfig() + basename_fmt = ecl_config.getEclBase() + runpath_fmt = model_config.getRunpathAsString() + qc_module = ert.getPostSimulationHook() + + runpath_list = qc_module.getRunpathList() + + runpath_list.clear() + + for realization_number in range(realization_count): + + if basename_fmt is not None: + basename = basename_fmt % realization_number + else: + raise UserWarning("EclBase not set!") + + if model_config.runpathRequiresIterations(): + runpath = runpath_fmt % (realization_number, iteration) + else: + runpath = runpath_fmt % realization_number + + runpath_list.add(realization_number, iteration, runpath, basename) diff --git a/ThirdParty/Ert/devel/share/workflows/jobs/internal/config/STD_SCALE_CORRELATED_OBS b/ThirdParty/Ert/devel/share/workflows/jobs/internal/config/STD_SCALE_CORRELATED_OBS new file mode 100644 index 0000000000..10baf75313 --- /dev/null +++ b/ThirdParty/Ert/devel/share/workflows/jobs/internal/config/STD_SCALE_CORRELATED_OBS @@ -0,0 +1,3 @@ +INTERNAL True +FUNCTION enkf_main_std_scale_correlated_obs_JOB + diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_1 b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_1 new file mode 100644 index 0000000000..9468fb3092 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_1 @@ -0,0 +1,5 @@ +GENERAL_OBSERVATION GEN_PERLIN_1 { + DATA = PERLIN; + RESTART = 1; + OBS_FILE = Observations/perlin_obs_1.txt; +}; diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_2 b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_2 new file mode 100644 index 0000000000..a52d2ddb9c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_2 @@ -0,0 +1,5 @@ +GENERAL_OBSERVATION GEN_PERLIN_2 { + DATA = PERLIN; + RESTART = 2; + OBS_FILE = Observations/perlin_obs_2.txt; +}; diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_3 b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_3 new file mode 100644 index 0000000000..7465c4c124 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observation_3 @@ -0,0 +1,5 @@ +GENERAL_OBSERVATION GEN_PERLIN_3 { + DATA = PERLIN; + RESTART = 3; + OBS_FILE = Observations/perlin_obs_3.txt; +}; \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observations b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observations new file mode 100644 index 0000000000..bff0c5823b --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/observations @@ -0,0 +1,17 @@ +GENERAL_OBSERVATION GEN_PERLIN_1 { + DATA = PERLIN; + RESTART = 1; + OBS_FILE = Observations/perlin_obs_1.txt; +}; + +GENERAL_OBSERVATION GEN_PERLIN_2 { + DATA = PERLIN; + RESTART = 2; + OBS_FILE = Observations/perlin_obs_2.txt; +}; + +GENERAL_OBSERVATION GEN_PERLIN_3 { + DATA = PERLIN; + RESTART = 3; + OBS_FILE = Observations/perlin_obs_3.txt; +}; \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_1.txt new file mode 100644 index 0000000000..fbfbf08d9e --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_1.txt @@ -0,0 +1,100 @@ +-0.616789 0.200000 +-0.626286 0.200000 +-0.642772 0.200000 +-0.623396 0.200000 +-0.601028 0.200000 +-0.587671 0.200000 +-0.545803 0.200000 +-0.548698 0.200000 +-0.576106 0.200000 +-0.547830 0.200000 +-0.499566 0.200000 +-0.390302 0.200000 +-0.274769 0.200000 +-0.218078 0.200000 +-0.206531 0.200000 +-0.256190 0.200000 +-0.286962 0.200000 +-0.290826 0.200000 +-0.279457 0.200000 +-0.220628 0.200000 +-0.175666 0.200000 +-0.134717 0.200000 +-0.041140 0.200000 +0.004634 0.200000 +-0.003586 0.200000 +-0.044667 0.200000 +-0.084128 0.200000 +-0.096405 0.200000 +-0.146272 0.200000 +-0.192659 0.200000 +-0.240387 0.200000 +-0.315781 0.200000 +-0.353862 0.200000 +-0.373289 0.200000 +-0.395017 0.200000 +-0.362747 0.200000 +-0.314473 0.200000 +-0.207889 0.200000 +-0.078605 0.200000 +-0.003939 0.200000 +0.034326 0.200000 +0.005587 0.200000 +0.013544 0.200000 +0.095579 0.200000 +0.191848 0.200000 +0.291420 0.200000 +0.337769 0.200000 +0.309285 0.200000 +0.283094 0.200000 +0.246823 0.200000 +0.190450 0.200000 +0.194585 0.200000 +0.244807 0.200000 +0.290661 0.200000 +0.329075 0.200000 +0.306089 0.200000 +0.264557 0.200000 +0.288901 0.200000 +0.331039 0.200000 +0.413380 0.200000 +0.466520 0.200000 +0.460285 0.200000 +0.444206 0.200000 +0.386893 0.200000 +0.350833 0.200000 +0.314020 0.200000 +0.255650 0.200000 +0.237356 0.200000 +0.229103 0.200000 +0.216303 0.200000 +0.232054 0.200000 +0.206562 0.200000 +0.164036 0.200000 +0.215742 0.200000 +0.336400 0.200000 +0.517183 0.200000 +0.654671 0.200000 +0.732607 0.200000 +0.814735 0.200000 +0.835433 0.200000 +0.826283 0.200000 +0.770065 0.200000 +0.673958 0.200000 +0.624376 0.200000 +0.615341 0.200000 +0.601582 0.200000 +0.585811 0.200000 +0.522072 0.200000 +0.459689 0.200000 +0.462806 0.200000 +0.463663 0.200000 +0.490711 0.200000 +0.483229 0.200000 +0.416017 0.200000 +0.344176 0.200000 +0.307064 0.200000 +0.311372 0.200000 +0.314551 0.200000 +0.275854 0.200000 +0.138191 0.200000 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_2.txt new file mode 100644 index 0000000000..1c0ee7d131 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_2.txt @@ -0,0 +1,100 @@ +0.553636 0.200000 +0.562210 0.200000 +0.577093 0.200000 +0.516574 0.200000 +0.453354 0.200000 +0.438536 0.200000 +0.362335 0.200000 +0.299754 0.200000 +0.294947 0.200000 +0.258916 0.200000 +0.199226 0.200000 +0.154968 0.200000 +0.076430 0.200000 +0.038162 0.200000 +0.047076 0.200000 +0.040351 0.200000 +0.044383 0.200000 +-0.022339 0.200000 +-0.098926 0.200000 +-0.182296 0.200000 +-0.239174 0.200000 +-0.175066 0.200000 +-0.098687 0.200000 +0.046630 0.200000 +0.163052 0.200000 +0.239754 0.200000 +0.379917 0.200000 +0.457436 0.200000 +0.500511 0.200000 +0.547066 0.200000 +0.589134 0.200000 +0.630865 0.200000 +0.648067 0.200000 +0.546752 0.200000 +0.382873 0.200000 +0.254339 0.200000 +0.167602 0.200000 +0.165063 0.200000 +0.107654 0.200000 +0.014283 0.200000 +-0.003453 0.200000 +-0.014968 0.200000 +0.001727 0.200000 +0.011346 0.200000 +0.009215 0.200000 +0.083611 0.200000 +0.234321 0.200000 +0.391352 0.200000 +0.455607 0.200000 +0.429702 0.200000 +0.462148 0.200000 +0.563361 0.200000 +0.647466 0.200000 +0.778980 0.200000 +0.862696 0.200000 +0.876752 0.200000 +0.897362 0.200000 +0.858848 0.200000 +0.813029 0.200000 +0.815672 0.200000 +0.829471 0.200000 +0.883008 0.200000 +0.938118 0.200000 +0.943737 0.200000 +0.943930 0.200000 +0.887728 0.200000 +0.749709 0.200000 +0.570611 0.200000 +0.427346 0.200000 +0.279535 0.200000 +0.134481 0.200000 +0.091839 0.200000 +0.092425 0.200000 +0.142324 0.200000 +0.217527 0.200000 +0.182289 0.200000 +0.063206 0.200000 +-0.052929 0.200000 +-0.124322 0.200000 +-0.149079 0.200000 +-0.160036 0.200000 +-0.180000 0.200000 +-0.213176 0.200000 +-0.191568 0.200000 +-0.140832 0.200000 +-0.131431 0.200000 +-0.164401 0.200000 +-0.253597 0.200000 +-0.316338 0.200000 +-0.275519 0.200000 +-0.191733 0.200000 +-0.019671 0.200000 +0.187348 0.200000 +0.371249 0.200000 +0.532809 0.200000 +0.604516 0.200000 +0.620637 0.200000 +0.517488 0.200000 +0.382527 0.200000 +0.308772 0.200000 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_3.txt new file mode 100644 index 0000000000..f2cad960e0 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Observations/perlin_obs_3.txt @@ -0,0 +1,100 @@ +-0.258515 0.200000 +-0.356107 0.200000 +-0.525515 0.200000 +-0.663313 0.200000 +-0.770373 0.200000 +-0.752177 0.200000 +-0.720117 0.200000 +-0.712752 0.200000 +-0.678174 0.200000 +-0.634873 0.200000 +-0.510858 0.200000 +-0.401601 0.200000 +-0.371298 0.200000 +-0.399836 0.200000 +-0.388296 0.200000 +-0.362204 0.200000 +-0.377951 0.200000 +-0.339453 0.200000 +-0.258223 0.200000 +-0.088966 0.200000 +0.113885 0.200000 +0.276111 0.200000 +0.391728 0.200000 +0.418974 0.200000 +0.416504 0.200000 +0.381174 0.200000 +0.323184 0.200000 +0.270447 0.200000 +0.279357 0.200000 +0.328360 0.200000 +0.328559 0.200000 +0.323026 0.200000 +0.327307 0.200000 +0.348794 0.200000 +0.376927 0.200000 +0.383302 0.200000 +0.372235 0.200000 +0.356978 0.200000 +0.397867 0.200000 +0.522396 0.200000 +0.601574 0.200000 +0.657218 0.200000 +0.723345 0.200000 +0.698378 0.200000 +0.639636 0.200000 +0.584196 0.200000 +0.523544 0.200000 +0.490729 0.200000 +0.486421 0.200000 +0.409534 0.200000 +0.286329 0.200000 +0.120963 0.200000 +-0.046326 0.200000 +-0.129596 0.200000 +-0.224071 0.200000 +-0.277277 0.200000 +-0.271037 0.200000 +-0.304891 0.200000 +-0.363780 0.200000 +-0.395722 0.200000 +-0.438535 0.200000 +-0.504110 0.200000 +-0.546085 0.200000 +-0.616035 0.200000 +-0.673682 0.200000 +-0.650552 0.200000 +-0.604866 0.200000 +-0.567949 0.200000 +-0.539873 0.200000 +-0.552954 0.200000 +-0.570381 0.200000 +-0.517706 0.200000 +-0.474400 0.200000 +-0.373474 0.200000 +-0.263037 0.200000 +-0.203820 0.200000 +-0.103226 0.200000 +-0.051460 0.200000 +0.023379 0.200000 +0.085632 0.200000 +0.073926 0.200000 +0.114264 0.200000 +0.210600 0.200000 +0.367117 0.200000 +0.493523 0.200000 +0.541983 0.200000 +0.555534 0.200000 +0.507462 0.200000 +0.468411 0.200000 +0.494860 0.200000 +0.511384 0.200000 +0.505254 0.200000 +0.497490 0.200000 +0.404108 0.200000 +0.324978 0.200000 +0.329421 0.200000 +0.331172 0.200000 +0.357684 0.200000 +0.334654 0.200000 +0.226313 0.200000 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Parameters/PERLIN_PARAMS.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/Parameters/PERLIN_PARAMS.txt new file mode 100644 index 0000000000..24926666bb --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Parameters/PERLIN_PARAMS.txt @@ -0,0 +1,7 @@ +SCALE UNIFORM 0.1 1 +OFFSET UNIFORM -1 1 +PERSISTENCE UNIFORM 0.01 1 +OCTAVES UNIFORM 1 64 +PRIME_1 UNIFORM 0 127 +PRIME_2 UNIFORM 0 127 +PRIME_3 UNIFORM 0 127 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/RandomSeed b/ThirdParty/Ert/devel/test-data/local/custom_kw/RandomSeed new file mode 100644 index 0000000000..a4571d8b82 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/RandomSeed @@ -0,0 +1 @@ +103 95 15 -86 -95 -5 16 -18 24 -60 -89 101 70 22 -104 -41 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/Template/PERLIN_TEMPLATE b/ThirdParty/Ert/devel/test-data/local/custom_kw/Template/PERLIN_TEMPLATE new file mode 100644 index 0000000000..527a92907c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/Template/PERLIN_TEMPLATE @@ -0,0 +1,7 @@ +SCALE:<SCALE> +OFFSET:<OFFSET> +PERSISTENCE:<PERSISTENCE> +OCTAVES:<OCTAVES> +PRIME_1:<PRIME_1> +PRIME_2:<PRIME_2> +PRIME_3:<PRIME_3> \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/aggregated.txt new file mode 100644 index 0000000000..de8aedc562 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.190479 +PERLIN_2 1.002630 +PERLIN_1 -0.167794 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/parameters.txt new file mode 100644 index 0000000000..142dbecaab --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.249225 +PERLIN_PARAM:OFFSET 0.185709 +PERLIN_PARAM:PERSISTENCE 0.936132 +PERLIN_PARAM:OCTAVES 22.4008 +PERLIN_PARAM:PRIME_1 70.2373 +PERLIN_PARAM:PRIME_2 73.2881 +PERLIN_PARAM:PRIME_3 73.2557 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_1.txt new file mode 100644 index 0000000000..fec0fd107e --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.167794 +-0.533157 +-0.582564 +-0.581187 +-0.544394 +-0.617389 +-0.471483 +-0.570636 +-0.513164 +-0.094431 +-0.489078 +-0.363713 +-0.116233 +0.104267 +-0.185805 +-0.200709 +-0.150918 +-0.384297 +0.293484 +0.122875 +-0.157933 +0.066183 +0.043334 +0.083941 +0.237257 +0.510188 +0.247252 +0.238908 +-0.087547 +-0.330292 +-0.126747 +-0.035823 +-0.234230 +0.031125 +-0.470002 +0.277528 +0.333005 +0.208194 +0.329248 +0.183316 +0.030305 +0.292607 +0.207885 +-0.055542 +0.267287 +0.489294 +0.351695 +0.473816 +0.486845 +0.161185 +0.750709 +0.334430 +0.487895 +-0.083531 +0.631333 +0.189402 +0.293179 +0.416287 +0.071861 +0.343657 +0.530727 +0.295893 +0.707495 +0.705177 +0.364062 +-0.028729 +0.627459 +0.665644 +0.110239 +0.074890 +0.898952 +0.507702 +0.793900 +0.376955 +0.740932 +0.768612 +1.072116 +0.641052 +0.951385 +1.114482 +0.779685 +1.030575 +0.960609 +0.819774 +0.728183 +0.880717 +0.390042 +0.616292 +0.534190 +0.332035 +0.597337 +0.310784 +0.480825 +0.510514 +0.527712 +0.106739 +0.459289 +0.091994 +0.167754 +0.291767 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_2.txt new file mode 100644 index 0000000000..a4c8ae2281 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.002630 +0.655338 +0.637300 +0.558783 +0.509989 +0.408818 +0.436655 +0.277816 +0.357889 +0.712315 +0.209713 +0.181557 +0.234966 +0.360507 +0.067803 +0.095832 +0.180428 +-0.115810 +0.474014 +0.161206 +-0.221441 +0.025834 +-0.014213 +0.125937 +0.403895 +0.794609 +0.711298 +0.792749 +0.559236 +0.409434 +0.702774 +0.910823 +0.767699 +0.951166 +0.307889 +0.894615 +0.815080 +0.581146 +0.515508 +0.201538 +-0.007474 +0.272051 +0.196068 +-0.139775 +0.084654 +0.281485 +0.248246 +0.555883 +0.659358 +0.344063 +1.022407 +0.703206 +0.890554 +0.404788 +1.164953 +0.760065 +0.925984 +0.986234 +0.553851 +0.745948 +0.893678 +0.718616 +1.201408 +1.262021 +0.957160 +0.544980 +1.121517 +0.998898 +0.308482 +0.138122 +0.801380 +0.392979 +0.722289 +0.303537 +0.622059 +0.433718 +0.480651 +-0.144483 +0.012328 +0.129970 +-0.206634 +0.080509 +0.073475 +0.003830 +-0.027990 +0.147703 +-0.360170 +-0.159376 +-0.241837 +-0.406290 +-0.058059 +-0.199599 +0.184944 +0.465746 +0.716346 +0.404191 +0.768554 +0.294930 +0.274427 +0.462347 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_3.txt new file mode 100644 index 0000000000..13a10a9e5d --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.190479 +-0.262978 +-0.465308 +-0.621105 +-0.713738 +-0.781896 +-0.645797 +-0.734690 +-0.615233 +-0.181474 +-0.500371 +-0.375013 +-0.212762 +-0.077491 +-0.367569 +-0.306723 +-0.241907 +-0.432924 +0.314717 +0.254536 +0.131618 +0.477011 +0.476202 +0.498281 +0.657347 +0.936028 +0.654565 +0.605760 +0.338082 +0.190727 +0.442199 +0.602984 +0.446939 +0.753207 +0.301943 +1.023577 +1.019714 +0.773061 +0.805721 +0.709651 +0.597553 +0.944238 +0.917685 +0.547257 +0.715075 +0.782070 +0.537469 +0.655260 +0.690172 +0.323895 +0.846589 +0.260808 +0.196762 +-0.503788 +0.078186 +-0.393964 +-0.242415 +-0.177505 +-0.622958 +-0.465445 +-0.374328 +-0.668502 +-0.282796 +-0.297752 +-0.660453 +-0.993300 +-0.233057 +-0.139662 +-0.658737 +-0.694367 +0.096517 +-0.216566 +0.155464 +-0.212261 +0.141495 +0.047609 +0.314219 +-0.143014 +0.160029 +0.364682 +0.027328 +0.374773 +0.497251 +0.562515 +0.606365 +0.821117 +0.359765 +0.601682 +0.542912 +0.364089 +0.645058 +0.325327 +0.495087 +0.498606 +0.508514 +0.129097 +0.479090 +0.135126 +0.226554 +0.379889 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_fail.status new file mode 100644 index 0000000000..6ac0122a28 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Did nothing! \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_params.txt new file mode 100644 index 0000000000..99b2ec3ff6 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.249225 +OFFSET:0.185709 +PERSISTENCE:0.936132 +OCTAVES:22.4008 +PRIME_1:70.2373 +PRIME_2:73.2881 +PRIME_3:73.2557 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/realization.ok b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/realization.ok new file mode 100644 index 0000000000..a0aba9318a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-0/iter-0/realization.ok @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/aggregated.txt new file mode 100644 index 0000000000..c42ebc2573 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.584204 +PERLIN_2 0.227947 +PERLIN_1 -0.942477 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/parameters.txt new file mode 100644 index 0000000000..d931876083 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.24275 +PERLIN_PARAM:OFFSET -0.29096 +PERLIN_PARAM:PERSISTENCE 0.860518 +PERLIN_PARAM:OCTAVES 14.7858 +PERLIN_PARAM:PRIME_1 11.8217 +PERLIN_PARAM:PRIME_2 48.9187 +PERLIN_PARAM:PRIME_3 89.5122 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_2.txt new file mode 100644 index 0000000000..296be5b8cd --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +0.227947 +0.461424 +0.496254 +0.385250 +0.382965 +0.294599 +0.215538 +0.354808 +0.194641 +0.061050 +0.006348 +-0.033658 +-0.137511 +-0.052176 +0.054974 +0.004020 +-0.119814 +-0.186461 +-0.385196 +-0.286967 +-0.540945 +-0.434223 +-0.424480 +-0.139600 +-0.216224 +0.069846 +0.120217 +0.327327 +0.326008 +0.431300 +0.341933 +0.550826 +0.259922 +0.392107 +0.003858 +0.014051 +-0.354946 +-0.083760 +-0.201720 +-0.372664 +-0.515754 +-0.416670 +-0.452153 +-0.378276 +-0.502741 +-0.226850 +-0.117039 +-0.170353 +-0.103309 +0.018785 +0.134857 +0.299396 +0.256928 +0.466775 +0.638846 +0.679726 +0.643554 +0.744558 +0.717986 +0.632070 +0.597780 +0.726447 +0.907347 +0.748545 +0.576996 +0.711178 +0.663988 +0.233265 +0.069050 +-0.047240 +-0.055375 +-0.163060 +-0.421085 +-0.171631 +0.043688 +-0.021042 +-0.190991 +-0.247524 +-0.463284 +-0.413005 +-0.644291 +-0.650833 +-0.570592 +-0.466943 +-0.568175 +-0.409936 +-0.512981 +-0.655652 +-0.830461 +-0.878072 +-0.495081 +-0.517236 +-0.159439 +0.026080 +-0.084928 +0.074934 +0.020797 +0.156703 +-0.069071 +0.019410 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_3.txt new file mode 100644 index 0000000000..d43e140291 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.584204 +-0.456892 +-0.606354 +-0.794637 +-0.840762 +-0.896115 +-0.866915 +-0.657698 +-0.778480 +-0.832740 +-0.703736 +-0.590227 +-0.585239 +-0.490175 +-0.380398 +-0.398535 +-0.542149 +-0.503575 +-0.544492 +-0.193638 +-0.187886 +0.016954 +0.065935 +0.232744 +0.037229 +0.211265 +0.063484 +0.140338 +0.104854 +0.212594 +0.081358 +0.242987 +-0.060839 +0.194148 +-0.002088 +0.143014 +-0.150313 +0.108155 +0.088492 +0.135449 +0.089272 +0.255517 +0.269465 +0.308757 +0.127679 +0.273734 +0.172184 +-0.070976 +-0.072495 +-0.001383 +-0.040962 +-0.143002 +-0.436864 +-0.441800 +-0.447921 +-0.474303 +-0.524845 +-0.419181 +-0.458823 +-0.579324 +-0.670226 +-0.660671 +-0.576856 +-0.811227 +-1.040616 +-0.827102 +-0.690587 +-0.905295 +-0.898169 +-0.879729 +-0.760237 +-0.772606 +-0.987910 +-0.687429 +-0.436876 +-0.407151 +-0.357423 +-0.246055 +-0.315583 +-0.178294 +-0.410329 +-0.356569 +-0.146816 +0.091742 +0.066180 +0.263478 +0.206954 +0.105406 +-0.045712 +-0.107693 +0.208035 +0.007690 +0.150704 +0.058939 +-0.292759 +-0.200161 +-0.268667 +-0.003101 +-0.116944 +-0.063049 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_fail.status new file mode 100644 index 0000000000..46a71f4e16 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Deleted report step: 1 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_params.txt new file mode 100644 index 0000000000..fb78e8c3e9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.24275 +OFFSET:-0.29096 +PERSISTENCE:0.860518 +OCTAVES:14.7858 +PRIME_1:11.8217 +PRIME_2:48.9187 +PRIME_3:89.5122 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/realization.ok b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/realization.ok new file mode 100644 index 0000000000..a0aba9318a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-1/iter-0/realization.ok @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/ERROR b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/ERROR new file mode 100644 index 0000000000..f5c9d83c76 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/ERROR @@ -0,0 +1,8 @@ +<error> + <time>11:38:08</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/EXIT b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/EXIT new file mode 100644 index 0000000000..f5c9d83c76 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/EXIT @@ -0,0 +1,8 @@ +<error> + <time>11:38:08</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/aggregated.txt new file mode 100644 index 0000000000..39c71d12aa --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.294383 +PERLIN_2 0.517768 +PERLIN_1 -0.652656 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/parameters.txt new file mode 100644 index 0000000000..0850de9c61 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.187883 +PERLIN_PARAM:OFFSET -0.512383 +PERLIN_PARAM:PERSISTENCE 0.850056 +PERLIN_PARAM:OCTAVES 39.9199 +PERLIN_PARAM:PRIME_1 76.7337 +PERLIN_PARAM:PRIME_2 54.1086 +PERLIN_PARAM:PRIME_3 16.0042 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_1.txt new file mode 100644 index 0000000000..122d4089ea --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.652656 +-0.856575 +-0.907574 +-0.921559 +-0.907052 +-0.798535 +-0.892001 +-0.898300 +-0.932647 +-0.887530 +-0.745258 +-0.774438 +-0.680597 +-0.707552 +-0.616984 +-0.784930 +-0.705796 +-0.672207 +-0.677662 +-0.517634 +-0.460960 +-0.512998 +-0.485822 +-0.377630 +-0.469687 +-0.463782 +-0.644529 +-0.631042 +-0.610238 +-0.645129 +-0.841183 +-0.813056 +-0.824549 +-0.985474 +-0.818724 +-1.021755 +-0.749654 +-0.643111 +-0.382287 +-0.319701 +-0.240893 +-0.293783 +-0.356379 +-0.315861 +-0.243741 +-0.061641 +-0.016073 +-0.078540 +-0.166452 +-0.204278 +-0.206156 +-0.339674 +-0.324650 +-0.218586 +-0.220018 +-0.365619 +-0.213129 +-0.161173 +-0.144854 +-0.088350 +-0.193806 +-0.111286 +-0.100984 +-0.235155 +-0.165413 +-0.278588 +-0.429381 +-0.254946 +-0.240835 +-0.227267 +-0.524615 +-0.423858 +-0.341032 +-0.369948 +-0.180422 +0.176827 +0.282667 +0.455645 +0.421888 +0.461117 +0.478802 +0.408361 +0.301001 +0.266791 +0.167743 +0.066362 +0.101881 +0.183729 +-0.037895 +0.191528 +0.077918 +0.193353 +0.109073 +0.001759 +-0.061599 +-0.001108 +-0.164077 +-0.253534 +-0.200586 +-0.275259 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_3.txt new file mode 100644 index 0000000000..1e03faf793 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.294383 +-0.586396 +-0.790317 +-0.961476 +-1.076396 +-0.963042 +-1.066316 +-1.062354 +-1.034715 +-0.974573 +-0.756551 +-0.785737 +-0.777126 +-0.889310 +-0.798749 +-0.890944 +-0.796785 +-0.720834 +-0.656429 +-0.385973 +-0.171410 +-0.102170 +-0.052955 +0.036709 +-0.049597 +-0.037941 +-0.237216 +-0.264190 +-0.184608 +-0.124110 +-0.272236 +-0.174249 +-0.143380 +-0.263391 +-0.046779 +-0.275706 +-0.062945 +-0.078243 +0.094185 +0.206634 +0.326354 +0.357848 +0.353421 +0.286938 +0.204047 +0.231135 +0.169701 +0.102903 +0.036875 +-0.041568 +-0.110276 +-0.413296 +-0.615784 +-0.638843 +-0.773164 +-0.948985 +-0.748723 +-0.754966 +-0.839672 +-0.897452 +-1.098861 +-1.075682 +-1.091275 +-1.238084 +-1.189928 +-1.243159 +-1.289897 +-1.060251 +-1.009811 +-0.996525 +-1.327050 +-1.148126 +-0.979468 +-0.959163 +-0.779859 +-0.544176 +-0.475229 +-0.328422 +-0.369468 +-0.288684 +-0.273556 +-0.247441 +-0.162358 +0.009532 +0.045926 +0.006763 +0.071604 +0.169119 +-0.029173 +0.223582 +0.125639 +0.207896 +0.123334 +-0.010150 +-0.080797 +0.021249 +-0.144276 +-0.210401 +-0.141786 +-0.187137 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_fail.status new file mode 100644 index 0000000000..2494f445e5 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Deleted report step: 2 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_params.txt new file mode 100644 index 0000000000..a069d36ab8 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-2/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.187883 +OFFSET:-0.512383 +PERSISTENCE:0.850056 +OCTAVES:39.9199 +PRIME_1:76.7337 +PRIME_2:54.1086 +PRIME_3:16.0042 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/ERROR b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/ERROR new file mode 100644 index 0000000000..f5c9d83c76 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/ERROR @@ -0,0 +1,8 @@ +<error> + <time>11:38:08</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/EXIT b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/EXIT new file mode 100644 index 0000000000..f5c9d83c76 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/EXIT @@ -0,0 +1,8 @@ +<error> + <time>11:38:08</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/aggregated.txt new file mode 100644 index 0000000000..b986f1b481 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.871387 +PERLIN_2 -0.059236 +PERLIN_1 -1.229660 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/parameters.txt new file mode 100644 index 0000000000..a7472afccf --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.542054 +PERLIN_PARAM:OFFSET -0.936072 +PERLIN_PARAM:PERSISTENCE 0.66513 +PERLIN_PARAM:OCTAVES 59.6891 +PERLIN_PARAM:PRIME_1 58.3958 +PERLIN_PARAM:PRIME_2 51.6271 +PERLIN_PARAM:PRIME_3 37.3286 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_1.txt new file mode 100644 index 0000000000..1f0aabd193 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-1.229660 +-1.403213 +-1.494882 +-1.481222 +-1.545058 +-1.605346 +-1.466829 +-1.460689 +-1.589462 +-1.462504 +-1.586371 +-1.419953 +-1.184666 +-1.064367 +-1.081730 +-1.130531 +-1.307146 +-1.330892 +-1.147255 +-1.230522 +-1.290812 +-1.243312 +-1.053225 +-0.837831 +-0.815416 +-0.794856 +-0.780118 +-0.867346 +-0.868595 +-0.844661 +-0.949974 +-1.135521 +-1.278698 +-1.237066 +-1.353473 +-1.274754 +-1.024540 +-1.062374 +-1.018191 +-0.989482 +-1.082235 +-1.083477 +-1.111900 +-0.884140 +-0.804378 +-0.649785 +-0.414051 +-0.453314 +-0.426393 +-0.376335 +-0.433952 +-0.369796 +-0.319725 +-0.318209 +-0.380495 +-0.274543 +-0.410077 +-0.265464 +-0.276032 +-0.293185 +-0.259478 +-0.307654 +-0.469020 +-0.606702 +-0.727993 +-0.657698 +-0.738949 +-0.779068 +-0.929409 +-0.925120 +-0.888902 +-0.818882 +-0.691387 +-0.806321 +-0.774223 +-0.725947 +-0.616177 +-0.575377 +-0.546778 +-0.619225 +-0.739783 +-0.805058 +-0.854443 +-1.003113 +-0.978222 +-0.724971 +-0.804323 +-0.920953 +-0.973738 +-0.936418 +-0.905518 +-0.717744 +-0.616881 +-0.785126 +-0.782606 +-0.680625 +-0.739233 +-0.708171 +-0.640854 +-0.813288 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_2.txt new file mode 100644 index 0000000000..58ac16bef2 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +-0.059236 +-0.214718 +-0.275017 +-0.341253 +-0.490676 +-0.579139 +-0.558691 +-0.612236 +-0.718408 +-0.655757 +-0.887580 +-0.874683 +-0.833466 +-0.808127 +-0.828123 +-0.833990 +-0.975800 +-1.062405 +-0.966725 +-1.192190 +-1.354320 +-1.283661 +-1.110772 +-0.795835 +-0.648779 +-0.510435 +-0.316072 +-0.313505 +-0.221812 +-0.104936 +-0.120453 +-0.188875 +-0.276769 +-0.317026 +-0.575582 +-0.657667 +-0.542465 +-0.689421 +-0.831931 +-0.971260 +-1.120014 +-1.104033 +-1.123718 +-0.968373 +-0.987011 +-0.857594 +-0.517499 +-0.371248 +-0.253880 +-0.193457 +-0.162254 +-0.001019 +0.082934 +0.170110 +0.153126 +0.296120 +0.222728 +0.304483 +0.205958 +0.109107 +0.103474 +0.115069 +0.024892 +-0.049858 +-0.134896 +-0.083989 +-0.244890 +-0.445814 +-0.731166 +-0.861888 +-0.986474 +-0.933604 +-0.762998 +-0.879739 +-0.893096 +-1.060842 +-1.207642 +-1.360912 +-1.485835 +-1.603737 +-1.726102 +-1.755124 +-1.741578 +-1.819057 +-1.734395 +-1.457985 +-1.554534 +-1.696621 +-1.749765 +-1.674743 +-1.560913 +-1.228126 +-0.912762 +-0.829894 +-0.593973 +-0.383174 +-0.429968 +-0.505235 +-0.534181 +-0.642708 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_fail.status new file mode 100644 index 0000000000..6842226365 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Deleted report step: 3 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_params.txt new file mode 100644 index 0000000000..f51328cc14 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-3/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.542054 +OFFSET:-0.936072 +PERSISTENCE:0.66513 +OCTAVES:59.6891 +PRIME_1:58.3958 +PRIME_2:51.6271 +PRIME_3:37.3286 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/aggregated.txt new file mode 100644 index 0000000000..35536135e9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.585905 +PERLIN_2 1.398056 +PERLIN_1 0.227632 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/parameters.txt new file mode 100644 index 0000000000..43486a893a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.434448 +PERLIN_PARAM:OFFSET 0.831105 +PERLIN_PARAM:PERSISTENCE 0.630867 +PERLIN_PARAM:OCTAVES 8.00407 +PERLIN_PARAM:PRIME_1 85.4235 +PERLIN_PARAM:PRIME_2 21.3039 +PERLIN_PARAM:PRIME_3 104.858 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_2.txt new file mode 100644 index 0000000000..b747326d4e --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.398056 +1.370914 +1.363998 +1.279446 +1.232190 +1.280908 +1.103097 +1.044700 +1.071948 +1.061684 +1.094715 +0.964632 +0.831411 +0.781949 +0.814620 +0.849516 +0.851001 +0.765851 +0.758157 +0.773463 +0.753641 +0.789955 +0.752934 +0.828227 +0.915443 +0.973537 +1.081467 +1.241200 +1.241392 +1.257672 +1.377862 +1.470086 +1.421784 +1.325527 +1.150346 +1.051501 +1.044802 +1.106502 +1.157155 +1.178239 +1.131983 +1.091121 +1.099748 +1.022758 +0.922794 +1.005841 +1.071597 +1.179689 +1.248927 +1.203617 +1.238719 +1.303884 +1.370907 +1.578622 +1.711466 +1.711839 +1.668280 +1.577131 +1.546602 +1.622520 +1.688682 +1.788272 +1.882089 +1.796176 +1.789849 +1.824672 +1.596314 +1.354986 +1.209724 +1.109246 +0.923528 +0.922481 +0.911951 +0.973918 +1.090397 +1.192352 +1.060059 +0.993187 +1.014380 +0.913349 +0.932815 +0.882706 +0.835195 +0.874574 +0.888107 +0.876224 +0.749712 +0.614713 +0.449095 +0.520278 +0.614327 +0.737773 +0.860582 +0.969577 +1.155922 +1.219523 +1.274034 +1.070757 +0.993013 +0.832009 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_3.txt new file mode 100644 index 0000000000..c5dd1d518a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.585905 +0.452598 +0.261390 +0.099559 +0.008463 +0.090195 +0.020645 +0.032193 +0.098826 +0.167894 +0.384631 +0.408063 +0.383683 +0.343951 +0.379248 +0.446961 +0.428666 +0.448737 +0.598860 +0.866793 +1.106700 +1.241132 +1.243349 +1.200570 +1.168896 +1.114956 +1.024733 +1.054210 +1.020238 +1.038965 +1.117287 +1.162247 +1.101024 +1.127568 +1.144400 +1.180464 +1.249435 +1.298417 +1.447368 +1.686352 +1.737009 +1.763308 +1.821366 +1.709790 +1.553214 +1.506426 +1.360820 +1.279066 +1.279741 +1.183449 +1.062901 +0.861486 +0.677115 +0.670046 +0.624699 +0.557809 +0.499881 +0.413392 +0.369794 +0.411126 +0.420676 +0.401154 +0.397886 +0.236404 +0.172236 +0.286392 +0.241739 +0.216426 +0.242506 +0.276757 +0.218665 +0.312935 +0.345126 +0.458120 +0.609833 +0.806243 +0.893627 +0.994656 +1.162081 +1.148060 +1.166777 +1.176970 +1.258971 +1.433259 +1.522462 +1.549638 +1.469646 +1.375772 +1.233844 +1.290657 +1.317444 +1.262699 +1.170724 +1.002436 +0.948090 +0.944428 +0.984570 +0.910954 +0.945140 +0.749551 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_fail.status new file mode 100644 index 0000000000..46a71f4e16 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Deleted report step: 1 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_params.txt new file mode 100644 index 0000000000..324cbda2ee --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.434448 +OFFSET:0.831105 +PERSISTENCE:0.630867 +OCTAVES:8.00407 +PRIME_1:85.4235 +PRIME_2:21.3039 +PRIME_3:104.858 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/realization.ok b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/realization.ok new file mode 100644 index 0000000000..a0aba9318a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-4/iter-0/realization.ok @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/ERROR b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/ERROR new file mode 100644 index 0000000000..48bc5b6354 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/ERROR @@ -0,0 +1,8 @@ +<error> + <time>11:38:15</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/EXIT b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/EXIT new file mode 100644 index 0000000000..48bc5b6354 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/EXIT @@ -0,0 +1,8 @@ +<error> + <time>11:38:15</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/aggregated.txt new file mode 100644 index 0000000000..72e58cbf64 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.638889 +PERLIN_2 1.451039 +PERLIN_1 0.280615 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/parameters.txt new file mode 100644 index 0000000000..463f5c41d8 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.72828 +PERLIN_PARAM:OFFSET 0.48251 +PERLIN_PARAM:PERSISTENCE 0.878696 +PERLIN_PARAM:OCTAVES 62.5026 +PERLIN_PARAM:PRIME_1 10.3564 +PERLIN_PARAM:PRIME_2 34.9666 +PERLIN_PARAM:PRIME_3 46.2883 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_1.txt new file mode 100644 index 0000000000..11da497a09 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +0.280615 +0.140016 +0.101814 +-0.129046 +0.108540 +0.255758 +-0.136433 +0.402995 +0.060006 +0.243033 +0.270699 +1.032076 +-0.013904 +-0.123877 +0.661223 +0.260982 +0.218027 +1.382060 +0.399264 +0.483361 +0.472825 +-0.400746 +1.339330 +0.692467 +0.043042 +0.542935 +-0.239154 +0.322095 +0.568886 +-0.253825 +0.069002 +0.151587 +-0.060719 +0.071557 +1.232762 +0.806173 +0.197592 +0.775339 +0.485706 +-0.340968 +0.563185 +-0.301442 +-0.470657 +0.391865 +1.604934 +1.366571 +0.978296 +0.533236 +0.199409 +0.640021 +0.724001 +0.620437 +-0.062286 +0.448127 +0.681424 +0.211811 +0.962468 +0.569284 +0.153403 +0.463251 +0.717336 +1.047732 +0.879313 +0.557671 +0.589243 +0.475895 +0.668305 +1.261389 +1.992548 +0.514705 +1.480108 +0.964709 +0.672593 +0.541782 +1.389203 +0.533862 +1.237538 +0.892042 +0.376384 +0.676731 +1.374955 +1.291646 +0.276911 +0.706050 +0.032507 +1.074094 +0.914922 +1.747032 +2.087744 +1.287205 +1.735100 +1.305039 +1.283753 +0.989592 +0.686460 +0.373096 +0.309114 +0.349820 +0.814016 +0.915557 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_3.txt new file mode 100644 index 0000000000..4b5a132c2c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.638889 +0.410195 +0.219070 +-0.168964 +-0.060804 +0.091251 +-0.310748 +0.238941 +-0.042062 +0.155990 +0.259406 +1.020776 +-0.110433 +-0.305635 +0.479458 +0.154968 +0.127038 +1.333433 +0.420498 +0.615022 +0.762375 +0.010082 +1.772197 +1.106807 +0.463132 +0.968775 +0.168158 +0.688947 +0.994515 +0.267193 +0.637949 +0.790394 +0.620450 +0.793639 +2.004706 +1.552222 +0.884301 +1.340207 +0.962178 +0.185367 +1.130433 +0.350189 +0.239143 +0.994664 +2.052722 +1.659346 +1.164070 +0.714679 +0.402736 +0.802732 +0.819881 +0.546816 +-0.353419 +0.027870 +0.128278 +-0.371555 +0.426874 +-0.024508 +-0.541415 +-0.345851 +-0.187719 +0.083337 +-0.110978 +-0.445258 +-0.435272 +-0.488676 +-0.192211 +0.456083 +1.223572 +-0.254552 +0.677673 +0.240441 +0.034157 +-0.047433 +0.789765 +-0.187141 +0.479641 +0.107975 +-0.414972 +-0.073069 +0.622598 +0.635844 +-0.186447 +0.448791 +-0.089311 +1.014494 +0.884645 +1.732422 +2.096466 +1.319259 +1.782821 +1.319583 +1.298015 +0.977683 +0.667262 +0.395453 +0.328915 +0.392952 +0.872816 +1.003679 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_fail.status new file mode 100644 index 0000000000..2494f445e5 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Deleted report step: 2 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_params.txt new file mode 100644 index 0000000000..6ffe51857b --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-5/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.72828 +OFFSET:0.48251 +PERSISTENCE:0.878696 +OCTAVES:62.5026 +PRIME_1:10.3564 +PRIME_2:34.9666 +PRIME_3:46.2883 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/aggregated.txt new file mode 100644 index 0000000000..07f12f2a08 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.870550 +PERLIN_2 1.682701 +PERLIN_1 0.512277 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/parameters.txt new file mode 100644 index 0000000000..04dc1adb80 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.105108 +PERLIN_PARAM:OFFSET 0.913379 +PERLIN_PARAM:PERSISTENCE 0.962764 +PERLIN_PARAM:OCTAVES 54.2875 +PERLIN_PARAM:PRIME_1 12.1353 +PERLIN_PARAM:PRIME_2 108.225 +PERLIN_PARAM:PRIME_3 58.2668 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_1.txt new file mode 100644 index 0000000000..309c31a80b --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +0.512277 +0.536404 +0.520619 +0.520234 +0.561383 +0.536841 +0.593527 +0.431159 +0.579716 +0.595432 +0.613877 +0.832759 +0.851509 +0.830369 +0.752398 +0.701988 +0.854139 +0.813144 +0.848016 +0.675839 +0.919173 +1.078956 +1.165071 +1.045397 +1.099168 +1.049976 +0.934854 +0.813458 +0.777245 +0.747191 +0.680688 +0.492784 +0.756629 +0.639112 +0.677362 +0.560299 +0.783620 +0.757035 +0.781494 +1.092201 +1.102767 +1.052654 +1.207713 +1.115009 +1.380213 +1.620005 +1.355587 +1.358326 +1.365758 +1.049275 +1.264629 +1.182026 +1.240226 +1.329804 +1.210895 +1.340758 +1.160254 +1.099240 +1.243394 +1.267952 +1.359115 +1.457122 +1.219766 +1.225781 +1.439935 +1.367284 +1.242810 +1.155161 +1.278395 +1.180081 +1.125988 +1.131542 +1.239492 +1.086901 +1.273243 +1.532824 +1.482385 +1.810195 +1.887451 +1.774089 +1.870171 +1.843973 +1.696110 +1.740468 +1.791604 +1.614504 +1.582554 +1.758357 +1.634232 +1.684106 +1.786180 +1.619646 +1.484936 +1.430948 +1.379634 +1.352505 +1.382218 +1.487943 +1.057155 +0.971585 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_2.txt new file mode 100644 index 0000000000..463edcab27 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.682701 +1.724900 +1.740484 +1.660204 +1.615765 +1.563048 +1.501665 +1.279611 +1.450770 +1.402179 +1.312668 +1.378029 +1.202709 +1.086610 +1.006006 +0.998528 +1.185484 +1.081631 +1.028546 +0.714171 +0.855664 +1.038607 +1.107524 +1.087393 +1.265806 +1.334397 +1.398900 +1.367299 +1.424028 +1.486916 +1.510209 +1.439430 +1.758558 +1.559152 +1.455253 +1.177386 +1.265695 +1.129987 +0.967754 +1.110422 +1.064988 +1.032099 +1.195895 +1.030776 +1.197580 +1.412196 +1.252139 +1.440393 +1.538272 +1.232153 +1.536327 +1.550802 +1.642885 +1.818122 +1.744516 +1.911422 +1.793059 +1.669187 +1.725384 +1.670243 +1.722066 +1.879845 +1.713679 +1.782625 +2.033032 +1.940992 +1.736869 +1.488416 +1.476638 +1.243313 +1.028416 +1.016820 +1.167881 +1.013483 +1.154370 +1.197929 +0.890921 +1.024660 +0.948394 +0.789577 +0.883852 +0.893907 +0.808975 +0.924524 +1.035431 +0.881490 +0.832342 +0.982689 +0.858205 +0.945780 +1.130784 +1.109264 +1.189055 +1.386180 +1.568267 +1.649957 +1.691483 +1.690880 +1.163828 +1.142166 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_fail.status new file mode 100644 index 0000000000..6842226365 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Deleted report step: 3 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_params.txt new file mode 100644 index 0000000000..29d18ec899 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.105108 +OFFSET:0.913379 +PERSISTENCE:0.962764 +OCTAVES:54.2875 +PRIME_1:12.1353 +PRIME_2:108.225 +PRIME_3:58.2668 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/realization.ok b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/realization.ok new file mode 100644 index 0000000000..a0aba9318a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-6/iter-0/realization.ok @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/ERROR b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/ERROR new file mode 100644 index 0000000000..1eb5bf0114 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/ERROR @@ -0,0 +1,8 @@ +<error> + <time>11:38:21</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/EXIT b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/EXIT new file mode 100644 index 0000000000..1eb5bf0114 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/EXIT @@ -0,0 +1,8 @@ +<error> + <time>11:38:21</time> + <job>REALIZATION_FAIL</job> + <reason>Could not find target_file:realization.ok</reason> + <stderr> +<stderr: Not redirected> +</stderr> +</error> diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/aggregated.txt new file mode 100644 index 0000000000..6b3b4204d7 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.223092 +PERLIN_2 0.589059 +PERLIN_1 -0.581365 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/parameters.txt new file mode 100644 index 0000000000..0fec4832fd --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.100905 +PERLIN_PARAM:OFFSET 0.749785 +PERLIN_PARAM:PERSISTENCE 0.960394 +PERLIN_PARAM:OCTAVES 27.0099 +PERLIN_PARAM:PRIME_1 40.6138 +PERLIN_PARAM:PRIME_2 61.0175 +PERLIN_PARAM:PRIME_3 87.8034 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_1.txt new file mode 100644 index 0000000000..f4ab414309 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.581365 +0.196529 +0.251092 +0.129792 +0.331063 +0.243506 +0.276892 +0.080451 +0.396119 +0.359775 +0.367571 +0.375403 +0.583877 +0.600213 +0.433206 +0.667000 +0.730207 +0.597004 +0.652034 +0.663611 +0.746119 +0.692967 +0.730701 +0.876335 +0.892405 +0.727578 +0.723739 +0.564331 +0.468088 +0.488808 +0.664805 +0.660028 +0.630792 +0.524399 +0.474312 +0.443139 +0.580488 +0.481039 +0.800572 +1.001564 +0.911524 +0.901357 +0.788429 +0.858484 +0.905262 +1.091118 +1.153703 +1.092191 +1.125297 +0.931559 +0.887913 +0.949225 +1.000548 +1.157858 +0.916321 +0.916039 +0.825100 +0.963569 +0.946300 +1.325529 +1.317807 +1.051895 +1.371837 +1.120878 +1.290153 +1.132642 +1.106899 +0.951717 +1.053646 +1.097485 +0.993622 +1.071263 +1.003207 +1.060272 +0.945896 +1.081059 +1.483716 +1.639907 +1.778137 +1.743444 +1.658571 +1.670091 +1.528567 +1.360096 +1.348333 +1.247859 +1.311556 +1.223970 +1.139654 +1.236625 +1.220851 +1.388255 +1.244178 +1.146154 +1.093360 +0.984612 +1.125281 +1.104519 +0.927790 +0.740832 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_2.txt new file mode 100644 index 0000000000..3b2079e9c1 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +0.589059 +1.385024 +1.470957 +1.269762 +1.385446 +1.269712 +1.185030 +0.928904 +1.267172 +1.166521 +1.066362 +0.920673 +0.935076 +0.856454 +0.686814 +0.963540 +1.061552 +0.865491 +0.832564 +0.701943 +0.682610 +0.652618 +0.673153 +0.918331 +1.059042 +1.011999 +1.187784 +1.118172 +1.114871 +1.228534 +1.494326 +1.606674 +1.632721 +1.444440 +1.252203 +1.060226 +1.062564 +0.853991 +0.986832 +1.019786 +0.873746 +0.880802 +0.776611 +0.774251 +0.722629 +0.883309 +1.050254 +1.174258 +1.297810 +1.114437 +1.159611 +1.318001 +1.403207 +1.646177 +1.449942 +1.486702 +1.457905 +1.533516 +1.428289 +1.727821 +1.680758 +1.474617 +1.865750 +1.677722 +1.883250 +1.706351 +1.600958 +1.284972 +1.251889 +1.160717 +0.896049 +0.956541 +0.931596 +0.986854 +0.827023 +0.746164 +0.892252 +0.854372 +0.839080 +0.758932 +0.672252 +0.720025 +0.641433 +0.544152 +0.592160 +0.514846 +0.561344 +0.448302 +0.363627 +0.498299 +0.565455 +0.877873 +0.948297 +1.101386 +1.281993 +1.282064 +1.434546 +1.307456 +1.034463 +0.911412 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_3.txt new file mode 100644 index 0000000000..520a51e79f --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.223092 +0.466707 +0.368349 +0.089874 +0.161719 +0.078999 +0.102578 +-0.083603 +0.294051 +0.272732 +0.356278 +0.364104 +0.487348 +0.418455 +0.251441 +0.560986 +0.639218 +0.548377 +0.673267 +0.795272 +1.035669 +1.103795 +1.163568 +1.290674 +1.312494 +1.153418 +1.131051 +0.931183 +0.893717 +1.009827 +1.233752 +1.298835 +1.311961 +1.246482 +1.246256 +1.189188 +1.267197 +1.045907 +1.277045 +1.527899 +1.478772 +1.552988 +1.498229 +1.461283 +1.353050 +1.383894 +1.339477 +1.273635 +1.328624 +1.094269 +0.983792 +0.875603 +0.709414 +0.737601 +0.363175 +0.332673 +0.289505 +0.369777 +0.251481 +0.516427 +0.412752 +0.087499 +0.381547 +0.117950 +0.265638 +0.168071 +0.246383 +0.146412 +0.284670 +0.328228 +0.191186 +0.346995 +0.364771 +0.471056 +0.346459 +0.360055 +0.725820 +0.855841 +0.986781 +0.993643 +0.906214 +1.014289 +1.065209 +1.102837 +1.226516 +1.188260 +1.281279 +1.209360 +1.148376 +1.268678 +1.268572 +1.402798 +1.258439 +1.134246 +1.074161 +1.006970 +1.145082 +1.147652 +0.986590 +0.828954 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_fail.status new file mode 100644 index 0000000000..6ac0122a28 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Did nothing! \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_params.txt new file mode 100644 index 0000000000..4455122772 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-7/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.100905 +OFFSET:0.749785 +PERSISTENCE:0.960394 +OCTAVES:27.0099 +PRIME_1:40.6138 +PRIME_2:61.0175 +PRIME_3:87.8034 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/aggregated.txt new file mode 100644 index 0000000000..244709c651 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.917785 +PERLIN_2 -0.105634 +PERLIN_1 -1.276058 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/parameters.txt new file mode 100644 index 0000000000..59ba741905 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.494279 +PERLIN_PARAM:OFFSET -0.526799 +PERLIN_PARAM:PERSISTENCE 0.0911083 +PERLIN_PARAM:OCTAVES 43.0492 +PERLIN_PARAM:PRIME_1 123.299 +PERLIN_PARAM:PRIME_2 42.4258 +PERLIN_PARAM:PRIME_3 14.0702 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_1.txt new file mode 100644 index 0000000000..6aa944dccf --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-1.276058 +-1.289017 +-1.314341 +-1.306601 +-1.296437 +-1.293440 +-1.259407 +-1.266510 +-1.294486 +-1.261902 +-1.202479 +-1.080475 +-0.954164 +-0.885534 +-0.858941 +-0.894787 +-0.919912 +-0.916939 +-0.886507 +-0.799550 +-0.721154 +-0.650200 +-0.537956 +-0.483812 +-0.489635 +-0.525394 +-0.546662 +-0.527208 +-0.534832 +-0.533549 +-0.538252 +-0.584050 +-0.611137 +-0.630059 +-0.650202 +-0.616093 +-0.568181 +-0.463276 +-0.334508 +-0.259597 +-0.221372 +-0.259230 +-0.279580 +-0.244302 +-0.207325 +-0.170186 +-0.177288 +-0.240439 +-0.278604 +-0.325685 +-0.411518 +-0.447688 +-0.438482 +-0.430901 +-0.426508 +-0.473419 +-0.523455 +-0.492174 +-0.429854 +-0.320462 +-0.242691 +-0.226471 +-0.221185 +-0.262628 +-0.292571 +-0.326766 +-0.377534 +-0.383441 +-0.373359 +-0.364832 +-0.330290 +-0.341756 +-0.378785 +-0.325450 +-0.201339 +-0.014930 +0.131198 +0.218084 +0.307262 +0.331535 +0.323047 +0.275638 +0.204499 +0.189781 +0.216423 +0.234694 +0.244237 +0.196780 +0.140343 +0.139795 +0.132064 +0.149348 +0.135500 +0.067575 +-0.002818 +-0.038351 +-0.033175 +-0.039802 +-0.104931 +-0.282153 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_2.txt new file mode 100644 index 0000000000..9527f5ea7a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +-0.105634 +-0.100522 +-0.094477 +-0.166631 +-0.242055 +-0.267233 +-0.351269 +-0.418058 +-0.423433 +-0.455156 +-0.503687 +-0.535205 +-0.602964 +-0.629293 +-0.605334 +-0.598246 +-0.588567 +-0.648452 +-0.705977 +-0.761218 +-0.784663 +-0.690549 +-0.595504 +-0.441816 +-0.322998 +-0.240974 +-0.082616 +0.026633 +0.111952 +0.206176 +0.291269 +0.362596 +0.390792 +0.289982 +0.127689 +0.000994 +-0.086106 +-0.090324 +-0.148248 +-0.241375 +-0.259151 +-0.279786 +-0.291397 +-0.328535 +-0.389958 +-0.377995 +-0.280737 +-0.158372 +-0.106091 +-0.142807 +-0.139820 +-0.078912 +-0.035823 +0.057418 +0.107112 +0.097244 +0.109350 +0.077772 +0.052136 +0.081830 +0.120261 +0.196251 +0.272728 +0.294216 +0.300526 +0.246943 +0.116525 +-0.050187 +-0.175115 +-0.301600 +-0.427862 +-0.456478 +-0.450396 +-0.398868 +-0.320212 +-0.349825 +-0.460267 +-0.567451 +-0.631795 +-0.652977 +-0.663271 +-0.674428 +-0.682635 +-0.626163 +-0.539750 +-0.498320 +-0.505975 +-0.578888 +-0.635684 +-0.598530 +-0.523332 +-0.361034 +-0.160381 +0.022807 +0.185816 +0.259100 +0.276090 +0.163135 +0.001742 +-0.111572 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_3.txt new file mode 100644 index 0000000000..cd80bec7c2 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.917785 +-1.018838 +-1.197085 +-1.346518 +-1.465782 +-1.457947 +-1.433721 +-1.430564 +-1.396554 +-1.348945 +-1.213771 +-1.091774 +-1.050692 +-1.067291 +-1.040706 +-1.000801 +-1.010901 +-0.965566 +-0.865274 +-0.667889 +-0.431604 +-0.239372 +-0.105089 +-0.069473 +-0.069545 +-0.099554 +-0.139350 +-0.160356 +-0.109202 +-0.012531 +0.030695 +0.054757 +0.070031 +0.092023 +0.121743 +0.129957 +0.118527 +0.101591 +0.141964 +0.266738 +0.345876 +0.392401 +0.430221 +0.358497 +0.240463 +0.122590 +0.008486 +-0.058995 +-0.075277 +-0.162975 +-0.315639 +-0.521310 +-0.729615 +-0.851158 +-0.979655 +-1.056785 +-1.059049 +-1.085967 +-1.124672 +-1.129564 +-1.147745 +-1.190867 +-1.211475 +-1.265556 +-1.317086 +-1.291337 +-1.238050 +-1.188747 +-1.142334 +-1.134089 +-1.132725 +-1.066024 +-1.017221 +-0.914666 +-0.800777 +-0.735933 +-0.626698 +-0.565983 +-0.484094 +-0.418266 +-0.429310 +-0.380164 +-0.258859 +-0.067478 +0.094606 +0.175094 +0.213959 +0.182170 +0.149065 +0.171849 +0.179785 +0.163891 +0.149761 +0.055666 +-0.022016 +-0.015994 +-0.013374 +0.003331 +-0.046131 +-0.194030 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_fail.status new file mode 100644 index 0000000000..6ac0122a28 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Did nothing! \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_params.txt new file mode 100644 index 0000000000..219b62155c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.494279 +OFFSET:-0.526799 +PERSISTENCE:0.0911083 +OCTAVES:43.0492 +PRIME_1:123.299 +PRIME_2:42.4258 +PRIME_3:14.0702 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/realization.ok b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/realization.ok new file mode 100644 index 0000000000..a0aba9318a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-8/iter-0/realization.ok @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/aggregated.txt new file mode 100644 index 0000000000..48b8531624 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.220371 +PERLIN_2 1.032522 +PERLIN_1 -0.137903 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/parameters.txt new file mode 100644 index 0000000000..2e4f0f7b04 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.971949 +PERLIN_PARAM:OFFSET 0.568165 +PERLIN_PARAM:PERSISTENCE 0.332226 +PERLIN_PARAM:OCTAVES 8.48231 +PERLIN_PARAM:PRIME_1 106.04 +PERLIN_PARAM:PRIME_2 17.4819 +PERLIN_PARAM:PRIME_3 56.9629 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_1.txt new file mode 100644 index 0000000000..36798a3f53 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.137903 +-0.157851 +-0.192276 +-0.201670 +-0.192839 +-0.193214 +-0.209423 +-0.243628 +-0.261796 +-0.213269 +-0.207591 +-0.203993 +-0.142490 +-0.122206 +-0.157129 +-0.193732 +-0.206432 +-0.177612 +-0.114381 +-0.050740 +-0.070342 +-0.154469 +-0.151716 +-0.137877 +-0.155888 +-0.199095 +-0.226091 +-0.254674 +-0.326284 +-0.337833 +-0.312344 +-0.317023 +-0.346853 +-0.332528 +-0.238504 +-0.042655 +0.146262 +0.376535 +0.617211 +0.752626 +0.797129 +0.714055 +0.660213 +0.707589 +0.786058 +0.902157 +0.982988 +0.972517 +0.950945 +0.917937 +0.833802 +0.834170 +0.874761 +0.874663 +0.835114 +0.714452 +0.615202 +0.641686 +0.698232 +0.833272 +0.978281 +1.070483 +1.118218 +1.061277 +1.031902 +0.998036 +0.965574 +1.010296 +1.079127 +1.148032 +1.260956 +1.285149 +1.247059 +1.290888 +1.424147 +1.629905 +1.764537 +1.819917 +1.898802 +1.893787 +1.855403 +1.728917 +1.536779 +1.375375 +1.281240 +1.209446 +1.131790 +1.009449 +0.933443 +0.938227 +0.970148 +1.049769 +1.076923 +1.035402 +0.981504 +0.949433 +0.958861 +0.977078 +0.958006 +0.802606 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_2.txt new file mode 100644 index 0000000000..ba557199f4 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.032522 +1.030645 +1.027589 +0.938300 +0.861544 +0.832993 +0.698715 +0.604825 +0.609257 +0.593477 +0.491201 +0.341277 +0.208709 +0.134035 +0.096478 +0.102808 +0.124913 +0.090875 +0.066149 +-0.012408 +-0.133850 +-0.194818 +-0.209263 +-0.095881 +0.010749 +0.085326 +0.237955 +0.299167 +0.320499 +0.401893 +0.517178 +0.629623 +0.655076 +0.587512 +0.539387 +0.574432 +0.628337 +0.749487 +0.803470 +0.770847 +0.759350 +0.693500 +0.648396 +0.623356 +0.603426 +0.694348 +0.879540 +1.054584 +1.123458 +1.100816 +1.105500 +1.202947 +1.277420 +1.362982 +1.368734 +1.285116 +1.248007 +1.211633 +1.180222 +1.235564 +1.341232 +1.493206 +1.612131 +1.618121 +1.625000 +1.571745 +1.459633 +1.343551 +1.277370 +1.211264 +1.163383 +1.170426 +1.175448 +1.217470 +1.305274 +1.295011 +1.173072 +1.034382 +0.959745 +0.909275 +0.869084 +0.778851 +0.649645 +0.559430 +0.525067 +0.476432 +0.381578 +0.233781 +0.157416 +0.199901 +0.314752 +0.539386 +0.781042 +0.990634 +1.170137 +1.246885 +1.268126 +1.180015 +1.064679 +0.973186 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_3.txt new file mode 100644 index 0000000000..2bb0cef781 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.220371 +0.112328 +-0.075019 +-0.241588 +-0.362184 +-0.357721 +-0.383737 +-0.407682 +-0.363864 +-0.300312 +-0.218883 +-0.215292 +-0.239019 +-0.303964 +-0.338894 +-0.299746 +-0.297421 +-0.226239 +-0.093147 +0.080922 +0.219209 +0.256359 +0.281152 +0.276463 +0.264202 +0.226745 +0.181221 +0.112178 +0.099345 +0.183186 +0.256603 +0.321784 +0.334316 +0.389554 +0.533441 +0.703395 +0.832970 +0.941402 +1.093683 +1.278960 +1.364377 +1.365686 +1.370013 +1.310389 +1.233846 +1.194933 +1.168762 +1.153961 +1.154271 +1.080648 +0.929681 +0.760549 +0.583628 +0.454406 +0.281967 +0.131086 +0.079608 +0.047894 +0.003413 +0.024170 +0.073226 +0.106088 +0.127928 +0.058349 +0.007387 +0.033465 +0.105058 +0.204991 +0.310151 +0.378775 +0.458521 +0.560881 +0.608623 +0.701672 +0.824709 +0.908902 +1.006640 +1.035850 +1.107446 +1.143986 +1.103046 +1.073115 +1.073421 +1.118115 +1.159422 +1.149846 +1.101513 +0.994839 +0.942165 +0.970280 +1.017869 +1.064312 +1.091185 +1.023493 +0.962306 +0.971791 +0.978662 +1.020211 +1.016806 +0.890728 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_fail.status b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_fail.status new file mode 100644 index 0000000000..6ac0122a28 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_fail.status @@ -0,0 +1 @@ +Did nothing! \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_params.txt new file mode 100644 index 0000000000..c3e63c5f53 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.971949 +OFFSET:0.568165 +PERSISTENCE:0.332226 +OCTAVES:8.48231 +PRIME_1:106.04 +PRIME_2:17.4819 +PRIME_3:56.9629 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/realization.ok b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/realization.ok new file mode 100644 index 0000000000..a0aba9318a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/Run/realisation-9/iter-0/realization.ok @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/current_case b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/current_case new file mode 100644 index 0000000000..331d858ce9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/current_case @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0001/files/PERLIN_active b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0001/files/PERLIN_active new file mode 100644 index 0000000000..c72400474a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0001/files/PERLIN_active differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0002/files/PERLIN_active b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0002/files/PERLIN_active new file mode 100644 index 0000000000..c72400474a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0002/files/PERLIN_active differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0003/files/PERLIN_active b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0003/files/PERLIN_active new file mode 100644 index 0000000000..c72400474a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/0003/files/PERLIN_active differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.data_0 new file mode 100644 index 0000000000..efbe7f58b3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.index new file mode 100644 index 0000000000..b0e9ebe688 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.data_0 new file mode 100644 index 0000000000..a9c2968ca3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.index new file mode 100644 index 0000000000..d16822022a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_0/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.data_0 new file mode 100644 index 0000000000..de1d02fa33 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.index new file mode 100644 index 0000000000..fb519c3d53 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.data_0 new file mode 100644 index 0000000000..5e8b2f1b17 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.index new file mode 100644 index 0000000000..34f7beab32 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_1/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_10/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_11/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_12/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_13/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_14/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_15/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_16/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_17/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_18/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_19/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.data_0 new file mode 100644 index 0000000000..b7b2db9ef2 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.index new file mode 100644 index 0000000000..6453ec00ca Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_2/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_20/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_21/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_22/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_23/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_24/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_25/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_26/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_27/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_28/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_29/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.data_0 new file mode 100644 index 0000000000..199393d8ef Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.index new file mode 100644 index 0000000000..cd8301dcf3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_3/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_30/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_31/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.data_0 new file mode 100644 index 0000000000..8b3a153a8a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.index new file mode 100644 index 0000000000..b5a589b271 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.data_0 new file mode 100644 index 0000000000..f02909a32a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.index new file mode 100644 index 0000000000..8ebbf01df8 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_4/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.data_0 new file mode 100644 index 0000000000..b5cb1eae3a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.index new file mode 100644 index 0000000000..46988dc345 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_5/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.data_0 new file mode 100644 index 0000000000..80f2a9aafd Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.index new file mode 100644 index 0000000000..10ceee2c80 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.data_0 new file mode 100644 index 0000000000..d6b1ac3e58 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.index new file mode 100644 index 0000000000..a3ec21810e Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_6/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.data_0 new file mode 100644 index 0000000000..57a1b2511a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.index new file mode 100644 index 0000000000..51cada30a8 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_7/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.data_0 new file mode 100644 index 0000000000..24edf52b05 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.index new file mode 100644 index 0000000000..bf076ad1aa Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.data_0 new file mode 100644 index 0000000000..703bfe7edb Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.index new file mode 100644 index 0000000000..21f092b0c6 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_8/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.data_0 new file mode 100644 index 0000000000..83c5711b3d Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.index new file mode 100644 index 0000000000..fd35646b63 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.data_0 new file mode 100644 index 0000000000..c78a769777 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.index new file mode 100644 index 0000000000..a8013e439c Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Ensemble/mod_9/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.index new file mode 100644 index 0000000000..05ba4b90c1 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/Index/INDEX.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/ert_fstab b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/ert_fstab new file mode 100644 index 0000000000..8c70bbc5ce Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/ert_fstab differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/case_config b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/case_config new file mode 100644 index 0000000000..593f4708db Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/case_config differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/custom_kw_config_set b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/custom_kw_config_set new file mode 100644 index 0000000000..b51c81a5bb Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/custom_kw_config_set differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/state-map b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/state-map new file mode 100644 index 0000000000..c37c4be56f Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/state-map differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/summary-key-set b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/summary-key-set new file mode 100644 index 0000000000..593f4708db Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/fail_storage/ertensemble/default/files/summary-key-set differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/constant_2 b/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/constant_2 new file mode 100644 index 0000000000..6ac35c9d82 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/constant_2 @@ -0,0 +1,2 @@ +1.414213562373095 +1.414213562373095 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/constant_4 b/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/constant_4 new file mode 100644 index 0000000000..01dd2b944d --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/constant_4 @@ -0,0 +1,4 @@ +2 +2 +2 +2 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/error_in_weights b/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/error_in_weights new file mode 100644 index 0000000000..48458af773 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/iteration_weights/error_in_weights @@ -0,0 +1,4 @@ +2 +2 +error +2 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/AGGREGATOR b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/AGGREGATOR new file mode 100644 index 0000000000..f9571d60f9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/AGGREGATOR @@ -0,0 +1,4 @@ +STDOUT aggregator.stdout +STDERR aggregator.stderr + +EXECUTABLE aggregator.py \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/PERLIN b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/PERLIN new file mode 100644 index 0000000000..fbf5c2ac87 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/PERLIN @@ -0,0 +1,4 @@ +STDOUT perlin.stdout +STDERR perlin.stderr + +EXECUTABLE perlin.py \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/PERLIN_FAIL b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/PERLIN_FAIL new file mode 100644 index 0000000000..f6da4542e8 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/PERLIN_FAIL @@ -0,0 +1,3 @@ +EXECUTABLE perlin_fail.py +TARGET_FILE perlin_fail.status +ARGLIST <IENS> \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/REALIZATION_FAIL b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/REALIZATION_FAIL new file mode 100644 index 0000000000..533677cf99 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/REALIZATION_FAIL @@ -0,0 +1,3 @@ +EXECUTABLE realization_fail.py +TARGET_FILE realization.ok +ARGLIST <IENS> \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/aggregator.py b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/aggregator.py new file mode 100644 index 0000000000..72561296f9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/aggregator.py @@ -0,0 +1,26 @@ +#! /usr/bin/env python + +if __name__ == "__main__": + files = {"PERLIN_1": "perlin_1.txt", + "PERLIN_2": "perlin_2.txt", + "PERLIN_3": "perlin_3.txt"} + + with open("aggregated.txt", "w") as output_file: + sum_of_sum = 0.0 + for key in files: + sum = 0.0 + with open(files[key], "r") as input_file: + sum += float(input_file.readline()) + sum_of_sum += sum + output_file.write("%s %f\n" % (key, sum)) + + if sum_of_sum < 0: + state = "Negative" + elif abs(sum_of_sum) < 0.00000001: + state = "Zero" + else: + state = "Positive" + + output_file.write("STATE %s" % state) + + diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/perlin.py b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/perlin.py new file mode 100644 index 0000000000..7cccc0d1f6 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/perlin.py @@ -0,0 +1,176 @@ +#! /usr/bin/env python +import math +import random + +PRIME_INDEX_1 = [49193,11887,23819,93983,28283,87179,74933,82561,29741,98453,72719,48193,66883,95071,12841,89603, + 49261,52529,57697,70321,54617,49363,41233,39883,35393,33149,37493,42989,58073,62507,99829,41999, + 44087,31907,10627,29231,57559,36809,17123,50593,38449,71317,38149,60637,10607,48677,23189,83701, + 78853,35617,28477,86117,46901,80819,89491,36097,54881,94781,20707,20011,69457,14593,49253,35257, + 14753,44851,10289,36097,62017,82723,10037,77551,89513,70429,30269,30703,77711,69313,20021,31657, + 33851,27749,85667,42793,47599,92789,97771,84551,61637,68659,93263,62201,42131,78823,17747,31183, + 89611,91009,76673,47051,94099,96757,90977,65141,46051,11093,19073,44633,27967,25171,41221,96223, + 88997,74941,49559,11909,11593,97369,55733,35869,55849,87931,81131,99023,76561,78977,48857,74717] + +PRIME_INDEX_2 = [7360349,1287757,3764759,5276833,2735671,7351777,7705903,2034551, + 2427493,3883639,4260859,6814097,3226933,2648249,4458793,8015303, + 2323733,7991233,5560879,9826913,3634811,3746299,1051543,2954789, + 7874983,9380681,4577789,4306829,6714599,8395733,2718493,1429867, + 5675147,6104573,3118727,2657243,9750043,1853377,9441353,7247969, + 7669553,5334157,9376649,9518137,9368297,3912679,3230237,7291939, + 1361677,1034167,4998089,1178239,5160677,6130199,8056553,8527361, + 4261093,8640553,5553391,6024797,7275019,7245019,7661483,5120033, + 4388117,5941147,7682189,9303467,7165777,1509163,5223929,9696487, + 8012383,6254273,1400731,9958177,7733573,1498993,1553467,4791257, + 4524521,7048633,3630821,7931179,2341457,6432269,9597703,4338011, + 6665059,7911653,8384317,2230531,7904621,1633559,9096533,6873301, + 2717821,5897977,3608543,2248243,3174599,8634233,4028963,6435001, + 6611399,3250469,4046353,1429943,8552111,1970261,1045043,9552523, + 6993799,6141467,5723479,9578867,9233299,7224641,3165023,4583899, + 3905861,1633993,5013137,5092613,2197163,7732213,6559019,2538499] + +PRIME_INDEX_3 = [1368916889,3054015583,6066123341,8673964289,9002483141,7187080993,5319345529,6961795349, + 1653814157,3416288497,6454122317,2480898239,3878100221,5956454227,9767569853,5981528503, + 4962084931,4489312199,3013312061,9818685161,4061204663,1816202221,7567463471,9839749459, + 3993070667,5872839331,9256050443,4854483611,4876755749,3823459247,6244209637,4199084081, + 6053970359,1093521049,7385602219,7289318273,9333908789,9701161343,8139801689,5013046681, + 4094649187,2372669671,9010267157,4298511787,7575340187,9252205969,5923706413,7112626819, + 6531270523,8379490583,4521945149,6804302789,6984132251,9173492033,1657527653,1532523367, + 3132088123,5910371431,7551540169,1643193353,6127000571,2637510193,7904761379,2954227033, + 7344843263,8077648457,9397237879,6775740173,1950824101,1152859999,2990299673,8197021109, + 2184824123,4309539167,1742841137,9113517421,4752058561,5594292329,9565022153,8519292151, + 6553311239,5204301593,8405487593,1987918357,3175759277,5659428917,6611421781,8765753053, + 3781235599,5651365571,8399394649,3867050417,3258145379,9836441977,2499690049,2742615479, + 7720787857,6135275183,9580731373,1860360379,2879750459,4302251633,8019104719,3889658671, + 7242891343,2516043583,8081336113,7718332591,4940550151,2216825899,7387662781,5562762407, + 2486416781,9111045257,1197705721,6649659239,6110149477,4548595937,3169540631,8993669479, + 6444114251,3098519969,1609592407,5803463207,8385117647,3056488453,1046337653,8165632597] + +class PerlinNoise(object): + + def __init__(self, persistence=0.5, number_of_octaves=4, prime_1=15731, prime_2=789221, prime_3=1376312589): + self.persistence = persistence + self.number_of_octaves = number_of_octaves + self.prime_1 = prime_1 + self.prime_2 = prime_2 + self.prime_3 = prime_3 + + + def cosineInterpolation(self, a, b, x): + ft = x * 3.1415927 + f = (1.0 - math.cos(ft)) * 0.5 + return a * (1 - f) + b * f + + + def noise(self, x): + x = (x << 13) ^ x + return 1.0 - ((x * (x * x + self.prime_1 + self.prime_2) + self.prime_3) & 0x7fffffff) / 1073741824.0 + + + def smoothedNoise(self, x): + return self.noise(x) / 2.0 + self.noise(x - 1) / 4.0 + self.noise(x + 1) / 4.0 + + + def interpolatedNoise(self, x): + int_x = int(x) + frac_x = x - int_x + + v1 = self.smoothedNoise(int_x) + v2 = self.smoothedNoise(int_x + 1) + + return self.cosineInterpolation(v1, v2, frac_x) + + + def perlinNoise1D(self, x): + total = 0.0 + + for octave in range(self.number_of_octaves - 1): + frequency = math.pow(2, octave) + amplitude = math.pow(self.persistence, octave) + + total += self.interpolatedNoise(x * frequency) * amplitude + + return total + + + @staticmethod + def isPrime(num): + for j in range(2, int(math.sqrt(num) + 1)): + if (num % j) == 0: + return False + return True + + @staticmethod + def createPrime(digits=10): + done = False + low = int("1" + "0" * (digits - 1)) + high = int("9" * digits) + + if low == 1: + low = 2 + + while not done: + num = random.randint(low, high) + if PerlinNoise.isPrime(num): + return num + + +def createObservationFile(report_step, observation, count, std=0.2): + with open("perlin_obs_%d.txt" % report_step, "w") as f: + + for index in range(count): + x = index / 8.0 + f.write("%f %f\n" % (observation.perlinNoise1D(x), std)) + + + +def readParameters(filename): + params = {} + with open(filename, "r") as f: + for line in f: + key, value = line.split(":", 1) + params[key] = float(value) + + return params + + +if __name__ == "__main__": + count = 100 + + # primes = [] + # for p in range(128): + # primes.append(str(PerlinNoise.createPrime(7))) + # + # print(",".join(primes)) + + observations = {1: PerlinNoise(prime_1=15731, prime_2=789221, prime_3=1376312589), + 2: PerlinNoise(prime_1=8831, prime_2=1300237, prime_3=32416187567), + 3: PerlinNoise(prime_1=10657, prime_2=105767, prime_3=2902956923)} + + for report_step in observations: + observation = observations[report_step] + # createObservationFile(report_step, observation, count) + + params = readParameters("perlin_params.txt") + + scale = params["SCALE"] + offset = params["OFFSET"] + octaves = int(round(params["OCTAVES"])) + persistence = params["PERSISTENCE"] + p1_index = int(round(params["PRIME_1"])) + p2_index = int(round(params["PRIME_2"])) + p3_index = int(round(params["PRIME_3"])) + + with open("perlin_%d.txt" % report_step, "w") as f: + P1 = PRIME_INDEX_1[p1_index] + P2 = PRIME_INDEX_2[p2_index] + P3 = PRIME_INDEX_3[p3_index] + # P1 = PerlinNoise.createPrime() + # P2 = PerlinNoise.createPrime() + # P3 = PerlinNoise.createPrime() + report_step_noise = PerlinNoise(persistence=persistence, number_of_octaves=octaves, prime_1=P1, prime_2=P2, prime_3=P3) + + for i in range(count): + x = i / 8.0 + obs = observation.perlinNoise1D(x) + noise = report_step_noise.perlinNoise1D(x) + f.write("%f\n" % (obs + offset + noise * scale)) diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/perlin_fail.py b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/perlin_fail.py new file mode 100644 index 0000000000..fed238f4b2 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/perlin_fail.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +import os +import sys + +iens = None +if len(sys.argv) > 1: + iens = int(sys.argv[1]) + +numbers = [1, 2, 3, 4, 5, 6] +if iens in numbers: + random_report_step = (numbers.index(iens) % 3) + 1 + os.remove("perlin_%d.txt" % random_report_step) + + with open("perlin_fail.status", "w") as f: + f.write("Deleted report step: %d" % random_report_step) + +else: + with open("perlin_fail.status", "w") as f: + f.write("Did nothing!") + + diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/realization_fail.py b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/realization_fail.py new file mode 100644 index 0000000000..33a16ae523 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/jobs/realization_fail.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +import sys + +iens = None +if len(sys.argv) > 1: + iens = int(sys.argv[1]) + +if iens is None or not iens in [2, 3, 5, 7]: + with open("realization.ok", "w") as f: + f.write("OK") + diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/mini_config b/ThirdParty/Ert/devel/test-data/local/custom_kw/mini_config new file mode 100644 index 0000000000..68cee8ce40 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/mini_config @@ -0,0 +1,39 @@ +QUEUE_SYSTEM LOCAL +QUEUE_OPTION LOCAL MAX_RUNNING 4 +DBASE_TYPE BLOCK_FS + +JOBNAME MINI_%d + +DEFINE <STORAGE> storage + +NUM_REALIZATIONS 10 + +STORE_SEED RandomSeed +LOAD_SEED RandomSeed + +RUNPATH <STORAGE>/Run/realisation-%d/iter-%d +ENSPATH <STORAGE>/ertensemble + +INSTALL_JOB AGGREGATOR jobs/AGGREGATOR +INSTALL_JOB PERLIN jobs/PERLIN + +FORWARD_MODEL PERLIN +FORWARD_MODEL AGGREGATOR + +TIME_MAP time_map +GEN_KW PERLIN_PARAM Template/PERLIN_TEMPLATE perlin_params.txt Parameters/PERLIN_PARAMS.txt +GEN_DATA PERLIN INPUT_FORMAT:ASCII RESULT_FILE:perlin_%d.txt REPORT_STEPS:1,2,3 + +UPDATE_RESULTS TRUE + +ENKF_MERGE_OBSERVATIONS TRUE + +LOG_LEVEL 3 +LOG_FILE log/log.txt +UPDATE_LOG_PATH log/UP + +DATA_KW CSV_OUTPUT_PATH custom_output.csv + +OBS_CONFIG Observations/observations + +CUSTOM_KW AGGREGATED aggregated.txt aggregated_out.txt diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/mini_fail_config b/ThirdParty/Ert/devel/test-data/local/custom_kw/mini_fail_config new file mode 100644 index 0000000000..3ef98c6861 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/mini_fail_config @@ -0,0 +1,44 @@ +QUEUE_SYSTEM LOCAL +QUEUE_OPTION LOCAL MAX_RUNNING 4 +DBASE_TYPE BLOCK_FS + +JOBNAME MINI_FAIL_%d + +DEFINE <STORAGE> fail_storage + +NUM_REALIZATIONS 10 +MAX_SUBMIT 1 + +STORE_SEED RandomSeed +LOAD_SEED RandomSeed + +RUNPATH <STORAGE>/Run/realisation-%d/iter-%d +ENSPATH <STORAGE>/ertensemble + +INSTALL_JOB AGGREGATOR jobs/AGGREGATOR +INSTALL_JOB PERLIN jobs/PERLIN +INSTALL_JOB PERLIN_FAIL jobs/PERLIN_FAIL +INSTALL_JOB REALIZATION_FAIL jobs/REALIZATION_FAIL + +FORWARD_MODEL PERLIN +FORWARD_MODEL AGGREGATOR +FORWARD_MODEL PERLIN_FAIL +FORWARD_MODEL REALIZATION_FAIL + +TIME_MAP time_map +GEN_KW PERLIN_PARAM Template/PERLIN_TEMPLATE perlin_params.txt Parameters/PERLIN_PARAMS.txt +GEN_DATA PERLIN INPUT_FORMAT:ASCII RESULT_FILE:perlin_%d.txt REPORT_STEPS:1,2,3 + +UPDATE_RESULTS TRUE + +ENKF_MERGE_OBSERVATIONS TRUE + +LOG_LEVEL 3 +LOG_FILE log/fail_log.txt +UPDATE_LOG_PATH log/UP + +DATA_KW CSV_OUTPUT_PATH custom_output.csv + +OBS_CONFIG Observations/observations + +CUSTOM_KW AGGREGATED aggregated.txt aggregated_out.txt diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/aggregated.txt new file mode 100644 index 0000000000..de8aedc562 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.190479 +PERLIN_2 1.002630 +PERLIN_1 -0.167794 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/parameters.txt new file mode 100644 index 0000000000..142dbecaab --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.249225 +PERLIN_PARAM:OFFSET 0.185709 +PERLIN_PARAM:PERSISTENCE 0.936132 +PERLIN_PARAM:OCTAVES 22.4008 +PERLIN_PARAM:PRIME_1 70.2373 +PERLIN_PARAM:PRIME_2 73.2881 +PERLIN_PARAM:PRIME_3 73.2557 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_1.txt new file mode 100644 index 0000000000..fec0fd107e --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.167794 +-0.533157 +-0.582564 +-0.581187 +-0.544394 +-0.617389 +-0.471483 +-0.570636 +-0.513164 +-0.094431 +-0.489078 +-0.363713 +-0.116233 +0.104267 +-0.185805 +-0.200709 +-0.150918 +-0.384297 +0.293484 +0.122875 +-0.157933 +0.066183 +0.043334 +0.083941 +0.237257 +0.510188 +0.247252 +0.238908 +-0.087547 +-0.330292 +-0.126747 +-0.035823 +-0.234230 +0.031125 +-0.470002 +0.277528 +0.333005 +0.208194 +0.329248 +0.183316 +0.030305 +0.292607 +0.207885 +-0.055542 +0.267287 +0.489294 +0.351695 +0.473816 +0.486845 +0.161185 +0.750709 +0.334430 +0.487895 +-0.083531 +0.631333 +0.189402 +0.293179 +0.416287 +0.071861 +0.343657 +0.530727 +0.295893 +0.707495 +0.705177 +0.364062 +-0.028729 +0.627459 +0.665644 +0.110239 +0.074890 +0.898952 +0.507702 +0.793900 +0.376955 +0.740932 +0.768612 +1.072116 +0.641052 +0.951385 +1.114482 +0.779685 +1.030575 +0.960609 +0.819774 +0.728183 +0.880717 +0.390042 +0.616292 +0.534190 +0.332035 +0.597337 +0.310784 +0.480825 +0.510514 +0.527712 +0.106739 +0.459289 +0.091994 +0.167754 +0.291767 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_2.txt new file mode 100644 index 0000000000..a4c8ae2281 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.002630 +0.655338 +0.637300 +0.558783 +0.509989 +0.408818 +0.436655 +0.277816 +0.357889 +0.712315 +0.209713 +0.181557 +0.234966 +0.360507 +0.067803 +0.095832 +0.180428 +-0.115810 +0.474014 +0.161206 +-0.221441 +0.025834 +-0.014213 +0.125937 +0.403895 +0.794609 +0.711298 +0.792749 +0.559236 +0.409434 +0.702774 +0.910823 +0.767699 +0.951166 +0.307889 +0.894615 +0.815080 +0.581146 +0.515508 +0.201538 +-0.007474 +0.272051 +0.196068 +-0.139775 +0.084654 +0.281485 +0.248246 +0.555883 +0.659358 +0.344063 +1.022407 +0.703206 +0.890554 +0.404788 +1.164953 +0.760065 +0.925984 +0.986234 +0.553851 +0.745948 +0.893678 +0.718616 +1.201408 +1.262021 +0.957160 +0.544980 +1.121517 +0.998898 +0.308482 +0.138122 +0.801380 +0.392979 +0.722289 +0.303537 +0.622059 +0.433718 +0.480651 +-0.144483 +0.012328 +0.129970 +-0.206634 +0.080509 +0.073475 +0.003830 +-0.027990 +0.147703 +-0.360170 +-0.159376 +-0.241837 +-0.406290 +-0.058059 +-0.199599 +0.184944 +0.465746 +0.716346 +0.404191 +0.768554 +0.294930 +0.274427 +0.462347 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_3.txt new file mode 100644 index 0000000000..13a10a9e5d --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.190479 +-0.262978 +-0.465308 +-0.621105 +-0.713738 +-0.781896 +-0.645797 +-0.734690 +-0.615233 +-0.181474 +-0.500371 +-0.375013 +-0.212762 +-0.077491 +-0.367569 +-0.306723 +-0.241907 +-0.432924 +0.314717 +0.254536 +0.131618 +0.477011 +0.476202 +0.498281 +0.657347 +0.936028 +0.654565 +0.605760 +0.338082 +0.190727 +0.442199 +0.602984 +0.446939 +0.753207 +0.301943 +1.023577 +1.019714 +0.773061 +0.805721 +0.709651 +0.597553 +0.944238 +0.917685 +0.547257 +0.715075 +0.782070 +0.537469 +0.655260 +0.690172 +0.323895 +0.846589 +0.260808 +0.196762 +-0.503788 +0.078186 +-0.393964 +-0.242415 +-0.177505 +-0.622958 +-0.465445 +-0.374328 +-0.668502 +-0.282796 +-0.297752 +-0.660453 +-0.993300 +-0.233057 +-0.139662 +-0.658737 +-0.694367 +0.096517 +-0.216566 +0.155464 +-0.212261 +0.141495 +0.047609 +0.314219 +-0.143014 +0.160029 +0.364682 +0.027328 +0.374773 +0.497251 +0.562515 +0.606365 +0.821117 +0.359765 +0.601682 +0.542912 +0.364089 +0.645058 +0.325327 +0.495087 +0.498606 +0.508514 +0.129097 +0.479090 +0.135126 +0.226554 +0.379889 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_params.txt new file mode 100644 index 0000000000..99b2ec3ff6 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-0/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.249225 +OFFSET:0.185709 +PERSISTENCE:0.936132 +OCTAVES:22.4008 +PRIME_1:70.2373 +PRIME_2:73.2881 +PRIME_3:73.2557 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/aggregated.txt new file mode 100644 index 0000000000..c42ebc2573 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.584204 +PERLIN_2 0.227947 +PERLIN_1 -0.942477 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/parameters.txt new file mode 100644 index 0000000000..d931876083 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.24275 +PERLIN_PARAM:OFFSET -0.29096 +PERLIN_PARAM:PERSISTENCE 0.860518 +PERLIN_PARAM:OCTAVES 14.7858 +PERLIN_PARAM:PRIME_1 11.8217 +PERLIN_PARAM:PRIME_2 48.9187 +PERLIN_PARAM:PRIME_3 89.5122 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_1.txt new file mode 100644 index 0000000000..20e4b55793 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.942477 +-0.727071 +-0.723611 +-0.754719 +-0.671417 +-0.731608 +-0.692600 +-0.493644 +-0.676412 +-0.745697 +-0.692443 +-0.578927 +-0.488710 +-0.308417 +-0.198633 +-0.292521 +-0.451160 +-0.454948 +-0.565726 +-0.325299 +-0.477437 +-0.393874 +-0.366932 +-0.181596 +-0.382861 +-0.214575 +-0.343829 +-0.226514 +-0.320776 +-0.308425 +-0.487588 +-0.395820 +-0.742008 +-0.527934 +-0.774032 +-0.603036 +-0.837021 +-0.456712 +-0.387980 +-0.390885 +-0.477976 +-0.396114 +-0.440335 +-0.294043 +-0.320108 +-0.019041 +-0.013591 +-0.252420 +-0.275822 +-0.164093 +-0.136841 +-0.069380 +-0.145731 +-0.021543 +0.105226 +0.109063 +0.010749 +0.174611 +0.235996 +0.229778 +0.234829 +0.303725 +0.413435 +0.191701 +-0.016101 +0.137470 +0.169930 +-0.099989 +-0.129193 +-0.110471 +0.042198 +-0.048338 +-0.349474 +-0.098213 +0.162561 +0.313852 +0.400474 +0.538012 +0.475773 +0.571507 +0.342028 +0.299233 +0.316542 +0.349001 +0.187998 +0.323078 +0.237231 +0.120016 +-0.054434 +-0.139747 +0.160315 +-0.006853 +0.136442 +0.070848 +-0.273561 +-0.222518 +-0.288468 +-0.046234 +-0.175744 +-0.151171 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_2.txt new file mode 100644 index 0000000000..296be5b8cd --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +0.227947 +0.461424 +0.496254 +0.385250 +0.382965 +0.294599 +0.215538 +0.354808 +0.194641 +0.061050 +0.006348 +-0.033658 +-0.137511 +-0.052176 +0.054974 +0.004020 +-0.119814 +-0.186461 +-0.385196 +-0.286967 +-0.540945 +-0.434223 +-0.424480 +-0.139600 +-0.216224 +0.069846 +0.120217 +0.327327 +0.326008 +0.431300 +0.341933 +0.550826 +0.259922 +0.392107 +0.003858 +0.014051 +-0.354946 +-0.083760 +-0.201720 +-0.372664 +-0.515754 +-0.416670 +-0.452153 +-0.378276 +-0.502741 +-0.226850 +-0.117039 +-0.170353 +-0.103309 +0.018785 +0.134857 +0.299396 +0.256928 +0.466775 +0.638846 +0.679726 +0.643554 +0.744558 +0.717986 +0.632070 +0.597780 +0.726447 +0.907347 +0.748545 +0.576996 +0.711178 +0.663988 +0.233265 +0.069050 +-0.047240 +-0.055375 +-0.163060 +-0.421085 +-0.171631 +0.043688 +-0.021042 +-0.190991 +-0.247524 +-0.463284 +-0.413005 +-0.644291 +-0.650833 +-0.570592 +-0.466943 +-0.568175 +-0.409936 +-0.512981 +-0.655652 +-0.830461 +-0.878072 +-0.495081 +-0.517236 +-0.159439 +0.026080 +-0.084928 +0.074934 +0.020797 +0.156703 +-0.069071 +0.019410 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_3.txt new file mode 100644 index 0000000000..d43e140291 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.584204 +-0.456892 +-0.606354 +-0.794637 +-0.840762 +-0.896115 +-0.866915 +-0.657698 +-0.778480 +-0.832740 +-0.703736 +-0.590227 +-0.585239 +-0.490175 +-0.380398 +-0.398535 +-0.542149 +-0.503575 +-0.544492 +-0.193638 +-0.187886 +0.016954 +0.065935 +0.232744 +0.037229 +0.211265 +0.063484 +0.140338 +0.104854 +0.212594 +0.081358 +0.242987 +-0.060839 +0.194148 +-0.002088 +0.143014 +-0.150313 +0.108155 +0.088492 +0.135449 +0.089272 +0.255517 +0.269465 +0.308757 +0.127679 +0.273734 +0.172184 +-0.070976 +-0.072495 +-0.001383 +-0.040962 +-0.143002 +-0.436864 +-0.441800 +-0.447921 +-0.474303 +-0.524845 +-0.419181 +-0.458823 +-0.579324 +-0.670226 +-0.660671 +-0.576856 +-0.811227 +-1.040616 +-0.827102 +-0.690587 +-0.905295 +-0.898169 +-0.879729 +-0.760237 +-0.772606 +-0.987910 +-0.687429 +-0.436876 +-0.407151 +-0.357423 +-0.246055 +-0.315583 +-0.178294 +-0.410329 +-0.356569 +-0.146816 +0.091742 +0.066180 +0.263478 +0.206954 +0.105406 +-0.045712 +-0.107693 +0.208035 +0.007690 +0.150704 +0.058939 +-0.292759 +-0.200161 +-0.268667 +-0.003101 +-0.116944 +-0.063049 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_params.txt new file mode 100644 index 0000000000..fb78e8c3e9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-1/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.24275 +OFFSET:-0.29096 +PERSISTENCE:0.860518 +OCTAVES:14.7858 +PRIME_1:11.8217 +PRIME_2:48.9187 +PRIME_3:89.5122 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/aggregated.txt new file mode 100644 index 0000000000..39c71d12aa --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.294383 +PERLIN_2 0.517768 +PERLIN_1 -0.652656 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/parameters.txt new file mode 100644 index 0000000000..0850de9c61 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.187883 +PERLIN_PARAM:OFFSET -0.512383 +PERLIN_PARAM:PERSISTENCE 0.850056 +PERLIN_PARAM:OCTAVES 39.9199 +PERLIN_PARAM:PRIME_1 76.7337 +PERLIN_PARAM:PRIME_2 54.1086 +PERLIN_PARAM:PRIME_3 16.0042 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_1.txt new file mode 100644 index 0000000000..122d4089ea --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.652656 +-0.856575 +-0.907574 +-0.921559 +-0.907052 +-0.798535 +-0.892001 +-0.898300 +-0.932647 +-0.887530 +-0.745258 +-0.774438 +-0.680597 +-0.707552 +-0.616984 +-0.784930 +-0.705796 +-0.672207 +-0.677662 +-0.517634 +-0.460960 +-0.512998 +-0.485822 +-0.377630 +-0.469687 +-0.463782 +-0.644529 +-0.631042 +-0.610238 +-0.645129 +-0.841183 +-0.813056 +-0.824549 +-0.985474 +-0.818724 +-1.021755 +-0.749654 +-0.643111 +-0.382287 +-0.319701 +-0.240893 +-0.293783 +-0.356379 +-0.315861 +-0.243741 +-0.061641 +-0.016073 +-0.078540 +-0.166452 +-0.204278 +-0.206156 +-0.339674 +-0.324650 +-0.218586 +-0.220018 +-0.365619 +-0.213129 +-0.161173 +-0.144854 +-0.088350 +-0.193806 +-0.111286 +-0.100984 +-0.235155 +-0.165413 +-0.278588 +-0.429381 +-0.254946 +-0.240835 +-0.227267 +-0.524615 +-0.423858 +-0.341032 +-0.369948 +-0.180422 +0.176827 +0.282667 +0.455645 +0.421888 +0.461117 +0.478802 +0.408361 +0.301001 +0.266791 +0.167743 +0.066362 +0.101881 +0.183729 +-0.037895 +0.191528 +0.077918 +0.193353 +0.109073 +0.001759 +-0.061599 +-0.001108 +-0.164077 +-0.253534 +-0.200586 +-0.275259 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_2.txt new file mode 100644 index 0000000000..6e35f0db00 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +0.517768 +0.331920 +0.312291 +0.218411 +0.147331 +0.227672 +0.016137 +-0.049848 +-0.061594 +-0.080783 +-0.046467 +-0.229168 +-0.329398 +-0.451311 +-0.363377 +-0.488389 +-0.374451 +-0.403720 +-0.497132 +-0.479302 +-0.524469 +-0.553347 +-0.543370 +-0.335634 +-0.303049 +-0.179361 +-0.180483 +-0.077200 +0.036546 +0.094596 +-0.011662 +0.133590 +0.177380 +-0.065433 +-0.040833 +-0.404669 +-0.267578 +-0.270158 +-0.196027 +-0.301479 +-0.278672 +-0.314339 +-0.368196 +-0.400094 +-0.426374 +-0.269450 +-0.119522 +0.003527 +0.006061 +-0.021400 +0.065542 +0.029102 +0.078009 +0.269733 +0.313603 +0.205045 +0.419677 +0.408773 +0.337136 +0.313942 +0.169145 +0.311436 +0.392928 +0.321689 +0.427685 +0.295121 +0.064678 +0.078309 +-0.042592 +-0.164036 +-0.622187 +-0.538581 +-0.412642 +-0.443366 +-0.299295 +-0.158067 +-0.308798 +-0.329891 +-0.517169 +-0.523395 +-0.507517 +-0.541705 +-0.586134 +-0.549153 +-0.588430 +-0.666651 +-0.648330 +-0.591939 +-0.813922 +-0.546797 +-0.577477 +-0.317029 +-0.186808 +-0.043009 +0.127034 +0.296344 +0.145188 +-0.050597 +-0.093913 +-0.104679 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_3.txt new file mode 100644 index 0000000000..1e03faf793 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.294383 +-0.586396 +-0.790317 +-0.961476 +-1.076396 +-0.963042 +-1.066316 +-1.062354 +-1.034715 +-0.974573 +-0.756551 +-0.785737 +-0.777126 +-0.889310 +-0.798749 +-0.890944 +-0.796785 +-0.720834 +-0.656429 +-0.385973 +-0.171410 +-0.102170 +-0.052955 +0.036709 +-0.049597 +-0.037941 +-0.237216 +-0.264190 +-0.184608 +-0.124110 +-0.272236 +-0.174249 +-0.143380 +-0.263391 +-0.046779 +-0.275706 +-0.062945 +-0.078243 +0.094185 +0.206634 +0.326354 +0.357848 +0.353421 +0.286938 +0.204047 +0.231135 +0.169701 +0.102903 +0.036875 +-0.041568 +-0.110276 +-0.413296 +-0.615784 +-0.638843 +-0.773164 +-0.948985 +-0.748723 +-0.754966 +-0.839672 +-0.897452 +-1.098861 +-1.075682 +-1.091275 +-1.238084 +-1.189928 +-1.243159 +-1.289897 +-1.060251 +-1.009811 +-0.996525 +-1.327050 +-1.148126 +-0.979468 +-0.959163 +-0.779859 +-0.544176 +-0.475229 +-0.328422 +-0.369468 +-0.288684 +-0.273556 +-0.247441 +-0.162358 +0.009532 +0.045926 +0.006763 +0.071604 +0.169119 +-0.029173 +0.223582 +0.125639 +0.207896 +0.123334 +-0.010150 +-0.080797 +0.021249 +-0.144276 +-0.210401 +-0.141786 +-0.187137 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_params.txt new file mode 100644 index 0000000000..a069d36ab8 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-2/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.187883 +OFFSET:-0.512383 +PERSISTENCE:0.850056 +OCTAVES:39.9199 +PRIME_1:76.7337 +PRIME_2:54.1086 +PRIME_3:16.0042 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/aggregated.txt new file mode 100644 index 0000000000..b986f1b481 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.871387 +PERLIN_2 -0.059236 +PERLIN_1 -1.229660 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/parameters.txt new file mode 100644 index 0000000000..a7472afccf --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.542054 +PERLIN_PARAM:OFFSET -0.936072 +PERLIN_PARAM:PERSISTENCE 0.66513 +PERLIN_PARAM:OCTAVES 59.6891 +PERLIN_PARAM:PRIME_1 58.3958 +PERLIN_PARAM:PRIME_2 51.6271 +PERLIN_PARAM:PRIME_3 37.3286 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_1.txt new file mode 100644 index 0000000000..1f0aabd193 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-1.229660 +-1.403213 +-1.494882 +-1.481222 +-1.545058 +-1.605346 +-1.466829 +-1.460689 +-1.589462 +-1.462504 +-1.586371 +-1.419953 +-1.184666 +-1.064367 +-1.081730 +-1.130531 +-1.307146 +-1.330892 +-1.147255 +-1.230522 +-1.290812 +-1.243312 +-1.053225 +-0.837831 +-0.815416 +-0.794856 +-0.780118 +-0.867346 +-0.868595 +-0.844661 +-0.949974 +-1.135521 +-1.278698 +-1.237066 +-1.353473 +-1.274754 +-1.024540 +-1.062374 +-1.018191 +-0.989482 +-1.082235 +-1.083477 +-1.111900 +-0.884140 +-0.804378 +-0.649785 +-0.414051 +-0.453314 +-0.426393 +-0.376335 +-0.433952 +-0.369796 +-0.319725 +-0.318209 +-0.380495 +-0.274543 +-0.410077 +-0.265464 +-0.276032 +-0.293185 +-0.259478 +-0.307654 +-0.469020 +-0.606702 +-0.727993 +-0.657698 +-0.738949 +-0.779068 +-0.929409 +-0.925120 +-0.888902 +-0.818882 +-0.691387 +-0.806321 +-0.774223 +-0.725947 +-0.616177 +-0.575377 +-0.546778 +-0.619225 +-0.739783 +-0.805058 +-0.854443 +-1.003113 +-0.978222 +-0.724971 +-0.804323 +-0.920953 +-0.973738 +-0.936418 +-0.905518 +-0.717744 +-0.616881 +-0.785126 +-0.782606 +-0.680625 +-0.739233 +-0.708171 +-0.640854 +-0.813288 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_2.txt new file mode 100644 index 0000000000..58ac16bef2 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +-0.059236 +-0.214718 +-0.275017 +-0.341253 +-0.490676 +-0.579139 +-0.558691 +-0.612236 +-0.718408 +-0.655757 +-0.887580 +-0.874683 +-0.833466 +-0.808127 +-0.828123 +-0.833990 +-0.975800 +-1.062405 +-0.966725 +-1.192190 +-1.354320 +-1.283661 +-1.110772 +-0.795835 +-0.648779 +-0.510435 +-0.316072 +-0.313505 +-0.221812 +-0.104936 +-0.120453 +-0.188875 +-0.276769 +-0.317026 +-0.575582 +-0.657667 +-0.542465 +-0.689421 +-0.831931 +-0.971260 +-1.120014 +-1.104033 +-1.123718 +-0.968373 +-0.987011 +-0.857594 +-0.517499 +-0.371248 +-0.253880 +-0.193457 +-0.162254 +-0.001019 +0.082934 +0.170110 +0.153126 +0.296120 +0.222728 +0.304483 +0.205958 +0.109107 +0.103474 +0.115069 +0.024892 +-0.049858 +-0.134896 +-0.083989 +-0.244890 +-0.445814 +-0.731166 +-0.861888 +-0.986474 +-0.933604 +-0.762998 +-0.879739 +-0.893096 +-1.060842 +-1.207642 +-1.360912 +-1.485835 +-1.603737 +-1.726102 +-1.755124 +-1.741578 +-1.819057 +-1.734395 +-1.457985 +-1.554534 +-1.696621 +-1.749765 +-1.674743 +-1.560913 +-1.228126 +-0.912762 +-0.829894 +-0.593973 +-0.383174 +-0.429968 +-0.505235 +-0.534181 +-0.642708 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_3.txt new file mode 100644 index 0000000000..3e28703234 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.871387 +-1.133034 +-1.377625 +-1.521140 +-1.714403 +-1.769853 +-1.641143 +-1.624743 +-1.691530 +-1.549547 +-1.597664 +-1.431252 +-1.281194 +-1.246125 +-1.263495 +-1.236545 +-1.398135 +-1.379519 +-1.126021 +-1.098861 +-1.001261 +-0.832484 +-0.620357 +-0.423492 +-0.395326 +-0.369015 +-0.372806 +-0.500494 +-0.442966 +-0.323643 +-0.381027 +-0.496714 +-0.597530 +-0.514984 +-0.581528 +-0.528705 +-0.337832 +-0.497506 +-0.541718 +-0.463147 +-0.514987 +-0.431846 +-0.402100 +-0.281341 +-0.356591 +-0.357009 +-0.228277 +-0.271871 +-0.223066 +-0.213625 +-0.338073 +-0.443417 +-0.610858 +-0.738466 +-0.933641 +-0.857909 +-0.945672 +-0.859256 +-0.970850 +-1.102287 +-1.164532 +-1.272049 +-1.459311 +-1.609631 +-1.752508 +-1.622269 +-1.599465 +-1.584374 +-1.698385 +-1.694377 +-1.691337 +-1.543150 +-1.329823 +-1.395537 +-1.373660 +-1.446951 +-1.374073 +-1.359444 +-1.338134 +-1.369026 +-1.492140 +-1.460860 +-1.317801 +-1.260372 +-1.100040 +-0.784571 +-0.834600 +-0.935563 +-0.965016 +-0.904364 +-0.857797 +-0.703201 +-0.602620 +-0.797035 +-0.801804 +-0.658268 +-0.719432 +-0.665039 +-0.582054 +-0.725166 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_params.txt new file mode 100644 index 0000000000..f51328cc14 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-3/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.542054 +OFFSET:-0.936072 +PERSISTENCE:0.66513 +OCTAVES:59.6891 +PRIME_1:58.3958 +PRIME_2:51.6271 +PRIME_3:37.3286 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/aggregated.txt new file mode 100644 index 0000000000..35536135e9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.585905 +PERLIN_2 1.398056 +PERLIN_1 0.227632 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/parameters.txt new file mode 100644 index 0000000000..43486a893a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.434448 +PERLIN_PARAM:OFFSET 0.831105 +PERLIN_PARAM:PERSISTENCE 0.630867 +PERLIN_PARAM:OCTAVES 8.00407 +PERLIN_PARAM:PRIME_1 85.4235 +PERLIN_PARAM:PRIME_2 21.3039 +PERLIN_PARAM:PRIME_3 104.858 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_1.txt new file mode 100644 index 0000000000..7ea431597a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +0.227632 +0.182419 +0.144134 +0.139476 +0.177808 +0.254702 +0.194959 +0.196247 +0.200894 +0.254938 +0.395923 +0.419362 +0.480212 +0.525709 +0.561013 +0.552975 +0.519655 +0.497365 +0.577627 +0.735132 +0.817150 +0.830304 +0.810482 +0.786231 +0.748806 +0.689116 +0.617421 +0.687358 +0.594608 +0.517947 +0.548341 +0.523440 +0.419855 +0.405486 +0.372455 +0.434415 +0.562727 +0.733549 +0.970895 +1.160018 +1.169762 +1.111676 +1.111566 +1.106991 +1.105426 +1.213650 +1.175046 +1.097622 +1.076414 +1.020738 +0.967021 +0.935108 +0.968248 +1.090303 +1.177846 +1.141175 +1.035475 +1.007184 +1.064612 +1.220228 +1.325731 +1.365550 +1.388177 +1.239332 +1.196752 +1.250964 +1.102255 +1.021732 +1.011481 +1.046014 +1.021100 +1.037203 +0.983562 +1.047336 +1.209270 +1.527246 +1.651524 +1.778722 +1.953437 +1.897861 +1.919134 +1.832772 +1.722330 +1.690519 +1.644280 +1.609237 +1.499923 +1.390382 +1.225122 +1.258604 +1.269723 +1.248156 +1.156463 +1.014345 +0.967288 +0.922071 +0.964769 +0.867821 +0.886340 +0.661428 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_2.txt new file mode 100644 index 0000000000..b747326d4e --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.398056 +1.370914 +1.363998 +1.279446 +1.232190 +1.280908 +1.103097 +1.044700 +1.071948 +1.061684 +1.094715 +0.964632 +0.831411 +0.781949 +0.814620 +0.849516 +0.851001 +0.765851 +0.758157 +0.773463 +0.753641 +0.789955 +0.752934 +0.828227 +0.915443 +0.973537 +1.081467 +1.241200 +1.241392 +1.257672 +1.377862 +1.470086 +1.421784 +1.325527 +1.150346 +1.051501 +1.044802 +1.106502 +1.157155 +1.178239 +1.131983 +1.091121 +1.099748 +1.022758 +0.922794 +1.005841 +1.071597 +1.179689 +1.248927 +1.203617 +1.238719 +1.303884 +1.370907 +1.578622 +1.711466 +1.711839 +1.668280 +1.577131 +1.546602 +1.622520 +1.688682 +1.788272 +1.882089 +1.796176 +1.789849 +1.824672 +1.596314 +1.354986 +1.209724 +1.109246 +0.923528 +0.922481 +0.911951 +0.973918 +1.090397 +1.192352 +1.060059 +0.993187 +1.014380 +0.913349 +0.932815 +0.882706 +0.835195 +0.874574 +0.888107 +0.876224 +0.749712 +0.614713 +0.449095 +0.520278 +0.614327 +0.737773 +0.860582 +0.969577 +1.155922 +1.219523 +1.274034 +1.070757 +0.993013 +0.832009 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_3.txt new file mode 100644 index 0000000000..c5dd1d518a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.585905 +0.452598 +0.261390 +0.099559 +0.008463 +0.090195 +0.020645 +0.032193 +0.098826 +0.167894 +0.384631 +0.408063 +0.383683 +0.343951 +0.379248 +0.446961 +0.428666 +0.448737 +0.598860 +0.866793 +1.106700 +1.241132 +1.243349 +1.200570 +1.168896 +1.114956 +1.024733 +1.054210 +1.020238 +1.038965 +1.117287 +1.162247 +1.101024 +1.127568 +1.144400 +1.180464 +1.249435 +1.298417 +1.447368 +1.686352 +1.737009 +1.763308 +1.821366 +1.709790 +1.553214 +1.506426 +1.360820 +1.279066 +1.279741 +1.183449 +1.062901 +0.861486 +0.677115 +0.670046 +0.624699 +0.557809 +0.499881 +0.413392 +0.369794 +0.411126 +0.420676 +0.401154 +0.397886 +0.236404 +0.172236 +0.286392 +0.241739 +0.216426 +0.242506 +0.276757 +0.218665 +0.312935 +0.345126 +0.458120 +0.609833 +0.806243 +0.893627 +0.994656 +1.162081 +1.148060 +1.166777 +1.176970 +1.258971 +1.433259 +1.522462 +1.549638 +1.469646 +1.375772 +1.233844 +1.290657 +1.317444 +1.262699 +1.170724 +1.002436 +0.948090 +0.944428 +0.984570 +0.910954 +0.945140 +0.749551 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_params.txt new file mode 100644 index 0000000000..324cbda2ee --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-4/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.434448 +OFFSET:0.831105 +PERSISTENCE:0.630867 +OCTAVES:8.00407 +PRIME_1:85.4235 +PRIME_2:21.3039 +PRIME_3:104.858 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/aggregated.txt new file mode 100644 index 0000000000..72e58cbf64 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.638889 +PERLIN_2 1.451039 +PERLIN_1 0.280615 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/parameters.txt new file mode 100644 index 0000000000..463f5c41d8 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.72828 +PERLIN_PARAM:OFFSET 0.48251 +PERLIN_PARAM:PERSISTENCE 0.878696 +PERLIN_PARAM:OCTAVES 62.5026 +PERLIN_PARAM:PRIME_1 10.3564 +PERLIN_PARAM:PRIME_2 34.9666 +PERLIN_PARAM:PRIME_3 46.2883 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_1.txt new file mode 100644 index 0000000000..11da497a09 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +0.280615 +0.140016 +0.101814 +-0.129046 +0.108540 +0.255758 +-0.136433 +0.402995 +0.060006 +0.243033 +0.270699 +1.032076 +-0.013904 +-0.123877 +0.661223 +0.260982 +0.218027 +1.382060 +0.399264 +0.483361 +0.472825 +-0.400746 +1.339330 +0.692467 +0.043042 +0.542935 +-0.239154 +0.322095 +0.568886 +-0.253825 +0.069002 +0.151587 +-0.060719 +0.071557 +1.232762 +0.806173 +0.197592 +0.775339 +0.485706 +-0.340968 +0.563185 +-0.301442 +-0.470657 +0.391865 +1.604934 +1.366571 +0.978296 +0.533236 +0.199409 +0.640021 +0.724001 +0.620437 +-0.062286 +0.448127 +0.681424 +0.211811 +0.962468 +0.569284 +0.153403 +0.463251 +0.717336 +1.047732 +0.879313 +0.557671 +0.589243 +0.475895 +0.668305 +1.261389 +1.992548 +0.514705 +1.480108 +0.964709 +0.672593 +0.541782 +1.389203 +0.533862 +1.237538 +0.892042 +0.376384 +0.676731 +1.374955 +1.291646 +0.276911 +0.706050 +0.032507 +1.074094 +0.914922 +1.747032 +2.087744 +1.287205 +1.735100 +1.305039 +1.283753 +0.989592 +0.686460 +0.373096 +0.309114 +0.349820 +0.814016 +0.915557 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_2.txt new file mode 100644 index 0000000000..1a12f1d5e3 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.451039 +1.328511 +1.321678 +1.010924 +1.162923 +1.281965 +0.771705 +1.251448 +0.931060 +1.049780 +0.969490 +1.577345 +0.337295 +0.132363 +0.914830 +0.557523 +0.549373 +1.650547 +0.579795 +0.521693 +0.409316 +-0.441095 +1.281782 +0.734463 +0.209679 +0.827356 +0.224891 +0.875937 +1.215669 +0.485900 +0.898524 +1.098233 +0.941210 +0.991598 +2.010653 +1.423259 +0.679667 +1.148292 +0.671966 +-0.322746 +0.525407 +-0.321998 +-0.482474 +0.307632 +1.422302 +1.158762 +0.874847 +0.615302 +0.371922 +0.822899 +0.995699 +0.989214 +0.340374 +0.936446 +1.215045 +0.782475 +1.595273 +1.139231 +0.635393 +0.865543 +1.080287 +1.470455 +1.373225 +1.114515 +1.182340 +1.049604 +1.162364 +1.594643 +2.190791 +0.577937 +1.382536 +0.849987 +0.600982 +0.468364 +1.270330 +0.198968 +0.646073 +0.106506 +-0.562673 +-0.307781 +0.388636 +0.341580 +-0.610223 +-0.109894 +-0.723666 +0.341080 +0.164710 +0.971363 +1.311717 +0.548880 +1.079704 +0.794657 +0.987872 +0.944824 +0.875093 +0.670548 +0.618379 +0.552756 +0.920689 +1.086138 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_3.txt new file mode 100644 index 0000000000..4b5a132c2c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.638889 +0.410195 +0.219070 +-0.168964 +-0.060804 +0.091251 +-0.310748 +0.238941 +-0.042062 +0.155990 +0.259406 +1.020776 +-0.110433 +-0.305635 +0.479458 +0.154968 +0.127038 +1.333433 +0.420498 +0.615022 +0.762375 +0.010082 +1.772197 +1.106807 +0.463132 +0.968775 +0.168158 +0.688947 +0.994515 +0.267193 +0.637949 +0.790394 +0.620450 +0.793639 +2.004706 +1.552222 +0.884301 +1.340207 +0.962178 +0.185367 +1.130433 +0.350189 +0.239143 +0.994664 +2.052722 +1.659346 +1.164070 +0.714679 +0.402736 +0.802732 +0.819881 +0.546816 +-0.353419 +0.027870 +0.128278 +-0.371555 +0.426874 +-0.024508 +-0.541415 +-0.345851 +-0.187719 +0.083337 +-0.110978 +-0.445258 +-0.435272 +-0.488676 +-0.192211 +0.456083 +1.223572 +-0.254552 +0.677673 +0.240441 +0.034157 +-0.047433 +0.789765 +-0.187141 +0.479641 +0.107975 +-0.414972 +-0.073069 +0.622598 +0.635844 +-0.186447 +0.448791 +-0.089311 +1.014494 +0.884645 +1.732422 +2.096466 +1.319259 +1.782821 +1.319583 +1.298015 +0.977683 +0.667262 +0.395453 +0.328915 +0.392952 +0.872816 +1.003679 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_params.txt new file mode 100644 index 0000000000..6ffe51857b --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-5/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.72828 +OFFSET:0.48251 +PERSISTENCE:0.878696 +OCTAVES:62.5026 +PRIME_1:10.3564 +PRIME_2:34.9666 +PRIME_3:46.2883 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/aggregated.txt new file mode 100644 index 0000000000..07f12f2a08 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.870550 +PERLIN_2 1.682701 +PERLIN_1 0.512277 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/parameters.txt new file mode 100644 index 0000000000..04dc1adb80 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.105108 +PERLIN_PARAM:OFFSET 0.913379 +PERLIN_PARAM:PERSISTENCE 0.962764 +PERLIN_PARAM:OCTAVES 54.2875 +PERLIN_PARAM:PRIME_1 12.1353 +PERLIN_PARAM:PRIME_2 108.225 +PERLIN_PARAM:PRIME_3 58.2668 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_1.txt new file mode 100644 index 0000000000..309c31a80b --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +0.512277 +0.536404 +0.520619 +0.520234 +0.561383 +0.536841 +0.593527 +0.431159 +0.579716 +0.595432 +0.613877 +0.832759 +0.851509 +0.830369 +0.752398 +0.701988 +0.854139 +0.813144 +0.848016 +0.675839 +0.919173 +1.078956 +1.165071 +1.045397 +1.099168 +1.049976 +0.934854 +0.813458 +0.777245 +0.747191 +0.680688 +0.492784 +0.756629 +0.639112 +0.677362 +0.560299 +0.783620 +0.757035 +0.781494 +1.092201 +1.102767 +1.052654 +1.207713 +1.115009 +1.380213 +1.620005 +1.355587 +1.358326 +1.365758 +1.049275 +1.264629 +1.182026 +1.240226 +1.329804 +1.210895 +1.340758 +1.160254 +1.099240 +1.243394 +1.267952 +1.359115 +1.457122 +1.219766 +1.225781 +1.439935 +1.367284 +1.242810 +1.155161 +1.278395 +1.180081 +1.125988 +1.131542 +1.239492 +1.086901 +1.273243 +1.532824 +1.482385 +1.810195 +1.887451 +1.774089 +1.870171 +1.843973 +1.696110 +1.740468 +1.791604 +1.614504 +1.582554 +1.758357 +1.634232 +1.684106 +1.786180 +1.619646 +1.484936 +1.430948 +1.379634 +1.352505 +1.382218 +1.487943 +1.057155 +0.971585 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_2.txt new file mode 100644 index 0000000000..463edcab27 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.682701 +1.724900 +1.740484 +1.660204 +1.615765 +1.563048 +1.501665 +1.279611 +1.450770 +1.402179 +1.312668 +1.378029 +1.202709 +1.086610 +1.006006 +0.998528 +1.185484 +1.081631 +1.028546 +0.714171 +0.855664 +1.038607 +1.107524 +1.087393 +1.265806 +1.334397 +1.398900 +1.367299 +1.424028 +1.486916 +1.510209 +1.439430 +1.758558 +1.559152 +1.455253 +1.177386 +1.265695 +1.129987 +0.967754 +1.110422 +1.064988 +1.032099 +1.195895 +1.030776 +1.197580 +1.412196 +1.252139 +1.440393 +1.538272 +1.232153 +1.536327 +1.550802 +1.642885 +1.818122 +1.744516 +1.911422 +1.793059 +1.669187 +1.725384 +1.670243 +1.722066 +1.879845 +1.713679 +1.782625 +2.033032 +1.940992 +1.736869 +1.488416 +1.476638 +1.243313 +1.028416 +1.016820 +1.167881 +1.013483 +1.154370 +1.197929 +0.890921 +1.024660 +0.948394 +0.789577 +0.883852 +0.893907 +0.808975 +0.924524 +1.035431 +0.881490 +0.832342 +0.982689 +0.858205 +0.945780 +1.130784 +1.109264 +1.189055 +1.386180 +1.568267 +1.649957 +1.691483 +1.690880 +1.163828 +1.142166 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_3.txt new file mode 100644 index 0000000000..bb7c009032 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.870550 +0.806583 +0.637876 +0.480317 +0.392038 +0.372334 +0.419213 +0.267105 +0.477648 +0.508389 +0.602584 +0.821460 +0.754981 +0.648612 +0.570634 +0.595973 +0.763150 +0.764517 +0.869249 +0.807500 +1.208723 +1.489784 +1.597939 +1.459736 +1.519258 +1.475816 +1.342167 +1.180310 +1.202874 +1.268209 +1.249634 +1.131591 +1.437798 +1.361194 +1.449307 +1.306349 +1.470329 +1.321902 +1.257966 +1.618535 +1.670015 +1.704286 +1.917513 +1.717808 +1.828000 +1.912781 +1.541362 +1.539769 +1.569085 +1.211985 +1.360508 +1.108404 +0.949092 +0.909547 +0.657749 +0.757392 +0.624659 +0.505448 +0.548575 +0.458850 +0.454060 +0.492727 +0.229476 +0.222852 +0.415420 +0.402712 +0.382294 +0.349856 +0.509419 +0.410824 +0.323553 +0.407274 +0.601056 +0.497685 +0.673805 +0.811821 +0.724489 +1.026129 +1.096095 +1.024289 +1.117814 +1.188171 +1.232752 +1.483209 +1.669786 +1.554904 +1.552277 +1.743747 +1.642953 +1.716159 +1.833900 +1.634190 +1.499198 +1.419039 +1.360436 +1.374862 +1.402018 +1.531076 +1.115955 +1.059708 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_params.txt new file mode 100644 index 0000000000..29d18ec899 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-6/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.105108 +OFFSET:0.913379 +PERSISTENCE:0.962764 +OCTAVES:54.2875 +PRIME_1:12.1353 +PRIME_2:108.225 +PRIME_3:58.2668 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/aggregated.txt new file mode 100644 index 0000000000..6b3b4204d7 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.223092 +PERLIN_2 0.589059 +PERLIN_1 -0.581365 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/parameters.txt new file mode 100644 index 0000000000..0fec4832fd --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.100905 +PERLIN_PARAM:OFFSET 0.749785 +PERLIN_PARAM:PERSISTENCE 0.960394 +PERLIN_PARAM:OCTAVES 27.0099 +PERLIN_PARAM:PRIME_1 40.6138 +PERLIN_PARAM:PRIME_2 61.0175 +PERLIN_PARAM:PRIME_3 87.8034 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_1.txt new file mode 100644 index 0000000000..f4ab414309 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.581365 +0.196529 +0.251092 +0.129792 +0.331063 +0.243506 +0.276892 +0.080451 +0.396119 +0.359775 +0.367571 +0.375403 +0.583877 +0.600213 +0.433206 +0.667000 +0.730207 +0.597004 +0.652034 +0.663611 +0.746119 +0.692967 +0.730701 +0.876335 +0.892405 +0.727578 +0.723739 +0.564331 +0.468088 +0.488808 +0.664805 +0.660028 +0.630792 +0.524399 +0.474312 +0.443139 +0.580488 +0.481039 +0.800572 +1.001564 +0.911524 +0.901357 +0.788429 +0.858484 +0.905262 +1.091118 +1.153703 +1.092191 +1.125297 +0.931559 +0.887913 +0.949225 +1.000548 +1.157858 +0.916321 +0.916039 +0.825100 +0.963569 +0.946300 +1.325529 +1.317807 +1.051895 +1.371837 +1.120878 +1.290153 +1.132642 +1.106899 +0.951717 +1.053646 +1.097485 +0.993622 +1.071263 +1.003207 +1.060272 +0.945896 +1.081059 +1.483716 +1.639907 +1.778137 +1.743444 +1.658571 +1.670091 +1.528567 +1.360096 +1.348333 +1.247859 +1.311556 +1.223970 +1.139654 +1.236625 +1.220851 +1.388255 +1.244178 +1.146154 +1.093360 +0.984612 +1.125281 +1.104519 +0.927790 +0.740832 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_2.txt new file mode 100644 index 0000000000..3b2079e9c1 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +0.589059 +1.385024 +1.470957 +1.269762 +1.385446 +1.269712 +1.185030 +0.928904 +1.267172 +1.166521 +1.066362 +0.920673 +0.935076 +0.856454 +0.686814 +0.963540 +1.061552 +0.865491 +0.832564 +0.701943 +0.682610 +0.652618 +0.673153 +0.918331 +1.059042 +1.011999 +1.187784 +1.118172 +1.114871 +1.228534 +1.494326 +1.606674 +1.632721 +1.444440 +1.252203 +1.060226 +1.062564 +0.853991 +0.986832 +1.019786 +0.873746 +0.880802 +0.776611 +0.774251 +0.722629 +0.883309 +1.050254 +1.174258 +1.297810 +1.114437 +1.159611 +1.318001 +1.403207 +1.646177 +1.449942 +1.486702 +1.457905 +1.533516 +1.428289 +1.727821 +1.680758 +1.474617 +1.865750 +1.677722 +1.883250 +1.706351 +1.600958 +1.284972 +1.251889 +1.160717 +0.896049 +0.956541 +0.931596 +0.986854 +0.827023 +0.746164 +0.892252 +0.854372 +0.839080 +0.758932 +0.672252 +0.720025 +0.641433 +0.544152 +0.592160 +0.514846 +0.561344 +0.448302 +0.363627 +0.498299 +0.565455 +0.877873 +0.948297 +1.101386 +1.281993 +1.282064 +1.434546 +1.307456 +1.034463 +0.911412 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_3.txt new file mode 100644 index 0000000000..520a51e79f --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.223092 +0.466707 +0.368349 +0.089874 +0.161719 +0.078999 +0.102578 +-0.083603 +0.294051 +0.272732 +0.356278 +0.364104 +0.487348 +0.418455 +0.251441 +0.560986 +0.639218 +0.548377 +0.673267 +0.795272 +1.035669 +1.103795 +1.163568 +1.290674 +1.312494 +1.153418 +1.131051 +0.931183 +0.893717 +1.009827 +1.233752 +1.298835 +1.311961 +1.246482 +1.246256 +1.189188 +1.267197 +1.045907 +1.277045 +1.527899 +1.478772 +1.552988 +1.498229 +1.461283 +1.353050 +1.383894 +1.339477 +1.273635 +1.328624 +1.094269 +0.983792 +0.875603 +0.709414 +0.737601 +0.363175 +0.332673 +0.289505 +0.369777 +0.251481 +0.516427 +0.412752 +0.087499 +0.381547 +0.117950 +0.265638 +0.168071 +0.246383 +0.146412 +0.284670 +0.328228 +0.191186 +0.346995 +0.364771 +0.471056 +0.346459 +0.360055 +0.725820 +0.855841 +0.986781 +0.993643 +0.906214 +1.014289 +1.065209 +1.102837 +1.226516 +1.188260 +1.281279 +1.209360 +1.148376 +1.268678 +1.268572 +1.402798 +1.258439 +1.134246 +1.074161 +1.006970 +1.145082 +1.147652 +0.986590 +0.828954 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_params.txt new file mode 100644 index 0000000000..4455122772 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-7/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.100905 +OFFSET:0.749785 +PERSISTENCE:0.960394 +OCTAVES:27.0099 +PRIME_1:40.6138 +PRIME_2:61.0175 +PRIME_3:87.8034 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/STATUS b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/STATUS new file mode 100644 index 0000000000..bfebf7ba94 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/STATUS @@ -0,0 +1,3 @@ +Current host : lx-774616.local/x86_64 +PERLIN : 17:15:11 .... 17:15:12 +AGGREGATOR : 17:15:12 .... 17:15:12 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/aggregated.txt new file mode 100644 index 0000000000..244709c651 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 -0.917785 +PERLIN_2 -0.105634 +PERLIN_1 -1.276058 +STATE Negative \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/jobs.py b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/jobs.py new file mode 100644 index 0000000000..ac1ccc465d --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/jobs.py @@ -0,0 +1,28 @@ +jobList = [ {"name" : "PERLIN", + "executable" : "/Users/jpb/projects/ert/devel/test-data/local/custom_kw/jobs/perlin.py", + "target_file" : None, + "error_file" : None, + "start_file" : None, + "stdout" : "perlin.stdout", + "stderr" : "perlin.stderr", + "stdin" : None, + "argList" : [], + "environment" : None, + "license_path" : None, + "max_running_minutes" : None, + "max_running" : None, +}, + {"name" : "AGGREGATOR", + "executable" : "/Users/jpb/projects/ert/devel/test-data/local/custom_kw/jobs/aggregator.py", + "target_file" : None, + "error_file" : None, + "start_file" : None, + "stdout" : "aggregator.stdout", + "stderr" : "aggregator.stderr", + "stdin" : None, + "argList" : [], + "environment" : None, + "license_path" : None, + "max_running_minutes" : None, + "max_running" : None, +}] diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/parameters.txt new file mode 100644 index 0000000000..59ba741905 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.494279 +PERLIN_PARAM:OFFSET -0.526799 +PERLIN_PARAM:PERSISTENCE 0.0911083 +PERLIN_PARAM:OCTAVES 43.0492 +PERLIN_PARAM:PRIME_1 123.299 +PERLIN_PARAM:PRIME_2 42.4258 +PERLIN_PARAM:PRIME_3 14.0702 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_1.txt new file mode 100644 index 0000000000..6aa944dccf --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-1.276058 +-1.289017 +-1.314341 +-1.306601 +-1.296437 +-1.293440 +-1.259407 +-1.266510 +-1.294486 +-1.261902 +-1.202479 +-1.080475 +-0.954164 +-0.885534 +-0.858941 +-0.894787 +-0.919912 +-0.916939 +-0.886507 +-0.799550 +-0.721154 +-0.650200 +-0.537956 +-0.483812 +-0.489635 +-0.525394 +-0.546662 +-0.527208 +-0.534832 +-0.533549 +-0.538252 +-0.584050 +-0.611137 +-0.630059 +-0.650202 +-0.616093 +-0.568181 +-0.463276 +-0.334508 +-0.259597 +-0.221372 +-0.259230 +-0.279580 +-0.244302 +-0.207325 +-0.170186 +-0.177288 +-0.240439 +-0.278604 +-0.325685 +-0.411518 +-0.447688 +-0.438482 +-0.430901 +-0.426508 +-0.473419 +-0.523455 +-0.492174 +-0.429854 +-0.320462 +-0.242691 +-0.226471 +-0.221185 +-0.262628 +-0.292571 +-0.326766 +-0.377534 +-0.383441 +-0.373359 +-0.364832 +-0.330290 +-0.341756 +-0.378785 +-0.325450 +-0.201339 +-0.014930 +0.131198 +0.218084 +0.307262 +0.331535 +0.323047 +0.275638 +0.204499 +0.189781 +0.216423 +0.234694 +0.244237 +0.196780 +0.140343 +0.139795 +0.132064 +0.149348 +0.135500 +0.067575 +-0.002818 +-0.038351 +-0.033175 +-0.039802 +-0.104931 +-0.282153 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_2.txt new file mode 100644 index 0000000000..9527f5ea7a --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +-0.105634 +-0.100522 +-0.094477 +-0.166631 +-0.242055 +-0.267233 +-0.351269 +-0.418058 +-0.423433 +-0.455156 +-0.503687 +-0.535205 +-0.602964 +-0.629293 +-0.605334 +-0.598246 +-0.588567 +-0.648452 +-0.705977 +-0.761218 +-0.784663 +-0.690549 +-0.595504 +-0.441816 +-0.322998 +-0.240974 +-0.082616 +0.026633 +0.111952 +0.206176 +0.291269 +0.362596 +0.390792 +0.289982 +0.127689 +0.000994 +-0.086106 +-0.090324 +-0.148248 +-0.241375 +-0.259151 +-0.279786 +-0.291397 +-0.328535 +-0.389958 +-0.377995 +-0.280737 +-0.158372 +-0.106091 +-0.142807 +-0.139820 +-0.078912 +-0.035823 +0.057418 +0.107112 +0.097244 +0.109350 +0.077772 +0.052136 +0.081830 +0.120261 +0.196251 +0.272728 +0.294216 +0.300526 +0.246943 +0.116525 +-0.050187 +-0.175115 +-0.301600 +-0.427862 +-0.456478 +-0.450396 +-0.398868 +-0.320212 +-0.349825 +-0.460267 +-0.567451 +-0.631795 +-0.652977 +-0.663271 +-0.674428 +-0.682635 +-0.626163 +-0.539750 +-0.498320 +-0.505975 +-0.578888 +-0.635684 +-0.598530 +-0.523332 +-0.361034 +-0.160381 +0.022807 +0.185816 +0.259100 +0.276090 +0.163135 +0.001742 +-0.111572 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_3.txt new file mode 100644 index 0000000000..cd80bec7c2 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +-0.917785 +-1.018838 +-1.197085 +-1.346518 +-1.465782 +-1.457947 +-1.433721 +-1.430564 +-1.396554 +-1.348945 +-1.213771 +-1.091774 +-1.050692 +-1.067291 +-1.040706 +-1.000801 +-1.010901 +-0.965566 +-0.865274 +-0.667889 +-0.431604 +-0.239372 +-0.105089 +-0.069473 +-0.069545 +-0.099554 +-0.139350 +-0.160356 +-0.109202 +-0.012531 +0.030695 +0.054757 +0.070031 +0.092023 +0.121743 +0.129957 +0.118527 +0.101591 +0.141964 +0.266738 +0.345876 +0.392401 +0.430221 +0.358497 +0.240463 +0.122590 +0.008486 +-0.058995 +-0.075277 +-0.162975 +-0.315639 +-0.521310 +-0.729615 +-0.851158 +-0.979655 +-1.056785 +-1.059049 +-1.085967 +-1.124672 +-1.129564 +-1.147745 +-1.190867 +-1.211475 +-1.265556 +-1.317086 +-1.291337 +-1.238050 +-1.188747 +-1.142334 +-1.134089 +-1.132725 +-1.066024 +-1.017221 +-0.914666 +-0.800777 +-0.735933 +-0.626698 +-0.565983 +-0.484094 +-0.418266 +-0.429310 +-0.380164 +-0.258859 +-0.067478 +0.094606 +0.175094 +0.213959 +0.182170 +0.149065 +0.171849 +0.179785 +0.163891 +0.149761 +0.055666 +-0.022016 +-0.015994 +-0.013374 +0.003331 +-0.046131 +-0.194030 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_params.txt new file mode 100644 index 0000000000..219b62155c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-8/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.494279 +OFFSET:-0.526799 +PERSISTENCE:0.0911083 +OCTAVES:43.0492 +PRIME_1:123.299 +PRIME_2:42.4258 +PRIME_3:14.0702 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/OK b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/OK new file mode 100644 index 0000000000..9590cb949c --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/OK @@ -0,0 +1 @@ +All jobs complete \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/aggregated.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/aggregated.txt new file mode 100644 index 0000000000..48b8531624 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/aggregated.txt @@ -0,0 +1,4 @@ +PERLIN_3 0.220371 +PERLIN_2 1.032522 +PERLIN_1 -0.137903 +STATE Positive \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/aggregator.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/aggregator.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/aggregator.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/aggregator.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/parameters.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/parameters.txt new file mode 100644 index 0000000000..2e4f0f7b04 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/parameters.txt @@ -0,0 +1,7 @@ +PERLIN_PARAM:SCALE 0.971949 +PERLIN_PARAM:OFFSET 0.568165 +PERLIN_PARAM:PERSISTENCE 0.332226 +PERLIN_PARAM:OCTAVES 8.48231 +PERLIN_PARAM:PRIME_1 106.04 +PERLIN_PARAM:PRIME_2 17.4819 +PERLIN_PARAM:PRIME_3 56.9629 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin.stderr b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin.stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin.stdout b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin.stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_1.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_1.txt new file mode 100644 index 0000000000..36798a3f53 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_1.txt @@ -0,0 +1,100 @@ +-0.137903 +-0.157851 +-0.192276 +-0.201670 +-0.192839 +-0.193214 +-0.209423 +-0.243628 +-0.261796 +-0.213269 +-0.207591 +-0.203993 +-0.142490 +-0.122206 +-0.157129 +-0.193732 +-0.206432 +-0.177612 +-0.114381 +-0.050740 +-0.070342 +-0.154469 +-0.151716 +-0.137877 +-0.155888 +-0.199095 +-0.226091 +-0.254674 +-0.326284 +-0.337833 +-0.312344 +-0.317023 +-0.346853 +-0.332528 +-0.238504 +-0.042655 +0.146262 +0.376535 +0.617211 +0.752626 +0.797129 +0.714055 +0.660213 +0.707589 +0.786058 +0.902157 +0.982988 +0.972517 +0.950945 +0.917937 +0.833802 +0.834170 +0.874761 +0.874663 +0.835114 +0.714452 +0.615202 +0.641686 +0.698232 +0.833272 +0.978281 +1.070483 +1.118218 +1.061277 +1.031902 +0.998036 +0.965574 +1.010296 +1.079127 +1.148032 +1.260956 +1.285149 +1.247059 +1.290888 +1.424147 +1.629905 +1.764537 +1.819917 +1.898802 +1.893787 +1.855403 +1.728917 +1.536779 +1.375375 +1.281240 +1.209446 +1.131790 +1.009449 +0.933443 +0.938227 +0.970148 +1.049769 +1.076923 +1.035402 +0.981504 +0.949433 +0.958861 +0.977078 +0.958006 +0.802606 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_2.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_2.txt new file mode 100644 index 0000000000..ba557199f4 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_2.txt @@ -0,0 +1,100 @@ +1.032522 +1.030645 +1.027589 +0.938300 +0.861544 +0.832993 +0.698715 +0.604825 +0.609257 +0.593477 +0.491201 +0.341277 +0.208709 +0.134035 +0.096478 +0.102808 +0.124913 +0.090875 +0.066149 +-0.012408 +-0.133850 +-0.194818 +-0.209263 +-0.095881 +0.010749 +0.085326 +0.237955 +0.299167 +0.320499 +0.401893 +0.517178 +0.629623 +0.655076 +0.587512 +0.539387 +0.574432 +0.628337 +0.749487 +0.803470 +0.770847 +0.759350 +0.693500 +0.648396 +0.623356 +0.603426 +0.694348 +0.879540 +1.054584 +1.123458 +1.100816 +1.105500 +1.202947 +1.277420 +1.362982 +1.368734 +1.285116 +1.248007 +1.211633 +1.180222 +1.235564 +1.341232 +1.493206 +1.612131 +1.618121 +1.625000 +1.571745 +1.459633 +1.343551 +1.277370 +1.211264 +1.163383 +1.170426 +1.175448 +1.217470 +1.305274 +1.295011 +1.173072 +1.034382 +0.959745 +0.909275 +0.869084 +0.778851 +0.649645 +0.559430 +0.525067 +0.476432 +0.381578 +0.233781 +0.157416 +0.199901 +0.314752 +0.539386 +0.781042 +0.990634 +1.170137 +1.246885 +1.268126 +1.180015 +1.064679 +0.973186 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_3.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_3.txt new file mode 100644 index 0000000000..2bb0cef781 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_3.txt @@ -0,0 +1,100 @@ +0.220371 +0.112328 +-0.075019 +-0.241588 +-0.362184 +-0.357721 +-0.383737 +-0.407682 +-0.363864 +-0.300312 +-0.218883 +-0.215292 +-0.239019 +-0.303964 +-0.338894 +-0.299746 +-0.297421 +-0.226239 +-0.093147 +0.080922 +0.219209 +0.256359 +0.281152 +0.276463 +0.264202 +0.226745 +0.181221 +0.112178 +0.099345 +0.183186 +0.256603 +0.321784 +0.334316 +0.389554 +0.533441 +0.703395 +0.832970 +0.941402 +1.093683 +1.278960 +1.364377 +1.365686 +1.370013 +1.310389 +1.233846 +1.194933 +1.168762 +1.153961 +1.154271 +1.080648 +0.929681 +0.760549 +0.583628 +0.454406 +0.281967 +0.131086 +0.079608 +0.047894 +0.003413 +0.024170 +0.073226 +0.106088 +0.127928 +0.058349 +0.007387 +0.033465 +0.105058 +0.204991 +0.310151 +0.378775 +0.458521 +0.560881 +0.608623 +0.701672 +0.824709 +0.908902 +1.006640 +1.035850 +1.107446 +1.143986 +1.103046 +1.073115 +1.073421 +1.118115 +1.159422 +1.149846 +1.101513 +0.994839 +0.942165 +0.970280 +1.017869 +1.064312 +1.091185 +1.023493 +0.962306 +0.971791 +0.978662 +1.020211 +1.016806 +0.890728 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_params.txt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_params.txt new file mode 100644 index 0000000000..c3e63c5f53 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/Run/realisation-9/iter-0/perlin_params.txt @@ -0,0 +1,7 @@ +SCALE:0.971949 +OFFSET:0.568165 +PERSISTENCE:0.332226 +OCTAVES:8.48231 +PRIME_1:106.04 +PRIME_2:17.4819 +PRIME_3:56.9629 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/current_case b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/current_case new file mode 100644 index 0000000000..331d858ce9 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/current_case @@ -0,0 +1 @@ +default \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0001/files/PERLIN_active b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0001/files/PERLIN_active new file mode 100644 index 0000000000..c72400474a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0001/files/PERLIN_active differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0002/files/PERLIN_active b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0002/files/PERLIN_active new file mode 100644 index 0000000000..c72400474a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0002/files/PERLIN_active differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0003/files/PERLIN_active b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0003/files/PERLIN_active new file mode 100644 index 0000000000..c72400474a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/0003/files/PERLIN_active differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.data_0 new file mode 100644 index 0000000000..8dcc722d5a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.index new file mode 100644 index 0000000000..0a01a88233 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.data_0 new file mode 100644 index 0000000000..1d8b6c18da Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.index new file mode 100644 index 0000000000..1f0db16ccc Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_0/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.data_0 new file mode 100644 index 0000000000..8cfcfa2250 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.index new file mode 100644 index 0000000000..9e25666ab4 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.data_0 new file mode 100644 index 0000000000..ff8922efbf Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.index new file mode 100644 index 0000000000..2f8c799aed Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_1/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_10/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_11/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_12/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_13/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_14/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_15/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_16/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_17/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_18/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_19/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.data_0 new file mode 100644 index 0000000000..6f7244c4fa Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.index new file mode 100644 index 0000000000..d90f7a9f75 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.data_0 new file mode 100644 index 0000000000..aad9490e0c Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.index new file mode 100644 index 0000000000..4c804b5b87 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_2/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_20/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_21/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_22/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_23/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_24/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_25/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_26/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_27/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_28/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_29/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.data_0 new file mode 100644 index 0000000000..fd7246d7ab Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.index new file mode 100644 index 0000000000..718956c242 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.data_0 new file mode 100644 index 0000000000..2fc669aaf7 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.index new file mode 100644 index 0000000000..cbeb9c1224 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_3/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_30/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_31/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.data_0 new file mode 100644 index 0000000000..28665371dc Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.index new file mode 100644 index 0000000000..a879653abd Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.data_0 new file mode 100644 index 0000000000..90b4c5e871 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.index new file mode 100644 index 0000000000..b7afb6bf58 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_4/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.data_0 new file mode 100644 index 0000000000..178960502d Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.index new file mode 100644 index 0000000000..7e09d8c482 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.data_0 new file mode 100644 index 0000000000..b47d88c6ce Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.index new file mode 100644 index 0000000000..68c8652b8a Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_5/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.data_0 new file mode 100644 index 0000000000..cfb98aa00e Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.index new file mode 100644 index 0000000000..2f03d8d11b Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.data_0 new file mode 100644 index 0000000000..bb97f570e8 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.index new file mode 100644 index 0000000000..e86f73216f Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_6/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.data_0 new file mode 100644 index 0000000000..c8b34c3179 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.index new file mode 100644 index 0000000000..7ef99ebfde Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.data_0 new file mode 100644 index 0000000000..9bc6a11543 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.index new file mode 100644 index 0000000000..40817c501f Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_7/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.data_0 new file mode 100644 index 0000000000..6ce8ff1142 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.index new file mode 100644 index 0000000000..c560413360 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.data_0 new file mode 100644 index 0000000000..674b8594d6 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.index new file mode 100644 index 0000000000..86d42f2def Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_8/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/ANALYZED.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.data_0 new file mode 100644 index 0000000000..27d18051fd Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.index new file mode 100644 index 0000000000..9bbcfc9ea7 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/FORECAST.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.data_0 new file mode 100644 index 0000000000..a6ce92b471 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.data_0 differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.index new file mode 100644 index 0000000000..727e912850 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/PARAMETER.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Ensemble/mod_9/STATIC.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.data_0 b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.data_0 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.index b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.index new file mode 100644 index 0000000000..e1de74ede3 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.index differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.mnt b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.mnt new file mode 100644 index 0000000000..5280360395 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/Index/INDEX.mnt differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/ert_fstab b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/ert_fstab new file mode 100644 index 0000000000..8c70bbc5ce Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/ert_fstab differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/case_config b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/case_config new file mode 100644 index 0000000000..593f4708db Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/case_config differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/custom_kw_config_set b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/custom_kw_config_set new file mode 100644 index 0000000000..b51c81a5bb Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/custom_kw_config_set differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/state-map b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/state-map new file mode 100644 index 0000000000..f2112badc8 Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/state-map differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/summary-key-set b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/summary-key-set new file mode 100644 index 0000000000..593f4708db Binary files /dev/null and b/ThirdParty/Ert/devel/test-data/local/custom_kw/storage/ertensemble/test_run/files/summary-key-set differ diff --git a/ThirdParty/Ert/devel/test-data/local/custom_kw/time_map b/ThirdParty/Ert/devel/test-data/local/custom_kw/time_map new file mode 100644 index 0000000000..95ec9b0216 --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/custom_kw/time_map @@ -0,0 +1,4 @@ +01/01/2015 +01/02/2015 +01/03/2015 +01/04/2015 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/test-data/local/geometry/pol8_noend.xyz b/ThirdParty/Ert/devel/test-data/local/geometry/pol8_noend.xyz new file mode 100644 index 0000000000..60e3a7551e --- /dev/null +++ b/ThirdParty/Ert/devel/test-data/local/geometry/pol8_noend.xyz @@ -0,0 +1,22 @@ +396202.413086 6606091.935028 0 +396645.891113 6606123.317261 0 +397240.054443 6605939.969238 0 +397610.076172 6605656.411438 0 +397868.064453 6604885.903809 0 +398026.336914 6604489.468872 0 +398316.978516 6603905.551758 0 +398432.308594 6603433.575195 0 +398449.528809 6602961.209473 0 +397890.646973 6602644.205811 0 +397346.204346 6603057.528320 0 +397066.059082 6603224.013672 0 +396678.629883 6603318.616211 0 +396396.212158 6603663.201172 0 +396367.576416 6604516.860718 0 +396214.364990 6605134.893372 0 +396155.645264 6605262.520691 0 +395988.849121 6605539.834412 0 +395980.233887 6605551.104919 0 +396056.314697 6605835.119461 0 + +