VTK  9.0.20200711
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;
84 class vtkPointData;
85 class vtkPolyData;
86 class vtkStringArray;
87 class vtkSurfaceType;
89 
90 class VTKFILTERSFLOWPATHS_EXPORT vtkLagrangianBasicIntegrationModel : public vtkFunctionSet
91 {
92 public:
94  void PrintSelf(ostream& os, vtkIndent indent) override;
95 
96  typedef enum SurfaceType
97  {
98  SURFACE_TYPE_MODEL = 0,
99  SURFACE_TYPE_TERM = 1,
100  SURFACE_TYPE_BOUNCE = 2,
101  SURFACE_TYPE_BREAK = 3,
102  SURFACE_TYPE_PASS = 4
103  } SurfaceType;
104 
105  typedef enum VariableStep
106  {
107  VARIABLE_STEP_PREV = -1,
108  VARIABLE_STEP_CURRENT = 0,
109  VARIABLE_STEP_NEXT = 1,
110  } VariableStep;
111 
112  typedef std::pair<unsigned int, vtkLagrangianParticle*> PassThroughParticlesItem;
113  typedef std::queue<PassThroughParticlesItem> PassThroughParticlesType;
114 
115  using Superclass::FunctionValues;
123  int FunctionValues(double* x, double* f, void* userData) override;
124 
126 
132  virtual void SetLocator(vtkAbstractCellLocator* locator);
133  vtkGetObjectMacro(Locator, vtkAbstractCellLocator);
135 
137 
140  vtkGetMacro(LocatorsBuilt, bool);
141  vtkSetMacro(LocatorsBuilt, bool);
143 
147  virtual void SetTracker(vtkLagrangianParticleTracker* Tracker);
148 
150 
159  virtual void AddDataSet(
160  vtkDataSet* dataset, bool surface = false, unsigned int surfaceFlatIndex = 0);
161  virtual void ClearDataSets(bool surface = false);
163 
165 
168  vtkSetMacro(UseInitialIntegrationTime, bool);
169  vtkGetMacro(UseInitialIntegrationTime, bool);
170  vtkBooleanMacro(UseInitialIntegrationTime, bool);
172 
174 
177  vtkGetMacro(Tolerance, double);
179 
181 
184  vtkGetMacro(LocatorTolerance, double);
186 
204  virtual vtkLagrangianParticle* ComputeSurfaceInteraction(vtkLagrangianParticle* particle,
205  std::queue<vtkLagrangianParticle*>& particles, unsigned int& interactedSurfaceFlatIndex,
206  PassThroughParticlesType& passThroughParticles);
207 
213  virtual void SetInputArrayToProcess(
214  int idx, int port, int connection, int fieldAssociation, const char* name);
215 
225  virtual bool FindInLocators(double* x, vtkLagrangianParticle* particle, vtkDataSet*& dataset,
226  vtkIdType& cellId, vtkAbstractCellLocator*& loc, double*& weights);
227 
229 
233  virtual bool FindInLocators(
234  double* x, vtkLagrangianParticle* particle, vtkDataSet*& dataset, vtkIdType& cellId);
235  virtual bool FindInLocators(double* x, vtkLagrangianParticle* particle);
237 
242  virtual void InitializeParticle(vtkLagrangianParticle* vtkNotUsed(particle)) {}
243 
252  virtual bool CheckAdaptiveStepReintegration(vtkLagrangianParticle* vtkNotUsed(particle))
253  {
254  return true;
255  }
256 
265  virtual bool CheckFreeFlightTermination(vtkLagrangianParticle* vtkNotUsed(particle))
266  {
267  return false;
268  }
269 
271 
274  vtkSetMacro(NonPlanarQuadSupport, bool);
275  vtkGetMacro(NonPlanarQuadSupport, bool);
276  vtkBooleanMacro(NonPlanarQuadSupport, bool);
278 
283  virtual vtkStringArray* GetSeedArrayNames();
284 
289  virtual vtkIntArray* GetSeedArrayComps();
290 
295  virtual vtkIntArray* GetSeedArrayTypes();
296 
301  virtual vtkStringArray* GetSurfaceArrayNames();
302 
307  virtual vtkIntArray* GetSurfaceArrayTypes();
308 
313  virtual vtkStringArray* GetSurfaceArrayEnumValues();
314 
319  virtual vtkDoubleArray* GetSurfaceArrayDefaultValues();
320 
325  virtual vtkIntArray* GetSurfaceArrayComps();
326 
328 
332  virtual int GetWeightsSize();
334 
358  virtual bool ManualIntegration(vtkInitialValueProblemSolver* integrator, double* xcur,
359  double* xnext, double t, double& delT, double& delTActual, double minStep, double maxStep,
360  double maxError, double cellLength, double& error, int& integrationResult,
361  vtkLagrangianParticle* particle);
362 
368  virtual void ParallelManualShift(vtkLagrangianParticle* vtkNotUsed(particle)) {}
369 
374  virtual vtkLagrangianThreadedData* InitializeThreadedData();
375 
380  virtual void FinalizeThreadedData(vtkLagrangianThreadedData*& data);
381 
387  virtual bool FinalizeOutputs(
388  vtkPolyData* vtkNotUsed(particlePathsOutput), vtkDataObject* vtkNotUsed(interractionOutput))
389  {
390  return true;
391  }
392 
396  virtual void PreParticleInitalization() {}
397 
401  virtual void PreIntegrate(std::queue<vtkLagrangianParticle*>& vtkNotUsed(particles)) {}
402 
407  virtual vtkAbstractArray* GetSeedArray(int idx, vtkPointData* pointData);
408 
416  vtkSetMacro(NumberOfTrackedUserData, int);
417  vtkGetMacro(NumberOfTrackedUserData, int);
418 
424  virtual void InitializePathData(vtkFieldData* data);
425 
431  virtual void InitializeInteractionData(vtkFieldData* data);
432 
438  virtual void InitializeParticleData(vtkFieldData* particleData, int maxTuples = 0);
439 
445  virtual void InsertPathData(vtkLagrangianParticle* particle, vtkFieldData* data);
446 
452  virtual void InsertInteractionData(vtkLagrangianParticle* particle, vtkFieldData* data);
453 
460  virtual void InsertParticleData(
461  vtkLagrangianParticle* particle, vtkFieldData* data, int stepEnum);
462 
468  virtual void InsertParticleSeedData(vtkLagrangianParticle* particle, vtkFieldData* data);
469 
476  virtual void ParticleAboutToBeDeleted(vtkLagrangianParticle* vtkNotUsed(particle)) {}
477 
478 protected:
481 
487  virtual int FunctionValues(vtkLagrangianParticle* particle, vtkDataSet* dataSet, vtkIdType cellId,
488  double* weights, double* x, double* f) = 0;
489 
496  virtual vtkIdType FindInLocator(vtkDataSet* dataSet, vtkAbstractCellLocator* locator, double* x,
497  vtkGenericCell* cell, double* weights);
498 
504  virtual bool TerminateParticle(vtkLagrangianParticle* particle);
505 
511  virtual bool BounceParticle(
512  vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId);
513 
521  virtual bool BreakParticle(vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId,
522  std::queue<vtkLagrangianParticle*>& particles);
523 
533  virtual bool InteractWithSurface(int surfaceType, vtkLagrangianParticle* particle,
534  vtkDataSet* surface, vtkIdType cellId, std::queue<vtkLagrangianParticle*>& particles);
535 
542  virtual bool IntersectWithLine(vtkLagrangianParticle* particle, vtkCell* cell, double p1[3],
543  double p2[3], double tol, double& t, double x[3]);
544 
549  virtual void InterpolateNextParticleVariables(
550  vtkLagrangianParticle* particle, double interpolationFactor, bool forceInside = false);
551 
557  virtual bool CheckSurfacePerforation(
558  vtkLagrangianParticle* particle, vtkDataSet* surface, vtkIdType cellId);
559 
566  virtual vtkAbstractArray* GetSeedArray(int idx, vtkLagrangianParticle* particle);
567 
575  virtual bool GetFlowOrSurfaceData(vtkLagrangianParticle* particle, int idx,
576  vtkDataSet* flowDataSet, vtkIdType tupleId, double* weights, double* data);
577 
585  virtual int GetFlowOrSurfaceDataNumberOfComponents(int idx, vtkDataSet* dataSet);
586 
592  virtual int GetFlowOrSurfaceDataFieldAssociation(int idx);
593 
602  virtual void ComputeSurfaceDefaultValues(
603  const char* arrayName, vtkDataSet* dataset, int nComponent, double* defaultValues);
604 
607  vtkLocatorsType* Locators;
608  vtkDataSetsType* DataSets;
609  int WeightsSize = 0;
610 
611  struct ArrayVal
612  {
613  int val[3];
614  };
615  typedef std::pair<ArrayVal, std::string> ArrayMapVal;
616  std::map<int, ArrayMapVal> InputArrays;
617 
618  typedef struct SurfaceArrayDescription
619  {
620  int nComp;
621  int type;
622  std::vector<std::pair<int, std::string>> enumValues;
624  std::map<std::string, SurfaceArrayDescription> SurfaceArrayDescriptions;
625 
626  vtkSurfaceType* Surfaces;
627  vtkLocatorsType* SurfaceLocators;
628 
629  double Tolerance;
630  double LocatorTolerance = 0.001;
633  int NumberOfTrackedUserData = 0;
634 
643 
645  std::mutex ParticleQueueMutex;
646 
647 private:
649  void operator=(const vtkLagrangianBasicIntegrationModel&) = delete;
650 };
651 
652 #endif
vtkLagrangianBasicIntegrationModel::SurfaceLocators
vtkLocatorsType * SurfaceLocators
Definition: vtkLagrangianBasicIntegrationModel.h:627
vtkLagrangianParticleTracker
Filter to inject and track particles in a flow.
Definition: vtkLagrangianParticleTracker.h:117
vtkLagrangianBasicIntegrationModel::SeedArrayComps
vtkNew< vtkIntArray > SeedArrayComps
Definition: vtkLagrangianBasicIntegrationModel.h:636
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:90
vtkLagrangianBasicIntegrationModel::Tolerance
double Tolerance
Definition: vtkLagrangianBasicIntegrationModel.h:629
vtkMultiPieceDataSet
composite dataset to encapsulates pieces of dataset.
Definition: vtkMultiPieceDataSet.h:40
vtkLagrangianBasicIntegrationModel::SurfaceType
SurfaceType
Definition: vtkLagrangianBasicIntegrationModel.h:96
vtkLagrangianBasicIntegrationModel::Locators
vtkLocatorsType * Locators
Definition: vtkLagrangianBasicIntegrationModel.h:607
vtkLagrangianBasicIntegrationModel::SurfaceArrayComps
vtkNew< vtkIntArray > SurfaceArrayComps
Definition: vtkLagrangianBasicIntegrationModel.h:639
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:32
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkLagrangianBasicIntegrationModel::ArrayVal
Definition: vtkLagrangianBasicIntegrationModel.h:611
vtkX3D::data
Definition: vtkX3D.h:321
vtkLagrangianBasicIntegrationModel::DataSets
vtkDataSetsType * DataSets
Definition: vtkLagrangianBasicIntegrationModel.h:608
vtkLagrangianBasicIntegrationModel::CheckFreeFlightTermination
virtual bool CheckFreeFlightTermination(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
Definition: vtkLagrangianBasicIntegrationModel.h:265
vtkLagrangianBasicIntegrationModel::SurfaceArrayNames
vtkNew< vtkStringArray > SurfaceArrayNames
Definition: vtkLagrangianBasicIntegrationModel.h:638
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescriptions
std::map< std::string, SurfaceArrayDescription > SurfaceArrayDescriptions
Definition: vtkLagrangianBasicIntegrationModel.h:624
vtkLagrangianBasicIntegrationModel::VariableStep
VariableStep
Definition: vtkLagrangianBasicIntegrationModel.h:105
vtkLagrangianBasicIntegrationModel::SeedArrayNames
vtkNew< vtkStringArray > SeedArrayNames
Definition: vtkLagrangianBasicIntegrationModel.h:635
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription::nComp
int nComp
Definition: vtkLagrangianBasicIntegrationModel.h:620
vtkFunctionSet.h
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkLagrangianBasicIntegrationModel::Surfaces
vtkSurfaceType * Surfaces
Definition: vtkLagrangianBasicIntegrationModel.h:626
vtkLagrangianBasicIntegrationModel::PreIntegrate
virtual void PreIntegrate(std::queue< vtkLagrangianParticle * > &vtkNotUsed(particles))
Enable model to modify particle before integration.
Definition: vtkLagrangianBasicIntegrationModel.h:401
vtkMultiBlockDataSet
Composite dataset that organizes datasets into blocks.
Definition: vtkMultiBlockDataSet.h:45
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.
vtkX3D::port
Definition: vtkX3D.h:453
vtkLagrangianBasicIntegrationModel::UseInitialIntegrationTime
bool UseInitialIntegrationTime
Definition: vtkLagrangianBasicIntegrationModel.h:632
vtkLagrangianBasicIntegrationModel::ArrayMapVal
std::pair< ArrayVal, std::string > ArrayMapVal
Definition: vtkLagrangianBasicIntegrationModel.h:615
vtkLagrangianBasicIntegrationModel::ParticleAboutToBeDeleted
virtual void ParticleAboutToBeDeleted(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
Definition: vtkLagrangianBasicIntegrationModel.h:476
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription
Definition: vtkLagrangianBasicIntegrationModel.h:618
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:242
vtkLagrangianBasicIntegrationModel::PassThroughParticlesType
std::queue< PassThroughParticlesItem > PassThroughParticlesType
Definition: vtkLagrangianBasicIntegrationModel.h:113
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:57
vtkLagrangianBasicIntegrationModel::InputArrays
std::map< int, ArrayMapVal > InputArrays
Definition: vtkLagrangianBasicIntegrationModel.h:616
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
vtkLagrangianThreadedData
struct to hold a user data
Definition: vtkLagrangianThreadedData.h:35
vtkLagrangianBasicIntegrationModel::SurfaceArrayEnumValues
vtkNew< vtkStringArray > SurfaceArrayEnumValues
Definition: vtkLagrangianBasicIntegrationModel.h:641
vtkNew< vtkStringArray >
vtkWeakPointer.h
vtkLagrangianBasicIntegrationModel::PassThroughParticlesItem
std::pair< unsigned int, vtkLagrangianParticle * > PassThroughParticlesItem
Definition: vtkLagrangianBasicIntegrationModel.h:112
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:46
vtkX3D::name
Definition: vtkX3D.h:225
vtkLagrangianBasicIntegrationModel::SurfaceArrayDefaultValues
vtkNew< vtkDoubleArray > SurfaceArrayDefaultValues
Definition: vtkLagrangianBasicIntegrationModel.h:642
vtkLagrangianBasicIntegrationModel::Locator
vtkAbstractCellLocator * Locator
Definition: vtkLagrangianBasicIntegrationModel.h:605
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:606
vtkLagrangianBasicIntegrationModel::CheckAdaptiveStepReintegration
virtual bool CheckAdaptiveStepReintegration(vtkLagrangianParticle *vtkNotUsed(particle))
Method to be reimplemented if needed in inherited classes.
Definition: vtkLagrangianBasicIntegrationModel.h:252
vtkLagrangianBasicIntegrationModel::PreParticleInitalization
virtual void PreParticleInitalization()
Allow for model setup prior to Particle Initalization.
Definition: vtkLagrangianBasicIntegrationModel.h:396
vtkNew.h
vtkLagrangianBasicIntegrationModel::ParticleQueueMutex
std::mutex ParticleQueueMutex
Definition: vtkLagrangianBasicIntegrationModel.h:645
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:387
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:36
vtkLagrangianBasicIntegrationModel::SeedArrayTypes
vtkNew< vtkIntArray > SeedArrayTypes
Definition: vtkLagrangianBasicIntegrationModel.h:637
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:631
vtkLagrangianBasicIntegrationModel::SurfaceArrayTypes
vtkNew< vtkIntArray > SurfaceArrayTypes
Definition: vtkLagrangianBasicIntegrationModel.h:640
vtkLagrangianBasicIntegrationModel::Tracker
vtkWeakPointer< vtkLagrangianParticleTracker > Tracker
Definition: vtkLagrangianBasicIntegrationModel.h:644
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:59
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription::enumValues
std::vector< std::pair< int, std::string > > enumValues
Definition: vtkLagrangianBasicIntegrationModel.h:622
vtkLagrangianBasicIntegrationModel::SurfaceArrayDescription::type
int type
Definition: vtkLagrangianBasicIntegrationModel.h:621
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:368