VTK  9.7.1
vtkStreamTracer.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
82 #ifndef vtkStreamTracer_h
83 #define vtkStreamTracer_h
84 
85 #include "vtkDeprecation.h" // VTK_DEPRECATED_IN_9_7_0
86 #include "vtkFiltersFlowPathsModule.h" // For export macro
87 #include "vtkPolyDataAlgorithm.h"
88 
89 #include "vtkDataSetAttributesFieldList.h" // Needed to identify common data arrays
90 #include "vtkInitialValueProblemSolver.h" // Needed for constants
91 
92 VTK_ABI_NAMESPACE_BEGIN
96 class vtkDataArray;
98 class vtkDoubleArray;
99 class vtkExecutive;
100 class vtkGenericCell;
101 class vtkIdList;
102 class vtkIntArray;
103 class vtkPoints;
104 
105 VTK_ABI_NAMESPACE_END
106 #include <vector> // for std::vector
107 
108 // Helper struct to convert between different length scales.
109 VTK_ABI_NAMESPACE_BEGIN
110 struct VTKFILTERSFLOWPATHS_EXPORT vtkIntervalInformation
111 {
112  double Interval;
113  int Unit;
114 
115  static double ConvertToLength(double interval, int unit, double cellLength);
116  static double ConvertToLength(vtkIntervalInformation& interval, double cellLength);
117 };
118 
130  void* clientdata, vtkPoints* points, vtkDataArray* velocity, int integrationDirection);
131 
132 class VTKFILTERSFLOWPATHS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
133 {
134 public:
142  static vtkStreamTracer* New();
143 
145 
149  void PrintSelf(ostream& os, vtkIndent indent) override;
151 
153 
158  vtkSetVector3Macro(StartPosition, double);
159  vtkGetVector3Macro(StartPosition, double);
161 
163 
169  void SetSourceData(vtkDataSet* source);
170  vtkDataSet* GetSource();
172 
178  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
179 
180  // The previously-supported TIME_UNIT is excluded in this current
181  // enumeration definition because the underlying step size is ALWAYS in
182  // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual
183  // for steady flows) that a particle actually takes to trave in a single
184  // step is obtained by dividing the arc length by the LOCAL speed. The
185  // overall elapsed time (i.e., the life span) of the particle is the sum
186  // of those individual step-wise time intervals. The arc-length-to-time
187  // conversion only occurs for vorticity computation and for generating a
188  // point data array named 'IntegrationTime'.
189  enum Units
190  {
191  LENGTH_UNIT = 1,
192  CELL_LENGTH_UNIT = 2
193  };
194 
195  enum Solvers
196  {
202  };
203 
205  {
209  OUT_OF_LENGTH = 4,
210  OUT_OF_STEPS = 5,
211  STAGNATION = 6,
212  FIXED_REASONS_FOR_TERMINATION_COUNT = 7,
213  };
214 
216 
226  void SetIntegrator(vtkInitialValueProblemSolver*);
227  vtkGetObjectMacro(Integrator, vtkInitialValueProblemSolver);
228  void SetIntegratorType(int type);
229  int GetIntegratorType();
230  void SetIntegratorTypeToRungeKutta2() { this->SetIntegratorType(RUNGE_KUTTA2); }
231  void SetIntegratorTypeToRungeKutta4() { this->SetIntegratorType(RUNGE_KUTTA4); }
232  void SetIntegratorTypeToRungeKutta45() { this->SetIntegratorType(RUNGE_KUTTA45); }
234 
244  VTK_DEPRECATED_IN_9_7_0("Use SetCellLocatorToJumpAndWalkCellLocator() instead")
245  void SetInterpolatorTypeToDataSetPointLocator();
246 
253  VTK_DEPRECATED_IN_9_7_0("Use SetCellLocatorToStaticCellLocator() instead")
254  void SetInterpolatorTypeToCellLocator();
255 
257 
260  vtkSetMacro(MaximumPropagation, double);
261  vtkGetMacro(MaximumPropagation, double);
263 
270  void SetIntegrationStepUnit(int unit);
271  int GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
272 
274 
281  vtkSetMacro(InitialIntegrationStep, double);
282  vtkGetMacro(InitialIntegrationStep, double);
284 
286 
292  vtkSetMacro(MinimumIntegrationStep, double);
293  vtkGetMacro(MinimumIntegrationStep, double);
295 
297 
303  vtkSetMacro(MaximumIntegrationStep, double);
304  vtkGetMacro(MaximumIntegrationStep, double);
306 
308 
311  vtkSetMacro(MaximumError, double);
312  vtkGetMacro(MaximumError, double);
314 
316 
324  vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
325  vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
327 
329 
333  vtkSetMacro(TerminalSpeed, double);
334  vtkGetMacro(TerminalSpeed, double);
336 
338 
342  vtkGetMacro(SurfaceStreamlines, bool);
343  vtkSetMacro(SurfaceStreamlines, bool);
344  vtkBooleanMacro(SurfaceStreamlines, bool);
346 
347  enum
348  {
351  BOTH
352  };
353 
354  enum
355  {
356  INTERPOLATOR_WITH_DATASET_POINT_LOCATOR VTK_DEPRECATED_IN_9_7_0(
357  "Use SetCellLocatorToJumpAndWalkCellLocator() instead"),
358  INTERPOLATOR_WITH_CELL_LOCATOR VTK_DEPRECATED_IN_9_7_0(
359  "Use SetCellLocatorToStaticCellLocator() instead")
360  };
361 
363 
370  vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
371  vtkGetMacro(IntegrationDirection, int);
372  void SetIntegrationDirectionToForward() { this->SetIntegrationDirection(FORWARD); }
373  void SetIntegrationDirectionToBackward() { this->SetIntegrationDirection(BACKWARD); }
374  void SetIntegrationDirectionToBoth() { this->SetIntegrationDirection(BOTH); }
376 
378 
383  vtkSetMacro(ComputeVorticity, bool);
384  vtkGetMacro(ComputeVorticity, bool);
386 
388 
392  vtkSetMacro(RotationScale, double);
393  vtkGetMacro(RotationScale, double);
395 
405  VTK_DEPRECATED_IN_9_7_0("Use SetCellLocator(vtkAbstractCellLocator*) instead")
406  void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField* ivf);
407 
417  VTK_DEPRECATED_IN_9_7_0("Use SetCellLocator(vtkAbstractCellLocator*) instead")
418  void SetInterpolatorType(int interpType);
419 
421 
426  virtual void SetCellLocator(vtkAbstractCellLocator*);
427  virtual void SetCellLocatorToStaticCellLocator();
428  virtual void SetCellLocatorToJumpAndWalkCellLocator();
429  vtkGetObjectMacro(CellLocator, vtkAbstractCellLocator);
431 
433 
437  vtkGetMacro(ForceSerialExecution, bool);
438  vtkSetMacro(ForceSerialExecution, bool);
439  vtkBooleanMacro(ForceSerialExecution, bool);
441 
450  void AddCustomTerminationCallback(
451  CustomTerminationCallbackType callback, void* clientdata, int reasonForTermination);
452 
461  void ConvertIntervals(
462  double& step, double& minStep, double& maxStep, int direction, double cellLength);
463 
465 
469  void GenerateNormals(vtkPolyData* output, double* firstNormal, const char* vecName);
470  void CalculateVorticity(
471  vtkGenericCell* cell, double pcoords[3], vtkDoubleArray* cellVectors, double vorticity[3]);
473 
475 
485  vtkSetMacro(UseLocalSeedSource, bool);
486  vtkGetMacro(UseLocalSeedSource, bool);
487  vtkBooleanMacro(UseLocalSeedSource, bool);
489 
490 protected:
491  vtkStreamTracer();
492  ~vtkStreamTracer() override;
493 
494  // Create a default executive.
495  vtkExecutive* CreateDefaultExecutive() override;
496 
497  // hide the superclass' AddInput() from the user and the compiler
498  void AddInput(vtkDataObject*)
499  {
500  vtkErrorMacro(<< "AddInput() must be called with a vtkDataSet not a vtkDataObject.");
501  }
502 
504  int FillInputPortInformation(int, vtkInformation*) override;
505 
506  void Integrate(vtkPointData* inputData, vtkPolyData* output, vtkDataArray* seedSource,
507  vtkIdList* seedIds, vtkIntArray* integrationDirections,
508  vtkAbstractInterpolatedVelocityField* func, int maxCellSize, int vecType,
509  const char* vecFieldName, double& propagation, vtkIdType& numSteps, double& integrationTime,
510  std::vector<CustomTerminationCallbackType>& customTerminationCallback,
511  std::vector<void*>& customTerminationClientData, std::vector<int>& customReasonForTermination);
512 
513  double SimpleIntegrate(double seed[3], double lastPoint[3], double stepSize,
515  int CheckInputs(vtkAbstractInterpolatedVelocityField*& func, int* maxCellSize);
516 
518 
519  // starting from global x-y-z position
520  double StartPosition[3];
521 
522  static const double EPSILON;
524 
525  // Used by subclasses, leave alone
527 
532 
533  int SetupOutput(vtkInformation* inInfo, vtkInformation* outInfo);
534  void InitializeSeeds(vtkDataArray*& seeds, vtkIdList*& seedIds,
535  vtkIntArray*& integrationDirections, vtkDataSet* source);
536 
539 
540  // Prototype showing the integrator type to be set by the user.
542 
543  double MaximumError;
545 
548 
549  // Compute streamlines only on surface.
551 
553 
554  // These are used to manage complex input types such as
555  // multiblock / composite datasets. Basically the filter input is
556  // converted to a composite dataset, and the point data attributes
557  // are intersected to produce a common set of output data arrays.
558  vtkCompositeDataSet* InputData; // convert input data to composite dataset
559  vtkDataSetAttributesFieldList InputPD; // intersect attributes of all datasets
560  bool
561  HasMatchingPointAttributes; // does the point data in the multiblocks have the same attributes?
562 
563  // Control execution as serial or threaded
565  bool SerialExecution; // internal use to combine information
566 
567  std::vector<CustomTerminationCallbackType> CustomTerminationCallback;
568  std::vector<void*> CustomTerminationClientData;
569  std::vector<int> CustomReasonForTermination;
570 
571  // Only relevant for this derived parallel version of vtkStreamTracer,
572  // but needs to be defined in this class to have a uniform interface
573  // between this class and the parallel override vtkPStreamTracer
575 
576  friend class PStreamTracerUtils;
577 
578 private:
579  vtkStreamTracer(const vtkStreamTracer&) = delete;
580  void operator=(const vtkStreamTracer&) = delete;
581 };
582 
583 VTK_ABI_NAMESPACE_END
584 #endif
void SetIntegrationDirectionToBoth()
Specify whether the streamline is integrated in the upstream or downstream direction, or in both directions.
static const double EPSILON
represent and manipulate point attribute data
Definition: vtkPointData.h:30
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.
helps manage arrays from multiple vtkDataSetAttributes.
an abstract base class for locators which find cells
An abstract class for obtaining the interpolated velocity values at a point.
bool GenerateNormalsInIntegrate
vtkCompositeDataSet * InputData
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:39
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, or in both directions.
std::vector< int > CustomReasonForTermination
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
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:28
list of point or cell ids
Definition: vtkIdList.h:25
bool(* CustomTerminationCallbackType)(void *clientdata, vtkPoints *points, vtkDataArray *velocity, int integrationDirection)
Used to specify custom conditions which are evaluated to determine whether a streamline should be ter...
vtkInitialValueProblemSolver * Integrator
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
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
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
double MaximumIntegrationStep
void SetIntegratorTypeToRungeKutta2()
Set/get the integrator type to be used for streamline generation.
void SetIntegratorTypeToRungeKutta45()
Set/get the integrator type to be used for streamline generation.
double InitialIntegrationStep
std::vector< void * > CustomTerminationClientData
vtkDataSetAttributesFieldList InputPD
Streamline generator.
vtkAbstractCellLocator * CellLocator
void SetIntegrationDirectionToBackward()
Specify whether the streamline is integrated in the upstream or downstream direction, or in both directions.
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:55
#define VTK_DEPRECATED_IN_9_7_0(reason)
represent and manipulate 3D points
Definition: vtkPoints.h:30
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.