VTK  9.3.1
vtkTemporalInterpolatedVelocityField.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
35 #ifndef vtkTemporalInterpolatedVelocityField_h
36 #define vtkTemporalInterpolatedVelocityField_h
37 
38 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
39 #include "vtkFiltersFlowPathsModule.h" // For export macro
40 #include "vtkFunctionSet.h"
41 #include "vtkSmartPointer.h" // For vtkSmartPointer
42 
43 #include <vector> // For internal structures
44 
45 VTK_ABI_NAMESPACE_BEGIN
49 class vtkDataArray;
50 class vtkDataSet;
51 class vtkDoubleArray;
53 class vtkGenericCell;
54 class vtkLocator;
55 class vtkPointData;
56 
57 class VTKFILTERSFLOWPATHS_EXPORT vtkTemporalInterpolatedVelocityField : public vtkFunctionSet
58 {
59 public:
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
68 
72  enum IDStates
73  {
74  INSIDE_ALL = 0,
75  OUTSIDE_ALL = 1,
76  OUTSIDE_T0 = 2,
77  OUTSIDE_T1 = 3
78  };
79 
84  {
85  DIFFERENT = 0,
86  STATIC = 1,
87  LINEAR_TRANSFORMATION = 2,
88  SAME_TOPOLOGY = 3
89  };
90 
92  /*
93  * Set/Get the type of variance of the mesh over time.
94  *
95  * DIFFERENT = 0,
96  * STATIC = 1,
97  * LINEAR_TRANSFORMATION = 2
98  * SAME_TOPOLOGY = 3
99  */
100  vtkSetClampMacro(MeshOverTime, int, DIFFERENT, SAME_TOPOLOGY);
101  void SetMeshOverTimeToDifferent() { this->SetMeshOverTime(DIFFERENT); }
102  void SetMeshOverTimeToStatic() { this->SetMeshOverTime(STATIC); }
103  void SetMeshOverTimeToLinearTransformation() { this->SetMeshOverTime(LINEAR_TRANSFORMATION); }
104  void SetMeshOverTimeToSameTopology() { this->SetMeshOverTime(SAME_TOPOLOGY); }
105  vtkGetMacro(MeshOverTime, int);
107 
115  void Initialize(vtkCompositeDataSet* t0, vtkCompositeDataSet* t1);
116 
123  virtual void CopyParameters(vtkTemporalInterpolatedVelocityField* from);
124 
125  using Superclass::FunctionValues;
127 
131  int FunctionValues(double* x, double* u) override;
132  int FunctionValuesAtT(int T, double* x, double* u);
134 
140  void SelectVectors(const char* fieldName) { this->SetVectorsSelection(fieldName); }
141 
143 
148  void AddDataSetAtTime(int N, double T, vtkDataSet* dataset);
149  VTK_DEPRECATED_IN_9_2_0("Use AddDataSetAtTime and SetMeshOverTime instead")
150  void SetDataSetAtTime(int, int, double, vtkDataSet*, bool) {}
152 
154 
159  bool GetCachedCellIds(vtkIdType id[2], int ds[2]);
160  void SetCachedCellIds(vtkIdType id[2], int ds[2]);
162 
167  void ClearCache();
168 
170 
174  int TestPoint(double* x);
175  int QuickTestPoint(double* x);
177 
179 
183  vtkGetVector3Macro(LastGoodVelocity, double);
185 
187 
190  vtkGetMacro(CurrentWeight, double);
192 
193  bool InterpolatePoint(vtkPointData* outPD1, vtkPointData* outPD2, vtkIdType outIndex);
194 
195  bool InterpolatePoint(int T, vtkPointData* outPD1, vtkIdType outIndex);
196 
197  bool GetVorticityData(
198  int T, double pcoords[3], double* weights, vtkGenericCell*& cell, vtkDoubleArray* cellVectors);
199 
200  void ShowCacheResults();
201  VTK_DEPRECATED_IN_9_2_0("Use GetMeshOverTime() instead.")
202  bool IsStatic(int) { return this->MeshOverTime == STATIC; }
203 
204  void AdvanceOneTimeStep();
205 
207 
213  virtual void SetFindCellStrategy(vtkFindCellStrategy*);
214  vtkGetObjectMacro(FindCellStrategy, vtkFindCellStrategy);
216 
217 protected:
220 
221  virtual void SetVectorsSelection(const char* v);
222 
223  int MeshOverTime = MeshOverTimeTypes::DIFFERENT;
224 
225  void InitializeWithLocators(vtkCompositeInterpolatedVelocityField* ivf,
226  const std::vector<vtkDataSet*>& datasets, vtkFindCellStrategy* strategy,
227  const std::vector<vtkSmartPointer<vtkLocator>>& locators,
229 
230  void CreateLocators(const std::vector<vtkDataSet*>& datasets, vtkFindCellStrategy* strategy,
232  void CreateLinks(const std::vector<vtkDataSet*>& datasets,
234  void CreateLinearTransformCellLocators(const std::vector<vtkSmartPointer<vtkLocator>>& locators,
235  std::vector<vtkSmartPointer<vtkLocator>>& linearCellLocators);
236 
237  double Vals1[3];
238  double Vals2[3];
239  double Times[2];
240  double LastGoodVelocity[3];
241 
242  static const double WEIGHT_TO_TOLERANCE;
243 
244  // The weight (0.0->1.0) of the value of T between the two available
245  // time values for the current computation
247  // One minus the CurrentWeight
249  // A scaling factor used when calculating the CurrentWeight { 1.0/(T2-T1) }
250  double ScaleCoeff;
251 
253  std::vector<vtkSmartPointer<vtkLocator>> Locators[2];
254  std::vector<vtkSmartPointer<vtkLocator>> InitialCellLocators;
255  std::vector<vtkSmartPointer<vtkAbstractCellLinks>> Links[2];
256  std::vector<size_t> MaxCellSizes[2];
257 
259 
260 private:
261  // Hide this since we need multiple time steps and are using a different
262  // function prototype
263  virtual void AddDataSet(vtkDataSet*) {}
264 
266  void operator=(const vtkTemporalInterpolatedVelocityField&) = delete;
267 };
268 
269 VTK_ABI_NAMESPACE_END
270 #endif
A helper class for interpolating between times during particle tracing.
represent and manipulate point attribute data
Definition: vtkPointData.h:29
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
MeshOverTimeTypes
Types of Variance of Mesh over time.
#define VTK_DEPRECATED_IN_9_2_0(reason)
IDStates
States that define where the cell id are.
abstract base class for objects that accelerate spatial searches
Definition: vtkLocator.h:58
std::vector< vtkSmartPointer< vtkLocator > > InitialCellLocators
An abstract class for obtaining the interpolated velocity values at a point.
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
int vtkIdType
Definition: vtkType.h:315
provides thread-safe access to cells
dynamic, self-adjusting array of double
helper class to manage the vtkPointSet::FindCell() METHOD
void SelectVectors(const char *fieldName)
If you want to work with an arbitrary vector array, then set its name here.
abstract superclass for composite (multi-block or AMR) datasets
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
Abstract interface for sets of functions.
virtual int FunctionValues(double *x, double *f)
Evaluate functions at x_j.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...