VTK
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 =========================================================================*/
54 #ifndef vtkLagrangianBasicIntegrationModel_h
55 #define vtkLagrangianBasicIntegrationModel_h
56 
57 #include "vtkFiltersFlowPathsModule.h" // For export macro
58 #include "vtkFunctionSet.h"
59 #include "vtkNew.h" // For arrays
60 #include "vtkWeakPointer.h" // For weak pointer
61 
62 #include <map> // for array indexes
63 #include <mutex> // for mutexes
64 #include <queue> // for new particles
65 
66 class vtkAbstractArray;
68 class vtkCell;
69 class vtkCellData;
70 class vtkDataArray;
71 class vtkDataObject;
72 class vtkDataSet;
73 class vtkDataSetsType;
74 class vtkDoubleArray;
75 class vtkFieldData;
76 class vtkGenericCell;
78 class vtkIntArray;
81 class vtkLocatorsType;
82 class vtkPointData;
83 class vtkPolyData;
84 class vtkStringArray;
85 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 
194  virtual vtkLagrangianParticle* ComputeSurfaceInteraction(vtkLagrangianParticle* particle,
195  std::queue<vtkLagrangianParticle*>& particles, unsigned int& interactedSurfaceFlatIndex,
196  PassThroughParticlesType& passThroughParticles);
197 
203  virtual void SetInputArrayToProcess(
204  int idx, int port, int connection, int fieldAssociation, const char* name);
205 
207 
216  virtual bool FindInLocators(double* x, vtkLagrangianParticle* particle, vtkDataSet*& dataset,
217  vtkIdType& cellId, vtkAbstractCellLocator*& loc, double*& weights);
218  virtual bool FindInLocators(
219  double* x, vtkLagrangianParticle* particle, vtkDataSet*& dataset, vtkIdType& cellId);
220  virtual bool FindInLocators(double* x, vtkLagrangianParticle* particle = nullptr);
222 
227  virtual void InitializeParticle(vtkLagrangianParticle* vtkNotUsed(particle)) {}
228 
237  virtual bool CheckAdaptiveStepReintegration(vtkLagrangianParticle* vtkNotUsed(particle))
238  {
239  return true;
240  }
241 
250  virtual bool CheckFreeFlightTermination(vtkLagrangianParticle* vtkNotUsed(particle))
251  {
252  return false;
253  }
254 
256 
259  vtkSetMacro(NonPlanarQuadSupport, bool);
260  vtkGetMacro(NonPlanarQuadSupport, bool);
261  vtkBooleanMacro(NonPlanarQuadSupport, bool);
263 
268  virtual vtkStringArray* GetSeedArrayNames();
269 
274  virtual vtkIntArray* GetSeedArrayComps();
275 
280  virtual vtkIntArray* GetSeedArrayTypes();
281 
286  virtual vtkStringArray* GetSurfaceArrayNames();
287 
292  virtual vtkIntArray* GetSurfaceArrayTypes();
293 
298  virtual vtkStringArray* GetSurfaceArrayEnumValues();
299 
304  virtual vtkDoubleArray* GetSurfaceArrayDefaultValues();
305 
310  virtual vtkIntArray* GetSurfaceArrayComps();
311 
313 
317  vtkGetMacro(WeightsSize, int);
319 
343  virtual bool ManualIntegration(vtkInitialValueProblemSolver* integrator, double* xcur,
344  double* xnext, double t, double& delT, double& delTActual, double minStep, double maxStep,
345  double maxError, double cellLength, double& error, int& integrationResult,
346  vtkLagrangianParticle* particle);
347 
353  virtual void ParallelManualShift(vtkLagrangianParticle* vtkNotUsed(particle)) {}
354 
360  virtual bool FinalizeOutputs(
361  vtkPolyData* vtkNotUsed(particlePathsOutput), vtkDataObject* vtkNotUsed(interractionOutput))
362  {
363  return true;
364  }
365 
369  virtual void PreIntegrate(std::queue<vtkLagrangianParticle*>& vtkNotUsed(particles)) {}
370 
375  virtual vtkAbstractArray* GetSeedArray(int idx, vtkPointData* pointData);
376 
384  vtkSetMacro(NumberOfTrackedUserData, int);
385  vtkGetMacro(NumberOfTrackedUserData, int);
386 
392  virtual void InitializePathData(vtkFieldData* data);
393 
399  virtual void InitializeInteractionData(vtkFieldData* data);
400 
406  virtual void InitializeParticleData(vtkFieldData* particleData, int maxTuples = 0);
407 
413  virtual void InsertPathData(vtkLagrangianParticle* particle, vtkFieldData* data);
414 
420  virtual void InsertInteractionData(vtkLagrangianParticle* particle, vtkFieldData* data);
421 
428  virtual void InsertParticleData(
429  vtkLagrangianParticle* particle, vtkFieldData* data, int stepEnum);
430 
436  virtual void InsertSeedData(vtkLagrangianParticle* particle, vtkFieldData* data);
437 
444  virtual void ParticleAboutToBeDeleted(vtkLagrangianParticle* vtkNotUsed(particle)) {}
445 
446 protected:
449 
455  virtual int FunctionValues(vtkLagrangianParticle* particle, vtkDataSet* dataSet, vtkIdType cellId,
456  double* weights, double* x, double* f) = 0;
457 
464  virtual vtkIdType FindInLocator(vtkDataSet* dataSet, vtkAbstractCellLocator* locator, double* x,
465  vtkGenericCell* cell, double* weights);
466 
472  virtual bool TerminateParticle(vtkLagrangianParticle* particle);
473 
479  virtual bool BounceParticle(
480  vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId);
481 
489  virtual bool BreakParticle(vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId,
490  std::queue<vtkLagrangianParticle*>& particles);
491 
501  virtual bool InteractWithSurface(int surfaceType, vtkLagrangianParticle* particle,
502  vtkDataSet* surface, vtkIdType cellId, std::queue<vtkLagrangianParticle*>& particles);
503 
510  virtual bool IntersectWithLine(
511  vtkCell* cell, double p1[3], double p2[3], double tol, double& t, double x[3]);
512 
517  virtual void InterpolateNextParticleVariables(
518  vtkLagrangianParticle* particle, double interpolationFactor, bool forceInside = false);
519 
525  virtual bool CheckSurfacePerforation(
526  vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId);
527 
535  virtual vtkAbstractArray* GetSeedArray(int idx, vtkLagrangianParticle* particle);
536 
544  virtual bool GetFlowOrSurfaceData(
545  int idx, vtkDataSet* flowDataSet, vtkIdType tupleId, double* weights, double* data);
546 
554  virtual int GetFlowOrSurfaceDataNumberOfComponents(int idx, vtkDataSet* dataSet);
555 
561  virtual int GetFlowOrSurfaceDataFieldAssociation(int idx);
562 
571  virtual void ComputeSurfaceDefaultValues(
572  const char* arrayName, vtkDataSet* dataset, int nComponent, double* defaultValues);
573 
576  vtkLocatorsType* Locators;
577  vtkDataSetsType* DataSets;
579 
580  struct ArrayVal
581  {
582  int val[3];
583  };
584  typedef std::pair<ArrayVal, std::string> ArrayMapVal;
585  std::map<int, ArrayMapVal> InputArrays;
586 
587  typedef struct SurfaceArrayDescription
588  {
589  int nComp;
590  int type;
591  std::vector<std::pair<int, std::string> > enumValues;
593  std::map<std::string, SurfaceArrayDescription> SurfaceArrayDescriptions;
594 
595  vtkSurfaceType* Surfaces;
596  vtkLocatorsType* SurfaceLocators;
597 
598  double Tolerance;
601  int NumberOfTrackedUserData = 0;
602 
611 
613  std::mutex ParticleQueueMutex;
614 
615 private:
617  void operator=(const vtkLagrangianBasicIntegrationModel&) = delete;
618 };
619 
620 #endif
vtkLagrangianBasicIntegrationModel::SurfaceLocators
vtkLocatorsType * SurfaceLocators
Definition: vtkLagrangianBasicIntegrationModel.h:596
vtkLagrangianParticleTracker
Filter to inject and track particles in a flow.
Definition: vtkLagrangianParticleTracker.h:113
vtkLagrangianBasicIntegrationModel::SeedArrayComps
vtkNew< vtkIntArray > SeedArrayComps
Definition: vtkLagrangianBasicIntegrationModel.h:604
vtkFunctionSet
Abstract interface for sets of functions.
Definition: vtkFunctionSet.h:35
vtkLagrangianBasicIntegrationModel
vtkFunctionSet abstract implementation to be used in the vtkLagrangianParticleTracker integrator.
Definition: vtkLagrangianBasicIntegrationModel.h:87
vtkLagrangianBasicIntegrationModel::Tolerance
double Tolerance
Definition: vtkLagrangianBasicIntegrationModel.h:598
vtkLagrangianBasicIntegrationModel::SurfaceType
SurfaceType
Definition: vtkLagrangianBasicIntegrationModel.h:93
vtkLagrangianBasicIntegrationModel::Locators
vtkLocatorsType * Locators
Definition: vtkLagrangianBasicIntegrationModel.h:576
vtkLagrangianBasicIntegrationModel::SurfaceArrayComps
vtkNew< vtkIntArray > SurfaceArrayComps
Definition: vtkLagrangianBasicIntegrationModel.h:607
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:31
vtkIdType
int vtkIdType
Definition: vtkType.h:349
vtkLagrangianBasicIntegrationModel::ArrayVal
Definition: vtkLagrangianBasicIntegrationModel.h:580
vtkX3D::data
Definition: vtkX3D.h:321
vtkLagrangianBasicIntegrationModel::DataSets
vtkDataSetsType * DataSets
Definition: vtkLagrangianBasicIntegrationModel.h:577
vtkLagrangianBasicIntegrationModel::CheckFreeFlightTermination
virtual bool CheckFreeFlightTermination(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
Definition: vtkLagrangianBasicIntegrationModel.h:250
vtkLagrangianBasicIntegrationModel::SurfaceArrayNames
vtkNew< vtkStringArray > SurfaceArrayNames
Definition: vtkLagrangianBasicIntegrationModel.h:606
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescriptions
std::map< std::string, SurfaceArrayDescription > SurfaceArrayDescriptions
Definition: vtkLagrangianBasicIntegrationModel.h:593
vtkLagrangianBasicIntegrationModel::VariableStep
VariableStep
Definition: vtkLagrangianBasicIntegrationModel.h:102
vtkLagrangianBasicIntegrationModel::SeedArrayNames
vtkNew< vtkStringArray > SeedArrayNames
Definition: vtkLagrangianBasicIntegrationModel.h:603
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription::nComp
int nComp
Definition: vtkLagrangianBasicIntegrationModel.h:589
vtkFunctionSet.h
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkLagrangianBasicIntegrationModel::Surfaces
vtkSurfaceType * Surfaces
Definition: vtkLagrangianBasicIntegrationModel.h:595
vtkLagrangianBasicIntegrationModel::PreIntegrate
virtual void PreIntegrate(std::queue< vtkLagrangianParticle * > &vtkNotUsed(particles))
Enable model to modify particle before integration.
Definition: vtkLagrangianBasicIntegrationModel.h:369
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:53
vtkFunctionSet::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkLagrangianBasicIntegrationModel::WeightsSize
int WeightsSize
Definition: vtkLagrangianBasicIntegrationModel.h:578
vtkX3D::port
Definition: vtkX3D.h:453
vtkLagrangianBasicIntegrationModel::UseInitialIntegrationTime
bool UseInitialIntegrationTime
Definition: vtkLagrangianBasicIntegrationModel.h:600
vtkLagrangianBasicIntegrationModel::ArrayMapVal
std::pair< ArrayVal, std::string > ArrayMapVal
Definition: vtkLagrangianBasicIntegrationModel.h:584
vtkLagrangianBasicIntegrationModel::ParticleAboutToBeDeleted
virtual void ParticleAboutToBeDeleted(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
Definition: vtkLagrangianBasicIntegrationModel.h:444
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription
Definition: vtkLagrangianBasicIntegrationModel.h:587
vtkLagrangianBasicIntegrationModel::InitializeParticle
virtual void InitializeParticle(vtkLagrangianParticle *vtkNotUsed(particle))
Initialize a particle by setting user variables and perform any user model specific operation.
Definition: vtkLagrangianBasicIntegrationModel.h:227
vtkLagrangianBasicIntegrationModel::PassThroughParticlesType
std::queue< PassThroughParticlesItem > PassThroughParticlesType
Definition: vtkLagrangianBasicIntegrationModel.h:110
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:56
vtkLagrangianBasicIntegrationModel::InputArrays
std::map< int, ArrayMapVal > InputArrays
Definition: vtkLagrangianBasicIntegrationModel.h:585
vtkCellData
represent and manipulate cell attribute data
Definition: vtkCellData.h:32
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkLagrangianBasicIntegrationModel::SurfaceArrayEnumValues
vtkNew< vtkStringArray > SurfaceArrayEnumValues
Definition: vtkLagrangianBasicIntegrationModel.h:609
vtkNew< vtkStringArray >
vtkWeakPointer.h
vtkLagrangianBasicIntegrationModel::PassThroughParticlesItem
std::pair< unsigned int, vtkLagrangianParticle * > PassThroughParticlesItem
Definition: vtkLagrangianBasicIntegrationModel.h:109
vtkFunctionSet::FunctionValues
virtual int FunctionValues(double *x, double *f)
Evaluate functions at x_j.
Definition: vtkFunctionSet.h:49
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:48
vtkLagrangianParticle
Basis class for Lagrangian particles.
Definition: vtkLagrangianParticle.h:41
vtkX3D::name
Definition: vtkX3D.h:225
vtkLagrangianBasicIntegrationModel::SurfaceArrayDefaultValues
vtkNew< vtkDoubleArray > SurfaceArrayDefaultValues
Definition: vtkLagrangianBasicIntegrationModel.h:610
vtkLagrangianBasicIntegrationModel::Locator
vtkAbstractCellLocator * Locator
Definition: vtkLagrangianBasicIntegrationModel.h:574
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkLagrangianBasicIntegrationModel::LocatorsBuilt
bool LocatorsBuilt
Definition: vtkLagrangianBasicIntegrationModel.h:575
vtkLagrangianBasicIntegrationModel::CheckAdaptiveStepReintegration
virtual bool CheckAdaptiveStepReintegration(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
Definition: vtkLagrangianBasicIntegrationModel.h:237
vtkNew.h
vtkLagrangianBasicIntegrationModel::ParticleQueueMutex
std::mutex ParticleQueueMutex
Definition: vtkLagrangianBasicIntegrationModel.h:613
vtkLagrangianBasicIntegrationModel::FinalizeOutputs
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...
Definition: vtkLagrangianBasicIntegrationModel.h:360
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:36
vtkLagrangianBasicIntegrationModel::SeedArrayTypes
vtkNew< vtkIntArray > SeedArrayTypes
Definition: vtkLagrangianBasicIntegrationModel.h:605
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:36
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkLagrangianBasicIntegrationModel::NonPlanarQuadSupport
bool NonPlanarQuadSupport
Definition: vtkLagrangianBasicIntegrationModel.h:599
vtkLagrangianBasicIntegrationModel::SurfaceArrayTypes
vtkNew< vtkIntArray > SurfaceArrayTypes
Definition: vtkLagrangianBasicIntegrationModel.h:608
vtkLagrangianBasicIntegrationModel::Tracker
vtkWeakPointer< vtkLagrangianParticleTracker > Tracker
Definition: vtkLagrangianBasicIntegrationModel.h:612
vtkInitialValueProblemSolver
Integrate a set of ordinary differential equations (initial value problem) in time.
Definition: vtkInitialValueProblemSolver.h:40
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription::enumValues
std::vector< std::pair< int, std::string > > enumValues
Definition: vtkLagrangianBasicIntegrationModel.h:591
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription::type
int type
Definition: vtkLagrangianBasicIntegrationModel.h:590
vtkWeakPointer< vtkLagrangianParticleTracker >
vtkLagrangianBasicIntegrationModel::ParallelManualShift
virtual void ParallelManualShift(vtkLagrangianParticle *vtkNotUsed(particle))
Method called by parallel algorithm after receiving a particle from stream if PManualShift flag has b...
Definition: vtkLagrangianBasicIntegrationModel.h:353