Commit 1a13b77f authored by Yuanxin Liu's avatar Yuanxin Liu
Browse files

vtkParticleTracerBase:: Improve functionality for coprocessing

1. Add a flag to disable this->ResetCache()
2. Remove an unnecessary condition when advancing this->CurrentTimeStep.
   This condition causes extra time requests in a coprocessing work flow
3. More graceful handling of the situation when there is only one time step
4. Fixes a few warnings and stylistic issues.

Change-Id: Id562c302a5e5503296a8787dc329607a9389eb18
parent 15ec2113
......@@ -56,7 +56,7 @@ public:
}
int GetNumberOfTimeSteps()
{
return this->TimeSteps.size();
return static_cast<int>(this->TimeSteps.size());
}
protected:
......@@ -131,7 +131,7 @@ protected:
range,2);
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
&TimeSteps[0], TimeSteps.size());
&TimeSteps[0], static_cast<int>(TimeSteps.size()));
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), this->Extent,6);
......
......@@ -81,7 +81,7 @@ int ParticlePathFilterInternal::OutputParticles(vtkPolyData* particles)
int outId = i+begin;
int pid = particleIds->GetValue(i);
for(int j=this->Paths.size(); j<=pid; j++)
for(int j= static_cast<int>(this->Paths.size()); j<=pid; j++)
{
this->Paths.push_back( vtkSmartPointer<vtkIdList>::New());
}
......
......@@ -165,6 +165,7 @@ vtkParticleTracerBase::vtkParticleTracerBase()
#endif
this->SetIntegratorType(RUNGE_KUTTA4);
this->DisableResetCache = 0;
}
//---------------------------------------------------------------------------
vtkParticleTracerBase::~vtkParticleTracerBase()
......@@ -257,8 +258,11 @@ int vtkParticleTracerBase::RequestInformation(
&this->InputTimeValues[0] );
if (numberOfInputTimeSteps==1)
{
vtkErrorMacro(<<"Not enough input time steps for particle integration");
return 0;
if(this->DisableResetCache==0) //warning would be skipped in coprocessing work flow
{
vtkWarningMacro(<<"Not enough input time steps for particle integration");
}
return 1;
}
}
else
......@@ -290,6 +294,15 @@ int vtkParticleTracerBase::RequestUpdateExtent(
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
if (this->InputTimeValues.size()<=1)
{
if(this->DisableResetCache==0) //warning would be skipped in coprocessing work flow
{
vtkWarningMacro(<<"Not enough input time steps for particle integration");
}
return 1;
}
int numInputs = inputVector[0]->GetNumberOfInformationObjects();
vtkInformation *outInfo = outputVector->GetInformationObject(0);
......@@ -300,8 +313,7 @@ int vtkParticleTracerBase::RequestUpdateExtent(
// do this only for the first time
if(this->FirstIteration)
{
StartTimeStep = FindInterval(StartTime, InputTimeValues);
this->StartTimeStep = FindInterval(StartTime, InputTimeValues);
if (!this->IgnorePipelineTime && outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
{
double terminationTime = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
......@@ -326,6 +338,7 @@ int vtkParticleTracerBase::RequestUpdateExtent(
unsigned long pmt = sddp->GetPipelineMTime();
if(pmt>this->ExecuteTime.GetMTime())
{
PRINT("Reset cache of because upstream is newer")
this->ResetCache();
}
}
......@@ -934,13 +947,11 @@ vtkPolyData* vtkParticleTracerBase::Execute(vtkInformationVector** inputVector)
output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), this->CurrentTime);
this->ExecuteTime.Modified();
this->HasCache = true;
PRINT("Output "<<output->GetNumberOfPoints()<<" particles");
PRINT("Output "<<output->GetNumberOfPoints()<<" particles, "<<this->ParticleHistories.size()<<" in cache");
//Check post condition
for (ParticleListIterator it=this->ParticleHistories.begin(); it!=this->ParticleHistories.end();it++)
{
Assert( (*it).CurrentPosition.x[3] == this->CurrentTime);
}
// To do: verify here that the particles in ParticleHistories are consistent with CurrentTime
return output;
}
......@@ -949,6 +960,15 @@ int vtkParticleTracerBase::RequestData(
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
if (this->InputTimeValues.size()<=1)
{
if(this->DisableResetCache==0) //warning would be skipped in coprocessing work flow
{
vtkWarningMacro(<<"Not enough input time steps for particle integration");
}
return 1;
}
PRINT("RD start: "<<this->CurrentTimeStep<<" "<<this->CurrentTime<<" "<<this->StartTimeStep<<" "<<this->TerminationTimeStep);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
......@@ -972,7 +992,6 @@ int vtkParticleTracerBase::RequestData(
this->CreateProtoPD(input);
}
vtkSmartPointer<vtkPolyData> particles;
particles.TakeReference(this->Execute(inputVector));
this->OutputParticles(particles);
......@@ -984,7 +1003,7 @@ int vtkParticleTracerBase::RequestData(
}
else //we are at the last step
{
if(this->TerminationTime == this->InputTimeValues[this->CurrentTimeStep] && this->CurrentTimeStep!=this->InputTimeValues.size()-1)
if(this->TerminationTime == this->InputTimeValues[this->CurrentTimeStep])
{
this->CurrentTimeStep++;
}
......@@ -1297,17 +1316,20 @@ unsigned int vtkParticleTracerBase::NumberOfParticles()
void vtkParticleTracerBase::ResetCache()
{
PRINT("Reset cache");
this->LocalSeeds.clear();
this->ParticleHistories.clear();
this->ReinjectionCounter = 0;
this->UniqueIdCounter = 0; ///check
if(this->DisableResetCache==0)
{
PRINT("Reset cache");
this->LocalSeeds.clear();
this->ParticleHistories.clear();
this->ReinjectionCounter = 0;
this->UniqueIdCounter = 0; ///check
this->CachedData[0] = NULL;
this->CachedData[1] = NULL;
this->CachedData[0] = NULL;
this->CachedData[1] = NULL;
this->Output = NULL;
this->HasCache = false;
this->Output = NULL;
this->HasCache = false;
}
}
void vtkParticleTracerBase::SetTerminationTime(double t)
......
......@@ -204,6 +204,14 @@ public:
vtkGetMacro(EnableParticleWriting,int);
vtkBooleanMacro(EnableParticleWriting,int);
// Description:
// Set/Get the flag to disable cache
// This is off by default and turned on in special circumstances
// such as in a coprocessing workflow
vtkSetMacro(DisableResetCache,int);
vtkGetMacro(DisableResetCache,int);
vtkBooleanMacro(DisableResetCache,int);
// Description:
// Provide support for multiple see sources
void AddSourceConnection(vtkAlgorithmOutput* input);
......@@ -215,8 +223,11 @@ public:
vtkIdType UniqueIdCounter;// global Id counter used to give particles a stamp
vtkParticleTracerBaseNamespace::ParticleDataList ParticleHistories;
int ReinjectionCounter;
//Everything related to time
int IgnorePipelineTime; //whether to use the pipeline time for termination
int DisableResetCache; //whether to enable ResetCache() method
vtkParticleTracerBase();
virtual ~vtkParticleTracerBase();
......@@ -408,9 +419,9 @@ private:
double TerminationTime;
double CurrentTime;
unsigned int StartTimeStep; //InputTimeValues[StartTimeStep] <= StartTime <= InputTimeValues[StartTimeStep+1]
unsigned int CurrentTimeStep;
unsigned int TerminationTimeStep; //computed from start time
int StartTimeStep; //InputTimeValues[StartTimeStep] <= StartTime <= InputTimeValues[StartTimeStep+1]
int CurrentTimeStep;
int TerminationTimeStep; //computed from start time
bool FirstIteration;
//Innjection parameters
......
......@@ -92,7 +92,7 @@ void StreaklineFilterInternal::Finalize()
for(vtkIdType i=0; i<points->GetNumberOfPoints(); i++)
{
int streakId = seedIds->GetValue(i);
for(int j=streaks.size(); j<=streakId; j++)
for(int j=static_cast<int>(streaks.size()); j<=streakId; j++)
{
streaks.push_back(Streak());
}
......
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