VTK
vtkStreamTracer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStreamTracer.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 =========================================================================*/
80 #ifndef vtkStreamTracer_h
81 #define vtkStreamTracer_h
82 
83 #include "vtkFiltersFlowPathsModule.h" // For export macro
84 #include "vtkPolyDataAlgorithm.h"
85 
86 #include "vtkInitialValueProblemSolver.h" // Needed for constants
87 
90 class vtkDataArray;
92 class vtkDoubleArray;
93 class vtkExecutive;
94 class vtkGenericCell;
95 class vtkIdList;
96 class vtkIntArray;
97 class vtkPoints;
98 
99 #include <vector>
100 
101 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
102 {
103 public:
105  void PrintSelf(ostream& os, vtkIndent indent) override;
106 
114  static vtkStreamTracer *New();
115 
117 
122  vtkSetVector3Macro(StartPosition, double);
123  vtkGetVector3Macro(StartPosition, double);
125 
127 
133  void SetSourceData(vtkDataSet *source);
134  vtkDataSet *GetSource();
136 
141  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
142 
143  // The previously-supported TIME_UNIT is excluded in this current
144  // enumeration definition because the underlying step size is ALWAYS in
145  // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual
146  // for steady flows) that a particle actually takes to trave in a single
147  // step is obtained by dividing the arc length by the LOCAL speed. The
148  // overall elapsed time (i.e., the life span) of the particle is the sum
149  // of those individual step-wise time intervals. The arc-length-to-time
150  // conversion only occurs for vorticity computation and for generating a
151  // point data array named 'IntegrationTime'.
152  enum Units
153  {
154  LENGTH_UNIT = 1,
155  CELL_LENGTH_UNIT = 2
156  };
157 
158  enum Solvers
159  {
164  UNKNOWN
165  };
166 
168  {
172  OUT_OF_LENGTH = 4,
173  OUT_OF_STEPS = 5,
174  STAGNATION = 6,
175  FIXED_REASONS_FOR_TERMINATION_COUNT
176  };
177 
179 
189  void SetIntegrator(vtkInitialValueProblemSolver *);
190  vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
191  void SetIntegratorType(int type);
192  int GetIntegratorType();
194  {this->SetIntegratorType(RUNGE_KUTTA2);};
196  {this->SetIntegratorType(RUNGE_KUTTA4);};
198  {this->SetIntegratorType(RUNGE_KUTTA45);};
200 
205  void SetInterpolatorTypeToDataSetPointLocator();
206 
211  void SetInterpolatorTypeToCellLocator();
212 
214 
217  vtkSetMacro(MaximumPropagation, double);
218  vtkGetMacro(MaximumPropagation, double);
220 
227  void SetIntegrationStepUnit( int unit );
228  int GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
229 
231 
238  vtkSetMacro(InitialIntegrationStep, double);
239  vtkGetMacro(InitialIntegrationStep, double);
241 
243 
249  vtkSetMacro(MinimumIntegrationStep, double);
250  vtkGetMacro(MinimumIntegrationStep, double);
252 
254 
260  vtkSetMacro(MaximumIntegrationStep, double);
261  vtkGetMacro(MaximumIntegrationStep, double);
263 
265 
268  vtkSetMacro(MaximumError, double);
269  vtkGetMacro(MaximumError, double);
271 
273 
276  vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
277  vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
279 
281 
284  vtkSetMacro(TerminalSpeed, double);
285  vtkGetMacro(TerminalSpeed, double);
287 
289 
292  vtkGetMacro(SurfaceStreamlines, bool);
293  vtkSetMacro(SurfaceStreamlines, bool);
294  vtkBooleanMacro(SurfaceStreamlines, bool);
296 
297  enum
298  {
301  BOTH
302  };
303 
304  enum
305  {
307  INTERPOLATOR_WITH_CELL_LOCATOR
308  };
309 
311 
315  vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
316  vtkGetMacro(IntegrationDirection, int);
318  {this->SetIntegrationDirection(FORWARD);};
320  {this->SetIntegrationDirection(BACKWARD);};
322  {this->SetIntegrationDirection(BOTH);};
324 
326 
331  vtkSetMacro(ComputeVorticity, bool);
332  vtkGetMacro(ComputeVorticity, bool);
334 
336 
340  vtkSetMacro(RotationScale, double);
341  vtkGetMacro(RotationScale, double);
343 
348  void SetInterpolatorPrototype( vtkAbstractInterpolatedVelocityField * ivf );
349 
359  void SetInterpolatorType( int interpType );
360 
370  typedef bool (*CustomTerminationCallbackType)(void * clientdata,
371  vtkPoints* points,
372  vtkDataArray* velocity,
373  int integrationDirection);
382  void AddCustomTerminationCallback(
383  CustomTerminationCallbackType callback, void* clientdata, int reasonForTermination);
384 
385 protected:
386 
387  vtkStreamTracer();
388  ~vtkStreamTracer() override;
389 
390  // Create a default executive.
392 
393  // hide the superclass' AddInput() from the user and the compiler
395  { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };
396 
398  int FillInputPortInformation(int, vtkInformation *) override;
399 
400  void CalculateVorticity( vtkGenericCell* cell, double pcoords[3],
401  vtkDoubleArray* cellVectors, double vorticity[3] );
402  void Integrate(vtkPointData *inputData,
403  vtkPolyData* output,
404  vtkDataArray* seedSource,
405  vtkIdList* seedIds,
406  vtkIntArray* integrationDirections,
407  double lastPoint[3],
409  int maxCellSize,
410  int vecType,
411  const char *vecFieldName,
412  double& propagation,
413  vtkIdType& numSteps,
414  double& integrationTime);
415  double SimpleIntegrate(double seed[3],
416  double lastPoint[3],
417  double stepSize,
419  int CheckInputs(vtkAbstractInterpolatedVelocityField*& func,
420  int* maxCellSize);
421  void GenerateNormals(vtkPolyData* output, double* firstNormal, const char *vecName);
422 
424 
425  // starting from global x-y-z position
426  double StartPosition[3];
427 
428  static const double EPSILON;
430 
432 
434  {
435  double Interval;
436  int Unit;
437  };
438 
443 
444  void ConvertIntervals( double& step, double& minStep, double& maxStep,
445  int direction, double cellLength );
446  static double ConvertToLength( double interval, int unit, double cellLength );
447  static double ConvertToLength( IntervalInformation& interval, double cellLength );
448 
449  int SetupOutput(vtkInformation* inInfo,
450  vtkInformation* outInfo);
451  void InitializeSeeds(vtkDataArray*& seeds,
452  vtkIdList*& seedIds,
453  vtkIntArray*& integrationDirections,
454  vtkDataSet *source);
455 
458 
459  // Prototype showing the integrator type to be set by the user.
461 
462  double MaximumError;
464 
467 
468  // Compute streamlines only on surface.
470 
472 
474  bool HasMatchingPointAttributes; //does the point data in the multiblocks have the same attributes?
475  std::vector<CustomTerminationCallbackType> CustomTerminationCallback;
476  std::vector<void*> CustomTerminationClientData;
477  std::vector<int> CustomReasonForTermination;
478 
479  friend class PStreamTracerUtils;
480 
481 private:
482  vtkStreamTracer(const vtkStreamTracer&) = delete;
483  void operator=(const vtkStreamTracer&) = delete;
484 };
485 
486 
487 #endif
488 // VTK-HeaderTest-Exclude: vtkStreamTracer.h
void SetIntegrationDirectionToBoth()
Specify whether the streamline is integrated in the upstream or downstream direction.
static const double EPSILON
represent and manipulate point attribute data
Definition: vtkPointData.h:31
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
An abstract class for obtaining the interpolated velocity values at a point.
void AddInput(vtkDataObject *)
bool GenerateNormalsInIntegrate
vtkCompositeDataSet * InputData
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:46
double MinimumIntegrationStep
provides thread-safe access to cells
vtkIdType MaximumNumberOfSteps
Proxy object to connect input/output ports.
dynamic, self-adjusting array of double
static vtkPolyDataAlgorithm * New()
void SetIntegrationDirectionToForward()
Specify whether the streamline is integrated in the upstream or downstream direction.
std::vector< int > CustomReasonForTermination
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
abstract superclass for composite (multi-block or AMR) datasets
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:33
int GetIntegrationStepUnit()
list of point or cell ids
Definition: vtkIdList.h:30
vtkInitialValueProblemSolver * Integrator
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
void SetIntegratorTypeToRungeKutta4()
Set/get the integrator type to be used for streamline generation.
std::vector< CustomTerminationCallbackType > CustomTerminationCallback
represent and manipulate attribute data in a dataset
double MaximumIntegrationStep
void SetIntegratorTypeToRungeKutta2()
Set/get the integrator type to be used for streamline generation.
boost::graph_traits< vtkGraph *>::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void SetIntegratorTypeToRungeKutta45()
Set/get the integrator type to be used for streamline generation.
double InitialIntegrationStep
vtkAbstractInterpolatedVelocityField * InterpolatorPrototype
std::vector< void * > CustomTerminationClientData
Streamline generator.
void SetIntegrationDirectionToBackward()
Specify whether the streamline is integrated in the upstream or downstream direction.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store zero or more vtkInformation instances.
bool HasMatchingPointAttributes
general representation of visualization data
Definition: vtkDataObject.h:58
represent and manipulate 3D points
Definition: vtkPoints.h:33
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Integrate a set of ordinary differential equations (initial value problem) in time.