Use odb "Steps" as animation steps

Issue #293
This is only tested with one step yet.
This commit is contained in:
Jacob Støren 2015-06-01 07:51:11 +02:00
parent ca6d9d364d
commit 96329793f3
10 changed files with 72 additions and 92 deletions

View File

@ -37,36 +37,31 @@ RigFemPartResults::~RigFemPartResults()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartResults::initResultStages(const std::vector<std::string>& stageNames)
void RigFemPartResults::initResultSteps(const std::vector<std::string>& stepNames)
{
m_femAnalysisStages.clear();
m_femAnalysisStages.resize(stageNames.size());
for (size_t sIdx = 0; sIdx < stageNames.size(); ++sIdx)
{
m_femAnalysisStages[sIdx].stageName = stageNames[sIdx];
}
m_stepNames = stepNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResults::createScalarResult(size_t stageIndex,
const RigFemResultAddress& resVarAddr,
const std::vector<double>& frameTimes)
RigFemScalarResultFrames* RigFemPartResults::createScalarResult(const RigFemResultAddress& resVarAddr)
{
RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(frameTimes);
m_femAnalysisStages[stageIndex].resultSets[resVarAddr] = resFrames;
CVF_ASSERT(m_stepNames.size());
RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(m_stepNames);
resultSets[resVarAddr] = resFrames;
return resFrames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResults::findScalarResult(size_t stageIndex,
const RigFemResultAddress& resVarAddr)
RigFemScalarResultFrames* RigFemPartResults::findScalarResult(const RigFemResultAddress& resVarAddr)
{
return m_femAnalysisStages[stageIndex].resultSets[resVarAddr].p();
return resultSets[resVarAddr].p();
}

View File

@ -37,14 +37,11 @@ public:
RigFemPartResults();
~RigFemPartResults();
void initResultStages( const std::vector<std::string>& stageNames);
void initResultSteps(const std::vector<std::string>& stepNames);
RigFemScalarResultFrames* createScalarResult( size_t stageIndex,
const RigFemResultAddress& resVarAddr,
const std::vector<double>& frameTimes);
RigFemScalarResultFrames* createScalarResult(const RigFemResultAddress& resVarAddr);
RigFemScalarResultFrames* findScalarResult( size_t stageIndex,
const RigFemResultAddress& resVarAddr);
RigFemScalarResultFrames* findScalarResult(const RigFemResultAddress& resVarAddr);
private:
@ -54,7 +51,8 @@ private:
std::map<RigFemResultAddress, cvf::ref<RigFemScalarResultFrames> > resultSets;
};
std::vector<RigAnalysisStage> m_femAnalysisStages;
//std::vector<RigAnalysisStage> m_femAnalysisStages;
std::vector<std::string> m_stepNames;
std::map<RigFemResultAddress, cvf::ref<RigFemScalarResultFrames> > resultSets;
};

View File

@ -26,10 +26,10 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames::RigFemScalarResultFrames(const std::vector<double>& frameTimes)
: m_frameTimes(frameTimes)
RigFemScalarResultFrames::RigFemScalarResultFrames(const std::vector<std::string>& frameNames)
: m_frameNames(frameNames)
{
m_dataForEachFrame.resize(m_frameTimes.size());
m_dataForEachFrame.resize(m_frameNames.size());
}
//--------------------------------------------------------------------------------------------------
@ -45,7 +45,7 @@ RigFemScalarResultFrames::~RigFemScalarResultFrames()
//--------------------------------------------------------------------------------------------------
size_t RigFemScalarResultFrames::frameCount()
{
return m_frameTimes.size();
return m_frameNames.size();
}
//--------------------------------------------------------------------------------------------------

View File

@ -29,7 +29,7 @@ class RigStatisticsDataCache;
class RigFemScalarResultFrames: public cvf::Object
{
public:
RigFemScalarResultFrames(const std::vector<double>& frameTimes);
RigFemScalarResultFrames(const std::vector<std::string>& frameNames);
virtual ~RigFemScalarResultFrames();
std::vector<float>& frameData(size_t frameIndex);
@ -39,7 +39,7 @@ public:
private:
std::vector< std::vector<float> > m_dataForEachFrame;
std::vector<double> m_frameTimes;
std::vector<std::string> m_frameNames;
cvf::ref<RigStatisticsDataCache> m_statistics;
};

View File

@ -92,7 +92,7 @@ bool RigGeoMechCaseData::openAndReadFemParts()
for (int pIdx = 0; pIdx < static_cast<int>(m_femPartResults.size()); ++pIdx)
{
m_femPartResults[pIdx] = new RigFemPartResults;
m_femPartResults[pIdx]->initResultStages(stepNames);
m_femPartResults[pIdx]->initResultSteps(stepNames);
}
// Calculate derived Fem data
@ -136,21 +136,25 @@ std::map<std::string, std::vector<std::string> > RigGeoMechCaseData::scalarField
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partIndex, int stepIndex,
RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partIndex,
const RigFemResultAddress& resVarAddr)
{
CVF_ASSERT(partIndex < m_femParts->partCount());
CVF_ASSERT(m_readerInterface.notNull());
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(stepIndex, resVarAddr);
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr);
if (frames) return frames;
std::vector<double > frameTimes = m_readerInterface->frameTimes((int)stepIndex);
frames = m_femPartResults[partIndex]->createScalarResult( stepIndex, resVarAddr, frameTimes);
std::vector<std::string> stepNames = m_readerInterface->stepNames();
frames = m_femPartResults[partIndex]->createScalarResult( resVarAddr);
for (int fIdx = 0; (size_t)fIdx < frameTimes.size(); ++fIdx)
for (int stepIndex = 0; stepIndex < stepNames.size(); ++stepIndex)
{
std::vector<float>* frameData = &(frames->frameData(fIdx));
std::vector<double > frameTimes = m_readerInterface->frameTimes((int)stepIndex);
for (int fIdx = 1; (size_t)fIdx < frameTimes.size() && fIdx < 2 ; ++fIdx) // Read only the second frame
{
std::vector<float>* frameData = &(frames->frameData(stepIndex));
switch (resVarAddr.resultPosType)
{
case RIG_NODAL:
@ -164,7 +168,7 @@ RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partInd
break;
}
}
}
return frames;
}
@ -180,25 +184,25 @@ std::vector<std::string> RigGeoMechCaseData::stepNames()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex,
double* localMin, double* localMax)
{
minMaxScalarValuesInternal(resVarAddr, stepIndex, frameIndex, localMin, localMax);
minMaxScalarValuesInternal(resVarAddr, frameIndex, localMin, localMax);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int stepIndex,
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr,
double* globalMin, double* globalMax)
{
minMaxScalarValuesInternal(resVarAddr, stepIndex, -1, globalMin, globalMax);
minMaxScalarValuesInternal(resVarAddr, -1, globalMin, globalMax);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* overallMin, double* overallMax)
void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex, double* overallMin, double* overallMax)
{
CVF_ASSERT(overallMax && overallMin);
@ -209,7 +213,7 @@ void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& r
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, stepIndex, resVarAddr);
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, resVarAddr);
if (frames)
{
double lmin;
@ -237,23 +241,23 @@ void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& r
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero)
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, stepIndex, frameIndex, localPosClosestToZero, localNegClosestToZero);
posNegClosestToZeroInternal(resVarAddr, frameIndex, localPosClosestToZero, localNegClosestToZero);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, double* globalPosClosestToZero, double* globalNegClosestToZero)
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, stepIndex, -1, globalPosClosestToZero, globalNegClosestToZero);
posNegClosestToZeroInternal(resVarAddr, -1, globalPosClosestToZero, globalNegClosestToZero);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* overallPosClosestToZero, double* overallNegClosestToZero)
{
CVF_ASSERT(overallPosClosestToZero && overallNegClosestToZero);
@ -265,7 +269,7 @@ void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress&
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, stepIndex, resVarAddr);
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, resVarAddr);
if (frames)
{
double partNeg, partPos;
@ -294,35 +298,21 @@ void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigGeoMechCaseData::frameCount(int stepIndex, const RigFemResultAddress& resVarAddr)
int RigGeoMechCaseData::frameCount()
{
size_t maxFrameCount = 0;
for (int pIdx = 0; pIdx < static_cast<int>(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 static_cast<int>(maxFrameCount);
return static_cast<int>(stepNames().size());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::assertResultsLoaded(int stepIndex, const RigFemResultAddress& resVarAddr)
void RigGeoMechCaseData::assertResultsLoaded( const RigFemResultAddress& resVarAddr)
{
for (int pIdx = 0; pIdx < static_cast<int>(m_femPartResults.size()); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
findOrLoadScalarResult(pIdx, stepIndex, resVarAddr);
findOrLoadScalarResult(pIdx, resVarAddr);
}
}
}

View File

@ -44,23 +44,21 @@ public:
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(RigFemResultPosEnum resPos);
std::vector<std::string> stepNames();
void assertResultsLoaded(int stepIndex, const RigFemResultAddress& resVarAddr);
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
int stepIndex,
const RigFemResultAddress& resVarAddr);
void assertResultsLoaded(const RigFemResultAddress& resVarAddr);
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
const RigFemResultAddress& resVarAddr);
int frameCount(int stepIndex, const RigFemResultAddress& resVarAddr);
std::vector<double> frameTimes(int stepIndex, const RigFemResultAddress& resVarAddr);
int frameCount();
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);
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);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero);
private:
void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* overallMin, double* overallMax);
void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* localPosClosestToZero, double* localNegClosestToZero);
std::string m_geoMechCaseFileName;

View File

@ -236,7 +236,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechRe
RigFemResultAddress resVarAddress(resPosType, fieldName.toStdString(), compName.toStdString());
RigFemScalarResultFrames* scalarResults = caseData->findOrLoadScalarResult(m_gridIdx, 0, resVarAddress);
RigFemScalarResultFrames* scalarResults = caseData->findOrLoadScalarResult(m_gridIdx, resVarAddress);
std::vector<float>& resultValues = scalarResults->frameData(timeStepIndex);
const std::vector<size_t>* vxToResultMapping = NULL;

View File

@ -173,7 +173,7 @@ void RimGeoMechResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
m_resultComponentName = "";
}
m_reservoirView->geoMechCase()->geoMechData()->assertResultsLoaded(0, this->resultAddress());
m_reservoirView->geoMechCase()->geoMechData()->assertResultsLoaded(this->resultAddress());
if (m_reservoirView)
{

View File

@ -137,7 +137,7 @@ void RimGeoMechView::loadDataAndUpdate()
progress.setProgressDescription("Reading Current Result");
CVF_ASSERT(this->cellResult() != NULL);
m_geomechCase->geoMechData()->assertResultsLoaded(0, this->cellResult()->resultAddress());
m_geomechCase->geoMechData()->assertResultsLoaded(this->cellResult()->resultAddress());
progress.incrementProgress();
progress.setProgressDescription("Create Display model");
@ -200,7 +200,7 @@ void RimGeoMechView::createDisplayModel()
if (isTimeStepDependentDataVisible())
{
int i;
for (i = 0; i < geoMechCase()->geoMechData()->frameCount(0, cellResult()->resultAddress()); i++)
for (i = 0; i < geoMechCase()->geoMechData()->frameCount(); ++i)
{
timeStepIndices.push_back(i);
}
@ -380,11 +380,11 @@ void RimGeoMechView::updateLegends()
RigFemResultAddress resVarAddress = cellResult->resultAddress();
if (resVarAddress.fieldName != "")
{
gmCase->minMaxScalarValues(resVarAddress, 0, m_currentTimeStep, &localMin, &localMax);
gmCase->posNegClosestToZero(resVarAddress, 0, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
gmCase->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax);
gmCase->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
gmCase->minMaxScalarValues(resVarAddress, 0, &globalMin, &globalMax);
gmCase->posNegClosestToZero(resVarAddress, 0, &globalPosClosestToZero, &globalNegClosestToZero);
gmCase->minMaxScalarValues(resVarAddress, &globalMin, &globalMax);
gmCase->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero);
cellResult->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
@ -421,7 +421,7 @@ void RimGeoMechView::clampCurrentTimestep()
int maxFrameCount = 0;
if (m_geomechCase){
maxFrameCount = m_geomechCase->geoMechData()->frameCount(0, cellResult()->resultAddress());
maxFrameCount = m_geomechCase->geoMechData()->frameCount();
}
if (m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = maxFrameCount -1;

View File

@ -764,11 +764,10 @@ void RiuMainWindow::refreshAnimationActions()
{
if (activeGmv->isTimeStepDependentDataVisible())
{
RigFemResultAddress resAddr = activeGmv->cellResult()->resultAddress();
size_t frameCount = activeGmv->geoMechCase()->geoMechData()->frameCount(0, resAddr);
for (size_t i = 0; i < frameCount; i++)
std::vector<std::string> stepNames = activeGmv->geoMechCase()->geoMechData()->stepNames();
for (size_t i = 0; i < stepNames.size(); i++)
{
timeStepStrings += QString::number(i);
timeStepStrings += QString::fromStdString(stepNames[i]);
}
}
}