Added statistics etc. access in GeomechCaseData

This commit is contained in:
Jacob Støren 2015-05-08 10:35:49 +02:00
parent 55512db6a0
commit 93d92e5cb5
2 changed files with 164 additions and 16 deletions

View File

@ -24,6 +24,8 @@
#ifdef USE_ODB_API
#include "RifOdbReader.h"
#endif
#include "RigFemScalarResultFrames.h"
#include "RigStatisticsDataCache.h"
//--------------------------------------------------------------------------------------------------
///
@ -117,33 +119,31 @@ std::map<std::string, std::vector<std::string> > RigGeoMechCaseData::scalarField
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(size_t partIndex, size_t stepIndex,
RigFemResultPosEnum resultPosType,
const std::string& fieldName,
const std::string& componentName)
RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partIndex, int stepIndex,
const RigFemResultAddress& resVarAddr)
{
CVF_ASSERT(partIndex < m_femParts->partCount());
CVF_ASSERT(m_readerInterface.notNull());
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(stepIndex, resultPosType, fieldName, componentName);
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(stepIndex, resVarAddr);
if (frames) return frames;
std::vector<double > frameTimes = m_readerInterface->frameTimes((int)stepIndex);
frames = m_femPartResults[partIndex]->createScalarResult( stepIndex, resultPosType, fieldName, componentName, frameTimes);
frames = m_femPartResults[partIndex]->createScalarResult( stepIndex, resVarAddr, frameTimes);
for (size_t fIdx = 0; fIdx < frameTimes.size(); ++fIdx)
for (int fIdx = 0; (size_t)fIdx < frameTimes.size(); ++fIdx)
{
std::vector<float>* frameData = &(frames->frameData(fIdx));
switch (resultPosType)
switch (resVarAddr.resultPosType)
{
case RIG_NODAL:
m_readerInterface->readScalarNodeField(fieldName, componentName, (int)partIndex, (int)stepIndex, (int)fIdx, frameData);
m_readerInterface->readScalarNodeField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
break;
case RIG_ELEMENT_NODAL:
//m_readerInterface->readScalarElementNodeField(fieldName, componentName, partIndex, stepIndex, fIdx, frameData);
m_readerInterface->readScalarElementNodeField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
break;
case RIG_INTEGRATION_POINT:
//m_readerInterface->readScalarIntegrationPointField(fieldName, componentName, partIndex, stepIndex, fIdx, frameData);
m_readerInterface->readScalarIntegrationPointField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
break;
}
}
@ -159,3 +159,140 @@ std::vector<std::string> RigGeoMechCaseData::stepNames()
CVF_ASSERT(m_readerInterface.notNull());
return m_readerInterface->stepNames();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* localMin, double* localMax)
{
minMaxScalarValuesInternal(resVarAddr, stepIndex, frameIndex, localMin, localMax);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int stepIndex,
double* globalMin, double* globalMax)
{
minMaxScalarValuesInternal(resVarAddr, stepIndex, -1, globalMin, globalMax);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* overallMin, double* overallMax)
{
CVF_ASSERT(overallMax && overallMin);
double min = HUGE_VAL;
double max = -HUGE_VAL;
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = m_femPartResults[pIdx]->findScalarResult(stepIndex, resVarAddr);
if (frames)
{
double lmin;
double lmax;
RigStatisticsDataCache* stats = frames->statistics();
if (frameIndex == -1)
{
stats->minMaxCellScalarValues(lmin, lmax);
}
else
{
stats->minMaxCellScalarValues(frameIndex, lmin, lmax);
}
min = lmin < min ? lmin: min;
max = lmax > max ? lmax: max;
}
}
}
*overallMax = max;
*overallMin = min;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, stepIndex, frameIndex, localPosClosestToZero, localNegClosestToZero);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, double* globalPosClosestToZero, double* globalNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, stepIndex, -1, globalPosClosestToZero, globalNegClosestToZero);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* overallPosClosestToZero, double* overallNegClosestToZero)
{
CVF_ASSERT(overallPosClosestToZero && overallNegClosestToZero);
double posClosestToZero = HUGE_VAL;
double negClosestToZero = -HUGE_VAL;
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = m_femPartResults[pIdx]->findScalarResult(stepIndex, resVarAddr);
if (frames)
{
double partNeg, partPos;
RigStatisticsDataCache* stats = frames->statistics();
if (frameIndex == -1)
{
stats->posNegClosestToZero(partPos, partNeg);
}
else
{
stats->posNegClosestToZero(frameIndex, partPos, partNeg);
}
if (partNeg > negClosestToZero && partNeg < 0) negClosestToZero = partNeg;
if (partPos < posClosestToZero && partPos > 0) posClosestToZero = partPos;
}
}
}
*overallPosClosestToZero = posClosestToZero;
*overallNegClosestToZero = negClosestToZero;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGeoMechCaseData::frameCount(int stepIndex, const RigFemResultAddress& resVarAddr)
{
size_t maxFrameCount = 0;
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = m_femPartResults[pIdx]->findScalarResult(stepIndex, resVarAddr);
if (frames)
{
size_t frameCount = frames->frameCount();
if (frameCount > maxFrameCount) maxFrameCount = frameCount;
}
}
}
return maxFrameCount;
}

View File

@ -25,6 +25,7 @@
#include "RigFemResultPosEnum.h"
#include "cvfCollection.h"
#include "RigFemPartResults.h"
#include "RigFemResultAddress.h"
class RifGeoMechReaderInterface;
class RigFemPartCollection;
@ -43,16 +44,26 @@ public:
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(RigFemResultPosEnum resPos);
std::vector<std::string> stepNames();
RigFemScalarResultFrames* findOrLoadScalarResult(size_t partIndex,
size_t stepIndex,
RigFemResultPosEnum resultPosType,
const std::string& fieldName,
const std::string& componentName);
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
int stepIndex,
const RigFemResultAddress& resVarAddr);
size_t frameCount(int stepIndex, const RigFemResultAddress& resVarAddr);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localMin, double* localMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int stepIndex, double* globalMin, double* globalMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, double* globalPosClosestToZero, double* globalNegClosestToZero);
private:
void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* overallMin, double* overallMax);
void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* localPosClosestToZero, double* localNegClosestToZero);
std::string m_geoMechCaseFileName;
cvf::ref<RigFemPartCollection> m_femParts;
cvf::Collection<RigFemPartResults> m_femPartResults;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
cvf::ref<RigStatisticsDataCache> m_statistics;
};