diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 0acd148c48..337084d979 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -22,6 +22,7 @@ #include "cafPdmUiFilePathEditor.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmUiCheckBoxEditor.h" +#include "RifReaderSettings.h" CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences"); //-------------------------------------------------------------------------------------------------- @@ -61,10 +62,16 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", ""); lastUsedProjectFileName.setUiHidden(true); - CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "SOIL", "", "SOIL = 1.0 - SGAS - SWAT", ""); - CAF_PDM_InitField(&autocomputeDepthRelatedProperties,"autocomputeDepth", true, "DEPTH related properties", "", "DEPTH, DX, DY, DZ, TOP, BOTTOM", ""); + CAF_PDM_InitField(&autocomputeSOIL, "autocomputeSOIL", true, "SOIL", "", "SOIL = 1.0 - SGAS - SWAT", ""); + CAF_PDM_InitField(&autocomputeDepthRelatedProperties, "autocomputeDepth", true, "DEPTH related properties", "", "DEPTH, DX, DY, DZ, TOP, BOTTOM", ""); + CAF_PDM_InitField(&autocomputeGridFaults, "autocomputeGridFaults", true, "Grid faults", "", "Detect all fault faces geometrically", ""); - CAF_PDM_InitField(&readFaultData, "readFaultData", true, "Read fault data", "", "", ""); + autocomputeDepthRelatedProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + autocomputeSOIL.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + autocomputeGridFaults.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + + readerSettings = new RifReaderSettings; + CAF_PDM_InitFieldNoDefault(&readerSettings, "readerSettings", "Reader settings", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -80,6 +87,8 @@ RiaPreferences::~RiaPreferences(void) //-------------------------------------------------------------------------------------------------- void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) { + readerSettings->defineEditorAttribute(field, uiConfigName, attribute); + if (field == &scriptDirectories) { caf::PdmUiFilePathEditorAttribute* myAttr = static_cast(attribute); @@ -89,7 +98,10 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt myAttr->m_appendUiSelectedFolderToText = true; } } - else if (field == &octaveShowHeaderInfoWhenExecutingScripts) + else if (field == &octaveShowHeaderInfoWhenExecutingScripts || + field == &autocomputeSOIL || + field == &autocomputeDepthRelatedProperties || + field == &autocomputeGridFaults) { caf::PdmUiCheckBoxEditorAttribute* myAttr = static_cast(attribute); if (myAttr) @@ -125,9 +137,16 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* autoComputeGroup = uiOrdering.addNewGroup("Compute when loading new case"); autoComputeGroup->add(&autocomputeSOIL); autoComputeGroup->add(&autocomputeDepthRelatedProperties); + autoComputeGroup->add(&autocomputeGridFaults); - caf::PdmUiGroup* faultsGroup = uiOrdering.addNewGroup("Faults"); - faultsGroup->add(&readFaultData); + + caf::PdmUiGroup* readerSettingsGroup = uiOrdering.addNewGroup("Reader settings"); + std::vector readerSettingsFields; + readerSettings->fields(readerSettingsFields); + for (size_t i = 0; i < readerSettingsFields.size(); i++) + { + readerSettingsGroup->add(readerSettingsFields[i]); + } } //-------------------------------------------------------------------------------------------------- @@ -142,6 +161,7 @@ void RiaPreferences::configureForRegressionTests() autocomputeSOIL = true; autocomputeDepthRelatedProperties = true; - readFaultData = false; + CVF_ASSERT(readerSettings); + readerSettings->importFaults = false; } diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index bb7d3f3354..78fd48e44e 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -27,6 +27,7 @@ // Include to make Pdm work for cvf::Color #include "cafPdmFieldCvfColor.h" +class RifReaderSettings; class RiaPreferences : public caf::PdmObject { @@ -63,8 +64,9 @@ public: // Pdm Fields caf::PdmField autocomputeSOIL; caf::PdmField autocomputeDepthRelatedProperties; + caf::PdmField autocomputeGridFaults; - caf::PdmField readFaultData; + caf::PdmField readerSettings; protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 1ddd99f08a..34a6ec93be 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -15,6 +15,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h ${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.h ${CEE_CURRENT_LIST_DIR}RifReaderInterface.h ${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h +${CEE_CURRENT_LIST_DIR}RifReaderSettings.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -26,7 +27,9 @@ ${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp ${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp ${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp ${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.cpp +${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp ${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp +${CEE_CURRENT_LIST_DIR}RifReaderSettings.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt index 475f353da7..092d8d9098 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt @@ -59,6 +59,7 @@ set( UNIT_TEST_CPP_SOURCES ) set( LINK_LIBRARIES + cafProjectDataModel CommonCode LibViewing diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index e9cb4e2918..a620ce1893 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -434,17 +434,26 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC progInfo.setProgressDescription("Reading NNC data"); progInfo.setNextProgressIncrement(5); - transferNNCData(mainEclGrid, m_ecl_init_file, eclipseCase->mainGrid()); + if (isNNCsEnabled()) + { + transferNNCData(mainEclGrid, m_ecl_init_file, eclipseCase->mainGrid()); + } progInfo.incrementProgress(); progInfo.setProgressDescription("Processing NNC data"); progInfo.setNextProgressIncrement(20); - eclipseCase->mainGrid()->nncData()->processConnections( *(eclipseCase->mainGrid())); + if (isNNCsEnabled()) + { + eclipseCase->mainGrid()->nncData()->processConnections( *(eclipseCase->mainGrid())); + } progInfo.incrementProgress(); progInfo.setNextProgressIncrement(8); progInfo.setProgressDescription("Reading Well information"); - readWellCells(mainEclGrid); + if (isSimulationWellDataEnabled()) + { + readWellCells(mainEclGrid); + } progInfo.setProgressDescription("Releasing reader memory"); ecl_grid_free( mainEclGrid ); diff --git a/ApplicationCode/FileInterface/RifReaderInterface.cpp b/ApplicationCode/FileInterface/RifReaderInterface.cpp new file mode 100644 index 0000000000..c08eb619e5 --- /dev/null +++ b/ApplicationCode/FileInterface/RifReaderInterface.cpp @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA, 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 "RifReaderInterface.h" + +#include "RifReaderSettings.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderInterface::setReaderSetting(RifReaderSettings* settings) +{ + m_settings = settings; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderInterface::isFaultImportEnabled() +{ + if (m_settings.notNull()) + { + return m_settings->importFaults; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderInterface::isSimulationWellDataEnabled() +{ + if (m_settings.notNull()) + { + return m_settings->importSimulationWellData; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderInterface::isNNCsEnabled() +{ + if (m_settings.notNull()) + { + return m_settings->importNNCs; + } + + return false; +} diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index b57a8d4976..6f66a4aeda 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -22,12 +22,16 @@ #include "cvfObject.h" #include "cvfLibCore.h" +#include "cafPdmPointer.h" + #include #include #include class RigCaseData; +class RifReaderSettings; + //================================================================================================== // @@ -44,11 +48,14 @@ public: }; public: - RifReaderInterface() { m_readFaultData = false; } - virtual ~RifReaderInterface() {} + RifReaderInterface() { } + virtual ~RifReaderInterface() { } - void readFaultData(bool readFaultData) { m_readFaultData = readFaultData; } - bool isFaultImportEnabled() { return m_readFaultData; } + void setReaderSetting(RifReaderSettings* settings); + + bool isFaultImportEnabled(); + bool isSimulationWellDataEnabled(); + bool isNNCsEnabled(); virtual bool open(const QString& fileName, RigCaseData* eclipseCase) = 0; virtual void close() = 0; @@ -63,6 +70,6 @@ public: private: - std::vector m_filenamesWithFaults; - bool m_readFaultData; + std::vector m_filenamesWithFaults; + caf::PdmPointer m_settings; }; diff --git a/ApplicationCode/FileInterface/RifReaderSettings.cpp b/ApplicationCode/FileInterface/RifReaderSettings.cpp new file mode 100644 index 0000000000..e3a743d188 --- /dev/null +++ b/ApplicationCode/FileInterface/RifReaderSettings.cpp @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA, 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 "RifReaderSettings.h" +#include "cafPdmUiCheckBoxEditor.h" + + +CAF_PDM_SOURCE_INIT(RifReaderSettings, "RifReaderSettings"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderSettings::RifReaderSettings() +{ + CAF_PDM_InitObject("RifReaderSettings", "", "", ""); + + CAF_PDM_InitField(&importFaults, "importFaults", false, "Import faults", "", "", ""); + importFaults.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + + CAF_PDM_InitField(&importSimulationWellData, "importSimulationWellData", false, "Import simulation wells", "", "", ""); + importSimulationWellData.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + + CAF_PDM_InitField(&importNNCs, "importSimulationNNCs", false, "Import NNCs", "", "", ""); + importNNCs.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderSettings::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (field == &importFaults || + field == &importSimulationWellData || + field == &importNNCs) + { + caf::PdmUiCheckBoxEditorAttribute* myAttr = static_cast(attribute); + if (myAttr) + { + myAttr->m_useNativeCheckBoxLabel = true; + } + } +} + diff --git a/ApplicationCode/FileInterface/RifReaderSettings.h b/ApplicationCode/FileInterface/RifReaderSettings.h new file mode 100644 index 0000000000..7bf3ed050e --- /dev/null +++ b/ApplicationCode/FileInterface/RifReaderSettings.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA, 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" + + +//================================================================================================== +/// +/// +//================================================================================================== +class RifReaderSettings : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + + friend class RiaPreferences; + +public: + RifReaderSettings(); + + caf::PdmField importFaults; + caf::PdmField importSimulationWellData; + caf::PdmField importNNCs; + +protected: + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + +}; + diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index c386fed410..c58b36f476 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -18,6 +18,8 @@ #include "RimCase.h" +#include "RiaApplication.h" +#include "RiaPreferences.h" #include "RigCaseCellResultsData.h" #include "RigCaseData.h" #include "RimCaseCollection.h" @@ -298,9 +300,13 @@ void RimCase::computeCachedData() rigEclipseCase->mainGrid()->computeCachedData(); pInf.incrementProgress(); - pInf.setProgressDescription("Calculating faults"); - rigEclipseCase->mainGrid()->calculateFaults(); - pInf.incrementProgress(); + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + if (prefs->autocomputeGridFaults) + { + pInf.setProgressDescription("Calculating faults"); + rigEclipseCase->mainGrid()->calculateFaults(); + pInf.incrementProgress(); + } } } diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.cpp b/ApplicationCode/ProjectDataModel/RimInputCase.cpp index adc91355bf..f003e5db0f 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputCase.cpp @@ -23,6 +23,7 @@ #include "RifReaderEclipseInput.h" #include "RifReaderInterface.h" #include "RifReaderMockModel.h" +#include "RifReaderSettings.h" #include "RigCaseCellResultsData.h" #include "RigCaseData.h" #include "RimDefines.h" @@ -96,7 +97,7 @@ void RimInputCase::openDataFileSet(const QStringList& fileNames) for (int i = 0; i < fileNames.size(); i++) { - if (RifEclipseInputFileTools::openGridFile(fileNames[i], this->reservoirData(), prefs->readFaultData())) + if (RifEclipseInputFileTools::openGridFile(fileNames[i], this->reservoirData(), prefs->readerSettings->importFaults())) { m_gridFileName = fileNames[i]; @@ -181,7 +182,7 @@ bool RimInputCase::openEclipseGridFile() { RiaPreferences* prefs = RiaApplication::instance()->preferences(); readerInterface = new RifReaderEclipseInput; - readerInterface->readFaultData(prefs->readFaultData()); + readerInterface->setReaderSetting(prefs->readerSettings()); cvf::ref eclipseCase = new RigCaseData; if (!readerInterface->open(m_gridFileName, eclipseCase.p())) diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index 8d1041fa63..da71221787 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -22,6 +22,7 @@ #include "RifEclipseOutputFileTools.h" #include "RifReaderEclipseOutput.h" #include "RifReaderMockModel.h" +#include "RifReaderSettings.h" #include "RigCaseCellResultsData.h" #include "RigCaseData.h" #include "RimMockModelSettings.h" @@ -90,7 +91,7 @@ bool RimResultCase::openEclipseGridFile() RiaPreferences* prefs = RiaApplication::instance()->preferences(); readerInterface = new RifReaderEclipseOutput; - readerInterface->readFaultData(prefs->readFaultData()); + readerInterface->setReaderSetting(prefs->readerSettings()); readerInterface->setFilenamesWithFaults(this->filesContainingFaults()); cvf::ref eclipseCase = new RigCaseData;