diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp index 5e8c8be505..762cb1fbd9 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp @@ -20,4 +20,73 @@ #pragma once #include "RigFemNativeStatCalc.h" +#include "RigFemScalarResultFrames.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemNativeStatCalc::RigFemNativeStatCalc(RigFemScalarResultFrames* cellResultsData) +{ + m_resultsData = cellResultsData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) +{ + std::vector& values = m_resultsData->frameData(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) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemNativeStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemNativeStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemNativeStatCalc::timeStepCount() +{ + return m_resultsData->frameCount(); +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp index 0509213336..848677f7a4 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp @@ -34,3 +34,41 @@ RigFemPartResults::~RigFemPartResults() { } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResults::initResultStages(const std::vector& stageNames) +{ + m_femAnalysisStages.clear(); + m_femAnalysisStages.resize(stageNames.size()); + for (size_t sIdx = 0; sIdx < stageNames.size(); ++sIdx) + { + m_femAnalysisStages[sIdx].stageName = stageNames[sIdx]; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResults::createScalarResult(size_t stageIndex, + RigFemResultPosEnum resultPosType, + const std::string& fieldName, + const std::string& componentName, + const std::vector& frameTimes) +{ + RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(frameTimes); + m_femAnalysisStages[stageIndex].resultSets[resultPosType][fieldName][componentName] = resFrames; + return resFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResults::findScalarResult(size_t stageIndex, + RigFemResultPosEnum resultPosType, + const std::string& fieldName, + const std::string& componentName) +{ + return m_femAnalysisStages[stageIndex].resultSets[resultPosType][fieldName][componentName].p(); +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp index 976ecb1935..94d691e58f 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp @@ -20,3 +20,52 @@ #pragma once #include "RigFemScalarResultFrames.h" +#include "RigFemNativeStatCalc.h" +#include "RigStatisticsDataCache.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames::RigFemScalarResultFrames(const std::vector& frameTimes) +: m_frameTimes(frameTimes) +{ + m_dataForEachFrame.resize(m_frameTimes.size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames::~RigFemScalarResultFrames() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemScalarResultFrames::frameCount() +{ + return m_frameTimes.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigStatisticsDataCache* RigFemScalarResultFrames::statistics() +{ + if (m_statistics.isNull()) + { + RigFemNativeStatCalc* calculator = new RigFemNativeStatCalc(this); + m_statistics = new RigStatisticsDataCache(calculator); + } + + return m_statistics.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector& RigFemScalarResultFrames::frameData(size_t frameIndex) +{ + return m_dataForEachFrame[frameIndex]; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index 2d57a5f8da..ef3a15701f 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -31,6 +31,7 @@ RigGeoMechCaseData::RigGeoMechCaseData(const std::string& fileName) { m_geoMechCaseFileName = fileName; + m_femParts = new RigFemPartCollection(); } //-------------------------------------------------------------------------------------------------- @@ -78,6 +79,7 @@ bool RigGeoMechCaseData::openAndReadFemParts() std::vector stepNames = m_readerInterface->stepNames(); for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx) { + m_femPartResults[pIdx] = new RigFemPartResults; m_femPartResults[pIdx]->initResultStages(stepNames); } return true; @@ -121,11 +123,12 @@ RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(size_t part const std::string& componentName) { CVF_ASSERT(partIndex < m_femParts->partCount()); + CVF_ASSERT(m_readerInterface.notNull()); RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(stepIndex, resultPosType, fieldName, componentName); if (frames) return frames; - std::vector frameTimes = m_readerInterface->frameTimes(stepIndex); + std::vector frameTimes = m_readerInterface->frameTimes((int)stepIndex); frames = m_femPartResults[partIndex]->createScalarResult( stepIndex, resultPosType, fieldName, componentName, frameTimes); for (size_t fIdx = 0; fIdx < frameTimes.size(); ++fIdx) @@ -134,7 +137,7 @@ RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(size_t part switch (resultPosType) { case RIG_NODAL: - m_readerInterface->readScalarNodeField(fieldName, componentName, partIndex, stepIndex, fIdx, frameData); + m_readerInterface->readScalarNodeField(fieldName, componentName, (int)partIndex, (int)stepIndex, (int)fIdx, frameData); break; case RIG_ELEMENT_NODAL: //m_readerInterface->readScalarElementNodeField(fieldName, componentName, partIndex, stepIndex, fIdx, frameData); @@ -144,4 +147,15 @@ RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(size_t part break; } } + + return frames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigGeoMechCaseData::stepNames() +{ + CVF_ASSERT(m_readerInterface.notNull()); + return m_readerInterface->stepNames(); }