VTK  9.1.0
vtkLagrangianParticleTracker.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLagrangianParticleTracker.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 =========================================================================*/
88 #ifndef vtkLagrangianParticleTracker_h
89 #define vtkLagrangianParticleTracker_h
90 
91 #include "vtkBoundingBox.h" // For cached bounds
92 #include "vtkDataObjectAlgorithm.h"
93 #include "vtkFiltersFlowPathsModule.h" // For export macro
94 
95 #include <atomic> // for atomic
96 #include <mutex> // for mutexes
97 #include <queue> // for particle queue
98 
99 class vtkBoundingBox;
100 class vtkCellArray;
101 class vtkDataSet;
102 class vtkDoubleArray;
103 class vtkIdList;
104 class vtkInformation;
110 class vtkPointData;
111 class vtkPoints;
112 class vtkPolyData;
113 class vtkPolyLine;
114 struct IntegratingFunctor;
116 
117 class VTKFILTERSFLOWPATHS_EXPORT vtkLagrangianParticleTracker : public vtkDataObjectAlgorithm
118 {
119 public:
121  void PrintSelf(ostream& os, vtkIndent indent) override;
123 
125  {
126  STEP_CUR_CELL_LENGTH = 1,
127  STEP_CUR_CELL_VEL_DIR = 3,
128  STEP_CUR_CELL_DIV_THEO = 5
129  } CellLengthComputation;
130 
132 
137  vtkGetObjectMacro(IntegrationModel, vtkLagrangianBasicIntegrationModel);
139 
141 
146  vtkGetObjectMacro(Integrator, vtkInitialValueProblemSolver);
148 
150 
155  vtkSetMacro(GeneratePolyVertexInteractionOutput, bool);
156  vtkGetMacro(GeneratePolyVertexInteractionOutput, bool);
158 
160 
173  vtkSetMacro(CellLengthComputationMode, int);
174  vtkGetMacro(CellLengthComputationMode, int);
176 
178 
181  vtkSetMacro(StepFactor, double);
182  vtkGetMacro(StepFactor, double);
184 
186 
189  vtkSetMacro(StepFactorMin, double);
190  vtkGetMacro(StepFactorMin, double);
192 
194 
197  vtkSetMacro(StepFactorMax, double);
198  vtkGetMacro(StepFactorMax, double);
200 
202 
205  vtkSetMacro(MaximumNumberOfSteps, int);
206  vtkGetMacro(MaximumNumberOfSteps, int);
208 
210 
214  vtkSetMacro(MaximumIntegrationTime, double);
215  vtkGetMacro(MaximumIntegrationTime, double);
217 
219 
225  vtkSetMacro(AdaptiveStepReintegration, bool);
226  vtkGetMacro(AdaptiveStepReintegration, bool);
227  vtkBooleanMacro(AdaptiveStepReintegration, bool);
229 
231 
235  vtkSetMacro(GenerateParticlePathsOutput, bool);
236  vtkGetMacro(GenerateParticlePathsOutput, bool);
237  vtkBooleanMacro(GenerateParticlePathsOutput, bool);
239 
241 
250 
255 
257 
266 
271 
276 
281 
286 
290  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
291  vtkInformationVector* outputVector) override;
292 
297  vtkMTimeType GetMTime() override;
298 
304 
305 protected:
308 
309  virtual bool InitializeFlow(vtkDataObject* flow, vtkBoundingBox* bounds);
310  virtual bool InitializeParticles(const vtkBoundingBox* bounds, vtkDataSet* seeds,
311  std::queue<vtkLagrangianParticle*>& particles, vtkPointData* seedData);
312  virtual void GenerateParticles(const vtkBoundingBox* bounds, vtkDataSet* seeds,
313  vtkDataArray* initialVelocities, vtkDataArray* initialIntegrationTimes, vtkPointData* seedData,
314  int nVar, std::queue<vtkLagrangianParticle*>& particles);
315  virtual bool UpdateSurfaceCacheIfNeeded(vtkDataObject*& surfaces);
316  virtual void InitializeSurface(vtkDataObject*& surfaces);
317 
321  virtual bool InitializePathsOutput(
322  vtkPointData* seedData, vtkIdType numberOfSeeds, vtkPolyData*& particlePathsOutput);
323 
328  vtkPointData* seedData, vtkDataObject* surfaces, vtkDataObject*& interractionOutput);
329 
330  virtual bool FinalizeOutputs(vtkPolyData* particlePathsOutput, vtkDataObject* interactionOutput);
331 
332  static void InsertPolyVertexCell(vtkPolyData* polydata);
333  static void InsertVertexCells(vtkPolyData* polydata);
334 
335  virtual void GetParticleFeed(std::queue<vtkLagrangianParticle*>& particleQueue);
336 
341  std::queue<vtkLagrangianParticle*>&, vtkPolyData* particlePathsOutput,
342  vtkPolyLine* particlePath, vtkDataObject* interactionOutput);
343 
347  void InsertPathOutputPoint(vtkLagrangianParticle* particle, vtkPolyData* particlePathsOutput,
348  vtkIdList* particlePathPointId, bool prev = false);
349 
354  unsigned int interactedSurfaceFlatIndex, vtkDataObject* interactionOutput);
355 
361 
365  bool ComputeNextStep(vtkInitialValueProblemSolver* integrator, double* xprev, double* xnext,
366  double t, double& delT, double& delTActual, double minStep, double maxStep, double cellLength,
367  int& integrationRes, vtkLagrangianParticle* particle);
368 
373  virtual void DeleteParticle(vtkLagrangianParticle* particle);
374 
377 
379  double StepFactor;
385  bool GenerateParticlePathsOutput = true;
387  std::atomic<vtkIdType> ParticleCounter;
388  std::atomic<vtkIdType> IntegratedParticleCounter;
391 
392  // internal parameters use for step computation
395 
396  // Cache related parameters
402 
403  std::mutex ProgressMutex;
404  friend struct IntegratingFunctor;
405 
407 
408 private:
410  void operator=(const vtkLagrangianParticleTracker&) = delete;
411 };
412 
413 #endif
Proxy object to connect input/output ports.
Fast, simple class for representing and operating on 3D bounds.
object to represent cell connectivity
Definition: vtkCellArray.h:181
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
Superclass for algorithms that produce only data object as output.
general representation of visualization data
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
dynamic, self-adjusting array of double
list of point or cell ids
Definition: vtkIdList.h:31
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Integrate a set of ordinary differential equations (initial value problem) in time.
vtkFunctionSet abstract implementation to be used in the vtkLagrangianParticleTracker integrator.
Filter to inject and track particles in a flow.
vtkDataObject * GetSurface()
Specify the source object used to compute surface interaction with Note that this method does not con...
void SetSourceConnection(vtkAlgorithmOutput *algOutput)
Specify the source object used to generate particle initial position (seeds).
vtkLagrangianBasicIntegrationModel * IntegrationModel
virtual bool UpdateSurfaceCacheIfNeeded(vtkDataObject *&surfaces)
virtual vtkIdType GetNewParticleId()
Get an unique id for a particle This method is thread safe.
void InsertPathOutputPoint(vtkLagrangianParticle *particle, vtkPolyData *particlePathsOutput, vtkIdList *particlePathPointId, bool prev=false)
This method is thread safe.
vtkInitialValueProblemSolver * Integrator
int FillInputPortInformation(int port, vtkInformation *info) override
Declare input port type.
virtual void GetParticleFeed(std::queue< vtkLagrangianParticle * > &particleQueue)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Process inputs to integrate particle and generate output.
bool ComputeNextStep(vtkInitialValueProblemSolver *integrator, double *xprev, double *xnext, double t, double &delT, double &delTActual, double minStep, double maxStep, double cellLength, int &integrationRes, vtkLagrangianParticle *particle)
This method is thread safe.
virtual void InitializeSurface(vtkDataObject *&surfaces)
virtual void DeleteParticle(vtkLagrangianParticle *particle)
This method is thread safe Call the ParticleAboutToBeDeleted model method and delete the particle.
virtual void GenerateParticles(const vtkBoundingBox *bounds, vtkDataSet *seeds, vtkDataArray *initialVelocities, vtkDataArray *initialIntegrationTimes, vtkPointData *seedData, int nVar, std::queue< vtkLagrangianParticle * > &particles)
static vtkLagrangianParticleTracker * New()
virtual bool InitializeParticles(const vtkBoundingBox *bounds, vtkDataSet *seeds, std::queue< vtkLagrangianParticle * > &particles, vtkPointData *seedData)
static void InsertPolyVertexCell(vtkPolyData *polydata)
double ComputeCellLength(vtkLagrangianParticle *particle)
Computes the cell length for the next step using the method set by CellLengthComputationMode.
void SetIntegrator(vtkInitialValueProblemSolver *integrator)
Set/Get the integrator.
void SetSurfaceData(vtkDataObject *source)
Specify the source object used to compute surface interaction with Note that this method does not con...
static void InsertVertexCells(vtkPolyData *polydata)
vtkMTimeType GetMTime() override
Get the tracker modified time taking into account the integration model and the integrator.
std::atomic< vtkIdType > IntegratedParticleCounter
void SetSurfaceConnection(vtkAlgorithmOutput *algOutput)
Specify the object used to compute surface interaction with.
vtkLagrangianThreadedData * SerialThreadedData
void SetIntegrationModel(vtkLagrangianBasicIntegrationModel *integrationModel)
Set/Get the integration model.
virtual int Integrate(vtkInitialValueProblemSolver *integrator, vtkLagrangianParticle *, std::queue< vtkLagrangianParticle * > &, vtkPolyData *particlePathsOutput, vtkPolyLine *particlePath, vtkDataObject *interactionOutput)
This method is thread safe.
virtual bool InitializeFlow(vtkDataObject *flow, vtkBoundingBox *bounds)
int FillOutputPortInformation(int port, vtkInformation *info) override
Declare output port type.
int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Create outputs objects.
virtual bool InitializePathsOutput(vtkPointData *seedData, vtkIdType numberOfSeeds, vtkPolyData *&particlePathsOutput)
This method is thread safe.
virtual bool InitializeInteractionOutput(vtkPointData *seedData, vtkDataObject *surfaces, vtkDataObject *&interractionOutput)
This method is thread safe.
vtkDataObject * GetSource()
Specify the source object used to generate particle initial position (seeds).
void SetSourceData(vtkDataObject *source)
Specify the source object used to generate particle initial position (seeds).
void InsertInteractionOutputPoint(vtkLagrangianParticle *particle, unsigned int interactedSurfaceFlatIndex, vtkDataObject *interactionOutput)
This method is thread safe.
virtual bool FinalizeOutputs(vtkPolyData *particlePathsOutput, vtkDataObject *interactionOutput)
~vtkLagrangianParticleTracker() override
Basis class for Lagrangian particles.
Composite dataset that organizes datasets into blocks.
composite dataset to encapsulates pieces of dataset.
represent and manipulate point attribute data
Definition: vtkPointData.h:33
represent and manipulate 3D points
Definition: vtkPoints.h:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
cell represents a set of 1D lines
Definition: vtkPolyLine.h:37
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
struct to hold a user data
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:332
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287