VTK
vtkTemporalStreamTracer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTemporalStreamTracer.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 =========================================================================*/
27 #ifndef vtkTemporalStreamTracer_h
28 #define vtkTemporalStreamTracer_h
29 
30 #include "vtkFiltersFlowPathsModule.h" // For export macro
31 #include "vtkSmartPointer.h" // For protected ivars.
32 #include "vtkStreamTracer.h"
33 
34 #include <vector> // STL Header
35 #include <list> // STL Header
36 
38 
40 class vtkDataArray;
41 class vtkDoubleArray;
42 class vtkGenericCell;
43 class vtkIntArray;
45 class vtkPoints;
46 class vtkCellArray;
47 class vtkDoubleArray;
48 class vtkFloatArray;
49 class vtkIntArray;
50 class vtkCharArray;
52 
54 {
55  typedef struct { double x[4]; } Position;
56  typedef struct {
57  // These are used during iteration
59  int CachedDataSetId[2];
60  vtkIdType CachedCellId[2];
62  // These are computed scalars we might display
63  int SourceID;
68  // These are useful to track for debugging etc
69  int ErrorCode;
70  float age;
71  // these are needed across time steps to compute vorticity
72  float rotation;
73  float angularVel;
74  float time;
75  float speed;
77 
78  typedef std::vector<ParticleInformation> ParticleVector;
79  typedef ParticleVector::iterator ParticleIterator;
80  typedef std::list<ParticleInformation> ParticleDataList;
81  typedef ParticleDataList::iterator ParticleListIterator;
82 };
83 
84 class VTKFILTERSFLOWPATHS_EXPORT vtkTemporalStreamTracer : public vtkStreamTracer
85 {
86 public:
87 
89  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
90 
94  static vtkTemporalStreamTracer *New();
95 
97 
102  vtkSetMacro(TimeStep,unsigned int);
103  vtkGetMacro(TimeStep,unsigned int);
105 
107 
111  vtkSetMacro(IgnorePipelineTime, int);
112  vtkGetMacro(IgnorePipelineTime, int);
113  vtkBooleanMacro(IgnorePipelineTime, int);
115 
117 
124  vtkSetMacro(TimeStepResolution,double);
125  vtkGetMacro(TimeStepResolution,double);
127 
129 
138  vtkSetMacro(ForceReinjectionEveryNSteps,int);
139  vtkGetMacro(ForceReinjectionEveryNSteps,int);
141 
142  enum Units
143  {
145  TERMINATION_STEP_UNIT
146  };
147 
149 
155  vtkSetMacro(TerminationTime,double);
156  vtkGetMacro(TerminationTime,double);
158 
160 
164  vtkSetMacro(TerminationTimeUnit,int);
165  vtkGetMacro(TerminationTimeUnit,int);
167  {this->SetTerminationTimeUnit(TERMINATION_TIME_UNIT);};
169  {this->SetTerminationTimeUnit(TERMINATION_STEP_UNIT);};
171 
173 
181  vtkSetMacro(StaticSeeds,int);
182  vtkGetMacro(StaticSeeds,int);
183  vtkBooleanMacro(StaticSeeds,int);
185 
187 
195  vtkSetMacro(StaticMesh,int);
196  vtkGetMacro(StaticMesh,int);
197  vtkBooleanMacro(StaticMesh,int);
199 
201 
207  virtual void SetParticleWriter(vtkAbstractParticleWriter *pw);
208  vtkGetObjectMacro(ParticleWriter, vtkAbstractParticleWriter);
210 
212 
216  vtkSetStringMacro(ParticleFileName);
217  vtkGetStringMacro(ParticleFileName);
219 
221 
225  vtkSetMacro(EnableParticleWriting,int);
226  vtkGetMacro(EnableParticleWriting,int);
227  vtkBooleanMacro(EnableParticleWriting,int);
229 
231 
234  void AddSourceConnection(vtkAlgorithmOutput* input);
235  void RemoveAllSources();
237 
238  protected:
239 
241  ~vtkTemporalStreamTracer() VTK_OVERRIDE;
242 
243  //
244  // Make sure the pipeline knows what type we expect as input
245  //
246  int FillInputPortInformation(int port, vtkInformation* info) VTK_OVERRIDE;
247 
248  //
249  // The usual suspects
250  //
251  int ProcessRequest(vtkInformation* request,
252  vtkInformationVector** inputVector,
253  vtkInformationVector* outputVector) VTK_OVERRIDE;
254 
255  //
256  // Store any information we need in the output and fetch what we can
257  // from the input
258  //
259  int RequestInformation(vtkInformation* request,
260  vtkInformationVector** inputVector,
261  vtkInformationVector* outputVector) VTK_OVERRIDE;
262 
263  //
264  // Compute input time steps given the output step
265  //
266  int RequestUpdateExtent(vtkInformation* request,
267  vtkInformationVector** inputVector,
268  vtkInformationVector* outputVector) VTK_OVERRIDE;
269 
270  //
271  // what the pipeline calls for each time step
272  //
273  int RequestData(vtkInformation* request,
274  vtkInformationVector** inputVector,
275  vtkInformationVector* outputVector) VTK_OVERRIDE;
276 
277  //
278  // these routines are internally called to actually generate the output
279  //
280  virtual int ProcessInput(vtkInformationVector** inputVector);
281 
282  virtual int GenerateOutput(vtkInformationVector** inputVector,
283  vtkInformationVector* outputVector);
284 
285  //
286  // Initialization of input (vector-field) geometry
287  //
288  int InitializeInterpolator();
289  int SetTemporalInput(vtkDataObject *td, int index);
290 
291 //
292 
297  void TestParticles(
300  int &count);
301 
308  virtual void AssignSeedsToProcessors(
309  vtkDataSet *source, int sourceID, int ptId,
311  int &LocalAssignedCount);
312 
317  virtual void AssignUniqueIds(
319 
324  void UpdateParticleList(
326 
331  virtual void TransmitReceiveParticles(
334  bool removeself);
335 
339  void IntegrateParticle(
341  double currenttime, double terminationtime,
342  vtkInitialValueProblemSolver* integrator);
343 
350  bool RetryWithPush(
352  double velocity[3], double delT);
353 
354  // if the particle is added to send list, then returns value is 1,
355  // if it is kept on this process after a retry return value is 0
356  bool SendParticleToAnotherProcess(
358  double point1[4], double delT);
359 
360  void AddParticleToMPISendList(
362 
368  bool ComputeDomainExitLocation(
369  double pos[4], double p2[4], double intersection[4],
370  vtkGenericCell *cell);
371 
372 //
373 
374 //
375  //Track internally which round of RequestData it is--between 0 and 2
377 
378  // Track which process we are
381 
382  // Important for Caching of Cells/Ids/Weights etc
386 
387  // Support 'pipeline' time or manual SetTimeStep
388  unsigned int TimeStep;
389  unsigned int ActualTimeStep;
392 
393  std::vector<double> InputTimeValues;
394  std::vector<double> OutputTimeValues;
395 
396  // more time management
397  double EarliestTime;
398  double CurrentTimeSteps[2];
400 
401  // Particle termination after time
404 
405  // Particle injection+Reinjection
410 
411  // Particle writing to disk
415 
416  // The main lists which are held during operation- between time step updates
417  unsigned int NumberOfParticles;
420 
421  //
422  // Scalar arrays that are generated as each particle is updated
423  //
436 
437  // The output geometry
440 
441  // List used for transmitting between processors during parallel operation
443 
444  // The velocity interpolator
446 
447  // The input datasets which are stored by time step 0 and 1
449  vtkSmartPointer<vtkDataSet> DataReferenceT[2];
450 
451  // Cache bounds info for each dataset we will use repeatedly
452  typedef struct {
453  double b[6];
454  } bounds;
455  std::vector<bounds> CachedBounds[2];
456 
457  // utility function we use to test if a point is inside any of our local datasets
458  bool InsideBounds(double point[]);
459 
460  // global Id counter used to give particles a stamp
463  // for debugging only;
464  int substeps;
465 
466 private:
470  void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField*) {}
471 
472 private:
473  vtkTemporalStreamTracer(const vtkTemporalStreamTracer&) VTK_DELETE_FUNCTION;
474  void operator=(const vtkTemporalStreamTracer&) VTK_DELETE_FUNCTION;
475 };
476 
477 #endif
A helper class for interpolating between times during particle tracing.
vtkSmartPointer< vtkDoubleArray > cellVectors
abstract class to write particle data to file
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkSmartPointer< vtkTemporalInterpolatedVelocityField > Interpolator
vtkSmartPointer< vtkFloatArray > ParticleAge
record modification and/or execution time
Definition: vtkTimeStamp.h:35
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
An abstract class for obtaining the interpolated velocity values at a point.
vtkSmartPointer< vtkPointData > OutputPointData
std::list< ParticleInformation > ParticleDataList
int vtkIdType
Definition: vtkType.h:345
vtkTemporalStreamTracerNamespace::ParticleDataList ParticleHistories
std::vector< double > InputTimeValues
vtkSmartPointer< vtkIntArray > InjectedStepIds
ParticleVector::iterator ParticleIterator
void SetTerminationTimeUnitToStepUnit()
The units of TerminationTime may be actual &#39;Time&#39; units as described by the data, or just TimeSteps o...
provides thread-safe access to cells
Proxy object to connect input/output ports.
dynamic, self-adjusting array of double
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:38
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
vtkSmartPointer< vtkIntArray > InjectedPointIds
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
A Parallel Particle tracer for unsteady vector fields.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkAbstractParticleWriter * ParticleWriter
vtkSmartPointer< vtkFloatArray > ParticleVorticity
vtkSmartPointer< vtkCellArray > ParticleCells
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkSmartPointer< vtkCharArray > ParticleSourceIds
vtkSmartPointer< vtkPoints > OutputCoordinates
vtkTemporalStreamTracerNamespace::ParticleVector MPISendList
Composite dataset that organizes datasets into blocks.
Streamline generator.
vtkSmartPointer< vtkFloatArray > ParticleAngularVel
ParticleDataList::iterator ParticleListIterator
vtkSmartPointer< vtkIntArray > ErrorCode
std::vector< double > OutputTimeValues
Store zero or more vtkInformation instances.
vtkSmartPointer< vtkIntArray > ParticleIds
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkTemporalStreamTracerNamespace::ParticleVector LocalSeeds
general representation of visualization data
Definition: vtkDataObject.h:64
std::vector< ParticleInformation > ParticleVector
represent and manipulate 3D points
Definition: vtkPoints.h:39
void SetTerminationTimeUnitToTimeUnit()
The units of TerminationTime may be actual &#39;Time&#39; units as described by the data, or just TimeSteps o...
vtkSmartPointer< vtkFloatArray > ParticleRotation
Integrate a set of ordinary differential equations (initial value problem) in time.
Multiprocessing communication superclass.