VTK  9.2.6
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=========================================================================*/
203#ifndef vtkStreamTracer_h
204#define vtkStreamTracer_h
205
206#include "vtkFiltersFlowPathsModule.h" // For export macro
207#include "vtkPolyDataAlgorithm.h"
208
209#include "vtkDataSetAttributesFieldList.h" // Needed to identify common data arrays
210#include "vtkInitialValueProblemSolver.h" // Needed for constants
211
214class vtkDataArray;
216class vtkDoubleArray;
217class vtkExecutive;
218class vtkGenericCell;
219class vtkIdList;
220class vtkIntArray;
221class vtkPoints;
222
223#include <vector> // for std::vector
224
225// Helper struct to convert between different length scales.
226struct VTKFILTERSFLOWPATHS_EXPORT vtkIntervalInformation
227{
228 double Interval;
229 int Unit;
230
231 static double ConvertToLength(double interval, int unit, double cellLength);
232 static double ConvertToLength(vtkIntervalInformation& interval, double cellLength);
233};
234
246 void* clientdata, vtkPoints* points, vtkDataArray* velocity, int integrationDirection);
247
248class VTKFILTERSFLOWPATHS_EXPORT vtkStreamTracer : public vtkPolyDataAlgorithm
249{
250public:
259
261
265 void PrintSelf(ostream& os, vtkIndent indent) override;
267
269
274 vtkSetVector3Macro(StartPosition, double);
275 vtkGetVector3Macro(StartPosition, double);
277
279
288
295
296 // The previously-supported TIME_UNIT is excluded in this current
297 // enumeration definition because the underlying step size is ALWAYS in
298 // arc length unit (LENGTH_UNIT) while the 'real' time interval (virtual
299 // for steady flows) that a particle actually takes to trave in a single
300 // step is obtained by dividing the arc length by the LOCAL speed. The
301 // overall elapsed time (i.e., the life span) of the particle is the sum
302 // of those individual step-wise time intervals. The arc-length-to-time
303 // conversion only occurs for vorticity computation and for generating a
304 // point data array named 'IntegrationTime'.
305 enum Units
306 {
307 LENGTH_UNIT = 1,
308 CELL_LENGTH_UNIT = 2
309 };
310
312 {
317 UNKNOWN
318 };
319
321 {
325 OUT_OF_LENGTH = 4,
326 OUT_OF_STEPS = 5,
327 STAGNATION = 6,
328 FIXED_REASONS_FOR_TERMINATION_COUNT
329 };
330
332
343 vtkGetObjectMacro(Integrator, vtkInitialValueProblemSolver);
346 void SetIntegratorTypeToRungeKutta2() { this->SetIntegratorType(RUNGE_KUTTA2); }
347 void SetIntegratorTypeToRungeKutta4() { this->SetIntegratorType(RUNGE_KUTTA4); }
348 void SetIntegratorTypeToRungeKutta45() { this->SetIntegratorType(RUNGE_KUTTA45); }
350
361
369
371
374 vtkSetMacro(MaximumPropagation, double);
375 vtkGetMacro(MaximumPropagation, double);
377
385 int GetIntegrationStepUnit() { return this->IntegrationStepUnit; }
386
388
395 vtkSetMacro(InitialIntegrationStep, double);
396 vtkGetMacro(InitialIntegrationStep, double);
398
400
406 vtkSetMacro(MinimumIntegrationStep, double);
407 vtkGetMacro(MinimumIntegrationStep, double);
409
411
417 vtkSetMacro(MaximumIntegrationStep, double);
418 vtkGetMacro(MaximumIntegrationStep, double);
420
422
425 vtkSetMacro(MaximumError, double);
426 vtkGetMacro(MaximumError, double);
428
430
438 vtkSetMacro(MaximumNumberOfSteps, vtkIdType);
439 vtkGetMacro(MaximumNumberOfSteps, vtkIdType);
441
443
447 vtkSetMacro(TerminalSpeed, double);
448 vtkGetMacro(TerminalSpeed, double);
450
452
455 vtkGetMacro(SurfaceStreamlines, bool);
456 vtkSetMacro(SurfaceStreamlines, bool);
457 vtkBooleanMacro(SurfaceStreamlines, bool);
459
460 enum
461 {
464 BOTH
465 };
466
467 enum
468 {
470 INTERPOLATOR_WITH_CELL_LOCATOR
471 };
472
474
481 vtkSetClampMacro(IntegrationDirection, int, FORWARD, BOTH);
482 vtkGetMacro(IntegrationDirection, int);
483 void SetIntegrationDirectionToForward() { this->SetIntegrationDirection(FORWARD); }
484 void SetIntegrationDirectionToBackward() { this->SetIntegrationDirection(BACKWARD); }
485 void SetIntegrationDirectionToBoth() { this->SetIntegrationDirection(BOTH); }
487
489
494 vtkSetMacro(ComputeVorticity, bool);
495 vtkGetMacro(ComputeVorticity, bool);
497
499
503 vtkSetMacro(RotationScale, double);
504 vtkGetMacro(RotationScale, double);
506
517
527 void SetInterpolatorType(int interpType);
528
530
534 vtkGetMacro(ForceSerialExecution, bool);
535 vtkSetMacro(ForceSerialExecution, bool);
536 vtkBooleanMacro(ForceSerialExecution, bool);
538
548 CustomTerminationCallbackType callback, void* clientdata, int reasonForTermination);
549
559 double& step, double& minStep, double& maxStep, int direction, double cellLength);
560
562
566 void GenerateNormals(vtkPolyData* output, double* firstNormal, const char* vecName);
568 vtkGenericCell* cell, double pcoords[3], vtkDoubleArray* cellVectors, double vorticity[3]);
570
572
582 vtkSetMacro(UseLocalSeedSource, bool);
583 vtkGetMacro(UseLocalSeedSource, bool);
584 vtkBooleanMacro(UseLocalSeedSource, bool);
586
587protected:
590
591 // Create a default executive.
593
594 // hide the superclass' AddInput() from the user and the compiler
596 {
597 vtkErrorMacro(<< "AddInput() must be called with a vtkDataSet not a vtkDataObject.");
598 }
599
602
603 void Integrate(vtkPointData* inputData, vtkPolyData* output, vtkDataArray* seedSource,
604 vtkIdList* seedIds, vtkIntArray* integrationDirections,
605 vtkAbstractInterpolatedVelocityField* func, int maxCellSize, int vecType,
606 const char* vecFieldName, double& propagation, vtkIdType& numSteps, double& integrationTime,
607 std::vector<CustomTerminationCallbackType>& customTerminationCallback,
608 std::vector<void*>& customTerminationClientData, std::vector<int>& customReasonForTermination);
609
610 double SimpleIntegrate(double seed[3], double lastPoint[3], double stepSize,
613
615
616 // starting from global x-y-z position
617 double StartPosition[3];
618
619 static const double EPSILON;
621
622 // Used by subclasses, leave alone
624
629
631 void InitializeSeeds(vtkDataArray*& seeds, vtkIdList*& seedIds,
632 vtkIntArray*& integrationDirections, vtkDataSet* source);
633
636
637 // Prototype showing the integrator type to be set by the user.
639
642
645
646 // Compute streamlines only on surface.
648
650
651 // These are used to manage complex input types such as
652 // multiblock / composite datasets. Basically the filter input is
653 // converted to a composite dataset, and the point data attributes
654 // are intersected to produce a common set of output data arrays.
655 vtkCompositeDataSet* InputData; // convert input data to composite dataset
656 vtkDataSetAttributesFieldList InputPD; // intersect attributes of all datasets
657 bool
658 HasMatchingPointAttributes; // does the point data in the multiblocks have the same attributes?
659
660 // Control execution as serial or threaded
662 bool SerialExecution; // internal use to combine information
663
664 std::vector<CustomTerminationCallbackType> CustomTerminationCallback;
665 std::vector<void*> CustomTerminationClientData;
667
668 // Only relevant for this derived parallel version of vtkStreamTracer,
669 // but needs to be defined in this class to have a uniform interface
670 // betwen this class and the parallel override vtkPStreamTracer
672
673 friend class PStreamTracerUtils;
674
675private:
676 vtkStreamTracer(const vtkStreamTracer&) = delete;
677 void operator=(const vtkStreamTracer&) = delete;
678};
679
680#endif
An abstract class for obtaining the interpolated velocity values at a point.
Proxy object to connect input/output ports.
abstract superclass for composite (multi-block or AMR) datasets
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
general representation of visualization data
helps manage arrays from multiple vtkDataSetAttributes.
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition: vtkDataSet.h:172
dynamic, self-adjusting array of double
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:79
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:143
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Integrate a set of ordinary differential equations (initial value problem) in time.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:155
represent and manipulate point attribute data
Definition: vtkPointData.h:151
represent and manipulate 3D points
Definition: vtkPoints.h:149
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
Streamline generator.
void SetIntegratorTypeToRungeKutta45()
Set/get the integrator type to be used for streamline generation.
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
int SetupOutput(vtkInformation *inInfo, vtkInformation *outInfo)
std::vector< void * > CustomTerminationClientData
vtkDataSetAttributesFieldList InputPD
void SetSourceData(vtkDataSet *source)
Specify the source object used to generate starting points (seeds).
vtkDataSet * GetSource()
Specify the source object used to generate starting points (seeds).
double InitialIntegrationStep
vtkAbstractInterpolatedVelocityField * InterpolatorPrototype
void SetInterpolatorTypeToCellLocator()
Set the velocity field interpolator type to one that uses a cell locator to perform spatial searching...
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods to obtain type information and print object state.
void CalculateVorticity(vtkGenericCell *cell, double pcoords[3], vtkDoubleArray *cellVectors, double vorticity[3])
Helper methods to generate normals on streamlines.
double MinimumIntegrationStep
@ INTERPOLATOR_WITH_DATASET_POINT_LOCATOR
void SetIntegratorTypeToRungeKutta4()
Set/get the integrator type to be used for streamline generation.
void SetIntegrator(vtkInitialValueProblemSolver *)
Set/get the integrator type to be used for streamline generation.
void SetSourceConnection(vtkAlgorithmOutput *algOutput)
Specify the source object used to generate starting points (seeds).
std::vector< int > CustomReasonForTermination
int CheckInputs(vtkAbstractInterpolatedVelocityField *&func, int *maxCellSize)
void ConvertIntervals(double &step, double &minStep, double &maxStep, int direction, double cellLength)
The following methods should not be called by the user.
void GenerateNormals(vtkPolyData *output, double *firstNormal, const char *vecName)
Helper methods to generate normals on streamlines.
static const double EPSILON
vtkIdType MaximumNumberOfSteps
void SetIntegrationDirectionToForward()
Specify whether the streamline is integrated in the upstream or downstream direction,...
std::vector< CustomTerminationCallbackType > CustomTerminationCallback
static vtkStreamTracer * New()
Construct the object to start from position (0,0,0), with forward integration, terminal speed 1....
bool HasMatchingPointAttributes
vtkCompositeDataSet * InputData
void SetInterpolatorType(int interpType)
Set the type of the velocity field interpolator to determine whether INTERPOLATOR_WITH_DATASET_POINT_...
double MaximumIntegrationStep
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
bool GenerateNormalsInIntegrate
vtkExecutive * CreateDefaultExecutive() override
Create a default executive.
void Integrate(vtkPointData *inputData, vtkPolyData *output, vtkDataArray *seedSource, vtkIdList *seedIds, vtkIntArray *integrationDirections, vtkAbstractInterpolatedVelocityField *func, int maxCellSize, int vecType, const char *vecFieldName, double &propagation, vtkIdType &numSteps, double &integrationTime, std::vector< CustomTerminationCallbackType > &customTerminationCallback, std::vector< void * > &customTerminationClientData, std::vector< int > &customReasonForTermination)
void SetIntegrationDirectionToBackward()
Specify whether the streamline is integrated in the upstream or downstream direction,...
void SetInterpolatorTypeToDataSetPointLocator()
Set the velocity field interpolator type to one that uses a point locator to perform local spatial se...
int GetIntegratorType()
Set/get the integrator type to be used for streamline generation.
void AddCustomTerminationCallback(CustomTerminationCallbackType callback, void *clientdata, int reasonForTermination)
Adds a custom termination callback.
void InitializeSeeds(vtkDataArray *&seeds, vtkIdList *&seedIds, vtkIntArray *&integrationDirections, vtkDataSet *source)
void SetIntegratorTypeToRungeKutta2()
Set/get the integrator type to be used for streamline generation.
void SetIntegrationDirectionToBoth()
Specify whether the streamline is integrated in the upstream or downstream direction,...
double SimpleIntegrate(double seed[3], double lastPoint[3], double stepSize, vtkAbstractInterpolatedVelocityField *func)
~vtkStreamTracer() override
void AddInput(vtkDataObject *)
vtkInitialValueProblemSolver * Integrator
void SetInterpolatorPrototype(vtkAbstractInterpolatedVelocityField *ivf)
The object used to interpolate the velocity field during integration is of the same class as this pro...
void SetIntegrationStepUnit(int unit)
Specify a uniform integration step unit for MinimumIntegrationStep, InitialIntegrationStep,...
void SetIntegratorType(int type)
Set/get the integrator type to be used for streamline generation.
int GetIntegrationStepUnit()
@ points
Definition: vtkX3D.h:452
@ direction
Definition: vtkX3D.h:266
@ type
Definition: vtkX3D.h:522
static double ConvertToLength(double interval, int unit, double cellLength)
static double ConvertToLength(vtkIntervalInformation &interval, double cellLength)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
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...
int vtkIdType
Definition: vtkType.h:332