diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index 7896e13770..305b64f998 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -38,7 +38,6 @@ RigGeoMechCaseData::RigGeoMechCaseData(const std::string& fileName) { m_geoMechCaseFileName = fileName; - m_femParts = new RigFemPartCollection(); } //-------------------------------------------------------------------------------------------------- @@ -65,6 +64,14 @@ const RigFemPartCollection* RigGeoMechCaseData::femParts() const return m_femParts.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFemPartResultsCollection* RigGeoMechCaseData::femPartResults() const +{ + return m_femPartResultsColl.p(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -87,13 +94,7 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) progress.setProgressDescription("Calculating element neighbors"); // Initialize results containers - 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); - } + m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_femParts->partCount()); // Calculate derived Fem data for (int pIdx = 0; pIdx < m_femParts->partCount(); ++pIdx) @@ -110,7 +111,32 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map > RigGeoMechCaseData::scalarFieldAndComponentNames(RigFemResultPosEnum resPos) +RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, int partCount) +{ + CVF_ASSERT(readerInterface); + m_readerInterface = readerInterface; + m_femPartResults.resize(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() +{ + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RigFemPartResultsCollection::scalarFieldAndComponentNames(RigFemResultPosEnum resPos) { std::map > fieldCompNames; @@ -136,10 +162,10 @@ std::map > RigGeoMechCaseData::scalarField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partIndex, +RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(int partIndex, const RigFemResultAddress& resVarAddr) { - CVF_ASSERT(partIndex < m_femParts->partCount()); + CVF_ASSERT(partIndex < m_femPartResults.size()); CVF_ASSERT(m_readerInterface.notNull()); RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr); @@ -175,7 +201,7 @@ RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partInd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigGeoMechCaseData::stepNames() +std::vector RigFemPartResultsCollection::stepNames() { CVF_ASSERT(m_readerInterface.notNull()); return m_readerInterface->stepNames(); @@ -184,7 +210,7 @@ std::vector RigGeoMechCaseData::stepNames() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex, +void RigFemPartResultsCollection::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax) { minMaxScalarValuesInternal(resVarAddr, frameIndex, localMin, localMax); @@ -193,7 +219,7 @@ void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAdd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, +void RigFemPartResultsCollection::minMaxScalarValues(const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax) { minMaxScalarValuesInternal(resVarAddr, -1, globalMin, globalMax); @@ -202,7 +228,7 @@ void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAdd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* overallMin, double* overallMax) +void RigFemPartResultsCollection::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* overallMin, double* overallMax) { CVF_ASSERT(overallMax && overallMin); @@ -241,7 +267,7 @@ void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& r //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero) +void RigFemPartResultsCollection::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero) { posNegClosestToZeroInternal(resVarAddr, frameIndex, localPosClosestToZero, localNegClosestToZero); } @@ -249,7 +275,7 @@ void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero) +void RigFemPartResultsCollection::posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero) { posNegClosestToZeroInternal(resVarAddr, -1, globalPosClosestToZero, globalNegClosestToZero); } @@ -257,7 +283,7 @@ void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex, +void RigFemPartResultsCollection::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* overallPosClosestToZero, double* overallNegClosestToZero) { CVF_ASSERT(overallPosClosestToZero && overallNegClosestToZero); @@ -298,7 +324,7 @@ void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::meanCellScalarValues(const RigFemResultAddress& resVarAddr, double* meanValue) +void RigFemPartResultsCollection::meanCellScalarValues(const RigFemResultAddress& resVarAddr, double* meanValue) { CVF_ASSERT(meanValue); @@ -329,7 +355,7 @@ void RigGeoMechCaseData::meanCellScalarValues(const RigFemResultAddress& resVarA //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RigGeoMechCaseData::frameCount() +int RigFemPartResultsCollection::frameCount() { return static_cast(stepNames().size()); } @@ -337,7 +363,7 @@ int RigGeoMechCaseData::frameCount() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechCaseData::assertResultsLoaded( const RigFemResultAddress& resVarAddr) +void RigFemPartResultsCollection::assertResultsLoaded( const RigFemResultAddress& resVarAddr) { for (int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx) { @@ -351,7 +377,7 @@ void RigGeoMechCaseData::assertResultsLoaded( const RigFemResultAddress& resVarA //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigGeoMechCaseData::resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex) +const std::vector& RigFemPartResultsCollection::resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex) { RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult(partIndex, resVarAddr); return scalarResults->frameData(frameIndex); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h index ea43fa0d82..67e42a6ea7 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h @@ -30,6 +30,7 @@ class RifGeoMechReaderInterface; class RigFemPartCollection; class RigFemScalarResultFrames; +class RigFemPartResultsCollection; class RigGeoMechCaseData: public cvf::Object { @@ -42,6 +43,22 @@ public: 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; +}; + +class RigFemPartResultsCollection: public cvf::Object +{ +public: + RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, int partCount); + ~RigFemPartResultsCollection(); + std::map > scalarFieldAndComponentNames(RigFemResultPosEnum resPos); std::vector stepNames(); void assertResultsLoaded(const RigFemResultAddress& resVarAddr); @@ -49,6 +66,7 @@ public: 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); @@ -59,14 +77,14 @@ private: RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex, const RigFemResultAddress& resVarAddr); + void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* overallMin, double* overallMax); void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero); - std::string m_geoMechCaseFileName; - cvf::ref m_femParts; cvf::Collection m_femPartResults; + cvf::ref m_readerInterface; }; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index b844a8d76f..a4c875eafc 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -236,7 +236,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechRe RigFemResultAddress resVarAddress(resPosType, fieldName.toStdString(), compName.toStdString()); - const std::vector& resultValues = caseData->resultValues(resVarAddress, m_gridIdx, timeStepIndex); + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, timeStepIndex); const std::vector* vxToResultMapping = NULL; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 8771ac05be..ea76f5fa66 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -330,8 +330,8 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) double mean = 0; RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); - caseData->meanCellScalarValues(resAddress, &mean); - caseData->minMaxScalarValues(resAddress,&min, &max); + caseData->femPartResults()->meanCellScalarValues(resAddress, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max); // ToDo: Implement statistics for geomech data @@ -346,7 +346,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) } int currentTimeStep = geoMechView->currentTimeStep(); - QString stepName = QString::fromStdString(caseData->stepNames()[currentTimeStep]); + QString stepName = QString::fromStdString(caseData->femPartResults()->stepNames()[currentTimeStep]); infoText += QString("Time Step: %1 Time: %2").arg(currentTimeStep).arg(stepName); } } @@ -378,13 +378,13 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) double mean = 0; RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); - caseData->meanCellScalarValues(resAddress, &mean); - caseData->minMaxScalarValues(resAddress,&min, &max); + caseData->femPartResults()->meanCellScalarValues(resAddress, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max); // ToDo: Implement statistics for geomech data //caseData->p10p90CellScalarValues(resAddress, p10, p90); - caseData->minMaxScalarValues(resAddress, &min, &max); + caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); //geoMechView->viewer()->setHistogram(min, max, caseData->scalarValuesHistogram(resAddress)); geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp index 1046795d37..8fe9de5560 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp @@ -173,7 +173,7 @@ void RimGeoMechResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedFi m_resultComponentName = ""; } - m_reservoirView->geoMechCase()->geoMechData()->assertResultsLoaded(this->resultAddress()); + m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()); if (m_reservoirView) { @@ -192,7 +192,7 @@ std::map > RimGeoMechResultSlot::getResult RimGeoMechCase* gmCase = m_reservoirView->geoMechCase(); if (gmCase && gmCase->geoMechData()) { - return gmCase->geoMechData()->scalarFieldAndComponentNames(m_resultPositionTypeUiField()); + return gmCase->geoMechData()->femPartResults()->scalarFieldAndComponentNames(m_resultPositionTypeUiField()); } else { diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index e3dd12709a..b0bea89e72 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -140,7 +140,7 @@ void RimGeoMechView::loadDataAndUpdate() progress.setProgressDescription("Reading Current Result"); CVF_ASSERT(this->cellResult() != NULL); - m_geomechCase->geoMechData()->assertResultsLoaded(this->cellResult()->resultAddress()); + m_geomechCase->geoMechData()->femPartResults()->assertResultsLoaded(this->cellResult()->resultAddress()); progress.incrementProgress(); progress.setProgressDescription("Create Display model"); @@ -203,7 +203,7 @@ void RimGeoMechView::createDisplayModel() if (isTimeStepDependentDataVisible()) { int i; - for (i = 0; i < geoMechCase()->geoMechData()->frameCount(); ++i) + for (i = 0; i < geoMechCase()->geoMechData()->femPartResults()->frameCount(); ++i) { timeStepIndices.push_back(i); } @@ -383,11 +383,11 @@ void RimGeoMechView::updateLegends() RigFemResultAddress resVarAddress = cellResult->resultAddress(); if (resVarAddress.fieldName != "") { - gmCase->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax); - gmCase->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero); + gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax); + gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero); - gmCase->minMaxScalarValues(resVarAddress, &globalMin, &globalMax); - gmCase->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); + gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax); + gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); cellResult->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); @@ -424,7 +424,7 @@ void RimGeoMechView::clampCurrentTimestep() int maxFrameCount = 0; if (m_geomechCase){ - maxFrameCount = m_geomechCase->geoMechData()->frameCount(); + maxFrameCount = m_geomechCase->geoMechData()->femPartResults()->frameCount(); } if (m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = maxFrameCount -1; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 2de015c101..2b2639179e 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -764,7 +764,7 @@ void RiuMainWindow::refreshAnimationActions() { if (activeGmv->isTimeStepDependentDataVisible()) { - std::vector stepNames = activeGmv->geoMechCase()->geoMechData()->stepNames(); + std::vector stepNames = activeGmv->geoMechCase()->geoMechData()->femPartResults()->stepNames(); for (size_t i = 0; i < stepNames.size(); i++) { timeStepStrings += QString::fromStdString(stepNames[i]);