Commit 585a7c9e authored by Andrew Bauer's avatar Andrew Bauer

Particle path improvements intended for in situ processing.

Cleaning up the particle paths implementation to get rid
of stuff intended for using particle paths in situ.
This allows some methods to be overwritten which only
make sense for in situ use and removes other parts
that only really make sense in situ. The new in situ
particle path filter will be in ParaView.
parent 2b37b7fe
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParticlePathFilter.cxx
Program: Visualization Toolkit
Module: vtkParticlePathFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkParticlePathFilter.h"
......@@ -35,6 +35,7 @@ void ParticlePathFilterInternal::Initialize(vtkParticleTracerBase* filter)
this->Filter = filter;
this->Filter->SetForceReinjectionEveryNSteps(0);
this->Filter->SetIgnorePipelineTime(1);
this->ClearCache = false;
}
void ParticlePathFilterInternal::Reset()
......@@ -43,15 +44,15 @@ void ParticlePathFilterInternal::Reset()
this->Paths.clear();
}
int ParticlePathFilterInternal::OutputParticles(vtkPolyData* particles, bool clearCache)
int ParticlePathFilterInternal::OutputParticles(vtkPolyData* particles)
{
if(!this->Filter->Output || clearCache)
if(!this->Filter->Output || this->ClearCache)
{
this->Filter->Output = vtkSmartPointer<vtkPolyData>::New();
this->Filter->Output->SetPoints(vtkSmartPointer<vtkPoints>::New());
this->Filter->Output->GetPointData()->CopyAllocate(particles->GetPointData());
}
if(clearCache)
if(this->ClearCache)
{ // clear cache no matter what
this->Paths.clear();
}
......@@ -137,7 +138,6 @@ vtkParticlePathFilter::vtkParticlePathFilter()
this->It.Initialize(this);
this->SimulationTime = NULL;
this->SimulationTimeStep = NULL;
this->ClearCache = false;
}
vtkParticlePathFilter::~vtkParticlePathFilter()
......@@ -163,12 +163,11 @@ void vtkParticlePathFilter::ResetCache()
void vtkParticlePathFilter::PrintSelf(ostream& os, vtkIndent indent)
{
Superclass::PrintSelf(os,indent);
os << indent << "ClearCache: " << this->ClearCache << endl;
}
int vtkParticlePathFilter::OutputParticles(vtkPolyData* particles)
{
return this->It.OutputParticles(particles, this->ClearCache);
return this->It.OutputParticles(particles);
}
void vtkParticlePathFilter::InitializeExtraPointDataArrays(vtkPointData* outputPD)
......
......@@ -35,13 +35,24 @@ public:
ParticlePathFilterInternal():Filter(NULL){}
void Initialize(vtkParticleTracerBase* filter);
virtual ~ParticlePathFilterInternal(){}
virtual int OutputParticles(vtkPolyData* poly, bool clearCache);
virtual int OutputParticles(vtkPolyData* poly);
void SetClearCache(bool clearCache)
{
this->ClearCache = clearCache;
}
bool GetClearCache()
{
return this->ClearCache;
}
void Finalize();
void Reset();
private:
vtkParticleTracerBase* Filter;
// Paths doesn't seem to work properly. it is meant to make connecting lines
// for the particles
std::vector<vtkSmartPointer<vtkIdList> > Paths;
bool ClearCache; // false by default
};
class VTKFILTERSFLOWPATHS_EXPORT vtkParticlePathFilter: public vtkParticleTracerBase
......@@ -52,12 +63,6 @@ public:
static vtkParticlePathFilter *New();
// Description:
// Set/get whether or not to clear out cache of previous time steps.
// Default value is false. Clearing the cache is aimed towards in situ use.
vtkSetMacro(ClearCache, bool);
vtkGetMacro(ClearCache, bool);
protected:
vtkParticlePathFilter();
~vtkParticlePathFilter();
......@@ -76,9 +81,6 @@ protected:
private:
vtkDoubleArray* SimulationTime;
vtkIntArray* SimulationTimeStep;
bool ClearCache;
};
#endif
......@@ -320,6 +320,12 @@ int vtkParticleTracerBase::RequestUpdateExtent(
for(int i=0; i<this->GetNumberOfInputPorts(); i++)
{
vtkInformation* info = this->GetInputPortInformation(i);
if(info->Get(vtkAlgorithm::INPUT_IS_OPTIONAL()) &&
this->GetNumberOfInputConnections(i) == 0)
{
continue;
}
vtkAlgorithm* inputAlgorithm = this->GetInputAlgorithm(i,0);
vtkStreamingDemandDrivenPipeline* sddp = vtkStreamingDemandDrivenPipeline::SafeDownCast(inputAlgorithm->GetExecutive());
if(sddp)
......@@ -474,6 +480,23 @@ int vtkParticleTracerBase::InitializeInterpolator()
return VTK_OK;
}
//---------------------------------------------------------------------------
std::vector<vtkDataSet*> vtkParticleTracerBase::GetSeedSources(
vtkInformationVector* inputVector, int vtkNotUsed(timeStep))
{
int numSources = inputVector->GetNumberOfInformationObjects();
std::vector<vtkDataSet*> seedSources;
for (int idx=0; idx<numSources; ++idx)
{
if(vtkInformation *inInfo = inputVector->GetInformationObject(idx))
{
vtkDataObject* dobj = inInfo->Get(vtkDataObject::DATA_OBJECT());
seedSources.push_back(vtkDataSet::SafeDownCast(dobj));
}
}
return seedSources;
}
//---------------------------------------------------------------------------
int vtkParticleTracerBase::UpdateDataCache(vtkDataObject *data)
{
......@@ -653,8 +676,6 @@ void vtkParticleTracerBase::AssignSeedsToProcessors(
// Assign unique identifiers taking into account uneven distribution
// across processes and seeds which were rejected
this->AssignUniqueIds(localSeedPoints);
//
}
//---------------------------------------------------------------------------
......@@ -776,23 +797,10 @@ vtkPolyData* vtkParticleTracerBase::Execute(vtkInformationVector** inputVector)
output->SetVerts(this->ParticleCells);
vtkDebugMacro(<< "Finished allocating point arrays ");
///
// How many Seed point sources are connected?
// Copy the sources into a vector for later use
//
int numSources = inputVector[1]->GetNumberOfInformationObjects();
std::vector<vtkDataSet*> seedSources;
for (int idx=0; idx<numSources; ++idx)
{
vtkDataObject *dobj = 0;
vtkInformation *inInfo = inputVector[1]->GetInformationObject(idx);
if (inInfo)
{
dobj = inInfo->Get(vtkDataObject::DATA_OBJECT());
seedSources.push_back(vtkDataSet::SafeDownCast(dobj));
}
}
std::vector<vtkDataSet*> seedSources = this->GetSeedSources(inputVector[1], this->CurrentTimeStep);
//
// Setup some variables
......@@ -814,6 +822,8 @@ vtkPolyData* vtkParticleTracerBase::Execute(vtkInformationVector** inputVector)
this->LocalSeeds.clear();
}
this->AddRestartSeeds(inputVector);
for (size_t i=0; i<seedSources.size(); i++)
{
this->AssignSeedsToProcessors(this->CurrentTimeValue,seedSources[i], static_cast<int>(i),
......
......@@ -218,7 +218,7 @@ public:
vtkBooleanMacro(DisableResetCache,int);
// Description:
// Provide support for multiple see sources
// Provide support for multiple seed sources
void AddSourceConnection(vtkAlgorithmOutput* input);
void RemoveAllSources();
......@@ -236,7 +236,6 @@ public:
int IgnorePipelineTime; //whether to use the pipeline time for termination
int DisableResetCache; //whether to enable ResetCache() method
vtkParticleTracerBase();
virtual ~vtkParticleTracerBase();
......@@ -292,6 +291,11 @@ public:
virtual int OutputParticles(vtkPolyData* poly)=0; //every iteration
virtual void Finalize(){} //the last iteration
// Description:
// Method to get the data set seed sources.
// For in situ we want to override how the seed sources are made available.
virtual std::vector<vtkDataSet*> GetSeedSources(vtkInformationVector* inputVector, int timeStep);
//
// Initialization of input (vector-field) geometry
//
......@@ -314,8 +318,8 @@ public:
// they belong to. This saves us retesting at every injection time
// providing 1) The volumes are static, 2) the seed points are static
// If either are non static, then this step is skipped.
virtual void AssignSeedsToProcessors(double time,
vtkDataSet *source, int sourceID, int ptId,
virtual void AssignSeedsToProcessors(
double time, vtkDataSet *source, int sourceID, int ptId,
vtkParticleTracerBaseNamespace::ParticleVector &localSeedPoints,
int &localAssignedCount);
......@@ -411,7 +415,13 @@ public:
virtual void AppendToExtraPointDataArrays(vtkParticleTracerBaseNamespace::ParticleInformation &) {}
vtkTemporalInterpolatedVelocityField* GetInterpolator();
private:
// Description:
// For restarts of particle paths, we add in the ability to add in
// particles from a previous computation that we will still advect.
virtual void AddRestartSeeds(vtkInformationVector** /*inputVector*/) {}
private:
// Description:
// Hide this because we require a new interpolator type
void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField*) {}
......@@ -509,7 +519,6 @@ private:
friend class StreaklineFilterInternal;
static const double Epsilon;
};
#endif
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPParticlePathFilter.cxx
Program: Visualization Toolkit
Module: vtkPParticlePathFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkPParticlePathFilter.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkCellArray.h"
#include "vtkCharArray.h"
......@@ -21,6 +21,7 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkDoubleArray.h"
#include "vtkFloatArray.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include <cassert>
vtkStandardNewMacro(vtkPParticlePathFilter);
......@@ -30,7 +31,6 @@ vtkPParticlePathFilter::vtkPParticlePathFilter()
this->It.Initialize(this);
this->SimulationTime = NULL;
this->SimulationTimeStep = NULL;
this->ClearCache = false;
}
vtkPParticlePathFilter::~vtkPParticlePathFilter()
......@@ -55,7 +55,6 @@ void vtkPParticlePathFilter::ResetCache()
void vtkPParticlePathFilter::PrintSelf(ostream& os, vtkIndent indent)
{
Superclass::PrintSelf(os,indent);
os << indent << "ClearCache: " << this->ClearCache << endl;
}
int vtkPParticlePathFilter::OutputParticles(vtkPolyData* particles)
......@@ -101,8 +100,9 @@ int vtkPParticlePathFilter::OutputParticles(vtkPolyData* particles)
}
}
this->It.OutputParticles(tailPoly.GetPointer(), this->ClearCache);
return this->It.OutputParticles(particles, false); // we've already cleared cache in the first call
this->It.OutputParticles(tailPoly.GetPointer());
return this->It.OutputParticles(particles); // we've already cleared cache in the first call
}
void vtkPParticlePathFilter::InitializeExtraPointDataArrays(vtkPointData* outputPD)
......
......@@ -15,7 +15,7 @@
// .NAME vtkPParticlePathFilter - A Parallel Particle tracer for unsteady vector fields
// .SECTION Description
// vtkPParticlePathFilter is a filter that integrates a vector field to generate
//
// path lines.
//
// .SECTION See Also
// vtkPParticlePathFilterBase has the details of the algorithms
......@@ -24,7 +24,6 @@
#ifndef vtkPParticlePathFilter_h
#define vtkPParticlePathFilter_h
#include "vtkPParticleTracerBase.h"
#include "vtkParticlePathFilter.h" //for utility
......@@ -37,12 +36,6 @@ public:
static vtkPParticlePathFilter *New();
// Description:
// Set/get whether or not to clear out cache of previous time steps.
// Default value is false. Clearing the cache is aimed towards in situ use.
vtkSetMacro(ClearCache, bool);
vtkGetMacro(ClearCache, bool);
protected:
vtkPParticlePathFilter();
~vtkPParticlePathFilter();
......@@ -54,15 +47,11 @@ protected:
void Finalize();
ParticlePathFilterInternal It;
private:
vtkPParticlePathFilter(const vtkPParticlePathFilter&); // Not implemented.
void operator=(const vtkPParticlePathFilter&); // Not implemented
vtkDoubleArray* SimulationTime;
vtkIntArray* SimulationTimeStep;
bool ClearCache;
private:
vtkPParticlePathFilter(const vtkPParticlePathFilter&); // Not implemented.
void operator=(const vtkPParticlePathFilter&); // Not implemented
};
#endif
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParticleTracerBase.cxx
Program: Visualization Toolkit
Module: vtkParticleTracerBase.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkPParticleTracerBase.h"
......@@ -118,8 +118,8 @@ bool vtkPParticleTracerBase::SendParticleToAnotherProcess(
info.CurrentPosition.x[3]>(this->GetCacheDataTime(1)+eps))
{
vtkErrorMacro(<< "Unexpected time value in MPISendList - expected ("
<< this->GetCacheDataTime(0) << "-" << this->GetCacheDataTime(1) << ") got "
<< info.CurrentPosition.x[3]);
<< this->GetCacheDataTime(0) << "-" << this->GetCacheDataTime(1) << ") got "
<< info.CurrentPosition.x[3]);
}
if (this->MPISendList.capacity()<(this->MPISendList.size()+1))
......@@ -171,7 +171,7 @@ void vtkPParticleTracerBase::AssignSeedsToProcessors(
info.ErrorCode = 0;
info.PointId = -1;
info.TailPointId = -1;
}
}
//
// Check all Seeds on all processors for classification
//
......@@ -248,14 +248,15 @@ void vtkPParticleTracerBase::AssignUniqueIds(
this->UniqueIdCounter += recvNumParticles[i];
}
}
else {
else
{
for (vtkIdType i=0; i<numParticles; i++)
{
localSeedPoints[i].UniqueParticleId =
this->UniqueIdCounter + particleCountOffset + i;
}
this->UniqueIdCounter += numParticles;
}
}
}
//---------------------------------------------------------------------------
......@@ -416,6 +417,7 @@ int vtkPParticleTracerBase::RequestUpdateExtent(
sourceInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(),
1);
}
return Superclass::RequestUpdateExtent(request,inputVector,outputVector);
}
......@@ -451,7 +453,7 @@ bool vtkPParticleTracerBase::UpdateParticleListFromOtherProcesses()
info.Current.TailPointId = info.Previous.TailPointId = this->Tail.size();
this->Tail.push_back(info);
this->ParticleHistories.push_back(info.Current);
}
}
return particlesMoved;
}
......
......@@ -7,11 +7,11 @@
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
=========================================================================*/
// .NAME vtkParticleTracerBase - A parallel particle tracer for vector fields
// .SECTION Description
// vtkPParticleTracerBase is the base class for parallel filters that advect particles
......@@ -70,7 +70,8 @@ protected:
vtkParticleTracerBaseNamespace::ParticleInformation & previous,
vtkPointData*);
// Description : Before starting the particle trace, classify
// Description:
// Before starting the particle trace, classify
// all the injection/seed points according to which processor
// they belong to. This saves us retesting at every injection time
// providing 1) The volumes are static, 2) the seed points are static
......@@ -112,10 +113,8 @@ protected:
RemoteParticleVector MPISendList;
RemoteParticleVector Tail; //this is to receive the "tails" of traces from other processes
private:
private:
vtkPParticleTracerBase(const vtkPParticleTracerBase&); // Not implemented.
void operator=(const vtkPParticleTracerBase&); // Not implemented.
};
#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