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_stepNames = stepNames;
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, RigFemScalarResultFrames* RigFemPartResults::createScalarResult(const RigFemResultAddress& resVarAddr)
const RigFemResultAddress& resVarAddr,
const std::vector<double>& frameTimes)
{ {
RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(frameTimes); CVF_ASSERT(m_stepNames.size());
m_femAnalysisStages[stageIndex].resultSets[resVarAddr] = resFrames;
RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(m_stepNames);
resultSets[resVarAddr] = resFrames;
return resFrames; return resFrames;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResults::findScalarResult(size_t stageIndex, RigFemScalarResultFrames* RigFemPartResults::findScalarResult(const RigFemResultAddress& resVarAddr)
const RigFemResultAddress& resVarAddr)
{ {
return m_femAnalysisStages[stageIndex].resultSets[resVarAddr].p(); return resultSets[resVarAddr].p();
} }

View File

@ -37,14 +37,11 @@ public:
RigFemPartResults(); RigFemPartResults();
~RigFemPartResults(); ~RigFemPartResults();
void initResultStages( const std::vector<std::string>& stageNames); void initResultSteps(const std::vector<std::string>& stepNames);
RigFemScalarResultFrames* createScalarResult( size_t stageIndex, RigFemScalarResultFrames* createScalarResult(const RigFemResultAddress& resVarAddr);
const RigFemResultAddress& resVarAddr,
const std::vector<double>& frameTimes);
RigFemScalarResultFrames* findScalarResult( size_t stageIndex, RigFemScalarResultFrames* findScalarResult(const RigFemResultAddress& resVarAddr);
const RigFemResultAddress& resVarAddr);
private: private:
@ -54,7 +51,8 @@ private:
std::map<RigFemResultAddress, cvf::ref<RigFemScalarResultFrames> > resultSets; 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) RigFemScalarResultFrames::RigFemScalarResultFrames(const std::vector<std::string>& frameNames)
: m_frameTimes(frameTimes) : 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() 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 class RigFemScalarResultFrames: public cvf::Object
{ {
public: public:
RigFemScalarResultFrames(const std::vector<double>& frameTimes); RigFemScalarResultFrames(const std::vector<std::string>& frameNames);
virtual ~RigFemScalarResultFrames(); virtual ~RigFemScalarResultFrames();
std::vector<float>& frameData(size_t frameIndex); std::vector<float>& frameData(size_t frameIndex);
@ -39,7 +39,7 @@ public:
private: private:
std::vector< std::vector<float> > m_dataForEachFrame; std::vector< std::vector<float> > m_dataForEachFrame;
std::vector<double> m_frameTimes; std::vector<std::string> m_frameNames;
cvf::ref<RigStatisticsDataCache> m_statistics; 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) for (int pIdx = 0; pIdx < static_cast<int>(m_femPartResults.size()); ++pIdx)
{ {
m_femPartResults[pIdx] = new RigFemPartResults; m_femPartResults[pIdx] = new RigFemPartResults;
m_femPartResults[pIdx]->initResultStages(stepNames); m_femPartResults[pIdx]->initResultSteps(stepNames);
} }
// Calculate derived Fem data // 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) const RigFemResultAddress& resVarAddr)
{ {
CVF_ASSERT(partIndex < m_femParts->partCount()); CVF_ASSERT(partIndex < m_femParts->partCount());
CVF_ASSERT(m_readerInterface.notNull()); CVF_ASSERT(m_readerInterface.notNull());
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(stepIndex, resVarAddr); RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr);
if (frames) return frames; if (frames) return frames;
std::vector<double > frameTimes = m_readerInterface->frameTimes((int)stepIndex); std::vector<std::string> stepNames = m_readerInterface->stepNames();
frames = m_femPartResults[partIndex]->createScalarResult( stepIndex, resVarAddr, frameTimes); 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) switch (resVarAddr.resultPosType)
{ {
case RIG_NODAL: case RIG_NODAL:
@ -164,7 +168,7 @@ RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partInd
break; break;
} }
} }
}
return frames; 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) 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) 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); CVF_ASSERT(overallMax && overallMin);
@ -209,7 +213,7 @@ void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& r
{ {
if (m_femPartResults[pIdx].notNull()) if (m_femPartResults[pIdx].notNull())
{ {
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, stepIndex, resVarAddr); RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, resVarAddr);
if (frames) if (frames)
{ {
double lmin; 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) double* overallPosClosestToZero, double* overallNegClosestToZero)
{ {
CVF_ASSERT(overallPosClosestToZero && overallNegClosestToZero); CVF_ASSERT(overallPosClosestToZero && overallNegClosestToZero);
@ -265,7 +269,7 @@ void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress&
{ {
if (m_femPartResults[pIdx].notNull()) if (m_femPartResults[pIdx].notNull())
{ {
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, stepIndex, resVarAddr); RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, resVarAddr);
if (frames) if (frames)
{ {
double partNeg, partPos; 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; return static_cast<int>(stepNames().size());
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);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
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) for (int pIdx = 0; pIdx < static_cast<int>(m_femPartResults.size()); ++pIdx)
{ {
if (m_femPartResults[pIdx].notNull()) 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::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(RigFemResultPosEnum resPos);
std::vector<std::string> stepNames(); std::vector<std::string> stepNames();
void assertResultsLoaded(int stepIndex, const RigFemResultAddress& resVarAddr); void assertResultsLoaded(const RigFemResultAddress& resVarAddr);
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex, RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
int stepIndex, const RigFemResultAddress& resVarAddr);
const RigFemResultAddress& resVarAddr);
int frameCount(int stepIndex, const RigFemResultAddress& resVarAddr); int frameCount();
std::vector<double> frameTimes(int stepIndex, const RigFemResultAddress& resVarAddr);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localMin, double* localMax); void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero); void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int stepIndex, double* globalMin, double* globalMax); void minMaxScalarValues (const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, double* globalPosClosestToZero, double* globalNegClosestToZero); void posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero);
private: private:
void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* overallMin, double* overallMax); double* overallMin, double* overallMax);
void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int frameIndex,
double* localPosClosestToZero, double* localNegClosestToZero); double* localPosClosestToZero, double* localNegClosestToZero);
std::string m_geoMechCaseFileName; std::string m_geoMechCaseFileName;

View File

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

View File

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

View File

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

View File

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