Commit a3b6e9d3 authored by allens's avatar allens

minor code clean up with an additional flag for inclusive/exclusive on time steps with odd stride

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@20649 18c085ea-50e0-402c-830e-de6fd14e8384
parent ae6e1f80
...@@ -72,7 +72,8 @@ avtTimeLoopFilter::avtTimeLoopFilter() ...@@ -72,7 +72,8 @@ avtTimeLoopFilter::avtTimeLoopFilter()
{ {
startTime = -1; startTime = -1;
endTime = -1; endTime = -1;
stride = -1; stride = -1;
includeLastTime = true;
nFrames = 0; nFrames = 0;
actualEnd = 0; actualEnd = 0;
nIterations = 1; nIterations = 1;
...@@ -179,26 +180,31 @@ avtTimeLoopFilter::Update(avtContract_p spec) ...@@ -179,26 +180,31 @@ avtTimeLoopFilter::Update(avtContract_p spec)
avtOriginatingSource *src = GetOriginatingSource(); avtOriginatingSource *src = GetOriginatingSource();
src->SetNumberOfExecutions(numIters); src->SetNumberOfExecutions(numIters);
for (int currentLoopIter = 0; currentLoopIter < numTimeLoopIterations; currentLoopIter++) for (int currentLoopIter=0; currentLoopIter<numTimeLoopIterations; ++currentLoopIter)
{ {
debug4 << "Time loop filter updating with iteration # "<<currentLoopIter<<endl; debug4 << "Time loop filter updating with iteration # "
<< currentLoopIter << endl;
int curIter = 0; int curIter = 0;
BeginIteration(currentLoopIter); BeginIteration(currentLoopIter);
for (i = startTime; i < actualEnd; i+= stride)
for (i=0, currentTime=startTime; i<nFrames; ++i, currentTime+=stride)
{ {
bool shouldDoThisTimeSlice = true; bool shouldDoThisTimeSlice = true;
if (parallelizingOverTime) if (parallelizingOverTime)
if ((curIter % PAR_Size()) != PAR_Rank()) if ((curIter % PAR_Size()) != PAR_Rank())
shouldDoThisTimeSlice = false; shouldDoThisTimeSlice = false;
curIter++; curIter++;
if (!shouldDoThisTimeSlice) if (!shouldDoThisTimeSlice)
continue; continue;
if (i < endTime) // Depending on the stride the last frame may be before
currentTime = i; // the end.
else if (currentTime > endTime)
currentTime = endTime; currentTime = endTime;
if (!NeedCurrentTimeSlice()) if (!NeedCurrentTimeSlice())
continue; continue;
...@@ -365,10 +371,12 @@ avtTimeLoopFilter::FinalizeTimeLoop() ...@@ -365,10 +371,12 @@ avtTimeLoopFilter::FinalizeTimeLoop()
{ {
startTime = 0; startTime = 0;
} }
if (endTime < 0) if (endTime < 0)
{ {
endTime = numStates - 1; endTime = numStates - 1;
} }
if (stride < 0) if (stride < 0)
{ {
stride = 1; stride = 1;
...@@ -385,6 +393,7 @@ avtTimeLoopFilter::FinalizeTimeLoop() ...@@ -385,6 +393,7 @@ avtTimeLoopFilter::FinalizeTimeLoop()
std::string msg(oss.str()); std::string msg(oss.str());
avtCallback::IssueWarning(msg.c_str()); avtCallback::IssueWarning(msg.c_str());
} }
if (startTime > endTime) if (startTime > endTime)
{ {
std::ostringstream oss; std::ostringstream oss;
...@@ -395,7 +404,12 @@ avtTimeLoopFilter::FinalizeTimeLoop() ...@@ -395,7 +404,12 @@ avtTimeLoopFilter::FinalizeTimeLoop()
EXCEPTION2(UnexpectedValueException, expected, startTime); EXCEPTION2(UnexpectedValueException, expected, startTime);
} }
nFrames = (int) ceil(((float) endTime - startTime) / (float) stride) + 1; // Regardless of the stride include the last frame. This only
// happens when the (endTime-startTime) % stride != 0.
if( includeLastTime )
nFrames = (int) ceil(((float) endTime - startTime) / (float) stride) + 1;
else
nFrames = (endTime - startTime) / stride + 1;
if (nFrames < 1) if (nFrames < 1)
{ {
...@@ -407,14 +421,6 @@ avtTimeLoopFilter::FinalizeTimeLoop() ...@@ -407,14 +421,6 @@ avtTimeLoopFilter::FinalizeTimeLoop()
std::string got(oss2.str()); std::string got(oss2.str());
EXCEPTION2(UnexpectedValueException, expected, got); EXCEPTION2(UnexpectedValueException, expected, got);
} }
//
// Ensure that the specified endTime is included,
// regardless of the stride.
//
actualEnd = startTime + nFrames *stride;
if (actualEnd < endTime)
actualEnd = endTime + stride;
} }
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include <avtFilter.h> #include <avtFilter.h>
// **************************************************************************** // ****************************************************************************
// Method: avtTimeLoopFilter // Method: avtTimeLoopFilter
// //
...@@ -98,9 +97,11 @@ class PIPELINE_API avtTimeLoopFilter : virtual public avtFilter ...@@ -98,9 +97,11 @@ class PIPELINE_API avtTimeLoopFilter : virtual public avtFilter
{ endTime = e; }; { endTime = e; };
void SetStride(int s) void SetStride(int s)
{ stride = s; }; { stride = s; };
void GetIncludeLastTime(bool val) { includeLastTime = val;};
int GetStartTime() const {return startTime;} int GetStartTime() const {return startTime;}
int GetEndTime() const {return endTime;} int GetEndTime() const {return endTime;}
int GetNFrames() const {return nFrames;} int GetNFrames() const {return nFrames;}
bool GetIncludeLastTime() const { return includeLastTime;};
protected: protected:
intVector validTimes; intVector validTimes;
...@@ -127,6 +128,7 @@ class PIPELINE_API avtTimeLoopFilter : virtual public avtFilter ...@@ -127,6 +128,7 @@ class PIPELINE_API avtTimeLoopFilter : virtual public avtFilter
int actualEnd; int actualEnd;
int nIterations; int nIterations;
int iteration; int iteration;
bool includeLastTime;
bool parallelizingOverTime; bool parallelizingOverTime;
virtual void InitializeTimeLoop(void) {}; virtual void InitializeTimeLoop(void) {};
...@@ -159,8 +161,6 @@ class PIPELINE_API avtTimeLoopFilter : virtual public avtFilter ...@@ -159,8 +161,6 @@ class PIPELINE_API avtTimeLoopFilter : virtual public avtFilter
bool CanDoTimeParallelization(void); bool CanDoTimeParallelization(void);
}; };
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment