From 593fe932449f46009725264ba89142e85e1e966b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 21 Oct 2016 14:30:45 +0200 Subject: [PATCH] #930, #925, #914 * Formation names format changed to allow no space around k-layer numbers. Also added possibility to use one number as k-layer count for the name. Based on previous names last layer * Deleted geomech cache of formation name result when updating the formation names * Added TNH TNQV THQV to plane transformed stresses. --- .../RicReloadFormationNamesFeature.cpp | 9 +++- .../GeoMechDataModel/RigFemPartResults.cpp | 8 ++++ .../GeoMechDataModel/RigFemPartResults.h | 1 + .../RigFemPartResultsCollection.cpp | 43 +++++++++++++++++-- .../RigFemPartResultsCollection.h | 2 + .../Intersections/RivIntersectionPartMgr.cpp | 9 ++-- .../ProjectDataModel/RimFormationNames.cpp | 35 ++++++++++++--- .../RimFormationNamesCollection.cpp | 17 +++++++- .../ReservoirDataModel/RigFormationNames.cpp | 31 ++++++++++++- .../ReservoirDataModel/RigFormationNames.h | 1 + 10 files changed, 140 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/Commands/RicReloadFormationNamesFeature.cpp b/ApplicationCode/Commands/RicReloadFormationNamesFeature.cpp index 542f0f1623..08080a4f43 100644 --- a/ApplicationCode/Commands/RicReloadFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicReloadFormationNamesFeature.cpp @@ -23,6 +23,7 @@ #include "cafSelectionManager.h" #include +#include "QMessageBox" CAF_CMD_SOURCE_INIT(RicReloadFormationNamesFeature, "RicReloadFormationNamesFeature"); @@ -62,7 +63,13 @@ void RicReloadFormationNamesFeature::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesObjs); for (RimFormationNames* fnames: selectedFormationNamesObjs) { - fnames->readFormationNamesFile(nullptr); + QString errorMessage; + fnames->readFormationNamesFile(&errorMessage); + if ( !errorMessage.isEmpty() ) + { + QMessageBox::warning(nullptr, "Reload Formation Names", errorMessage); + } + fnames->updateConnectedViews(); } } diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp index 3dab449ba8..de45b44d1a 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp @@ -65,3 +65,11 @@ RigFemScalarResultFrames* RigFemPartResults::findScalarResult(const RigFemResult { return resultSets[resVarAddr].p(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResults::deleteScalarResult(const RigFemResultAddress& resVarAddr) +{ + resultSets.erase(resVarAddr); // Refcounting is supposed to destroy the data. +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h index 42ff852145..c193f0212f 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h @@ -41,6 +41,7 @@ public: RigFemScalarResultFrames* createScalarResult(const RigFemResultAddress& resVarAddr); RigFemScalarResultFrames* findScalarResult(const RigFemResultAddress& resVarAddr); + void deleteScalarResult(const RigFemResultAddress& resVarAddr); private: diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index eb0a43f3e9..1ec800b857 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -75,6 +75,7 @@ RigFemPartResultsCollection::~RigFemPartResultsCollection() void RigFemPartResultsCollection::setActiveFormationNames(RigFormationNames* activeFormationNames) { m_activeFormationNamesData = activeFormationNames; + this->deleteResult(RigFemResultAddress(RIG_FORMATION_NAMES, "Active Formation Names", "")); } //-------------------------------------------------------------------------------------------------- @@ -297,10 +298,16 @@ std::map > RigFemPartResultsCollection::sc fieldCompNames["SE"].push_back("SN"); fieldCompNames["SE"].push_back("STH"); fieldCompNames["SE"].push_back("STQV"); + fieldCompNames["SE"].push_back("TNH" ); + fieldCompNames["SE"].push_back("TNQV"); + fieldCompNames["SE"].push_back("THQV"); fieldCompNames["ST"].push_back("SN"); fieldCompNames["ST"].push_back("STH"); fieldCompNames["ST"].push_back("STQV"); + fieldCompNames["ST"].push_back("TNH"); + fieldCompNames["ST"].push_back("TNQV"); + fieldCompNames["ST"].push_back("THQV"); } } @@ -566,7 +573,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateVolumetricStrain //-------------------------------------------------------------------------------------------------- RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAlignedStress(int partIndex, const RigFemResultAddress& resVarAddr) { - CVF_ASSERT(resVarAddr.componentName == "STH" || resVarAddr.componentName == "STQV" || resVarAddr.componentName == "SN"); + CVF_ASSERT( resVarAddr.componentName == "STH" || resVarAddr.componentName == "STQV" || resVarAddr.componentName == "SN" + || resVarAddr.componentName == "TNH" || resVarAddr.componentName == "TNQV" || resVarAddr.componentName == "THQV"); RigFemScalarResultFrames * s11Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S11")); RigFemScalarResultFrames * s22Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S22")); @@ -578,7 +586,10 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAlignedSt RigFemScalarResultFrames * sNormFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "SN")); RigFemScalarResultFrames * sHoriFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "STH")); RigFemScalarResultFrames * sVertFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "STQV")); - + RigFemScalarResultFrames * sNHFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "TNH" )); + RigFemScalarResultFrames * sNVFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "TNQV")); + RigFemScalarResultFrames * sHVFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "THQV")); + const RigFemPart * femPart = m_femParts->part(partIndex); const std::vector& nodeCoordinates = femPart->nodes().coordinates; @@ -595,12 +606,18 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAlignedSt std::vector& sNorm = sNormFrames->frameData(fIdx); std::vector& sHori = sHoriFrames->frameData(fIdx); std::vector& sVert = sVertFrames->frameData(fIdx); + std::vector& sNH = sNHFrames->frameData(fIdx); + std::vector& sHV = sNVFrames->frameData(fIdx); + std::vector& sNV = sHVFrames->frameData(fIdx); // HACK ! Todo : make it robust against other elements than Hex8 size_t valCount = s11.size() * 3; // Number of Elm Node Face results 24 = 4 * num faces = 3* numElmNodes sNorm.resize(valCount); sHori.resize(valCount); sVert.resize(valCount); + sNH.resize(valCount); + sHV.resize(valCount); + sNV.resize(valCount); int elementCount = femPart->elementCount(); for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) @@ -651,7 +668,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAlignedSt sHori[elmNodFaceResIdx]= xfTen[caf::Ten3f::SXX]; sVert[elmNodFaceResIdx]= xfTen[caf::Ten3f::SYY]; sNorm[elmNodFaceResIdx]= xfTen[caf::Ten3f::SZZ]; - + sNH[elmNodFaceResIdx]= xfTen[caf::Ten3f::SZX]; + sHV[elmNodFaceResIdx]= xfTen[caf::Ten3f::SXY]; + sNV[elmNodFaceResIdx]= xfTen[caf::Ten3f::SYZ]; } } } @@ -1192,6 +1211,24 @@ bool RigFemPartResultsCollection::assertResultsLoaded(const RigFemResultAddress& return foundResults; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::deleteResult(const RigFemResultAddress& resVarAddr) +{ + CVF_ASSERT ( resVarAddr.isValid() ); + + for ( int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx ) + { + if ( m_femPartResults[pIdx].notNull() ) + { + m_femPartResults[pIdx]->deleteScalarResult(resVarAddr); + } + } + + m_resultStatistics.erase(resVarAddr); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index e525e8c29f..47a3ce24bd 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -46,6 +46,8 @@ public: std::map > scalarFieldAndComponentNames(RigFemResultPosEnum resPos); std::vector stepNames(); bool assertResultsLoaded(const RigFemResultAddress& resVarAddr); + void deleteResult(const RigFemResultAddress& resVarAddr); + const std::vector& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); int partCount() const; int frameCount(); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 8546784ee1..7b24a9c1d4 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -285,9 +285,12 @@ void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArr caf::Ten3f::TensorComponentEnum resultComponent = caf::Ten3f::SZZ; - if (resVarAddress.componentName == "SN") resultComponent = caf::Ten3f::SZZ; - if (resVarAddress.componentName == "STH") resultComponent = caf::Ten3f::SXX; - if (resVarAddress.componentName == "STQV") resultComponent = caf::Ten3f::SYY; + if ( resVarAddress.componentName == "SN" ) resultComponent = caf::Ten3f::SZZ; + if ( resVarAddress.componentName == "STH" ) resultComponent = caf::Ten3f::SXX; + if ( resVarAddress.componentName == "STQV" ) resultComponent = caf::Ten3f::SYY; + if ( resVarAddress.componentName == "TNH" ) resultComponent = caf::Ten3f::SZX; + if ( resVarAddress.componentName == "TNQV" ) resultComponent = caf::Ten3f::SYZ; + if ( resVarAddress.componentName == "THQV" ) resultComponent = caf::Ten3f::SXY; if(tens11.size() == 0) { diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp index fc0b654689..749983db3e 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp @@ -28,6 +28,7 @@ #include #include +#include "QMessageBox" CAF_PDM_SOURCE_INIT(RimFormationNames, "FormationNames"); @@ -60,8 +61,12 @@ void RimFormationNames::fieldChangedByUi(const caf::PdmFieldHandle* changedField if (&m_formationNamesFileName == changedField) { updateUiTreeName(); - - readFormationNamesFile(nullptr); + QString errorMessage; + readFormationNamesFile(&errorMessage); + if (!errorMessage.isEmpty()) + { + QMessageBox::warning(nullptr, "Formation Names", errorMessage); + } } } @@ -131,7 +136,12 @@ void RimFormationNames::updateConnectedViews() void RimFormationNames::readFormationNamesFile(QString * errorMessage) { QFile dataFile(m_formationNamesFileName()); - if (!dataFile.open(QFile::ReadOnly)){ if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_formationNamesFileName()) + "\n"; return;} + + if (!dataFile.open(QFile::ReadOnly)) + { + if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_formationNamesFileName()) + "\n"; + return; + } m_formationNamesData = new RigFormationNames; @@ -158,13 +168,13 @@ void RimFormationNames::readFormationNamesFile(QString * errorMessage) QString numberString = lineSegs[2]; if (commentMarkPos >= 0) numberString.truncate(commentMarkPos); - QStringList numberWords = numberString.split(QRegExp("\\s+"), QString::SkipEmptyParts); - if (numberWords.size() == 3) + QStringList numberWords = numberString.split(QRegExp("-"), QString::SkipEmptyParts); + if (numberWords.size() == 2) { bool isNumber1 = false; bool isNumber2 = false; int startK = numberWords[0].toInt(&isNumber1); - int endK = numberWords[2].toInt(&isNumber2); + int endK = numberWords[1].toInt(&isNumber2); if (!(isNumber2 && isNumber1)) { @@ -177,6 +187,19 @@ void RimFormationNames::readFormationNamesFile(QString * errorMessage) m_formationNamesData->appendFormationRange(formationName, startK-1, endK-1); } + else if (numberWords.size() == 1) + { + bool isNumber1 = false; + int kLayerCount = numberWords[0].toInt(&isNumber1); + + if ( !isNumber1 ) + { + if ( errorMessage ) (*errorMessage) += "Format error on line: " + QString::number(lineNumber) + "\n"; + continue; + } + + m_formationNamesData->appendFormationRangeHeight(formationName, kLayerCount); + } else { if (errorMessage) (*errorMessage) += "Format error on line: " + QString::number(lineNumber) + "\n"; diff --git a/ApplicationCode/ProjectDataModel/RimFormationNamesCollection.cpp b/ApplicationCode/ProjectDataModel/RimFormationNamesCollection.cpp index 57b84c4c10..06de7100b2 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNamesCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNamesCollection.cpp @@ -18,6 +18,7 @@ #include "RimFormationNamesCollection.h" #include "RimFormationNames.h" +#include "QMessageBox" CAF_PDM_SOURCE_INIT(RimFormationNamesCollection, "FormationNamesCollectionObject"); @@ -87,9 +88,23 @@ void RimFormationNamesCollection::importFiles(const QStringList& fileNames) formNamesObjsToReload.push_back(newFNs); } + QString totalErrorMessage; + for (RimFormationNames* fmNames: formNamesObjsToReload) { - fmNames->readFormationNamesFile(nullptr); + QString errormessage; + + fmNames->readFormationNamesFile(&errormessage); + if (!errormessage.isEmpty()) + { + totalErrorMessage += "\nError in: " + fmNames->fileName() + + "\n\t" + errormessage; + } + } + + if (!totalErrorMessage.isEmpty()) + { + QMessageBox::warning(nullptr, "Import Formation Names", totalErrorMessage); } } diff --git a/ApplicationCode/ReservoirDataModel/RigFormationNames.cpp b/ApplicationCode/ReservoirDataModel/RigFormationNames.cpp index 83b97c7c40..88e3939557 100644 --- a/ApplicationCode/ReservoirDataModel/RigFormationNames.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFormationNames.cpp @@ -52,13 +52,40 @@ QString RigFormationNames::formationNameFromKLayerIdx(size_t Kidx) void RigFormationNames::appendFormationRange(const QString& name, int kStartIdx, int kEndIdx) { CVF_ASSERT(kStartIdx <= kEndIdx); + int nameIdx = static_cast(m_formationNames.size()); + m_formationNames.push_back(name); - if(kEndIdx >= static_cast(m_nameIndexPrKLayer.size())) m_nameIndexPrKLayer.resize(kEndIdx + 1, -1); - for(int kIdx = kStartIdx; kIdx <= kEndIdx; ++kIdx) + if ( kEndIdx >= static_cast(m_nameIndexPrKLayer.size()) ) + { + m_nameIndexPrKLayer.resize(kEndIdx + 1, -1); + } + + for ( int kIdx = kStartIdx; kIdx <= kEndIdx; ++kIdx ) { m_nameIndexPrKLayer[kIdx] = nameIdx; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFormationNames::appendFormationRangeHeight(const QString& name, int kLayerCount) +{ + if (kLayerCount < 1) return; + + int nameIdx = static_cast(m_formationNames.size()); + + m_formationNames.push_back(name); + + int kStartIdx = static_cast(m_nameIndexPrKLayer.size()); + + m_nameIndexPrKLayer.resize(kStartIdx + kLayerCount, -1); + + for ( int kIdx = kStartIdx; kIdx < kStartIdx + kLayerCount; ++kIdx ) + { + m_nameIndexPrKLayer[kIdx] = nameIdx; + } +} diff --git a/ApplicationCode/ReservoirDataModel/RigFormationNames.h b/ApplicationCode/ReservoirDataModel/RigFormationNames.h index c59e0a1bac..a984421256 100644 --- a/ApplicationCode/ReservoirDataModel/RigFormationNames.h +++ b/ApplicationCode/ReservoirDataModel/RigFormationNames.h @@ -41,6 +41,7 @@ public: const std::vector& formationNames() const { return m_formationNames;} void appendFormationRange(const QString& name, int kStartIdx, int kEndIdx); + void appendFormationRangeHeight(const QString& name, int kLayerCount); private: