VTK  9.0.1
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 =========================================================================*/
32 #ifndef vtkTemporalStreamTracer_h
33 #define vtkTemporalStreamTracer_h
34 
35 #include "vtkConfigure.h" // For legacy defines
36 #include "vtkSetGet.h" // For legacy macros
37 #ifndef VTK_LEGACY_REMOVE
38 
39 #include "vtkFiltersFlowPathsModule.h" // For export macro
40 #include "vtkSmartPointer.h" // For protected ivars.
41 #include "vtkStreamTracer.h"
42 
43 #include <list> // STL Header
44 #include <vector> // STL Header
45 
47 
49 class vtkDataArray;
50 class vtkDoubleArray;
51 class vtkGenericCell;
52 class vtkIntArray;
54 class vtkPoints;
55 class vtkCellArray;
56 class vtkDoubleArray;
57 class vtkFloatArray;
58 class vtkIntArray;
59 class vtkCharArray;
61 
63 {
64 typedef struct
65 {
66  double x[4];
67 } Position;
68 typedef struct
69 {
70  // These are used during iteration
72  int CachedDataSetId[2];
73  vtkIdType CachedCellId[2];
75  // These are computed scalars we might display
76  int SourceID;
81  // These are useful to track for debugging etc
82  int ErrorCode;
83  float age;
84  // these are needed across time steps to compute vorticity
85  float rotation;
86  float angularVel;
87  float time;
88  float speed;
90 
91 typedef std::vector<ParticleInformation> ParticleVector;
92 typedef ParticleVector::iterator ParticleIterator;
93 typedef std::list<ParticleInformation> ParticleDataList;
94 typedef ParticleDataList::iterator ParticleListIterator;
95 };
96 
97 class VTKFILTERSFLOWPATHS_EXPORT vtkTemporalStreamTracer : public vtkStreamTracer
98 {
99 public:
101  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
106  static vtkTemporalStreamTracer* New();
107 
109 
114  vtkSetMacro(TimeStep, unsigned int);
115  vtkGetMacro(TimeStep, unsigned int);
117 
119 
123  vtkSetMacro(IgnorePipelineTime, vtkTypeBool);
124  vtkGetMacro(IgnorePipelineTime, vtkTypeBool);
125  vtkBooleanMacro(IgnorePipelineTime, vtkTypeBool);
127 
129 
136  vtkSetMacro(TimeStepResolution, double);
137  vtkGetMacro(TimeStepResolution, double);
139 
141 
150  vtkSetMacro(ForceReinjectionEveryNSteps, int);
151  vtkGetMacro(ForceReinjectionEveryNSteps, int);
153 
154  enum Units
155  {
157  TERMINATION_STEP_UNIT
158  };
159 
161 
167  vtkSetMacro(TerminationTime, double);
168  vtkGetMacro(TerminationTime, double);
170 
172 
176  vtkSetMacro(TerminationTimeUnit, int);
177  vtkGetMacro(TerminationTimeUnit, int);
178  void SetTerminationTimeUnitToTimeUnit() { this->SetTerminationTimeUnit(TERMINATION_TIME_UNIT); }
179  void SetTerminationTimeUnitToStepUnit() { this->SetTerminationTimeUnit(TERMINATION_STEP_UNIT); }
181 
183 
191  vtkSetMacro(StaticSeeds, vtkTypeBool);
192  vtkGetMacro(StaticSeeds, vtkTypeBool);
193  vtkBooleanMacro(StaticSeeds, vtkTypeBool);
195 
197 
205  vtkSetMacro(StaticMesh, vtkTypeBool);
206  vtkGetMacro(StaticMesh, vtkTypeBool);
207  vtkBooleanMacro(StaticMesh, vtkTypeBool);
209 
211 
217  virtual void SetParticleWriter(vtkAbstractParticleWriter* pw);
218  vtkGetObjectMacro(ParticleWriter, vtkAbstractParticleWriter);
220 
222 
226  vtkSetStringMacro(ParticleFileName);
227  vtkGetStringMacro(ParticleFileName);
229 
231 
235  vtkSetMacro(EnableParticleWriting, vtkTypeBool);
236  vtkGetMacro(EnableParticleWriting, vtkTypeBool);
237  vtkBooleanMacro(EnableParticleWriting, vtkTypeBool);
239 
241 
244  void AddSourceConnection(vtkAlgorithmOutput* input);
245  void RemoveAllSources();
247 
248 protected:
249  VTK_LEGACY(vtkTemporalStreamTracer());
250  ~vtkTemporalStreamTracer() override;
251 
252  //
253  // Make sure the pipeline knows what type we expect as input
254  //
255  int FillInputPortInformation(int port, vtkInformation* info) override;
256 
257  //
258  // The usual suspects
259  //
261  vtkInformationVector* outputVector) override;
262 
263  //
264  // Store any information we need in the output and fetch what we can
265  // from the input
266  //
267  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
268  vtkInformationVector* outputVector) override;
269 
270  //
271  // Compute input time steps given the output step
272  //
273  int RequestUpdateExtent(vtkInformation* request, vtkInformationVector** inputVector,
274  vtkInformationVector* outputVector) override;
275 
276  //
277  // what the pipeline calls for each time step
278  //
279  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
280  vtkInformationVector* outputVector) override;
281 
282  //
283  // these routines are internally called to actually generate the output
284  //
285  virtual int ProcessInput(vtkInformationVector** inputVector);
286 
287  virtual int GenerateOutput(
288  vtkInformationVector** inputVector, vtkInformationVector* outputVector);
289 
290  //
291  // Initialization of input (vector-field) geometry
292  //
293  int InitializeInterpolator();
294  int SetTemporalInput(vtkDataObject* td, int index);
295 
296  //
297 
302  void TestParticles(vtkTemporalStreamTracerNamespace::ParticleVector& candidates,
304 
311  virtual void AssignSeedsToProcessors(vtkDataSet* source, int sourceID, int ptId,
312  vtkTemporalStreamTracerNamespace::ParticleVector& LocalSeedPoints, int& LocalAssignedCount);
313 
318  virtual void AssignUniqueIds(vtkTemporalStreamTracerNamespace::ParticleVector& LocalSeedPoints);
319 
324  void UpdateParticleList(vtkTemporalStreamTracerNamespace::ParticleVector& candidates);
325 
330  virtual void TransmitReceiveParticles(
332  vtkTemporalStreamTracerNamespace::ParticleVector& received, bool removeself);
333 
338  double currenttime, double terminationtime, vtkInitialValueProblemSolver* integrator);
339 
346  bool RetryWithPush(
347  vtkTemporalStreamTracerNamespace::ParticleInformation& info, double velocity[3], double delT);
348 
349  // if the particle is added to send list, then returns value is 1,
350  // if it is kept on this process after a retry return value is 0
351  bool SendParticleToAnotherProcess(
352  vtkTemporalStreamTracerNamespace::ParticleInformation& info, double point1[4], double delT);
353 
354  void AddParticleToMPISendList(vtkTemporalStreamTracerNamespace::ParticleInformation& info);
355 
361  bool ComputeDomainExitLocation(
362  double pos[4], double p2[4], double intersection[4], vtkGenericCell* cell);
363 
364  //
365 
366  //
367  // Track internally which round of RequestData it is--between 0 and 2
369 
370  // Track which process we are
373 
374  // Important for Caching of Cells/Ids/Weights etc
378 
379  // Support 'pipeline' time or manual SetTimeStep
380  unsigned int TimeStep;
381  unsigned int ActualTimeStep;
384 
385  std::vector<double> InputTimeValues;
386  std::vector<double> OutputTimeValues;
387 
388  // more time management
389  double EarliestTime;
390  double CurrentTimeSteps[2];
392 
393  // Particle termination after time
396 
397  // Particle injection+Reinjection
402 
403  // Particle writing to disk
407 
408  // The main lists which are held during operation- between time step updates
409  unsigned int NumberOfParticles;
412 
413  //
414  // Scalar arrays that are generated as each particle is updated
415  //
428 
429  // The output geometry
432 
433  // List used for transmitting between processors during parallel operation
435 
436  // The velocity interpolator
438 
439  // The input datasets which are stored by time step 0 and 1
441  vtkSmartPointer<vtkDataSet> DataReferenceT[2];
442 
443  // Cache bounds info for each dataset we will use repeatedly
444  typedef struct
445  {
446  double b[6];
447  } bounds;
448  std::vector<bounds> CachedBounds[2];
449 
450  // utility function we use to test if a point is inside any of our local datasets
451  bool InsideBounds(double point[]);
452 
453  // global Id counter used to give particles a stamp
456  // for debugging only;
457  int substeps;
458 
459 private:
464 
465 private:
467  void operator=(const vtkTemporalStreamTracer&) = delete;
468 };
469 
470 #endif // VTK_LEGACY_REMOVE
471 
472 #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:56
vtkSmartPointer< vtkTemporalInterpolatedVelocityField > Interpolator
vtkSmartPointer< vtkFloatArray > ParticleAge
record modification and/or execution time
Definition: vtkTimeStamp.h:32
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
An abstract class for obtaining the interpolated velocity values at a point.
vtkSmartPointer< vtkPointData > OutputPointData
std::list< ParticleInformation > ParticleDataList
int vtkIdType
Definition: vtkType.h:338
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
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
Proxy object to connect input/output ports.
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:69
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:35
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkSmartPointer< vtkIntArray > InjectedPointIds
static vtkStreamTracer * New()
Construct object to start from position (0,0,0), with forward integration, terminal speed 1...
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
A Parallel Particle tracer for unsteady vector fields.
vtkAbstractParticleWriter * ParticleWriter
vtkSmartPointer< vtkFloatArray > ParticleVorticity
vtkSmartPointer< vtkCellArray > ParticleCells
vtkTypeBool ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
see vtkAlgorithm for details
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
object to represent cell connectivity
Definition: vtkCellArray.h:179
vtkSmartPointer< vtkCharArray > ParticleSourceIds
vtkSmartPointer< vtkPoints > OutputCoordinates
vtkTemporalStreamTracerNamespace::ParticleVector MPISendList
Composite dataset that organizes datasets into blocks.
Streamline generator.
void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField *ivf)
The object used to interpolate the velocity field during integration is of the same class as this pro...
vtkSmartPointer< vtkFloatArray > ParticleAngularVel
ParticleDataList::iterator ParticleListIterator
std::vector< double > OutputTimeValues
vtkSmartPointer< vtkIntArray > ErrorCodeArray
Store zero or more vtkInformation instances.
vtkSmartPointer< vtkIntArray > ParticleIds
vtkTemporalStreamTracerNamespace::ParticleVector LocalSeeds
general representation of visualization data
Definition: vtkDataObject.h:59
std::vector< ParticleInformation > ParticleVector
represent and manipulate 3D points
Definition: vtkPoints.h:33
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
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
Integrate a set of ordinary differential equations (initial value problem) in time.
Multiprocessing communication superclass.