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 =========================================================================*/
86 #ifndef vtkStreamTracer_h
87 #define vtkStreamTracer_h
88 
89 #include "vtkFiltersFlowPathsModule.h" // For export macro
90 #include "vtkPolyDataAlgorithm.h"
91 
92 #include "vtkInitialValueProblemSolver.h" // Needed for constants
93 
96 class vtkDataArray;
98 class vtkDoubleArray;
99 class vtkExecutive;
100 class vtkGenericCell;
101 class vtkIdList;
102 class vtkIntArray;
103 class vtkPoints;
104 
105 #include <vector>
106 
107 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
108 {
109 public:
111  void PrintSelf(ostream& os, vtkIndent indent) override;
112 
120  static vtkStreamTracer *New();
121 
123 
128  vtkSetVector3Macro(StartPosition, double);
129  vtkGetVector3Macro(StartPosition, double);
131 
133 
142 
148 
149  // The previously-supported TIME_UNIT is excluded in this current
150  // enumeration definition because the underlying step size is ALWAYS in
151  // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual
152  // for steady flows) that a particle actually takes to trave in a single
153  // step is obtained by dividing the arc length by the LOCAL speed. The
154  // overall elapsed time (i.e., the life span) of the particle is the sum
155  // of those individual step-wise time intervals. The arc-length-to-time
156  // conversion only occurs for vorticity computation and for generating a
157  // point data array named 'IntegrationTime'.
158  enum Units
159  {
160  LENGTH_UNIT = 1,
161  CELL_LENGTH_UNIT = 2
162  };
163 
164  enum Solvers
165  {
170  UNKNOWN
171  };
172 
174  {
178  OUT_OF_LENGTH = 4,
179  OUT_OF_STEPS = 5,
180  STAGNATION = 6,
181  FIXED_REASONS_FOR_TERMINATION_COUNT
182  };
183 
185 
196  vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver );
200  {this->SetIntegratorType(RUNGE_KUTTA2);};
202  {this->SetIntegratorType(RUNGE_KUTTA4);};
204  {this->SetIntegratorType(RUNGE_KUTTA45);};
206 
212 
218 
220 
223  vtkSetMacro(MaximumPropagation, double);
224  vtkGetMacro(MaximumPropagation, double);
226 
233  void SetIntegrationStepUnit( int unit );
234  int GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
235 
237 
244  vtkSetMacro(InitialIntegrationStep, double);
245  vtkGetMacro(InitialIntegrationStep, double);
247 
249 
255  vtkSetMacro(MinimumIntegrationStep, double);
256  vtkGetMacro(MinimumIntegrationStep, double);
258 
260 
266  vtkSetMacro(MaximumIntegrationStep, double);
267  vtkGetMacro(MaximumIntegrationStep, double);
269 
271 
274  vtkSetMacro(MaximumError, double);
275  vtkGetMacro(MaximumError, double);
277 
279 
282  vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
283  vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
285 
287 
290  vtkSetMacro(TerminalSpeed, double);
291  vtkGetMacro(TerminalSpeed, double);
293 
295 
298  vtkGetMacro(SurfaceStreamlines, bool);
299  vtkSetMacro(SurfaceStreamlines, bool);
300  vtkBooleanMacro(SurfaceStreamlines, bool);
302 
303  enum
304  {
307  BOTH
308  };
309 
310  enum
311  {
313  INTERPOLATOR_WITH_CELL_LOCATOR
314  };
315 
317 
321  vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
322  vtkGetMacro(IntegrationDirection, int);
324  {this->SetIntegrationDirection(FORWARD);};
326  {this->SetIntegrationDirection(BACKWARD);};
328  {this->SetIntegrationDirection(BOTH);};
330 
332 
337  vtkSetMacro(ComputeVorticity, bool);
338  vtkGetMacro(ComputeVorticity, bool);
340 
342 
346  vtkSetMacro(RotationScale, double);
347  vtkGetMacro(RotationScale, double);
349 
355 
365  void SetInterpolatorType( int interpType );
366 
376  typedef bool (*CustomTerminationCallbackType)(void * clientdata,
377  vtkPoints* points,
378  vtkDataArray* velocity,
379  int integrationDirection);
389  CustomTerminationCallbackType callback, void* clientdata, int reasonForTermination);
390 
391 protected:
392 
394  ~vtkStreamTracer() override;
395 
396  // Create a default executive.
398 
399  // hide the superclass' AddInput() from the user and the compiler
401  { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };
402 
405 
406  void CalculateVorticity( vtkGenericCell* cell, double pcoords[3],
407  vtkDoubleArray* cellVectors, double vorticity[3] );
408  void Integrate(vtkPointData *inputData,
409  vtkPolyData* output,
410  vtkDataArray* seedSource,
411  vtkIdList* seedIds,
412  vtkIntArray* integrationDirections,
413  double lastPoint[3],
415  int maxCellSize,
416  int vecType,
417  const char *vecFieldName,
418  double& propagation,
419  vtkIdType& numSteps,
420  double& integrationTime);
421  double SimpleIntegrate(double seed[3],
422  double lastPoint[3],
423  double stepSize,
426  int* maxCellSize);
427  void GenerateNormals(vtkPolyData* output, double* firstNormal, const char *vecName);
428 
430 
431  // starting from global x-y-z position
432  double StartPosition[3];
433 
434  static const double EPSILON;
436 
438 
440  {
441  double Interval;
442  int Unit;
443  };
444 
449 
450  void ConvertIntervals( double& step, double& minStep, double& maxStep,
451  int direction, double cellLength );
452  static double ConvertToLength( double interval, int unit, double cellLength );
453  static double ConvertToLength( IntervalInformation& interval, double cellLength );
454 
456  vtkInformation* outInfo);
458  vtkIdList*& seedIds,
459  vtkIntArray*& integrationDirections,
460  vtkDataSet *source);
461 
464 
465  // Prototype showing the integrator type to be set by the user.
467 
468  double MaximumError;
470 
473 
474  // Compute streamlines only on surface.
476 
478 
480  bool HasMatchingPointAttributes; //does the point data in the multiblocks have the same attributes?
481  std::vector<CustomTerminationCallbackType> CustomTerminationCallback;
482  std::vector<void*> CustomTerminationClientData;
483  std::vector<int> CustomReasonForTermination;
484 
485  friend class PStreamTracerUtils;
486 
487 private:
488  vtkStreamTracer(const vtkStreamTracer&) = delete;
489  void operator=(const vtkStreamTracer&) = delete;
490 };
491 
492 
493 #endif
494 // VTK-HeaderTest-Exclude: vtkStreamTracer.h
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:40
vtkStreamTracer::ConvertToLength
static double ConvertToLength(double interval, int unit, double cellLength)
vtkStreamTracer::InputData
vtkCompositeDataSet * InputData
Definition: vtkStreamTracer.h:479
vtkStreamTracer::SetIntegratorTypeToRungeKutta2
void SetIntegratorTypeToRungeKutta2()
Definition: vtkStreamTracer.h:199
vtkStreamTracer::TerminalSpeed
double TerminalSpeed
Definition: vtkStreamTracer.h:435
vtkStreamTracer::ConvertIntervals
void ConvertIntervals(double &step, double &minStep, double &maxStep, int direction, double cellLength)
vtkStreamTracer::HasMatchingPointAttributes
bool HasMatchingPointAttributes
Definition: vtkStreamTracer.h:480
vtkStreamTracer::GenerateNormalsInIntegrate
bool GenerateNormalsInIntegrate
Definition: vtkStreamTracer.h:429
vtkStreamTracer::Integrate
void Integrate(vtkPointData *inputData, vtkPolyData *output, vtkDataArray *seedSource, vtkIdList *seedIds, vtkIntArray *integrationDirections, double lastPoint[3], vtkAbstractInterpolatedVelocityField *func, int maxCellSize, int vecType, const char *vecFieldName, double &propagation, vtkIdType &numSteps, double &integrationTime)
vtkStreamTracer::AddCustomTerminationCallback
void AddCustomTerminationCallback(CustomTerminationCallbackType callback, void *clientdata, int reasonForTermination)
Adds a custom termination callback.
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:38
vtkStreamTracer::CalculateVorticity
void CalculateVorticity(vtkGenericCell *cell, double pcoords[3], vtkDoubleArray *cellVectors, double vorticity[3])
vtkStreamTracer::GetIntegrationStepUnit
int GetIntegrationStepUnit()
Definition: vtkStreamTracer.h:234
vtkX3D::type
@ type
Definition: vtkX3D.h:516
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkStreamTracer::SetSourceData
void SetSourceData(vtkDataSet *source)
Specify the source object used to generate starting points (seeds).
vtkStreamTracer::BACKWARD
@ BACKWARD
Definition: vtkStreamTracer.h:306
vtkStreamTracer::GenerateNormals
void GenerateNormals(vtkPolyData *output, double *firstNormal, const char *vecName)
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:60
vtkX3D::direction
@ direction
Definition: vtkX3D.h:260
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:42
vtkStreamTracer::Integrator
vtkInitialValueProblemSolver * Integrator
Definition: vtkStreamTracer.h:466
vtkStreamTracer::MaximumPropagation
double MaximumPropagation
Definition: vtkStreamTracer.h:445
vtkStreamTracer::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkStreamTracer::SetIntegrationStepUnit
void SetIntegrationStepUnit(int unit)
Specify a uniform integration step unit for MinimumIntegrationStep, InitialIntegrationStep,...
vtkStreamTracer::IntervalInformation::Interval
double Interval
Definition: vtkStreamTracer.h:441
vtkStreamTracer::SetIntegrationDirectionToForward
void SetIntegrationDirectionToForward()
Definition: vtkStreamTracer.h:323
vtkStreamTracer::MaximumError
double MaximumError
Definition: vtkStreamTracer.h:468
vtkStreamTracer::FORWARD
@ FORWARD
Definition: vtkStreamTracer.h:305
vtkStreamTracer::InitializeSeeds
void InitializeSeeds(vtkDataArray *&seeds, vtkIdList *&seedIds, vtkIntArray *&integrationDirections, vtkDataSet *source)
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkStreamTracer::SetSourceConnection
void SetSourceConnection(vtkAlgorithmOutput *algOutput)
Specify the source object used to generate starting points (seeds).
vtkCompositeDataSet
abstract superclass for composite (multi-block or AMR) datasets
Definition: vtkCompositeDataSet.h:52
vtkStreamTracer::CustomTerminationClientData
std::vector< void * > CustomTerminationClientData
Definition: vtkStreamTracer.h:482
vtkStreamTracer::ConvertToLength
static double ConvertToLength(IntervalInformation &interval, double cellLength)
vtkStreamTracer::FillInputPortInformation
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
vtkStreamTracer::ComputeVorticity
bool ComputeVorticity
Definition: vtkStreamTracer.h:471
vtkPolyDataAlgorithm.h
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:825
vtkStreamTracer::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkStreamTracer::SetInterpolatorTypeToCellLocator
void SetInterpolatorTypeToCellLocator()
Set the velocity field interpolator type to the one involving a cell locator.
vtkStreamTracer::INTERPOLATOR_WITH_DATASET_POINT_LOCATOR
@ INTERPOLATOR_WITH_DATASET_POINT_LOCATOR
Definition: vtkStreamTracer.h:312
vtkX3D::points
@ points
Definition: vtkX3D.h:446
vtkExecutive
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:50
vtkStreamTracer::MaximumNumberOfSteps
vtkIdType MaximumNumberOfSteps
Definition: vtkStreamTracer.h:469
vtkStreamTracer::SetIntegrator
void SetIntegrator(vtkInitialValueProblemSolver *)
Set/get the integrator type to be used for streamline generation.
vtkStreamTracer::SetIntegrationDirectionToBoth
void SetIntegrationDirectionToBoth()
Definition: vtkStreamTracer.h:327
vtkStreamTracer::vtkStreamTracer
vtkStreamTracer()
vtkStreamTracer::LastUsedStepSize
double LastUsedStepSize
Definition: vtkStreamTracer.h:437
vtkStreamTracer::SimpleIntegrate
double SimpleIntegrate(double seed[3], double lastPoint[3], double stepSize, vtkAbstractInterpolatedVelocityField *func)
vtkStreamTracer::NONE
@ NONE
Definition: vtkStreamTracer.h:169
vtkStreamTracer::SetIntegratorTypeToRungeKutta45
void SetIntegratorTypeToRungeKutta45()
Definition: vtkStreamTracer.h:203
vtkStreamTracer::MinimumIntegrationStep
double MinimumIntegrationStep
Definition: vtkStreamTracer.h:446
vtkStreamTracer::IntervalInformation
Definition: vtkStreamTracer.h:440
vtkStreamTracer::EPSILON
static const double EPSILON
Definition: vtkStreamTracer.h:434
vtkStreamTracer::RUNGE_KUTTA4
@ RUNGE_KUTTA4
Definition: vtkStreamTracer.h:167
vtkStreamTracer::SetupOutput
int SetupOutput(vtkInformation *inInfo, vtkInformation *outInfo)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkInitialValueProblemSolver.h
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:46
vtkStreamTracer::CustomTerminationCallback
std::vector< CustomTerminationCallbackType > CustomTerminationCallback
Definition: vtkStreamTracer.h:481
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:37
vtkStreamTracer::~vtkStreamTracer
~vtkStreamTracer() override
vtkStreamTracer::AddInput
void AddInput(vtkDataObject *)
Definition: vtkStreamTracer.h:400
vtkStreamTracer
Streamline generator.
Definition: vtkStreamTracer.h:108
vtkStreamTracer::GetSource
vtkDataSet * GetSource()
vtkInitialValueProblemSolver::UNEXPECTED_VALUE
@ UNEXPECTED_VALUE
Definition: vtkInitialValueProblemSolver.h:120
vtkStreamTracer::GetIntegratorType
int GetIntegratorType()
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
vtkAbstractInterpolatedVelocityField
An abstract class for obtaining the interpolated velocity values at a point.
Definition: vtkAbstractInterpolatedVelocityField.h:85
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:87
vtkStreamTracer::Units
Units
Definition: vtkStreamTracer.h:159
vtkStreamTracer::RUNGE_KUTTA45
@ RUNGE_KUTTA45
Definition: vtkStreamTracer.h:168
vtkStreamTracer::CheckInputs
int CheckInputs(vtkAbstractInterpolatedVelocityField *&func, int *maxCellSize)
vtkStreamTracer::IntegrationStepUnit
int IntegrationStepUnit
Definition: vtkStreamTracer.h:462
vtkStreamTracer::InterpolatorPrototype
vtkAbstractInterpolatedVelocityField * InterpolatorPrototype
Definition: vtkStreamTracer.h:477
vtkStreamTracer::IntervalInformation::Unit
int Unit
Definition: vtkStreamTracer.h:442
vtkStreamTracer::IntegrationDirection
int IntegrationDirection
Definition: vtkStreamTracer.h:463
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:40
vtkStreamTracer::SurfaceStreamlines
bool SurfaceStreamlines
Definition: vtkStreamTracer.h:475
vtkStreamTracer::InitialIntegrationStep
double InitialIntegrationStep
Definition: vtkStreamTracer.h:448
vtkStreamTracer::RUNGE_KUTTA2
@ RUNGE_KUTTA2
Definition: vtkStreamTracer.h:166
vtkStreamTracer::SetInterpolatorType
void SetInterpolatorType(int interpType)
Set the type of the velocity field interpolator to determine whether vtkInterpolatedVelocityField (IN...
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:40
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:42
vtkStreamTracer::SetInterpolatorTypeToDataSetPointLocator
void SetInterpolatorTypeToDataSetPointLocator()
Set the velocity field interpolator type to the one involving a dataset point locator.
vtkStreamTracer::SetIntegrationDirectionToBackward
void SetIntegrationDirectionToBackward()
Definition: vtkStreamTracer.h:325
vtkStreamTracer::CustomReasonForTermination
std::vector< int > CustomReasonForTermination
Definition: vtkStreamTracer.h:483
vtkStreamTracer::MaximumIntegrationStep
double MaximumIntegrationStep
Definition: vtkStreamTracer.h:447
vtkInitialValueProblemSolver
Integrate a set of ordinary differential equations (initial value problem) in time.
Definition: vtkInitialValueProblemSolver.h:41
vtkInitialValueProblemSolver::OUT_OF_DOMAIN
@ OUT_OF_DOMAIN
Definition: vtkInitialValueProblemSolver.h:118
vtkStreamTracer::Solvers
Solvers
Definition: vtkStreamTracer.h:165
vtkStreamTracer::ReasonForTermination
ReasonForTermination
Definition: vtkStreamTracer.h:174
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:65
vtkStreamTracer::RotationScale
double RotationScale
Definition: vtkStreamTracer.h:472
vtkStreamTracer::New
static vtkStreamTracer * New()
Construct object to start from position (0,0,0), with forward integration, terminal speed 1....
vtkStreamTracer::SetIntegratorTypeToRungeKutta4
void SetIntegratorTypeToRungeKutta4()
Definition: vtkStreamTracer.h:201
vtkStreamTracer::SetInterpolatorPrototype
void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField *ivf)
The object used to interpolate the velocity field during integration is of the same class as this pro...
vtkStreamTracer::CreateDefaultExecutive
vtkExecutive * CreateDefaultExecutive() override
Create a default executive.
vtkInitialValueProblemSolver::NOT_INITIALIZED
@ NOT_INITIALIZED
Definition: vtkInitialValueProblemSolver.h:119
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:45
vtkStreamTracer::SetIntegratorType
void SetIntegratorType(int type)