VTK  9.1.0
vtkParticleTracerBase.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkParticleTracerBase.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
28#ifndef vtkParticleTracerBase_h
29#define vtkParticleTracerBase_h
30
31#include "vtkFiltersFlowPathsModule.h" // For export macro
33#include "vtkSmartPointer.h" // For protected ivars.
34
35#include <list> // STL Header
36#include <vector> // STL Header
37
40class vtkCellArray;
42class vtkDataArray;
43class vtkDataSet;
44class vtkDoubleArray;
45class vtkFloatArray;
46class vtkGenericCell;
48class vtkIntArray;
51class vtkPointData;
52class vtkPoints;
53class vtkPolyData;
56
58{
60{
61 double x[4];
62};
63using Position = struct Position_t;
64
66{
67 // These are used during iteration
72 // These are computed scalars we might display
74 int TimeStepAge; // amount of time steps the particle has advanced
76 int InjectedStepId; // time step the particle was injected
79 // These are useful to track for debugging etc
81 float age;
82 // these are needed across time steps to compute vorticity
83 float rotation;
85 float time;
86 float speed;
87 // once the partice is added, PointId is valid and is the tuple location
88 // in ProtoPD.
90 // if PointId is negative then in parallel this particle was just
91 // received and we need to get the tuple value from vtkPParticleTracerBase::Tail.
93};
95
96typedef std::vector<ParticleInformation> ParticleVector;
97typedef ParticleVector::iterator ParticleIterator;
98typedef std::list<ParticleInformation> ParticleDataList;
99typedef ParticleDataList::iterator ParticleListIterator;
100};
101
102class VTKFILTERSFLOWPATHS_EXPORT vtkParticleTracerBase : public vtkPolyDataAlgorithm
103{
104public:
106 {
111 UNKNOWN
112 };
113
115 void PrintSelf(ostream& os, vtkIndent indent) override;
117
119
124 vtkGetMacro(ComputeVorticity, bool);
127
129
132 vtkGetMacro(TerminalSpeed, double);
133 void SetTerminalSpeed(double);
135
137
141 vtkGetMacro(RotationScale, double);
142 void SetRotationScale(double);
144
146
150 vtkSetMacro(IgnorePipelineTime, vtkTypeBool);
151 vtkGetMacro(IgnorePipelineTime, vtkTypeBool);
152 vtkBooleanMacro(IgnorePipelineTime, vtkTypeBool);
154
156
165 vtkGetMacro(ForceReinjectionEveryNSteps, int);
168
170
176 void SetTerminationTime(double t);
177 vtkGetMacro(TerminationTime, double);
179
181 vtkGetObjectMacro(Integrator, vtkInitialValueProblemSolver);
182
185
187
191 vtkGetMacro(StartTime, double);
192 void SetStartTime(double t);
194
196
205 vtkSetMacro(StaticSeeds, int);
206 vtkGetMacro(StaticSeeds, int);
208
210
219 vtkSetMacro(StaticMesh, int);
220 vtkGetMacro(StaticMesh, int);
222
224
231 vtkGetObjectMacro(ParticleWriter, vtkAbstractParticleWriter);
233
235
239 vtkSetFilePathMacro(ParticleFileName);
240 vtkGetFilePathMacro(ParticleFileName);
242
244
248 vtkSetMacro(EnableParticleWriting, vtkTypeBool);
249 vtkGetMacro(EnableParticleWriting, vtkTypeBool);
250 vtkBooleanMacro(EnableParticleWriting, vtkTypeBool);
252
254
259 vtkSetMacro(DisableResetCache, vtkTypeBool);
260 vtkGetMacro(DisableResetCache, vtkTypeBool);
261 vtkBooleanMacro(DisableResetCache, vtkTypeBool);
263
265
271
272protected:
273 vtkSmartPointer<vtkPolyData> Output; // managed by child classes
275
280 vtkIdType UniqueIdCounter; // global Id counter used to give particles a stamp
282 vtkSmartPointer<vtkPointData> ParticlePointData; // the current particle point data consistent
283 // with particle history
284 // Everything related to time
285 vtkTypeBool IgnorePipelineTime; // whether to use the pipeline time for termination
286 vtkTypeBool DisableResetCache; // whether to enable ResetCache() method
288
291
292 //
293 // Make sure the pipeline knows what type we expect as input
294 //
296
297 //
298 // The usual suspects
299 //
301 vtkInformationVector* outputVector) override;
302
303 //
304 // Store any information we need in the output and fetch what we can
305 // from the input
306 //
308 vtkInformationVector* outputVector) override;
309
310 //
311 // Compute input time steps given the output step
312 //
314 vtkInformationVector* outputVector) override;
315
316 //
317 // what the pipeline calls for each time step
318 //
320 vtkInformationVector* outputVector) override;
321
322 //
323 // these routines are internally called to actually generate the output
324 //
325 virtual int ProcessInput(vtkInformationVector** inputVector);
326
327 // This is the main part of the algorithm:
328 // * move all the particles one step
329 // * Reinject particles (by adding them to this->ParticleHistories)
330 // either at the beginning or at the end of each step (modulo
331 // this->ForceReinjectionEveryNSteps)
332 // * Output a polydata representing the moved particles
333 // Note that if the starting and the ending time coincide, the polydata is still valid.
334 virtual vtkPolyData* Execute(vtkInformationVector** inputVector);
335
336 // the RequestData will call these methods in turn
337 virtual void Initialize() {} // the first iteration
338 virtual int OutputParticles(vtkPolyData* poly) = 0; // every iteration
339 virtual void Finalize() {} // the last iteration
340
345 virtual std::vector<vtkDataSet*> GetSeedSources(vtkInformationVector* inputVector, int timeStep);
346
347 //
348 // Initialization of input (vector-field) geometry
349 //
352
359
361 vtkParticleTracerBaseNamespace::ParticleVector& candidates, std::vector<int>& passed);
362
369 virtual void AssignSeedsToProcessors(double time, vtkDataSet* source, int sourceID, int ptId,
370 vtkParticleTracerBaseNamespace::ParticleVector& localSeedPoints, int& localAssignedCount);
371
377
383
389 virtual bool UpdateParticleListFromOtherProcesses() { return false; }
390
395 double currenttime, double terminationtime, vtkInitialValueProblemSolver* integrator);
396
397 // if the particle is added to send list, then returns value is 1,
398 // if it is kept on this process after a retry return value is 0
401 {
402 return true;
403 }
404
412 double pos[4], double p2[4], double intersection[4], vtkGenericCell* cell);
413
414 //
415 // Scalar arrays that are generated as each particle is updated
416 //
418
428
429 // utility function we use to test if a point is inside any of our local datasets
430 bool InsideBounds(double point[]);
431
433 vtkGenericCell* cell, double pcoords[3], vtkDoubleArray* cellVectors, double vorticity[3]);
434
435 //------------------------------------------------------
436
437 double GetCacheDataTime(int i);
439
440 virtual void ResetCache();
442
444
449 virtual bool IsPointDataValid(vtkDataObject* input);
450 bool IsPointDataValid(vtkCompositeDataSet* input, std::vector<std::string>& arrayNames);
451 void GetPointDataArrayNames(vtkDataSet* input, std::vector<std::string>& names);
453
454 vtkGetMacro(ReinjectionCounter, int);
455 vtkGetMacro(CurrentTimeValue, double);
456
461 virtual void InitializeExtraPointDataArrays(vtkPointData* vtkNotUsed(outputPD)) {}
462
464
466
471 virtual void AddRestartSeeds(vtkInformationVector** /*inputVector*/) {}
472
473private:
477 void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField*) {}
478
488 bool RetryWithPush(vtkParticleTracerBaseNamespace::ParticleInformation& info, double* point1,
489 double delT, int subSteps);
490
491 bool SetTerminationTimeNoModify(double t);
492
493 // Parameters of tracing
495 double IntegrationStep;
496 double MaximumError;
497 bool ComputeVorticity;
498 double RotationScale;
499 double TerminalSpeed;
500
501 // A counter to keep track of how many times we reinjected
502 int ReinjectionCounter;
503
504 // Important for Caching of Cells/Ids/Weights etc
505 int AllFixedGeometry;
506 int StaticMesh;
507 int StaticSeeds;
508
509 std::vector<double> InputTimeValues;
510 double StartTime;
511 double TerminationTime;
512 double CurrentTimeValue;
513
514 int StartTimeStep; // InputTimeValues[StartTimeStep] <= StartTime <=
515 // InputTimeValues[StartTimeStep+1]
516 int CurrentTimeStep;
517 int TerminationTimeStep; // computed from start time
518 bool FirstIteration;
519
520 // Innjection parameters
521 int ForceReinjectionEveryNSteps;
522 vtkTimeStamp ParticleInjectionTime;
523 bool HasCache;
524
525 // Particle writing to disk
526 vtkAbstractParticleWriter* ParticleWriter;
527 char* ParticleFileName;
528 vtkTypeBool EnableParticleWriting;
529
530 // The main lists which are held during operation- between time step updates
532
533 // The velocity interpolator
535 vtkAbstractInterpolatedVelocityField* InterpolatorPrototype;
536
537 // Data for time step CurrentTimeStep-1 and CurrentTimeStep
539
540 // Cache bounds info for each dataset we will use repeatedly
541 struct bounds_t
542 {
543 double b[6];
544 };
545 using bounds = struct bounds_t;
546 std::vector<bounds> CachedBounds[2];
547
548 // temporary variables used by Exeucte(), for convenience only
549
550 vtkSmartPointer<vtkPoints> OutputCoordinates;
553 vtkSmartPointer<vtkSignedCharArray> ParticleSourceIds;
554 vtkSmartPointer<vtkIntArray> InjectedPointIds;
555 vtkSmartPointer<vtkIntArray> InjectedStepIds;
556 vtkSmartPointer<vtkIntArray> ErrorCodeArray;
557 vtkSmartPointer<vtkFloatArray> ParticleVorticity;
558 vtkSmartPointer<vtkFloatArray> ParticleRotation;
559 vtkSmartPointer<vtkFloatArray> ParticleAngularVel;
561 vtkSmartPointer<vtkPointData> OutputPointData;
562 vtkSmartPointer<vtkDataSet> DataReferenceT[2];
563 vtkSmartPointer<vtkCellArray> ParticleCells;
564
566 void operator=(const vtkParticleTracerBase&) = delete;
567 vtkTimeStamp ExecuteTime;
568
569 unsigned int NumberOfParticles();
570
573
574 static const double Epsilon;
575};
576
577#endif
An abstract class for obtaining the interpolated velocity values at a point.
abstract class to write particle data to file
Proxy object to connect input/output ports.
object to represent cell connectivity
Definition: vtkCellArray.h:290
abstract superclass for composite (multi-block or AMR) datasets
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
dynamic, self-adjusting array of double
dynamic, self-adjusting array of float
provides thread-safe access to cells
a simple class to control print indentation
Definition: vtkIndent.h:113
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Integrate a set of ordinary differential equations (initial value problem) in time.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:149
Composite dataset that organizes datasets into blocks.
Multiprocessing communication superclass.
A particle tracer for vector fields.
vtkTypeBool DisableResetCache
ProtoPD is used just to keep track of the input array names and number of components for copy allocat...
vtkFloatArray * GetParticleVorticity(vtkPointData *)
vtkSmartPointer< vtkPointData > ProtoPD
ProtoPD is used just to keep track of the input array names and number of components for copy allocat...
void IntegrateParticle(vtkParticleTracerBaseNamespace::ParticleListIterator &it, double currenttime, double terminationtime, vtkInitialValueProblemSolver *integrator)
particle between the two times supplied.
void SetComputeVorticity(bool)
Turn on/off vorticity computation at streamline points (necessary for generating proper stream-ribbon...
vtkSmartPointer< vtkPointData > ParticlePointData
ProtoPD is used just to keep track of the input array names and number of components for copy allocat...
vtkIntArray * GetInjectedPointIds(vtkPointData *)
vtkFloatArray * GetParticleAge(vtkPointData *)
void TestParticles(vtkParticleTracerBaseNamespace::ParticleVector &candidates, std::vector< int > &passed)
virtual void AddRestartSeeds(vtkInformationVector **)
For restarts of particle paths, we add in the ability to add in particles from a previous computation...
bool IsPointDataValid(vtkCompositeDataSet *input, std::vector< std::string > &arrayNames)
Methods that check that the input arrays are ordered the same on all data sets.
void SetTerminationTime(double t)
Setting TerminationTime to a positive value will cause particles to terminate when the time is reache...
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkIntArray * GetInjectedStepIds(vtkPointData *)
virtual bool UpdateParticleListFromOtherProcesses()
this is used during classification of seed points and also between iterations of the main loop as par...
virtual std::vector< vtkDataSet * > GetSeedSources(vtkInformationVector *inputVector, int timeStep)
Method to get the data set seed sources.
vtkIntArray * GetErrorCodeArr(vtkPointData *)
void UpdateParticleList(vtkParticleTracerBaseNamespace::ParticleVector &candidates)
and sending between processors, into a list, which is used as the master list on this processor
vtkGetFilePathMacro(ParticleFileName)
Set/Get the filename to be used with the particle writer when dumping particles to disk.
virtual void AppendToExtraPointDataArrays(vtkParticleTracerBaseNamespace::ParticleInformation &)
vtkFloatArray * GetParticleAngularVel(vtkPointData *)
double GetCacheDataTime(int i)
void TestParticles(vtkParticleTracerBaseNamespace::ParticleVector &candidates, vtkParticleTracerBaseNamespace::ParticleVector &passed, int &count)
inside our data.
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
see vtkAlgorithm for details
void AddSourceConnection(vtkAlgorithmOutput *input)
Provide support for multiple seed sources.
virtual vtkPolyData * Execute(vtkInformationVector **inputVector)
void RemoveAllSources()
Provide support for multiple seed sources.
void CalculateVorticity(vtkGenericCell *cell, double pcoords[3], vtkDoubleArray *cellVectors, double vorticity[3])
void CreateProtoPD(vtkDataObject *input)
virtual int ProcessInput(vtkInformationVector **inputVector)
virtual bool SendParticleToAnotherProcess(vtkParticleTracerBaseNamespace::ParticleInformation &, vtkParticleTracerBaseNamespace::ParticleInformation &, vtkPointData *)
vtkIntArray * GetParticleIds(vtkPointData *)
void SetForceReinjectionEveryNSteps(int)
When animating particles, it is nice to inject new ones every Nth step to produce a continuous flow.
int UpdateDataCache(vtkDataObject *td)
void SetTerminalSpeed(double)
Specify the terminal speed value, below which integration is terminated.
virtual void SetParticleWriter(vtkAbstractParticleWriter *pw)
Set/Get the Writer associated with this Particle Tracer Ideally a parallel IO capable vtkH5PartWriter...
void SetRotationScale(double)
This can be used to scale the rate with which the streamribbons twist.
void AddParticle(vtkParticleTracerBaseNamespace::ParticleInformation &info, double *velocity)
vtkParticleTracerBaseNamespace::ParticleDataList ParticleHistories
ProtoPD is used just to keep track of the input array names and number of components for copy allocat...
vtkFloatArray * GetParticleRotation(vtkPointData *)
void GetPointDataArrayNames(vtkDataSet *input, std::vector< std::string > &names)
Methods that check that the input arrays are ordered the same on all data sets.
int RequestUpdateExtent(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
void SetStartTime(double t)
Set the time value for particle tracing to begin.
virtual void AssignSeedsToProcessors(double time, vtkDataSet *source, int sourceID, int ptId, vtkParticleTracerBaseNamespace::ParticleVector &localSeedPoints, int &localAssignedCount)
all the injection/seed points according to which processor they belong to.
vtkTypeBool IgnorePipelineTime
ProtoPD is used just to keep track of the input array names and number of components for copy allocat...
bool InsideBounds(double point[])
virtual bool IsPointDataValid(vtkDataObject *input)
Methods that check that the input arrays are ordered the same on all data sets.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
vtkTemporalInterpolatedVelocityField * GetInterpolator()
void SetIntegratorType(int type)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkIdType UniqueIdCounter
ProtoPD is used just to keep track of the input array names and number of components for copy allocat...
virtual void InitializeExtraPointDataArrays(vtkPointData *vtkNotUsed(outputPD))
Methods to append values to existing point data arrays that may only be desired on specific concrete ...
~vtkParticleTracerBase() override
void SetIntegrator(vtkInitialValueProblemSolver *)
bool ComputeDomainExitLocation(double pos[4], double p2[4], double intersection[4], vtkGenericCell *cell)
This is an old routine kept for possible future use.
virtual void ResetCache()
vtkSignedCharArray * GetParticleSourceIds(vtkPointData *)
virtual void AssignUniqueIds(vtkParticleTracerBaseNamespace::ParticleVector &localSeedPoints)
give each one a unique ID.
vtkSetFilePathMacro(ParticleFileName)
Set/Get the filename to be used with the particle writer when dumping particles to disk.
virtual int OutputParticles(vtkPolyData *poly)=0
vtkSmartPointer< vtkPolyData > Output
represent and manipulate point attribute data
Definition: vtkPointData.h:142
represent and manipulate 3D points
Definition: vtkPoints.h:143
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
dynamic, self-adjusting array of signed char
A helper class for interpolating between times during particle tracing.
record modification and/or execution time
Definition: vtkTimeStamp.h:52
ParticleVector::iterator ParticleIterator
std::list< ParticleInformation > ParticleDataList
ParticleDataList::iterator ParticleListIterator
std::vector< ParticleInformation > ParticleVector
@ point
Definition: vtkX3D.h:242
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ time
Definition: vtkX3D.h:503
@ type
Definition: vtkX3D.h:522
int vtkTypeBool
Definition: vtkABI.h:69
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:332