VTK  9.2.5
vtkTemporalInterpolatedVelocityField.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTemporalInterpolatedVelocityField.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 =========================================================================*/
47 #ifndef vtkTemporalInterpolatedVelocityField_h
48 #define vtkTemporalInterpolatedVelocityField_h
49 
50 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
51 #include "vtkFiltersFlowPathsModule.h" // For export macro
52 #include "vtkFunctionSet.h"
53 #include "vtkSmartPointer.h" // For vtkSmartPointer
54 
55 #include <vector> // For internal structures
56 
60 class vtkDataArray;
61 class vtkDataSet;
62 class vtkDoubleArray;
64 class vtkGenericCell;
65 class vtkLocator;
66 class vtkPointData;
67 
68 class VTKFILTERSFLOWPATHS_EXPORT vtkTemporalInterpolatedVelocityField : public vtkFunctionSet
69 {
70 public:
72  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
79 
83  enum IDStates
84  {
85  INSIDE_ALL = 0,
86  OUTSIDE_ALL = 1,
87  OUTSIDE_T0 = 2,
88  OUTSIDE_T1 = 3
89  };
90 
95  {
96  DIFFERENT = 0,
97  STATIC = 1,
98  LINEAR_TRANSFORMATION = 2,
99  SAME_TOPOLOGY = 3
100  };
101 
103  /*
104  * Set/Get the type of variance of the mesh over time.
105  *
106  * DIFFERENT = 0,
107  * STATIC = 1,
108  * LINEAR_TRANSFORMATION = 2
109  * SAME_TOPOLOGY = 3
110  */
111  vtkSetClampMacro(MeshOverTime, int, DIFFERENT, SAME_TOPOLOGY);
112  void SetMeshOverTimeToDifferent() { this->SetMeshOverTime(DIFFERENT); }
113  void SetMeshOverTimeToStatic() { this->SetMeshOverTime(STATIC); }
114  void SetMeshOverTimeToLinearTransformation() { this->SetMeshOverTime(LINEAR_TRANSFORMATION); }
115  void SetMeshOverTimeToSameTopology() { this->SetMeshOverTime(SAME_TOPOLOGY); }
116  vtkGetMacro(MeshOverTime, int);
118 
127 
135 
136  using Superclass::FunctionValues;
138 
142  int FunctionValues(double* x, double* u) override;
143  int FunctionValuesAtT(int T, double* x, double* u);
145 
151  void SelectVectors(const char* fieldName) { this->SetVectorsSelection(fieldName); }
152 
154 
159  void AddDataSetAtTime(int N, double T, vtkDataSet* dataset);
160  VTK_DEPRECATED_IN_9_2_0("Use AddDataSetAtTime and SetMeshOverTime instead")
161  void SetDataSetAtTime(int, int, double, vtkDataSet*, bool) {}
163 
165 
170  bool GetCachedCellIds(vtkIdType id[2], int ds[2]);
171  void SetCachedCellIds(vtkIdType id[2], int ds[2]);
173 
178  void ClearCache();
179 
181 
185  int TestPoint(double* x);
186  int QuickTestPoint(double* x);
188 
190 
194  vtkGetVector3Macro(LastGoodVelocity, double);
196 
198 
201  vtkGetMacro(CurrentWeight, double);
203 
204  bool InterpolatePoint(vtkPointData* outPD1, vtkPointData* outPD2, vtkIdType outIndex);
205 
206  bool InterpolatePoint(int T, vtkPointData* outPD1, vtkIdType outIndex);
207 
209  int T, double pcoords[3], double* weights, vtkGenericCell*& cell, vtkDoubleArray* cellVectors);
210 
212  VTK_DEPRECATED_IN_9_2_0("Use GetMeshOverTime() instead.")
213  bool IsStatic(int) { return this->MeshOverTime == STATIC; }
214 
216 
218 
225  vtkGetObjectMacro(FindCellStrategy, vtkFindCellStrategy);
227 
228 protected:
231 
232  virtual void SetVectorsSelection(const char* v);
233 
234  int MeshOverTime = MeshOverTimeTypes::DIFFERENT;
235 
237  const std::vector<vtkDataSet*>& datasets, vtkFindCellStrategy* strategy,
238  const std::vector<vtkSmartPointer<vtkLocator>>& locators,
240 
241  void CreateLocators(const std::vector<vtkDataSet*>& datasets, vtkFindCellStrategy* strategy,
243  void CreateLinks(const std::vector<vtkDataSet*>& datasets,
246  std::vector<vtkSmartPointer<vtkLocator>>& linearCellLocators);
247 
248  double Vals1[3];
249  double Vals2[3];
250  double Times[2];
251  double LastGoodVelocity[3];
252 
253  static const double WEIGHT_TO_TOLERANCE;
254 
255  // The weight (0.0->1.0) of the value of T between the two available
256  // time values for the current computation
258  // One minus the CurrentWeight
260  // A scaling factor used when calculating the CurrentWeight { 1.0/(T2-T1) }
261  double ScaleCoeff;
262 
264  std::vector<vtkSmartPointer<vtkLocator>> Locators[2];
265  std::vector<vtkSmartPointer<vtkLocator>> InitialCellLocators;
266  std::vector<vtkSmartPointer<vtkAbstractCellLinks>> Links[2];
267  std::vector<size_t> MaxCellSizes[2];
268 
270 
271 private:
272  // Hide this since we need multiple time steps and are using a different
273  // function prototype
274  virtual void AddDataSet(vtkDataSet*) {}
275 
276 private:
278  void operator=(const vtkTemporalInterpolatedVelocityField&) = delete;
279 };
280 
281 #endif
abstract superclass for composite (multi-block or AMR) datasets
An abstract class for obtaining the interpolated velocity values at a point.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
abstract class to specify dataset behavior
Definition: vtkDataSet.h:172
dynamic, self-adjusting array of double
helper class to manage the vtkPointSet::FindCell() METHOD
Abstract interface for sets of functions.
provides thread-safe access to cells
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for objects that accelerate spatial searches
Definition: vtkLocator.h:89
represent and manipulate point attribute data
Definition: vtkPointData.h:151
Hold a reference to a vtkObjectBase instance.
A helper class for interpolating between times during particle tracing.
int QuickTestPoint(double *x)
A utility function which evaluates the point at T1, T2 to see if it is inside the data at both times ...
int TestPoint(double *x)
A utility function which evaluates the point at T1, T2 to see if it is inside the data at both times ...
IDStates
States that define where the cell id are.
void AddDataSetAtTime(int N, double T, vtkDataSet *dataset)
In order to use this class, two sets of data must be supplied, corresponding to times T1 and T2.
MeshOverTimeTypes
Types of Variance of Mesh over time.
virtual void CopyParameters(vtkTemporalInterpolatedVelocityField *from)
Copy essential parameters between instances of this class.
static vtkTemporalInterpolatedVelocityField * New()
Construct a vtkTemporalInterpolatedVelocityField with no initial data set.
bool InterpolatePoint(vtkPointData *outPD1, vtkPointData *outPD2, vtkIdType outIndex)
void SelectVectors(const char *fieldName)
If you want to work with an arbitrary vector array, then set its name here.
virtual void SetVectorsSelection(const char *v)
bool GetVorticityData(int T, double pcoords[3], double *weights, vtkGenericCell *&cell, vtkDoubleArray *cellVectors)
std::vector< vtkSmartPointer< vtkLocator > > InitialCellLocators
bool InterpolatePoint(int T, vtkPointData *outPD1, vtkIdType outIndex)
virtual void SetFindCellStrategy(vtkFindCellStrategy *)
Set / get the strategy used to perform the FindCell() operation.
void SetCachedCellIds(vtkIdType id[2], int ds[2])
Between iterations of the Particle Tracer, Id's of the Cell are stored and then at the start of the n...
bool GetCachedCellIds(vtkIdType id[2], int ds[2])
Between iterations of the Particle Tracer, Id's of the Cell are stored and then at the start of the n...
void CreateLocators(const std::vector< vtkDataSet * > &datasets, vtkFindCellStrategy *strategy, std::vector< vtkSmartPointer< vtkLocator >> &locators)
void CreateLinearTransformCellLocators(const std::vector< vtkSmartPointer< vtkLocator >> &locators, std::vector< vtkSmartPointer< vtkLocator >> &linearCellLocators)
void InitializeWithLocators(vtkCompositeInterpolatedVelocityField *ivf, const std::vector< vtkDataSet * > &datasets, vtkFindCellStrategy *strategy, const std::vector< vtkSmartPointer< vtkLocator >> &locators, const std::vector< vtkSmartPointer< vtkAbstractCellLinks >> &links)
void CreateLinks(const std::vector< vtkDataSet * > &datasets, std::vector< vtkSmartPointer< vtkAbstractCellLinks >> &links)
void ClearCache()
Set the last cell id to -1 so that the next search does not start from the previous cell.
int FunctionValues(double *x, double *u) override
Evaluate the velocity field, f, at (x, y, z, t).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int FunctionValuesAtT(int T, double *x, double *u)
Evaluate the velocity field, f, at (x, y, z, t).
void Initialize(vtkCompositeDataSet *t0, vtkCompositeDataSet *t1)
The Initialize() method is used to build and cache supporting structures (such as locators) which are...
@ vector
Definition: vtkX3D.h:243
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition: vtkType.h:332