VTK  9.7.1
vtkLagrangianParticleTracker.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
79 #ifndef vtkLagrangianParticleTracker_h
80 #define vtkLagrangianParticleTracker_h
81 
82 #include "vtkBoundingBox.h" // For cached bounds
83 #include "vtkDataObjectAlgorithm.h"
84 #include "vtkFiltersFlowPathsModule.h" // For export macro
85 #include "vtkSmartPointer.h" // For smart pointer
86 
87 #include <atomic> // for atomic
88 #include <mutex> // for mutexes
89 #include <queue> // for particle queue
90 
91 VTK_ABI_NAMESPACE_BEGIN
92 class vtkBoundingBox;
93 class vtkCellArray;
94 class vtkDataSet;
95 class vtkDoubleArray;
96 class vtkIdList;
97 class vtkInformation;
103 class vtkPointData;
104 class vtkPoints;
105 class vtkPolyData;
106 class vtkPolyLine;
107 struct IntegratingFunctor;
109 
110 class VTKFILTERSFLOWPATHS_EXPORT vtkLagrangianParticleTracker : public vtkDataObjectAlgorithm
111 {
112 public:
114  void PrintSelf(ostream& os, vtkIndent indent) override;
116 
118  {
119  STEP_CUR_CELL_LENGTH = 1,
120  STEP_CUR_CELL_VEL_DIR = 3,
121  STEP_CUR_CELL_DIV_THEO = 5
122  } CellLengthComputation;
123 
125 
129  void SetIntegrationModel(vtkLagrangianBasicIntegrationModel* integrationModel);
130  vtkLagrangianBasicIntegrationModel* GetIntegrationModel();
132 
134 
138  void SetIntegrator(vtkInitialValueProblemSolver* integrator);
139  vtkInitialValueProblemSolver* GetIntegrator();
141 
143 
148  vtkSetMacro(GeneratePolyVertexInteractionOutput, bool);
149  vtkGetMacro(GeneratePolyVertexInteractionOutput, bool);
151 
153 
166  vtkSetMacro(CellLengthComputationMode, int);
167  vtkGetMacro(CellLengthComputationMode, int);
169 
171 
174  vtkSetMacro(StepFactor, double);
175  vtkGetMacro(StepFactor, double);
177 
179 
182  vtkSetMacro(StepFactorMin, double);
183  vtkGetMacro(StepFactorMin, double);
185 
187 
190  vtkSetMacro(StepFactorMax, double);
191  vtkGetMacro(StepFactorMax, double);
193 
195 
198  vtkSetMacro(MaximumNumberOfSteps, int);
199  vtkGetMacro(MaximumNumberOfSteps, int);
201 
203 
207  vtkSetMacro(MaximumIntegrationTime, double);
208  vtkGetMacro(MaximumIntegrationTime, double);
210 
212 
218  vtkSetMacro(AdaptiveStepReintegration, bool);
219  vtkGetMacro(AdaptiveStepReintegration, bool);
220  vtkBooleanMacro(AdaptiveStepReintegration, bool);
222 
224 
228  vtkSetMacro(GenerateParticlePathsOutput, bool);
229  vtkGetMacro(GenerateParticlePathsOutput, bool);
230  vtkBooleanMacro(GenerateParticlePathsOutput, bool);
232 
234 
239  vtkSetMacro(ForcePManualShift, bool);
240  vtkGetMacro(ForcePManualShift, bool);
241  vtkBooleanMacro(ForcePManualShift, bool);
243 
245 
251  void SetSourceData(vtkDataObject* source);
252  vtkDataObject* GetSource();
254 
258  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
259 
261 
267  void SetSurfaceData(vtkDataObject* source);
268  vtkDataObject* GetSurface();
270 
274  void SetSurfaceConnection(vtkAlgorithmOutput* algOutput);
275 
279  int FillInputPortInformation(int port, vtkInformation* info) override;
280 
285 
290 
294  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
295  vtkInformationVector* outputVector) override;
296 
301  vtkMTimeType GetMTime() override;
302 
307  virtual vtkIdType GetNewParticleId();
308 
309 protected:
311  ~vtkLagrangianParticleTracker() override;
312 
313  virtual bool InitializeFlow(vtkDataObject* flow, vtkBoundingBox* bounds);
314  virtual bool InitializeParticles(const vtkBoundingBox* bounds, vtkDataSet* seeds,
315  std::queue<vtkLagrangianParticle*>& particles, vtkPointData* seedData);
316  virtual void GenerateParticles(const vtkBoundingBox* bounds, vtkDataSet* seeds,
317  vtkDataArray* initialVelocities, vtkDataArray* initialIntegrationTimes, vtkPointData* seedData,
318  int nVar, std::queue<vtkLagrangianParticle*>& particles);
319  virtual bool UpdateSurfaceCacheIfNeeded(vtkDataObject*& surfaces);
320  virtual void InitializeSurface(vtkDataObject*& surfaces);
321 
325  virtual bool InitializePathsOutput(
326  vtkPointData* seedData, vtkIdType numberOfSeeds, vtkPolyData*& particlePathsOutput);
327 
331  virtual bool InitializeInteractionOutput(
332  vtkPointData* seedData, vtkDataObject* surfaces, vtkDataObject*& interractionOutput);
333 
334  virtual bool FinalizeOutputs(vtkPolyData* particlePathsOutput, vtkDataObject* interactionOutput);
335 
336  static void InsertPolyVertexCell(vtkPolyData* polydata);
337  static void InsertVertexCells(vtkPolyData* polydata);
338 
339  virtual void GetParticleFeed(std::queue<vtkLagrangianParticle*>& particleQueue);
340 
344  virtual int Integrate(vtkInitialValueProblemSolver* integrator, vtkLagrangianParticle*,
345  std::queue<vtkLagrangianParticle*>&, vtkPolyData* particlePathsOutput,
346  vtkPolyLine* particlePath, vtkDataObject* interactionOutput);
347 
351  void InsertPathOutputPoint(vtkLagrangianParticle* particle, vtkPolyData* particlePathsOutput,
352  vtkIdList* particlePathPointId, bool prev = false);
353 
357  void InsertInteractionOutputPoint(vtkLagrangianParticle* particle,
358  unsigned int interactedSurfaceFlatIndex, vtkDataObject* interactionOutput);
359 
364  double ComputeCellLength(vtkLagrangianParticle* particle);
365 
369  bool ComputeNextStep(vtkInitialValueProblemSolver* integrator, double* xprev, double* xnext,
370  double t, double& delT, double& delTActual, double minStep, double maxStep, double cellLength,
371  int& integrationRes, vtkLagrangianParticle* particle);
372 
377  virtual void DeleteParticle(vtkLagrangianParticle* particle);
378 
381 
383  double StepFactor;
389  bool GenerateParticlePathsOutput = true;
391  bool ForcePManualShift = false;
392  std::atomic<vtkIdType> ParticleCounter;
393  std::atomic<vtkIdType> IntegratedParticleCounter;
396 
397  // internal parameters use for step computation
400 
401  // Cache related parameters
405  bool FlowCacheInvalid = true;
408  bool SurfaceCacheInvalid = true;
409 
410  std::mutex ProgressMutex;
411  friend struct IntegratingFunctor;
412 
414 
415 private:
417  void operator=(const vtkLagrangianParticleTracker&) = delete;
418 };
419 
420 VTK_ABI_NAMESPACE_END
421 #endif
virtual int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
represent and manipulate point attribute data
Definition: vtkPointData.h:30
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
static vtkDataObjectAlgorithm * New()
struct to hold a user data
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
vtkLagrangianThreadedData * SerialThreadedData
Proxy object to connect input/output ports.
dynamic, self-adjusting array of double
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
std::atomic< vtkIdType > IntegratedParticleCounter
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkFunctionSet abstract implementation to be used in the vtkLagrangianParticleTracker integrator...
list of point or cell ids
Definition: vtkIdList.h:25
composite dataset to encapsulates pieces of dataset.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkSmartPointer< vtkInitialValueProblemSolver > Integrator
Basis class for Lagrangian particles.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Superclass for algorithms that produce only data object as output.
object to represent cell connectivity
Definition: vtkCellArray.h:177
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Composite dataset that organizes datasets into blocks.
Store zero or more vtkInformation instances.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
general representation of visualization data
Definition: vtkDataObject.h:55
vtkSmartPointer< vtkLagrangianBasicIntegrationModel > IntegrationModel
Filter to inject and track particles in a flow.
represent and manipulate 3D points
Definition: vtkPoints.h:30
cell represents a set of 1D lines
Definition: vtkPolyLine.h:29
Fast, simple class for representing and operating on 3D bounds.
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.