VTK  9.1.0
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 =========================================================================*/
195 #ifndef vtkStreamTracer_h
196 #define vtkStreamTracer_h
197 
198 #include "vtkFiltersFlowPathsModule.h" // For export macro
199 #include "vtkPolyDataAlgorithm.h"
200 
201 #include "vtkInitialValueProblemSolver.h" // Needed for constants
202 
204 class vtkCompositeDataSet;
205 class vtkDataArray;
207 class vtkDoubleArray;
208 class vtkExecutive;
209 class vtkGenericCell;
210 class vtkIdList;
211 class vtkIntArray;
212 class vtkPoints;
213 
214 #include <vector> // for std::vector
215 
216 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
217 {
218 public:
220  void PrintSelf(ostream& os, vtkIndent indent) override;
221 
229  static vtkStreamTracer* New();
230 
232 
237  vtkSetVector3Macro(StartPosition, double);
238  vtkGetVector3Macro(StartPosition, double);
240 
242 
251 
257 
258  // The previously-supported TIME_UNIT is excluded in this current
259  // enumeration definition because the underlying step size is ALWAYS in
260  // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual
261  // for steady flows) that a particle actually takes to trave in a single
262  // step is obtained by dividing the arc length by the LOCAL speed. The
263  // overall elapsed time (i.e., the life span) of the particle is the sum
264  // of those individual step-wise time intervals. The arc-length-to-time
265  // conversion only occurs for vorticity computation and for generating a
266  // point data array named 'IntegrationTime'.
267  enum Units
268  {
269  LENGTH_UNIT = 1,
270  CELL_LENGTH_UNIT = 2
271  };
272 
273  enum Solvers
274  {
279  UNKNOWN
280  };
281 
283  {
287  OUT_OF_LENGTH = 4,
288  OUT_OF_STEPS = 5,
289  STAGNATION = 6,
290  FIXED_REASONS_FOR_TERMINATION_COUNT
291  };
292 
294 
305  vtkGetObjectMacro(Integrator, vtkInitialValueProblemSolver);
308  void SetIntegratorTypeToRungeKutta2() { this->SetIntegratorType(RUNGE_KUTTA2); }
309  void SetIntegratorTypeToRungeKutta4() { this->SetIntegratorType(RUNGE_KUTTA4); }
310  void SetIntegratorTypeToRungeKutta45() { this->SetIntegratorType(RUNGE_KUTTA45); }
312 
318 
324 
326 
329  vtkSetMacro(MaximumPropagation, double);
330  vtkGetMacro(MaximumPropagation, double);
332 
339  void SetIntegrationStepUnit(int unit);
340  int GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
341 
343 
350  vtkSetMacro(InitialIntegrationStep, double);
351  vtkGetMacro(InitialIntegrationStep, double);
353 
355 
361  vtkSetMacro(MinimumIntegrationStep, double);
362  vtkGetMacro(MinimumIntegrationStep, double);
364 
366 
372  vtkSetMacro(MaximumIntegrationStep, double);
373  vtkGetMacro(MaximumIntegrationStep, double);
375 
377 
380  vtkSetMacro(MaximumError, double);
381  vtkGetMacro(MaximumError, double);
383 
385 
388  vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
389  vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
391 
393 
396  vtkSetMacro(TerminalSpeed, double);
397  vtkGetMacro(TerminalSpeed, double);
399 
401 
404  vtkGetMacro(SurfaceStreamlines, bool);
405  vtkSetMacro(SurfaceStreamlines, bool);
406  vtkBooleanMacro(SurfaceStreamlines, bool);
408 
409  enum
410  {
413  BOTH
414  };
415 
416  enum
417  {
419  INTERPOLATOR_WITH_CELL_LOCATOR
420  };
421 
423 
427  vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
428  vtkGetMacro(IntegrationDirection, int);
429  void SetIntegrationDirectionToForward() { this->SetIntegrationDirection(FORWARD); }
430  void SetIntegrationDirectionToBackward() { this->SetIntegrationDirection(BACKWARD); }
431  void SetIntegrationDirectionToBoth() { this->SetIntegrationDirection(BOTH); }
433 
435 
440  vtkSetMacro(ComputeVorticity, bool);
441  vtkGetMacro(ComputeVorticity, bool);
443 
445 
449  vtkSetMacro(RotationScale, double);
450  vtkGetMacro(RotationScale, double);
452 
454 
462  vtkSetMacro(UseLocalSeedSource, bool);
463  vtkGetMacro(UseLocalSeedSource, bool);
464  vtkBooleanMacro(UseLocalSeedSource, bool);
466 
472 
482  void SetInterpolatorType(int interpType);
483 
493  typedef bool (*CustomTerminationCallbackType)(
494  void* clientdata, vtkPoints* points, vtkDataArray* velocity, int integrationDirection);
504  CustomTerminationCallbackType callback, void* clientdata, int reasonForTermination);
505 
506 protected:
508  ~vtkStreamTracer() override;
509 
510  // Create a default executive.
512 
513  // hide the superclass' AddInput() from the user and the compiler
515  {
516  vtkErrorMacro(<< "AddInput() must be called with a vtkDataSet not a vtkDataObject.");
517  }
518 
521 
523  vtkGenericCell* cell, double pcoords[3], vtkDoubleArray* cellVectors, double vorticity[3]);
524  void Integrate(vtkPointData* inputData, vtkPolyData* output, vtkDataArray* seedSource,
525  vtkIdList* seedIds, vtkIntArray* integrationDirections, double lastPoint[3],
526  vtkAbstractInterpolatedVelocityField* func, int maxCellSize, int vecType,
527  const char* vecFieldName, double& propagation, vtkIdType& numSteps, double& integrationTime);
528  double SimpleIntegrate(double seed[3], double lastPoint[3], double stepSize,
530  int CheckInputs(vtkAbstractInterpolatedVelocityField*& func, int* maxCellSize);
531  void GenerateNormals(vtkPolyData* output, double* firstNormal, const char* vecName);
532 
534 
535  // starting from global x-y-z position
536  double StartPosition[3];
537 
538  static const double EPSILON;
540 
542 
544  {
545  double Interval;
546  int Unit;
547  };
548 
553 
555  double& step, double& minStep, double& maxStep, int direction, double cellLength);
556  static double ConvertToLength(double interval, int unit, double cellLength);
557  static double ConvertToLength(IntervalInformation& interval, double cellLength);
558 
559  int SetupOutput(vtkInformation* inInfo, vtkInformation* outInfo);
560  void InitializeSeeds(vtkDataArray*& seeds, vtkIdList*& seedIds,
561  vtkIntArray*& integrationDirections, vtkDataSet* source);
562 
565 
566  // Prototype showing the integrator type to be set by the user.
568 
569  double MaximumError;
571 
574 
575  // Compute streamlines only on surface.
577 
578  // Only relevant for the parallel version of this filter (see vtkPStreamTracer)
579  bool UseLocalSeedSource = true;
580 
582 
584  bool
585  HasMatchingPointAttributes; // does the point data in the multiblocks have the same attributes?
586  std::vector<CustomTerminationCallbackType> CustomTerminationCallback;
587  std::vector<void*> CustomTerminationClientData;
588  std::vector<int> CustomReasonForTermination;
589 
590  friend class PStreamTracerUtils;
591 
592 private:
593  vtkStreamTracer(const vtkStreamTracer&) = delete;
594  void operator=(const vtkStreamTracer&) = delete;
595 };
596 
597 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkStreamTracer::ConvertToLength
static double ConvertToLength(double interval, int unit, double cellLength)
vtkStreamTracer::InputData
vtkCompositeDataSet * InputData
Definition: vtkStreamTracer.h:583
vtkStreamTracer::SetIntegratorTypeToRungeKutta2
void SetIntegratorTypeToRungeKutta2()
Set/get the integrator type to be used for streamline generation.
Definition: vtkStreamTracer.h:308
vtkStreamTracer::TerminalSpeed
double TerminalSpeed
Definition: vtkStreamTracer.h:539
vtkStreamTracer::ConvertIntervals
void ConvertIntervals(double &step, double &minStep, double &maxStep, int direction, double cellLength)
vtkStreamTracer::HasMatchingPointAttributes
bool HasMatchingPointAttributes
Definition: vtkStreamTracer.h:585
vtkStreamTracer::GenerateNormalsInIntegrate
bool GenerateNormalsInIntegrate
Definition: vtkStreamTracer.h:533
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:142
vtkStreamTracer::CalculateVorticity
void CalculateVorticity(vtkGenericCell *cell, double pcoords[3], vtkDoubleArray *cellVectors, double vorticity[3])
vtkStreamTracer::GetIntegrationStepUnit
int GetIntegrationStepUnit()
Definition: vtkStreamTracer.h:340
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkStreamTracer::SetSourceData
void SetSourceData(vtkDataSet *source)
Specify the source object used to generate starting points (seeds).
vtkStreamTracer::GenerateNormals
void GenerateNormals(vtkPolyData *output, double *firstNormal, const char *vecName)
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:170
vtkX3D::direction
@ direction
Definition: vtkX3D.h:266
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkStreamTracer::Integrator
vtkInitialValueProblemSolver * Integrator
Definition: vtkStreamTracer.h:567
vtkStreamTracer::MaximumPropagation
double MaximumPropagation
Definition: vtkStreamTracer.h:549
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:545
vtkStreamTracer::SetIntegrationDirectionToForward
void SetIntegrationDirectionToForward()
Specify whether the streamline is integrated in the upstream or downstream direction.
Definition: vtkStreamTracer.h:429
vtkStreamTracer::MaximumError
double MaximumError
Definition: vtkStreamTracer.h:569
vtkStreamTracer::INTERPOLATOR_WITH_DATASET_POINT_LOCATOR
@ INTERPOLATOR_WITH_DATASET_POINT_LOCATOR
Definition: vtkStreamTracer.h:418
vtkStreamTracer::InitializeSeeds
void InitializeSeeds(vtkDataArray *&seeds, vtkIdList *&seedIds, vtkIntArray *&integrationDirections, vtkDataSet *source)
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
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:68
vtkStreamTracer::CustomTerminationClientData
std::vector< void * > CustomTerminationClientData
Definition: vtkStreamTracer.h:587
vtkIOSSUtilities::UNKNOWN
@ UNKNOWN
Definition: vtkIOSSUtilities.h:60
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:572
vtkPolyDataAlgorithm.h
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.
vtkX3D::points
@ points
Definition: vtkX3D.h:452
vtkExecutive
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:76
vtkStreamTracer::MaximumNumberOfSteps
vtkIdType MaximumNumberOfSteps
Definition: vtkStreamTracer.h:570
vtkStreamTracer::SetIntegrator
void SetIntegrator(vtkInitialValueProblemSolver *)
Set/get the integrator type to be used for streamline generation.
vtkStreamTracer::SetIntegrationDirectionToBoth
void SetIntegrationDirectionToBoth()
Specify whether the streamline is integrated in the upstream or downstream direction.
Definition: vtkStreamTracer.h:431
vtkStreamTracer::vtkStreamTracer
vtkStreamTracer()
vtkStreamTracer::LastUsedStepSize
double LastUsedStepSize
Definition: vtkStreamTracer.h:541
vtkStreamTracer::SimpleIntegrate
double SimpleIntegrate(double seed[3], double lastPoint[3], double stepSize, vtkAbstractInterpolatedVelocityField *func)
vtkStreamTracer::NONE
@ NONE
Definition: vtkStreamTracer.h:278
vtkStreamTracer::SetIntegratorTypeToRungeKutta45
void SetIntegratorTypeToRungeKutta45()
Set/get the integrator type to be used for streamline generation.
Definition: vtkStreamTracer.h:310
vtkStreamTracer::MinimumIntegrationStep
double MinimumIntegrationStep
Definition: vtkStreamTracer.h:550
vtkStreamTracer::IntervalInformation
Definition: vtkStreamTracer.h:544
vtkStreamTracer::EPSILON
static const double EPSILON
Definition: vtkStreamTracer.h:538
vtkStreamTracer::RUNGE_KUTTA4
@ RUNGE_KUTTA4
Definition: vtkStreamTracer.h:276
vtkStreamTracer::SetupOutput
int SetupOutput(vtkInformation *inInfo, vtkInformation *outInfo)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkInitialValueProblemSolver.h
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:149
vtkStreamTracer::CustomTerminationCallback
std::vector< CustomTerminationCallbackType > CustomTerminationCallback
Definition: vtkStreamTracer.h:586
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkStreamTracer::~vtkStreamTracer
~vtkStreamTracer() override
vtkStreamTracer::AddInput
void AddInput(vtkDataObject *)
Definition: vtkStreamTracer.h:514
vtkStreamTracer
Streamline generator.
Definition: vtkStreamTracer.h:217
vtkStreamTracer::GetSource
vtkDataSet * GetSource()
Specify the source object used to generate starting points (seeds).
vtkInitialValueProblemSolver::UNEXPECTED_VALUE
@ UNEXPECTED_VALUE
Definition: vtkInitialValueProblemSolver.h:148
vtkStreamTracer::GetIntegratorType
int GetIntegratorType()
Set/get the integrator type to be used for streamline generation.
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
vtkAbstractInterpolatedVelocityField
An abstract class for obtaining the interpolated velocity values at a point.
Definition: vtkAbstractInterpolatedVelocityField.h:83
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkStreamTracer::Units
Units
Definition: vtkStreamTracer.h:268
vtkStreamTracer::RUNGE_KUTTA45
@ RUNGE_KUTTA45
Definition: vtkStreamTracer.h:277
vtkStreamTracer::CheckInputs
int CheckInputs(vtkAbstractInterpolatedVelocityField *&func, int *maxCellSize)
vtkStreamTracer::IntegrationStepUnit
int IntegrationStepUnit
Definition: vtkStreamTracer.h:563
vtkStreamTracer::InterpolatorPrototype
vtkAbstractInterpolatedVelocityField * InterpolatorPrototype
Definition: vtkStreamTracer.h:581
vtkStreamTracer::IntervalInformation::Unit
int Unit
Definition: vtkStreamTracer.h:546
vtkStreamTracer::IntegrationDirection
int IntegrationDirection
Definition: vtkStreamTracer.h:564
vtkStreamTracer::FORWARD
@ FORWARD
Definition: vtkStreamTracer.h:411
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:66
vtkStreamTracer::SurfaceStreamlines
bool SurfaceStreamlines
Definition: vtkStreamTracer.h:576
vtkStreamTracer::InitialIntegrationStep
double InitialIntegrationStep
Definition: vtkStreamTracer.h:552
vtkStreamTracer::RUNGE_KUTTA2
@ RUNGE_KUTTA2
Definition: vtkStreamTracer.h:275
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:195
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:116
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:998
vtkStreamTracer::SetInterpolatorTypeToDataSetPointLocator
void SetInterpolatorTypeToDataSetPointLocator()
Set the velocity field interpolator type to the one involving a dataset point locator.
vtkStreamTracer::SetIntegrationDirectionToBackward
void SetIntegrationDirectionToBackward()
Specify whether the streamline is integrated in the upstream or downstream direction.
Definition: vtkStreamTracer.h:430
vtkStreamTracer::CustomReasonForTermination
std::vector< int > CustomReasonForTermination
Definition: vtkStreamTracer.h:588
vtkStreamTracer::MaximumIntegrationStep
double MaximumIntegrationStep
Definition: vtkStreamTracer.h:551
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:146
vtkStreamTracer::Solvers
Solvers
Definition: vtkStreamTracer.h:274
vtkStreamTracer::ReasonForTermination
ReasonForTermination
Definition: vtkStreamTracer.h:283
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkStreamTracer::RotationScale
double RotationScale
Definition: vtkStreamTracer.h:573
vtkStreamTracer::New
static vtkStreamTracer * New()
Construct object to start from position (0,0,0), with forward integration, terminal speed 1....
vtkStreamTracer::SetIntegratorTypeToRungeKutta4
void SetIntegratorTypeToRungeKutta4()
Set/get the integrator type to be used for streamline generation.
Definition: vtkStreamTracer.h:309
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::BACKWARD
@ BACKWARD
Definition: vtkStreamTracer.h:412
vtkStreamTracer::CreateDefaultExecutive
vtkExecutive * CreateDefaultExecutive() override
Create a default executive.
vtkInitialValueProblemSolver::NOT_INITIALIZED
@ NOT_INITIALIZED
Definition: vtkInitialValueProblemSolver.h:147
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:151
vtkStreamTracer::SetIntegratorType
void SetIntegratorType(int type)
Set/get the integrator type to be used for streamline generation.