Fem-results caching now up and running

Still work in progress. Statistics not complete
This commit is contained in:
Jacob Støren
2015-05-07 10:11:55 +02:00
parent 41b0847041
commit d405643d60
4 changed files with 172 additions and 2 deletions

View File

@@ -20,4 +20,73 @@
#pragma once
#include "RigFemNativeStatCalc.h"
#include "RigFemScalarResultFrames.h"
#include <math.h>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemNativeStatCalc::RigFemNativeStatCalc(RigFemScalarResultFrames* cellResultsData)
{
m_resultsData = cellResultsData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
{
std::vector<float>& 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();
}

View File

@@ -34,3 +34,41 @@ RigFemPartResults::~RigFemPartResults()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartResults::initResultStages(const std::vector<std::string>& 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<double>& 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();
}

View File

@@ -20,3 +20,52 @@
#pragma once
#include "RigFemScalarResultFrames.h"
#include "RigFemNativeStatCalc.h"
#include "RigStatisticsDataCache.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames::RigFemScalarResultFrames(const std::vector<double>& 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<float>& RigFemScalarResultFrames::frameData(size_t frameIndex)
{
return m_dataForEachFrame[frameIndex];
}

View File

@@ -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<std::string> 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<double > frameTimes = m_readerInterface->frameTimes(stepIndex);
std::vector<double > 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<std::string> RigGeoMechCaseData::stepNames()
{
CVF_ASSERT(m_readerInterface.notNull());
return m_readerInterface->stepNames();
}