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 =========================================================================*/
26 #ifndef __vtkTemporalStreamTracer_h
27 #define __vtkTemporalStreamTracer_h
28 
29 #include "vtkSmartPointer.h" // For protected ivars.
30 #include "vtkStreamTracer.h"
31 
32 //BTX
33 #include <vtkstd/vector> // STL Header
34 #include <vtkstd/list> // STL Header
35 //ETX
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 class vtkTemporalDataSet;
53 
54 //BTX
55 namespace vtkTemporalStreamTracerNamespace
56 {
57  typedef struct { double x[4]; } Position;
58  typedef struct {
59  // These are used during iteration
61  int CachedDataSetId[2];
62  vtkIdType CachedCellId[2];
64  // These are computed scalars we might display
65  int SourceID;
70  // These are useful to track for debugging etc
71  int ErrorCode;
72  float age;
73  // these are needed across time steps to compute vorticity
74  float rotation;
75  float angularVel;
76  float time;
77  float speed;
79 
80  typedef vtkstd::vector<ParticleInformation> ParticleVector;
81  typedef ParticleVector::iterator ParticleIterator;
82  typedef vtkstd::list<ParticleInformation> ParticleDataList;
83  typedef ParticleDataList::iterator ParticleListIterator;
84 };
85 //ETX
86 
88 {
89 public:
90 
92  void PrintSelf(ostream& os, vtkIndent indent);
93 
95  static vtkTemporalStreamTracer *New();
96 
98 
101  vtkSetMacro(TimeStep,unsigned int);
102  vtkGetMacro(TimeStep,unsigned int);
104 
106 
108  vtkSetMacro(IgnorePipelineTime, int);
109  vtkGetMacro(IgnorePipelineTime, int);
110  vtkBooleanMacro(IgnorePipelineTime, int);
112 
114 
119  vtkSetMacro(TimeStepResolution,double);
120  vtkGetMacro(TimeStepResolution,double);
122 
124 
131  vtkSetMacro(ForceReinjectionEveryNSteps,int);
132  vtkGetMacro(ForceReinjectionEveryNSteps,int);
134 
135 //BTX
136  enum Units
137  {
139  TERMINATION_STEP_UNIT
140  };
141 //ETX
142 
144 
148  vtkSetMacro(TerminationTime,double);
149  vtkGetMacro(TerminationTime,double);
151 
153 
155  vtkSetMacro(TerminationTimeUnit,int);
156  vtkGetMacro(TerminationTimeUnit,int);
158  {this->SetTerminationTimeUnit(TERMINATION_TIME_UNIT);};
160  {this->SetTerminationTimeUnit(TERMINATION_STEP_UNIT);};
162 
164 
170  vtkSetMacro(StaticSeeds,int);
171  vtkGetMacro(StaticSeeds,int);
172  vtkBooleanMacro(StaticSeeds,int);
174 
176 
181  vtkSetMacro(StaticMesh,int);
182  vtkGetMacro(StaticMesh,int);
183  vtkBooleanMacro(StaticMesh,int);
185 
187 
191  virtual void SetController(vtkMultiProcessController* controller);
192  vtkGetObjectMacro(Controller, vtkMultiProcessController);
194 
196 
200  virtual void SetParticleWriter(vtkAbstractParticleWriter *pw);
201  vtkGetObjectMacro(ParticleWriter, vtkAbstractParticleWriter);
203 
205 
207  vtkSetStringMacro(ParticleFileName);
208  vtkGetStringMacro(ParticleFileName);
210 
212 
214  vtkSetMacro(EnableParticleWriting,int);
215  vtkGetMacro(EnableParticleWriting,int);
216  vtkBooleanMacro(EnableParticleWriting,int);
218 
220 
221  void AddSourceConnection(vtkAlgorithmOutput* input);
222  void RemoveAllSources();
224 
225  protected:
226 
229 
230  //
231  // Make sure the pipeline knows what type we expect as input
232  //
234 
235  //
236  // The usual suspects
237  //
238  virtual int ProcessRequest(vtkInformation* request,
239  vtkInformationVector** inputVector,
240  vtkInformationVector* outputVector);
241 
242  //
243  // Store any information we need in the output and fetch what we can
244  // from the input
245  //
246  virtual int RequestInformation(vtkInformation* request,
247  vtkInformationVector** inputVector,
248  vtkInformationVector* outputVector);
249 
250  //
251  // Compute input time steps given the output step
252  //
253  virtual int RequestUpdateExtent(vtkInformation* request,
254  vtkInformationVector** inputVector,
255  vtkInformationVector* outputVector);
256 
257  //
258  // Generate output
259  //
260  virtual int RequestData(vtkInformation* request,
261  vtkInformationVector** inputVector,
262  vtkInformationVector* outputVector);
263 
264  //
265  // Initialization of input (vector-field) geometry
266  //
267  int InitializeInterpolator();
268  int AddTemporalInput(vtkTemporalDataSet *td);
269 
270 //
271 //BTX
272 //
273 
275 
277  void TestParticles(
280  int &count);
282 
284 
288  void AssignSeedsToProcessors(
289  vtkDataSet *source, int sourceID, int ptId,
291  int &LocalAssignedCount);
293 
295 
297  void AssignUniqueIds(
300 
302 
304  void UpdateParticleList(
307 
309 
312  void TransmitReceiveParticles(
315  bool removeself);
317 
319 
320  void IntegrateParticle(
322  double currenttime, double terminationtime,
323  vtkInitialValueProblemSolver* integrator);
325 
327 
332  bool RetryWithPush(
334  double velocity[3], double delT);
336 
337  // if the particle is added to send list, then returns value is 1,
338  // if it is kept on this process after a retry return value is 0
339  bool SendParticleToAnotherProcess(
341  double point1[4], double delT);
342 
343  void AddParticleToMPISendList(
345 
347 
350  bool ComputeDomainExitLocation(
351  double pos[4], double p2[4], double intersection[4],
352  vtkGenericCell *cell);
354 
355 //
356 //ETX
357 //
358 
359  // Track which process we are
362 
363  // Important for Caching of Cells/Ids/Weights etc
367 
368  // Support 'pipeline' time or manual SetTimeStep
369  unsigned int TimeStep;
370  unsigned int ActualTimeStep;
373 //BTX
374  vtkstd::vector<double> InputTimeValues;
375  vtkstd::vector<double> OutputTimeValues;
376 //ETX
377 
378  // more time management
379  double EarliestTime;
380  double CurrentTimeSteps[2];
382 
383  // Particle termination after time
386 
387  // Particle injection+Reinjection
392 
393  // Particle writing to disk
397 
398 //BTX
399  // The main lists which are held during operation- between time step updates
400  unsigned int NumberOfParticles;
403 //ETX
404 
405 //BTX
406  //
407  // Scalar arrays that are generated as each particle is updated
408  //
421 
422  // The output geometry
425 
426  // List used for transmitting between processors during parallel operation
428 
429  // The velocity interpolator
431 
432  // The input datasets which are stored by time step 0 and 1
434  vtkSmartPointer<vtkDataSet> DataReferenceT[2];
435 
436  // Cache bounds info for each dataset we will use repeatedly
437  typedef struct {
438  double b[6];
439  } bounds;
440  vtkstd::vector<bounds> CachedBounds[2];
441 
442  // utility funtion we use to test if a point is inside any of our local datasets
443  bool InsideBounds(double point[]);
444 
445 //ETX
446 
447  // MPI controller needed when running in parallel
449 
450  // global Id counter used to give particles a stamp
453  // for debugging only;
454  int substeps;
455 
456 private:
459 
460 private:
461  vtkTemporalStreamTracer(const vtkTemporalStreamTracer&); // Not implemented.
462  void operator=(const vtkTemporalStreamTracer&); // Not implemented.
463 };
464 
465 
466 #endif
467 
468