VTK  9.1.0
vtkLagrangianBasicIntegrationModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLagrangianBasicIntegrationModel.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 =========================================================================*/
51 #ifndef vtkLagrangianBasicIntegrationModel_h
52 #define vtkLagrangianBasicIntegrationModel_h
53 
54 #include "vtkFiltersFlowPathsModule.h" // For export macro
55 #include "vtkFunctionSet.h"
56 #include "vtkNew.h" // For arrays
57 #include "vtkWeakPointer.h" // For weak pointer
58 
59 #include <map> // for array indexes
60 #include <mutex> // for mutexes
61 #include <queue> // for new particles
62 
63 class vtkAbstractArray;
65 class vtkCell;
66 class vtkCellData;
67 class vtkDataArray;
68 class vtkDataObject;
69 class vtkDataSet;
70 class vtkDataSetsType;
71 class vtkDoubleArray;
72 class vtkFieldData;
73 class vtkGenericCell;
75 class vtkIntArray;
78 class vtkLocatorsType;
81 class vtkPointData;
82 class vtkPolyData;
83 class vtkStringArray;
84 class vtkSurfaceType;
86 
87 class VTKFILTERSFLOWPATHS_EXPORT vtkLagrangianBasicIntegrationModel : public vtkFunctionSet
88 {
89 public:
91  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
93  typedef enum SurfaceType
94  {
95  SURFACE_TYPE_MODEL = 0,
96  SURFACE_TYPE_TERM = 1,
97  SURFACE_TYPE_BOUNCE = 2,
98  SURFACE_TYPE_BREAK = 3,
99  SURFACE_TYPE_PASS = 4
100  } SurfaceType;
101 
102  typedef enum VariableStep
103  {
104  VARIABLE_STEP_PREV = -1,
105  VARIABLE_STEP_CURRENT = 0,
106  VARIABLE_STEP_NEXT = 1,
107  } VariableStep;
108 
109  typedef std::pair<unsigned int, vtkLagrangianParticle*> PassThroughParticlesItem;
110  typedef std::queue<PassThroughParticlesItem> PassThroughParticlesType;
111 
112  using Superclass::FunctionValues;
120  int FunctionValues(double* x, double* f, void* userData) override;
121 
123 
129  virtual void SetLocator(vtkAbstractCellLocator* locator);
130  vtkGetObjectMacro(Locator, vtkAbstractCellLocator);
132 
134 
137  vtkGetMacro(LocatorsBuilt, bool);
138  vtkSetMacro(LocatorsBuilt, bool);
140 
144  virtual void SetTracker(vtkLagrangianParticleTracker* Tracker);
145 
147 
156  virtual void AddDataSet(
157  vtkDataSet* dataset, bool surface = false, unsigned int surfaceFlatIndex = 0);
158  virtual void ClearDataSets(bool surface = false);
160 
162 
165  vtkSetMacro(UseInitialIntegrationTime, bool);
166  vtkGetMacro(UseInitialIntegrationTime, bool);
167  vtkBooleanMacro(UseInitialIntegrationTime, bool);
169 
171 
174  vtkGetMacro(Tolerance, double);
176 
178 
181  vtkGetMacro(LocatorTolerance, double);
183 
202  std::queue<vtkLagrangianParticle*>& particles, unsigned int& interactedSurfaceFlatIndex,
203  PassThroughParticlesType& passThroughParticles);
204 
211  int idx, int port, int connection, int fieldAssociation, const char* name);
212 
222  virtual bool FindInLocators(double* x, vtkLagrangianParticle* particle, vtkDataSet*& dataset,
223  vtkIdType& cellId, vtkAbstractCellLocator*& loc, double*& weights);
224 
226 
230  virtual bool FindInLocators(
231  double* x, vtkLagrangianParticle* particle, vtkDataSet*& dataset, vtkIdType& cellId);
232  virtual bool FindInLocators(double* x, vtkLagrangianParticle* particle);
234 
239  virtual void InitializeParticle(vtkLagrangianParticle* vtkNotUsed(particle)) {}
240 
249  virtual bool CheckAdaptiveStepReintegration(vtkLagrangianParticle* vtkNotUsed(particle))
250  {
251  return true;
252  }
253 
262  virtual bool CheckFreeFlightTermination(vtkLagrangianParticle* vtkNotUsed(particle))
263  {
264  return false;
265  }
266 
268 
271  vtkSetMacro(NonPlanarQuadSupport, bool);
272  vtkGetMacro(NonPlanarQuadSupport, bool);
273  vtkBooleanMacro(NonPlanarQuadSupport, bool);
275 
281 
287 
293 
299 
305 
311 
317 
323 
325 
329  virtual int GetWeightsSize();
331 
355  virtual bool ManualIntegration(vtkInitialValueProblemSolver* integrator, double* xcur,
356  double* xnext, double t, double& delT, double& delTActual, double minStep, double maxStep,
357  double maxError, double cellLength, double& error, int& integrationResult,
358  vtkLagrangianParticle* particle);
359 
365  virtual void ParallelManualShift(vtkLagrangianParticle* vtkNotUsed(particle)) {}
366 
372 
378 
384  virtual bool FinalizeOutputs(
385  vtkPolyData* vtkNotUsed(particlePathsOutput), vtkDataObject* vtkNotUsed(interractionOutput))
386  {
387  return true;
388  }
389 
393  virtual void PreParticleInitalization() {}
394 
398  virtual void PreIntegrate(std::queue<vtkLagrangianParticle*>& vtkNotUsed(particles)) {}
399 
404  virtual vtkAbstractArray* GetSeedArray(int idx, vtkPointData* pointData);
405 
413  vtkSetMacro(NumberOfTrackedUserData, int);
414  vtkGetMacro(NumberOfTrackedUserData, int);
415 
422 
429 
435  virtual void InitializeParticleData(vtkFieldData* particleData, int maxTuples = 0);
436 
443 
450 
457  virtual void InsertParticleData(
458  vtkLagrangianParticle* particle, vtkFieldData* data, int stepEnum);
459 
466 
473  virtual void ParticleAboutToBeDeleted(vtkLagrangianParticle* vtkNotUsed(particle)) {}
474 
480  vtkLagrangianParticle* vtkNotUsed(particle), vtkPointData* vtkNotUsed(particleData))
481  {
482  }
483 
484 protected:
487 
493  virtual int FunctionValues(vtkLagrangianParticle* particle, vtkDataSet* dataSet, vtkIdType cellId,
494  double* weights, double* x, double* f) = 0;
495 
502  virtual vtkIdType FindInLocator(vtkDataSet* dataSet, vtkAbstractCellLocator* locator, double* x,
503  vtkGenericCell* cell, double* weights);
504 
510  virtual bool TerminateParticle(vtkLagrangianParticle* particle);
511 
517  virtual bool BounceParticle(
518  vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId);
519 
527  virtual bool BreakParticle(vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId,
528  std::queue<vtkLagrangianParticle*>& particles);
529 
539  virtual bool InteractWithSurface(int surfaceType, vtkLagrangianParticle* particle,
540  vtkDataSet* surface, vtkIdType cellId, std::queue<vtkLagrangianParticle*>& particles);
541 
548  virtual bool IntersectWithLine(vtkLagrangianParticle* particle, vtkCell* cell, double p1[3],
549  double p2[3], double tol, double& t, double x[3]);
550 
556  vtkLagrangianParticle* particle, double interpolationFactor, bool forceInside = false);
557 
564  vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId);
565 
573 
581  virtual bool GetFlowOrSurfaceData(vtkLagrangianParticle* particle, int idx,
582  vtkDataSet* flowDataSet, vtkIdType tupleId, double* weights, double* data);
583 
591  virtual int GetFlowOrSurfaceDataNumberOfComponents(int idx, vtkDataSet* dataSet);
592 
599 
609  const char* arrayName, vtkDataSet* dataset, int nComponent, double* defaultValues);
610 
613  vtkLocatorsType* Locators;
614  vtkDataSetsType* DataSets;
615  int WeightsSize = 0;
616 
617  struct ArrayVal
618  {
619  int val[3];
620  };
621  typedef std::pair<ArrayVal, std::string> ArrayMapVal;
622  std::map<int, ArrayMapVal> InputArrays;
623 
624  typedef struct SurfaceArrayDescription
625  {
626  int nComp;
627  int type;
628  std::vector<std::pair<int, std::string>> enumValues;
629  } SurfaceArrayDescription;
630  std::map<std::string, SurfaceArrayDescription> SurfaceArrayDescriptions;
631 
632  vtkSurfaceType* Surfaces;
633  vtkLocatorsType* SurfaceLocators;
634 
635  double Tolerance;
636  double LocatorTolerance = 0.001;
639  int NumberOfTrackedUserData = 0;
640 
649 
651  std::mutex ParticleQueueMutex;
652 
653 private:
655  void operator=(const vtkLagrangianBasicIntegrationModel&) = delete;
656 };
657 
658 #endif
Abstract superclass for all arrays.
an abstract base class for locators which find cells
represent and manipulate cell attribute data
Definition: vtkCellData.h:33
abstract class to specify cell behavior
Definition: vtkCell.h:58
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
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
represent and manipulate fields of data
Definition: vtkFieldData.h:55
Abstract interface for sets of functions.
provides thread-safe access to cells
a simple class to control print indentation
Definition: vtkIndent.h:34
Integrate a set of ordinary differential equations (initial value problem) in time.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:40
vtkFunctionSet abstract implementation to be used in the vtkLagrangianParticleTracker integrator.
virtual vtkIntArray * GetSeedArrayComps()
Get the seed arrays expected number of components Used Only be the vtkLagrangianSeedHelper in ParaVie...
virtual void InsertInteractionData(vtkLagrangianParticle *particle, vtkFieldData *data)
Method used by the LPT to insert data from the partice into the provided vtkFieldData.
virtual void InitializeParticle(vtkLagrangianParticle *vtkNotUsed(particle))
Initialize a particle by setting user variables and perform any user model specific operation.
virtual void SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, const char *name)
Set a input array to process at a specific index, identified by a port, connection,...
virtual bool FinalizeOutputs(vtkPolyData *vtkNotUsed(particlePathsOutput), vtkDataObject *vtkNotUsed(interractionOutput))
Enable model post process on output Return true if successful, false otherwise Empty and Always retur...
virtual int GetFlowOrSurfaceDataFieldAssociation(int idx)
Recover a field association for a specified array index if it has been set using SetInputArrayToProce...
std::queue< PassThroughParticlesItem > PassThroughParticlesType
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void InitializeParticleData(vtkFieldData *particleData, int maxTuples=0)
Method used by the LPT to initialize data insertion in the provided vtkFieldData.
virtual bool TerminateParticle(vtkLagrangianParticle *particle)
Terminate a particle, by positioning flags.
virtual vtkStringArray * GetSurfaceArrayNames()
Get the surface arrays expected name Used Only be the vtkLagrangianSurfaceHelper in ParaView plugins.
virtual bool FindInLocators(double *x, vtkLagrangianParticle *particle, vtkDataSet *&dataset, vtkIdType &cellId)
Convienience methods to call FindInLocators with less arguments THESE METHODS ARE NOT THREAD-SAFE.
virtual void InterpolateNextParticleVariables(vtkLagrangianParticle *particle, double interpolationFactor, bool forceInside=false)
compute all particle variables using interpolation factor This method is thread-safe.
virtual void PreIntegrate(std::queue< vtkLagrangianParticle * > &vtkNotUsed(particles))
Enable model to modify particle before integration.
virtual void AddDataSet(vtkDataSet *dataset, bool surface=false, unsigned int surfaceFlatIndex=0)
Add a dataset to locate cells in This create a specific locator for the provided dataset using the Lo...
virtual void InitializePathData(vtkFieldData *data)
Method used by the LPT to initialize data insertion in the provided vtkFieldData.
virtual void SetTracker(vtkLagrangianParticleTracker *Tracker)
Set the parent tracker.
virtual bool CheckSurfacePerforation(vtkLagrangianParticle *particle, vtkDataSet *surface, vtkIdType cellId)
Given a particle, check if it perforate a surface cell ie : interact with next step after interacting...
virtual bool ManualIntegration(vtkInitialValueProblemSolver *integrator, double *xcur, double *xnext, double t, double &delT, double &delTActual, double minStep, double maxStep, double maxError, double cellLength, double &error, int &integrationResult, vtkLagrangianParticle *particle)
Let the model define it's own way to integrate Signature is very close to the integrator method signa...
virtual vtkStringArray * GetSurfaceArrayEnumValues()
Get the surface arrays expected values and associated enums Used Only be the vtkLagrangianSurfaceHelp...
virtual void SetLocator(vtkAbstractCellLocator *locator)
Set/Get the locator used to locate cells in the datasets.
virtual void InsertPathData(vtkLagrangianParticle *particle, vtkFieldData *data)
Method used by the LPT to insert data from the partice into the provided vtkFieldData.
virtual bool IntersectWithLine(vtkLagrangianParticle *particle, vtkCell *cell, double p1[3], double p2[3], double tol, double &t, double x[3])
Call vtkCell::IntersectWithLine This method is to be reimplemented in inherited classes willing to im...
virtual vtkStringArray * GetSeedArrayNames()
Get the seed arrays expected name Used Only be the vtkLagrangianSeedHelper in ParaView plugins.
virtual vtkIntArray * GetSurfaceArrayComps()
Get the seed array expected number of components Used Only be the vtkLagrangianSurfaceHelper in ParaV...
virtual vtkLagrangianThreadedData * InitializeThreadedData()
Let the model allocate and initialize a threaded data.
std::pair< unsigned int, vtkLagrangianParticle * > PassThroughParticlesItem
virtual void InitializeInteractionData(vtkFieldData *data)
Method used by the LPT to initialize data insertion in the provided vtkFieldData.
virtual bool BounceParticle(vtkLagrangianParticle *particle, vtkDataSet *surface, vtkIdType cellId)
Bounce a particle, using the normal of the cell it bounces on.
virtual void ParticleAboutToBeDeleted(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
virtual void FinalizeThreadedData(vtkLagrangianThreadedData *&data)
Let the model finalize and deallocate a user data at thread level This method is called serially for ...
virtual vtkLagrangianParticle * ComputeSurfaceInteraction(vtkLagrangianParticle *particle, std::queue< vtkLagrangianParticle * > &particles, unsigned int &interactedSurfaceFlatIndex, PassThroughParticlesType &passThroughParticles)
Interact the current particle with a surfaces Return a particle to record as interaction point if not...
int FunctionValues(double *x, double *f, void *userData) override
Evaluate integration model velocity f at position x.
virtual bool CheckFreeFlightTermination(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
virtual int GetFlowOrSurfaceDataNumberOfComponents(int idx, vtkDataSet *dataSet)
Recover the number of components for a specified array index if it has been set using SetInputArrayTo...
virtual bool CheckAdaptiveStepReintegration(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
virtual void ClearDataSets(bool surface=false)
Add a dataset to locate cells in This create a specific locator for the provided dataset using the Lo...
virtual void InsertSurfaceInteractionData(vtkLagrangianParticle *vtkNotUsed(particle), vtkPointData *vtkNotUsed(particleData))
Method to be reimplemented if needed in inherited classes.
std::map< std::string, SurfaceArrayDescription > SurfaceArrayDescriptions
virtual void ComputeSurfaceDefaultValues(const char *arrayName, vtkDataSet *dataset, int nComponent, double *defaultValues)
Method used by ParaView surface helper to get default values for each leaf of each dataset of surface...
virtual bool FindInLocators(double *x, vtkLagrangianParticle *particle, vtkDataSet *&dataset, vtkIdType &cellId, vtkAbstractCellLocator *&loc, double *&weights)
Look for a dataset in this integration model containing the point x.
std::pair< ArrayVal, std::string > ArrayMapVal
virtual bool FindInLocators(double *x, vtkLagrangianParticle *particle)
Convienience methods to call FindInLocators with less arguments THESE METHODS ARE NOT THREAD-SAFE.
virtual void PreParticleInitalization()
Allow for model setup prior to Particle Initalization.
virtual void ParallelManualShift(vtkLagrangianParticle *vtkNotUsed(particle))
Method called by parallel algorithm after receiving a particle from stream if PManualShift flag has b...
virtual bool InteractWithSurface(int surfaceType, vtkLagrangianParticle *particle, vtkDataSet *surface, vtkIdType cellId, std::queue< vtkLagrangianParticle * > &particles)
Call vtkLagrangianBasicIntegrationModel::Terminate This method is to be reimplemented in inherited cl...
virtual vtkAbstractArray * GetSeedArray(int idx, vtkPointData *pointData)
Get a seed array, as set in setInputArrayToProcess from the provided seed point data.
virtual void InsertParticleSeedData(vtkLagrangianParticle *particle, vtkFieldData *data)
Method used by the LPT to insert data from the partice into the provided vtkFieldData.
virtual int FunctionValues(vtkLagrangianParticle *particle, vtkDataSet *dataSet, vtkIdType cellId, double *weights, double *x, double *f)=0
Actually compute the integration model velocity field pure abstract, to be implemented in inherited c...
vtkWeakPointer< vtkLagrangianParticleTracker > Tracker
virtual vtkAbstractArray * GetSeedArray(int idx, vtkLagrangianParticle *particle)
Get a seed array, as set in setInputArrayToProcess from the provided particle seed data Access then t...
virtual vtkIdType FindInLocator(vtkDataSet *dataSet, vtkAbstractCellLocator *locator, double *x, vtkGenericCell *cell, double *weights)
Look in the given dataset and associated locator to see if it contains the point x,...
virtual int GetWeightsSize()
Get the maximum weights size necessary for calling FindInLocators with weights.
virtual vtkDoubleArray * GetSurfaceArrayDefaultValues()
Get the surface arrays default values for each leaf Used Only be the vtkLagrangianSurfaceHelper in Pa...
virtual void InsertParticleData(vtkLagrangianParticle *particle, vtkFieldData *data, int stepEnum)
Method used by the LPT to insert data from the partice into the provided vtkFieldData.
virtual bool BreakParticle(vtkLagrangianParticle *particle, vtkDataSet *surface, vtkIdType cellId, std::queue< vtkLagrangianParticle * > &particles)
Breakup a particle at intersection point, by terminating it and creating two new particle using the i...
virtual vtkIntArray * GetSeedArrayTypes()
Get the seed arrays expected type Used Only be the vtkLagrangianSeedHelper in ParaView plugins.
virtual bool GetFlowOrSurfaceData(vtkLagrangianParticle *particle, int idx, vtkDataSet *flowDataSet, vtkIdType tupleId, double *weights, double *data)
Directly get a double value from flow or surface data as defined in SetInputArrayToProcess.
virtual vtkIntArray * GetSurfaceArrayTypes()
Get the surface arrays expected type Used Only be the vtkLagrangianSurfaceHelper in ParaView plugins.
Filter to inject and track particles in a flow.
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
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
a vtkAbstractArray subclass for strings
@ port
Definition: vtkX3D.h:453
@ name
Definition: vtkX3D.h:225
@ data
Definition: vtkX3D.h:321
struct to hold a user data
int vtkIdType
Definition: vtkType.h:332