VTK  9.0.1
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 =========================================================================*/
81 #ifndef vtkStreamTracer_h
82 #define vtkStreamTracer_h
83 
84 #include "vtkFiltersFlowPathsModule.h" // For export macro
85 #include "vtkPolyDataAlgorithm.h"
86 
87 #include "vtkInitialValueProblemSolver.h" // Needed for constants
88 
91 class vtkDataArray;
93 class vtkDoubleArray;
94 class vtkExecutive;
95 class vtkGenericCell;
96 class vtkIdList;
97 class vtkIntArray;
98 class vtkPoints;
99 
100 #include <vector>
101 
102 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
103 {
104 public:
106  void PrintSelf(ostream& os, vtkIndent indent) override;
107 
115  static vtkStreamTracer* New();
116 
118 
123  vtkSetVector3Macro(StartPosition, double);
124  vtkGetVector3Macro(StartPosition, double);
126 
128 
134  void SetSourceData(vtkDataSet* source);
135  vtkDataSet* GetSource();
137 
142  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
143 
144  // The previously-supported TIME_UNIT is excluded in this current
145  // enumeration definition because the underlying step size is ALWAYS in
146  // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual
147  // for steady flows) that a particle actually takes to trave in a single
148  // step is obtained by dividing the arc length by the LOCAL speed. The
149  // overall elapsed time (i.e., the life span) of the particle is the sum
150  // of those individual step-wise time intervals. The arc-length-to-time
151  // conversion only occurs for vorticity computation and for generating a
152  // point data array named 'IntegrationTime'.
153  enum Units
154  {
155  LENGTH_UNIT = 1,
156  CELL_LENGTH_UNIT = 2
157  };
158 
159  enum Solvers
160  {
165  UNKNOWN
166  };
167 
169  {
173  OUT_OF_LENGTH = 4,
174  OUT_OF_STEPS = 5,
175  STAGNATION = 6,
176  FIXED_REASONS_FOR_TERMINATION_COUNT
177  };
178 
180 
190  void SetIntegrator(vtkInitialValueProblemSolver*);
191  vtkGetObjectMacro(Integrator, vtkInitialValueProblemSolver);
192  void SetIntegratorType(int type);
193  int GetIntegratorType();
194  void SetIntegratorTypeToRungeKutta2() { this->SetIntegratorType(RUNGE_KUTTA2); }
195  void SetIntegratorTypeToRungeKutta4() { this->SetIntegratorType(RUNGE_KUTTA4); }
196  void SetIntegratorTypeToRungeKutta45() { this->SetIntegratorType(RUNGE_KUTTA45); }
198 
203  void SetInterpolatorTypeToDataSetPointLocator();
204 
209  void SetInterpolatorTypeToCellLocator();
210 
212 
215  vtkSetMacro(MaximumPropagation, double);
216  vtkGetMacro(MaximumPropagation, double);
218 
225  void SetIntegrationStepUnit(int unit);
226  int GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
227 
229 
236  vtkSetMacro(InitialIntegrationStep, double);
237  vtkGetMacro(InitialIntegrationStep, double);
239 
241 
247  vtkSetMacro(MinimumIntegrationStep, double);
248  vtkGetMacro(MinimumIntegrationStep, double);
250 
252 
258  vtkSetMacro(MaximumIntegrationStep, double);
259  vtkGetMacro(MaximumIntegrationStep, double);
261 
263 
266  vtkSetMacro(MaximumError, double);
267  vtkGetMacro(MaximumError, double);
269 
271 
274  vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
275  vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
277 
279 
282  vtkSetMacro(TerminalSpeed, double);
283  vtkGetMacro(TerminalSpeed, double);
285 
287 
290  vtkGetMacro(SurfaceStreamlines, bool);
291  vtkSetMacro(SurfaceStreamlines, bool);
292  vtkBooleanMacro(SurfaceStreamlines, bool);
294 
295  enum
296  {
299  BOTH
300  };
301 
302  enum
303  {
305  INTERPOLATOR_WITH_CELL_LOCATOR
306  };
307 
309 
313  vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
314  vtkGetMacro(IntegrationDirection, int);
315  void SetIntegrationDirectionToForward() { this->SetIntegrationDirection(FORWARD); }
316  void SetIntegrationDirectionToBackward() { this->SetIntegrationDirection(BACKWARD); }
317  void SetIntegrationDirectionToBoth() { this->SetIntegrationDirection(BOTH); }
319 
321 
326  vtkSetMacro(ComputeVorticity, bool);
327  vtkGetMacro(ComputeVorticity, bool);
329 
331 
335  vtkSetMacro(RotationScale, double);
336  vtkGetMacro(RotationScale, double);
338 
343  void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField* ivf);
344 
354  void SetInterpolatorType(int interpType);
355 
365  typedef bool (*CustomTerminationCallbackType)(
366  void* clientdata, vtkPoints* points, vtkDataArray* velocity, int integrationDirection);
375  void AddCustomTerminationCallback(
376  CustomTerminationCallbackType callback, void* clientdata, int reasonForTermination);
377 
378 protected:
379  vtkStreamTracer();
380  ~vtkStreamTracer() override;
381 
382  // Create a default executive.
384 
385  // hide the superclass' AddInput() from the user and the compiler
387  {
388  vtkErrorMacro(<< "AddInput() must be called with a vtkDataSet not a vtkDataObject.");
389  }
390 
392  int FillInputPortInformation(int, vtkInformation*) override;
393 
394  void CalculateVorticity(
395  vtkGenericCell* cell, double pcoords[3], vtkDoubleArray* cellVectors, double vorticity[3]);
396  void Integrate(vtkPointData* inputData, vtkPolyData* output, vtkDataArray* seedSource,
397  vtkIdList* seedIds, vtkIntArray* integrationDirections, double lastPoint[3],
398  vtkAbstractInterpolatedVelocityField* func, int maxCellSize, int vecType,
399  const char* vecFieldName, double& propagation, vtkIdType& numSteps, double& integrationTime);
400  double SimpleIntegrate(double seed[3], double lastPoint[3], double stepSize,
402  int CheckInputs(vtkAbstractInterpolatedVelocityField*& func, int* maxCellSize);
403  void GenerateNormals(vtkPolyData* output, double* firstNormal, const char* vecName);
404 
406 
407  // starting from global x-y-z position
408  double StartPosition[3];
409 
410  static const double EPSILON;
412 
414 
416  {
417  double Interval;
418  int Unit;
419  };
420 
425 
426  void ConvertIntervals(
427  double& step, double& minStep, double& maxStep, int direction, double cellLength);
428  static double ConvertToLength(double interval, int unit, double cellLength);
429  static double ConvertToLength(IntervalInformation& interval, double cellLength);
430 
431  int SetupOutput(vtkInformation* inInfo, vtkInformation* outInfo);
432  void InitializeSeeds(vtkDataArray*& seeds, vtkIdList*& seedIds,
433  vtkIntArray*& integrationDirections, vtkDataSet* source);
434 
437 
438  // Prototype showing the integrator type to be set by the user.
440 
441  double MaximumError;
443 
446 
447  // Compute streamlines only on surface.
449 
451 
453  bool
454  HasMatchingPointAttributes; // does the point data in the multiblocks have the same attributes?
455  std::vector<CustomTerminationCallbackType> CustomTerminationCallback;
456  std::vector<void*> CustomTerminationClientData;
457  std::vector<int> CustomReasonForTermination;
458 
459  friend class PStreamTracerUtils;
460 
461 private:
462  vtkStreamTracer(const vtkStreamTracer&) = delete;
463  void operator=(const vtkStreamTracer&) = delete;
464 };
465 
466 #endif
467 // VTK-HeaderTest-Exclude: vtkStreamTracer.h
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkAlgorithm::CreateDefaultExecutive
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
vtkStreamTracer::InputData
vtkCompositeDataSet * InputData
Definition: vtkStreamTracer.h:452
vtkStreamTracer::INTERPOLATOR_WITH_DATASET_POINT_LOCATOR
@ INTERPOLATOR_WITH_DATASET_POINT_LOCATOR
Definition: vtkStreamTracer.h:304
vtkStreamTracer::SetIntegratorTypeToRungeKutta2
void SetIntegratorTypeToRungeKutta2()
Definition: vtkStreamTracer.h:194
vtkStreamTracer::TerminalSpeed
double TerminalSpeed
Definition: vtkStreamTracer.h:411
vtkStreamTracer::FORWARD
@ FORWARD
Definition: vtkStreamTracer.h:297
vtkStreamTracer::HasMatchingPointAttributes
bool HasMatchingPointAttributes
Definition: vtkStreamTracer.h:454
vtkStreamTracer::GenerateNormalsInIntegrate
bool GenerateNormalsInIntegrate
Definition: vtkStreamTracer.h:405
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:31
vtkStreamTracer::GetIntegrationStepUnit
int GetIntegrationStepUnit()
Definition: vtkStreamTracer.h:226
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:53
vtkX3D::direction
@ direction
Definition: vtkX3D.h:266
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkStreamTracer::Integrator
vtkInitialValueProblemSolver * Integrator
Definition: vtkStreamTracer.h:439
vtkStreamTracer::MaximumPropagation
double MaximumPropagation
Definition: vtkStreamTracer.h:421
vtkStreamTracer::IntervalInformation::Interval
double Interval
Definition: vtkStreamTracer.h:417
vtkStreamTracer::SetIntegrationDirectionToForward
void SetIntegrationDirectionToForward()
Definition: vtkStreamTracer.h:315
vtkStreamTracer::MaximumError
double MaximumError
Definition: vtkStreamTracer.h:441
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkPolyDataAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCompositeDataSet
abstract superclass for composite (multi-block or AMR) datasets
Definition: vtkCompositeDataSet.h:45
vtkStreamTracer::CustomTerminationClientData
std::vector< void * > CustomTerminationClientData
Definition: vtkStreamTracer.h:456
vtkStreamTracer::ComputeVorticity
bool ComputeVorticity
Definition: vtkStreamTracer.h:444
vtkPolyDataAlgorithm.h
vtkX3D::points
@ points
Definition: vtkX3D.h:452
vtkExecutive
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:46
vtkStreamTracer::MaximumNumberOfSteps
vtkIdType MaximumNumberOfSteps
Definition: vtkStreamTracer.h:442
vtkStreamTracer::SetIntegrationDirectionToBoth
void SetIntegrationDirectionToBoth()
Definition: vtkStreamTracer.h:317
vtkStreamTracer::LastUsedStepSize
double LastUsedStepSize
Definition: vtkStreamTracer.h:413
vtkPolyDataAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
vtkStreamTracer::NONE
@ NONE
Definition: vtkStreamTracer.h:164
vtkStreamTracer::SetIntegratorTypeToRungeKutta45
void SetIntegratorTypeToRungeKutta45()
Definition: vtkStreamTracer.h:196
vtkStreamTracer::MinimumIntegrationStep
double MinimumIntegrationStep
Definition: vtkStreamTracer.h:422
vtkStreamTracer::IntervalInformation
Definition: vtkStreamTracer.h:415
vtkStreamTracer::EPSILON
static const double EPSILON
Definition: vtkStreamTracer.h:410
vtkStreamTracer::RUNGE_KUTTA4
@ RUNGE_KUTTA4
Definition: vtkStreamTracer.h:162
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkInitialValueProblemSolver.h
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkStreamTracer::CustomTerminationCallback
std::vector< CustomTerminationCallbackType > CustomTerminationCallback
Definition: vtkStreamTracer.h:455
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkStreamTracer::AddInput
void AddInput(vtkDataObject *)
Definition: vtkStreamTracer.h:386
vtkStreamTracer
Streamline generator.
Definition: vtkStreamTracer.h:102
vtkPolyDataAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkInitialValueProblemSolver::UNEXPECTED_VALUE
@ UNEXPECTED_VALUE
Definition: vtkInitialValueProblemSolver.h:148
vtkStreamTracer::BACKWARD
@ BACKWARD
Definition: vtkStreamTracer.h:298
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkAbstractInterpolatedVelocityField
An abstract class for obtaining the interpolated velocity values at a point.
Definition: vtkAbstractInterpolatedVelocityField.h:82
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkStreamTracer::Units
Units
Definition: vtkStreamTracer.h:153
vtkStreamTracer::RUNGE_KUTTA45
@ RUNGE_KUTTA45
Definition: vtkStreamTracer.h:163
vtkStreamTracer::IntegrationStepUnit
int IntegrationStepUnit
Definition: vtkStreamTracer.h:435
vtkStreamTracer::InterpolatorPrototype
vtkAbstractInterpolatedVelocityField * InterpolatorPrototype
Definition: vtkStreamTracer.h:450
vtkStreamTracer::IntervalInformation::Unit
int Unit
Definition: vtkStreamTracer.h:418
vtkStreamTracer::IntegrationDirection
int IntegrationDirection
Definition: vtkStreamTracer.h:436
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:36
vtkStreamTracer::SurfaceStreamlines
bool SurfaceStreamlines
Definition: vtkStreamTracer.h:448
vtkStreamTracer::InitialIntegrationStep
double InitialIntegrationStep
Definition: vtkStreamTracer.h:424
vtkStreamTracer::RUNGE_KUTTA2
@ RUNGE_KUTTA2
Definition: vtkStreamTracer.h:161
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:36
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:959
vtkStreamTracer::SetIntegrationDirectionToBackward
void SetIntegrationDirectionToBackward()
Definition: vtkStreamTracer.h:316
vtkStreamTracer::CustomReasonForTermination
std::vector< int > CustomReasonForTermination
Definition: vtkStreamTracer.h:457
vtkStreamTracer::MaximumIntegrationStep
double MaximumIntegrationStep
Definition: vtkStreamTracer.h:423
vtkInitialValueProblemSolver
Integrate a set of ordinary differential equations (initial value problem) in time.
Definition: vtkInitialValueProblemSolver.h:40
vtkInitialValueProblemSolver::OUT_OF_DOMAIN
@ OUT_OF_DOMAIN
Definition: vtkInitialValueProblemSolver.h:146
vtkStreamTracer::Solvers
Solvers
Definition: vtkStreamTracer.h:159
vtkStreamTracer::ReasonForTermination
ReasonForTermination
Definition: vtkStreamTracer.h:168
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkStreamTracer::RotationScale
double RotationScale
Definition: vtkStreamTracer.h:445
vtkStreamTracer::SetIntegratorTypeToRungeKutta4
void SetIntegratorTypeToRungeKutta4()
Definition: vtkStreamTracer.h:195
vtkPolyDataAlgorithm::New
static vtkPolyDataAlgorithm * New()
vtkInitialValueProblemSolver::NOT_INITIALIZED
@ NOT_INITIALIZED
Definition: vtkInitialValueProblemSolver.h:147
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41