diff --git a/Filters/FlowPaths/vtkParticlePathFilter.cxx b/Filters/FlowPaths/vtkParticlePathFilter.cxx index 433b78503e5ebae0d0f14fb0b2d946ddeec3fb73..1aa2fe14d8b1f2a914fe21e48fad04c288b3d6aa 100644 --- a/Filters/FlowPaths/vtkParticlePathFilter.cxx +++ b/Filters/FlowPaths/vtkParticlePathFilter.cxx @@ -1,15 +1,15 @@ /*========================================================================= -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::New(); this->Filter->Output->SetPoints(vtkSmartPointer::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) diff --git a/Filters/FlowPaths/vtkParticlePathFilter.h b/Filters/FlowPaths/vtkParticlePathFilter.h index 2d0bc5685beec310b96523c0c077df3603420d51..0fccf0b82e8e24d324f97b2c628e7c1c66c162e1 100644 --- a/Filters/FlowPaths/vtkParticlePathFilter.h +++ b/Filters/FlowPaths/vtkParticlePathFilter.h @@ -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 > 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 diff --git a/Filters/FlowPaths/vtkParticleTracerBase.cxx b/Filters/FlowPaths/vtkParticleTracerBase.cxx index 82a20e4bd44126ca842d79fdfb70cb9a4fd9db4b..f1b96a7187c6020f71d4fc5a8e60baed3f1554fc 100644 --- a/Filters/FlowPaths/vtkParticleTracerBase.cxx +++ b/Filters/FlowPaths/vtkParticleTracerBase.cxx @@ -320,6 +320,12 @@ int vtkParticleTracerBase::RequestUpdateExtent( for(int i=0; iGetNumberOfInputPorts(); 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 vtkParticleTracerBase::GetSeedSources( + vtkInformationVector* inputVector, int vtkNotUsed(timeStep)) +{ + int numSources = inputVector->GetNumberOfInformationObjects(); + std::vector seedSources; + for (int idx=0; idxGetInformationObject(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 seedSources; - for (int idx=0; idxGetInformationObject(idx); - if (inInfo) - { - dobj = inInfo->Get(vtkDataObject::DATA_OBJECT()); - seedSources.push_back(vtkDataSet::SafeDownCast(dobj)); - } - } + std::vector 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; iAssignSeedsToProcessors(this->CurrentTimeValue,seedSources[i], static_cast(i), diff --git a/Filters/FlowPaths/vtkParticleTracerBase.h b/Filters/FlowPaths/vtkParticleTracerBase.h index cf453942f35d05b3a162383b0462351a71bc549f..9ec6af399cd64afe66474ffc131a2d40d2696cb7 100644 --- a/Filters/FlowPaths/vtkParticleTracerBase.h +++ b/Filters/FlowPaths/vtkParticleTracerBase.h @@ -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 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 diff --git a/Filters/ParallelFlowPaths/vtkPParticlePathFilter.cxx b/Filters/ParallelFlowPaths/vtkPParticlePathFilter.cxx index 1fe1d7f2166fff19cc7b7a1e7f42b0ffb0357448..20bd4c2f5a46e0b06f087bbc6f67a40b7a3057aa 100644 --- a/Filters/ParallelFlowPaths/vtkPParticlePathFilter.cxx +++ b/Filters/ParallelFlowPaths/vtkPParticlePathFilter.cxx @@ -1,19 +1,19 @@ /*========================================================================= -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 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) diff --git a/Filters/ParallelFlowPaths/vtkPParticlePathFilter.h b/Filters/ParallelFlowPaths/vtkPParticlePathFilter.h index b19707d5f222349f507750b6fda76a67cdad8ed2..3a0c12fc0a18b13d526c4624f1a4aacc6da538b8 100644 --- a/Filters/ParallelFlowPaths/vtkPParticlePathFilter.h +++ b/Filters/ParallelFlowPaths/vtkPParticlePathFilter.h @@ -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 diff --git a/Filters/ParallelFlowPaths/vtkPParticleTracerBase.cxx b/Filters/ParallelFlowPaths/vtkPParticleTracerBase.cxx index 1d7e7dd7799cd82d1952b81efa00445fde333fc3..485fbca12351f9b4226a6b076c67fb9bdcacab35 100644 --- a/Filters/ParallelFlowPaths/vtkPParticleTracerBase.cxx +++ b/Filters/ParallelFlowPaths/vtkPParticleTracerBase.cxx @@ -1,15 +1,15 @@ /*========================================================================= -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; iUniqueIdCounter + 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; } diff --git a/Filters/ParallelFlowPaths/vtkPParticleTracerBase.h b/Filters/ParallelFlowPaths/vtkPParticleTracerBase.h index 6c4aa497839505df3881a583804f5640b9d336f4..3dca902b13976dfdff79c1ba9993c5d2455b9af0 100644 --- a/Filters/ParallelFlowPaths/vtkPParticleTracerBase.h +++ b/Filters/ParallelFlowPaths/vtkPParticleTracerBase.h @@ -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