VMTK
Loading...
Searching...
No Matches
vtkvmtkStaticTemporalInterpolatedVelocityField Class Reference

Evaluates an interpolated velocity field from a time-tabulated, temporally piecewise-linear velocity field sampled on a fixed (non-moving) mesh. More...

#include <vtkvmtkStaticTemporalInterpolatedVelocityField.h>

Inheritance diagram for vtkvmtkStaticTemporalInterpolatedVelocityField:
[legend]
Collaboration diagram for vtkvmtkStaticTemporalInterpolatedVelocityField:
[legend]

Public Types

typedef vtkInterpolatedVelocityField Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkStaticTemporalInterpolatedVelocityField * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetLastCellId (vtkIdType c, int dataindex) override
virtual void CopyParameters (vtkAbstractInterpolatedVelocityField *from) override
virtual vtkTable * GetTimeStepsTable ()
virtual void SetTimeStepsTable (vtkTable *)
virtual void SetPeriodic (int)
virtual int GetPeriodic ()
virtual void PeriodicOn ()
virtual void PeriodicOff ()
virtual void SetVelocityScale (double)
virtual double GetVelocityScale ()
virtual void SetUseVectorComponents (int)
virtual int GetUseVectorComponents ()
virtual void UseVectorComponentsOn ()
virtual void UseVectorComponentsOff ()
virtual void SetVectorPrefix (const char *)
virtual char * GetVectorPrefix ()
virtual void SetComponent0Prefix (const char *)
virtual char * GetComponent0Prefix ()
virtual void SetComponent1Prefix (const char *)
virtual char * GetComponent1Prefix ()
virtual void SetComponent2Prefix (const char *)
virtual char * GetComponent2Prefix ()
virtual void SetLastCellId (vtkIdType c) override

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkStaticTemporalInterpolatedVelocityField * SafeDownCast (vtkObjectBase *o)
static vtkvmtkStaticTemporalInterpolatedVelocityField * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkStaticTemporalInterpolatedVelocityField ()
 ~vtkvmtkStaticTemporalInterpolatedVelocityField ()
virtual int FunctionValues (vtkDataSet *ds, double *x, double *f) override
void FindTimeRowId (double time, int &prevRowId, int &nextRowId, double &p)
void BuildArrayName (char *prefix, int index, char *name)

Protected Attributes

vtkTable * TimeStepsTable
int Periodic
double VelocityScale
int UseVectorComponents
char * VectorPrefix
char * Component0Prefix
char * Component1Prefix
char * Component2Prefix
int LastDataSetIndex

Detailed Description

Evaluates an interpolated velocity field from a time-tabulated, temporally piecewise-linear velocity field sampled on a fixed (non-moving) mesh.

This class extends VTK's interpolated velocity field machinery (vtkInterpolatedVelocityField on VTK < 9.2, vtkCompositeInterpolatedVelocityField on VTK >= 9.2) so that, in addition to spatial interpolation within the dataset's cells, it also interpolates in time between a discrete set of time steps whose velocity samples are stored as separate point data arrays on the same static mesh (hence "static": the mesh connectivity/geometry does not change over time, only the velocity values attached to it do). TimeStepsTable maps each time step index to a time value; FunctionValues looks up, for a query point (x,y,z,t), which two consecutive time steps bracket t (wrapping around if Periodic is on) and linearly interpolates in time between the spatially-interpolated velocity at each of them. Velocity samples can be provided either as a single 3-component vector array per time step (named with VectorPrefix followed by the time step index) or as three separate scalar component arrays per time step (named with Component0Prefix/Component1Prefix/Component2Prefix followed by the time step index), selected with UseVectorComponents.

This is the velocity field evaluator used by vtkvmtkStaticTemporalStreamTracer (and, through it, the vmtkparticletracer pype script) to trace particle/streak lines through unsteady (e.g. CFD) flow fields sampled at discrete time points on a fixed mesh.

See also
vtkvmtkStaticTemporalStreamTracer

Definition at line 77 of file vtkvmtkStaticTemporalInterpolatedVelocityField.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkStaticTemporalInterpolatedVelocityField()

vtkvmtkStaticTemporalInterpolatedVelocityField::vtkvmtkStaticTemporalInterpolatedVelocityField ( )
protected

Definition at line 34 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

35{
36 this->Periodic = 0;
37 this->VelocityScale = 1.0;
38 this->TimeStepsTable = NULL;
39 this->UseVectorComponents = 0;
40 this->VectorPrefix = NULL;
41 this->Component0Prefix = NULL;
42 this->Component1Prefix = NULL;
43 this->Component2Prefix = NULL;
44#if VMTK_VTK_HAS_REWORKED_IVF
45 this->TemporalGenCell = vtkGenericCell::New();
46 this->TemporalCell = vtkGenericCell::New();
47#endif
48}

◆ ~vtkvmtkStaticTemporalInterpolatedVelocityField()

vtkvmtkStaticTemporalInterpolatedVelocityField::~vtkvmtkStaticTemporalInterpolatedVelocityField ( )
protected

Definition at line 50 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

51{
52 if (this->VectorPrefix) {
53 delete[] this->VectorPrefix;
54 this->VectorPrefix = NULL;
55 }
56
57 if (this->Component0Prefix) {
58 delete[] this->Component0Prefix;
59 this->Component0Prefix = NULL;
60 }
61
62 if (this->Component1Prefix) {
63 delete[] this->Component1Prefix;
64 this->Component1Prefix = NULL;
65 }
66
67 if (this->Component2Prefix) {
68 delete[] this->Component2Prefix;
69 this->Component2Prefix = NULL;
70 }
71
72 this->SetTimeStepsTable(NULL);
73
74#if VMTK_VTK_HAS_REWORKED_IVF
75 this->TemporalGenCell->Delete();
76 this->TemporalCell->Delete();
77#endif
78}

Member Function Documentation

◆ IsTypeOf()

int vtkvmtkStaticTemporalInterpolatedVelocityField::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkStaticTemporalInterpolatedVelocityField::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkStaticTemporalInterpolatedVelocityField * vtkvmtkStaticTemporalInterpolatedVelocityField::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkStaticTemporalInterpolatedVelocityField::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkStaticTemporalInterpolatedVelocityField * vtkvmtkStaticTemporalInterpolatedVelocityField::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkStaticTemporalInterpolatedVelocityField::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 419 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

420{
421 this->Superclass::PrintSelf( os, indent );
422}

◆ New()

vtkvmtkStaticTemporalInterpolatedVelocityField * vtkvmtkStaticTemporalInterpolatedVelocityField::New ( )
static

Construct a vtkvmtkStaticTemporalInterpolatedVelocityField without an initial dataset. Caching is set on and LastCellId is set to -1.

◆ GetTimeStepsTable()

virtual vtkTable * vtkvmtkStaticTemporalInterpolatedVelocityField::GetTimeStepsTable ( )
virtual

Set/Get the table mapping time step index to time value, used to interpolate in time. The table must have (at least) two columns: column 0 holds the integer time step index appended to the array name prefixes (VectorPrefix, or Component0Prefix/Component1Prefix/ Component2Prefix) to look up each time step's velocity array(s), and column 1 holds the corresponding time value, with rows in increasing time order (need not be evenly spaced).

◆ SetTimeStepsTable()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetTimeStepsTable ( vtkTable * )
virtual

Set/Get the table mapping time step index to time value, used to interpolate in time. The table must have (at least) two columns: column 0 holds the integer time step index appended to the array name prefixes (VectorPrefix, or Component0Prefix/Component1Prefix/ Component2Prefix) to look up each time step's velocity array(s), and column 1 holds the corresponding time value, with rows in increasing time order (need not be evenly spaced).

◆ SetPeriodic()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetPeriodic ( int )
virtual

Toggle whether time values are treated as periodic, i.e. wrapped modulo the span between the first and last row of TimeStepsTable, so that a query time beyond the last time step maps back into range (useful for cyclic flows, e.g. one cardiac cycle). When off, query times at or beyond the last time step use the last time interval with no extrapolation. Default: off.

◆ GetPeriodic()

virtual int vtkvmtkStaticTemporalInterpolatedVelocityField::GetPeriodic ( )
virtual

Toggle whether time values are treated as periodic, i.e. wrapped modulo the span between the first and last row of TimeStepsTable, so that a query time beyond the last time step maps back into range (useful for cyclic flows, e.g. one cardiac cycle). When off, query times at or beyond the last time step use the last time interval with no extrapolation. Default: off.

◆ PeriodicOn()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::PeriodicOn ( )
virtual

Toggle whether time values are treated as periodic, i.e. wrapped modulo the span between the first and last row of TimeStepsTable, so that a query time beyond the last time step maps back into range (useful for cyclic flows, e.g. one cardiac cycle). When off, query times at or beyond the last time step use the last time interval with no extrapolation. Default: off.

◆ PeriodicOff()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::PeriodicOff ( )
virtual

Toggle whether time values are treated as periodic, i.e. wrapped modulo the span between the first and last row of TimeStepsTable, so that a query time beyond the last time step maps back into range (useful for cyclic flows, e.g. one cardiac cycle). When off, query times at or beyond the last time step use the last time interval with no extrapolation. Default: off.

◆ SetVelocityScale()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetVelocityScale ( double )
virtual

Set/Get a uniform scale factor applied to every interpolated velocity vector/component before it is combined into the output. Default: 1.0.

◆ GetVelocityScale()

virtual double vtkvmtkStaticTemporalInterpolatedVelocityField::GetVelocityScale ( )
virtual

Set/Get a uniform scale factor applied to every interpolated velocity vector/component before it is combined into the output. Default: 1.0.

◆ SetUseVectorComponents()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetUseVectorComponents ( int )
virtual

Toggle whether each time step's velocity is read from three separate scalar point data arrays (named with Component0Prefix/Component1Prefix/Component2Prefix followed by the time step index) rather than from a single 3-component vector point data array (named with VectorPrefix followed by the time step index). Default: off (use vector arrays).

◆ GetUseVectorComponents()

virtual int vtkvmtkStaticTemporalInterpolatedVelocityField::GetUseVectorComponents ( )
virtual

Toggle whether each time step's velocity is read from three separate scalar point data arrays (named with Component0Prefix/Component1Prefix/Component2Prefix followed by the time step index) rather than from a single 3-component vector point data array (named with VectorPrefix followed by the time step index). Default: off (use vector arrays).

◆ UseVectorComponentsOn()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::UseVectorComponentsOn ( )
virtual

Toggle whether each time step's velocity is read from three separate scalar point data arrays (named with Component0Prefix/Component1Prefix/Component2Prefix followed by the time step index) rather than from a single 3-component vector point data array (named with VectorPrefix followed by the time step index). Default: off (use vector arrays).

◆ UseVectorComponentsOff()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::UseVectorComponentsOff ( )
virtual

Toggle whether each time step's velocity is read from three separate scalar point data arrays (named with Component0Prefix/Component1Prefix/Component2Prefix followed by the time step index) rather than from a single 3-component vector point data array (named with VectorPrefix followed by the time step index). Default: off (use vector arrays).

◆ SetVectorPrefix()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetVectorPrefix ( const char * )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the 3-component point data vector array holding each time step's velocity samples. Only used when UseVectorComponents is off.

◆ GetVectorPrefix()

virtual char * vtkvmtkStaticTemporalInterpolatedVelocityField::GetVectorPrefix ( )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the 3-component point data vector array holding each time step's velocity samples. Only used when UseVectorComponents is off.

◆ SetComponent0Prefix()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetComponent0Prefix ( const char * )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the scalar point data array holding the x-component of each time step's velocity samples. Only used when UseVectorComponents is on.

◆ GetComponent0Prefix()

virtual char * vtkvmtkStaticTemporalInterpolatedVelocityField::GetComponent0Prefix ( )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the scalar point data array holding the x-component of each time step's velocity samples. Only used when UseVectorComponents is on.

◆ SetComponent1Prefix()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetComponent1Prefix ( const char * )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the scalar point data array holding the y-component of each time step's velocity samples. Only used when UseVectorComponents is on.

◆ GetComponent1Prefix()

virtual char * vtkvmtkStaticTemporalInterpolatedVelocityField::GetComponent1Prefix ( )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the scalar point data array holding the y-component of each time step's velocity samples. Only used when UseVectorComponents is on.

◆ SetComponent2Prefix()

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetComponent2Prefix ( const char * )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the scalar point data array holding the z-component of each time step's velocity samples. Only used when UseVectorComponents is on.

◆ GetComponent2Prefix()

virtual char * vtkvmtkStaticTemporalInterpolatedVelocityField::GetComponent2Prefix ( )
virtual

Set/Get the prefix used, together with the time step index taken from TimeStepsTable, to build the name of the scalar point data array holding the z-component of each time step's velocity samples. Only used when UseVectorComponents is on.

◆ SetLastCellId() [1/2]

void vtkvmtkStaticTemporalInterpolatedVelocityField::SetLastCellId ( vtkIdType c,
int dataindex )
overridevirtual

Set the cell id cached by the last evaluation within a specified dataset.

Definition at line 80 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

81{
82 this->LastCellId = c;
83#if VMTK_VTK_HAS_REWORKED_IVF
84 this->LastDataSet = this->DataSetsInfo[dataindex].DataSet;
85
86 // if the dataset changes, then the cached cell is invalidated
87 // we might as well prefetch the cached cell either way
88 if ( this->LastCellId != -1 )
89 {
90 this->LastDataSet->GetCell( this->LastCellId, this->TemporalGenCell );
91 }
92#else
93 this->LastDataSet = ( *this->DataSets )[dataindex];
94
95 // if the dataset changes, then the cached cell is invalidated
96 // we might as well prefetch the cached cell either way
97 if ( this->LastCellId != -1 )
98 {
99 this->LastDataSet->GetCell( this->LastCellId, this->GenCell );
100 }
101#endif
102
103 this->LastDataSetIndex = dataindex;
104}

◆ SetLastCellId() [2/2]

virtual void vtkvmtkStaticTemporalInterpolatedVelocityField::SetLastCellId ( vtkIdType c)
inlineoverridevirtual

Set the cell id cached by the last evaluation.

Definition at line 186 of file vtkvmtkStaticTemporalInterpolatedVelocityField.h.

187 { this->Superclass::SetLastCellId( c ); }

◆ CopyParameters()

void vtkvmtkStaticTemporalInterpolatedVelocityField::CopyParameters ( vtkAbstractInterpolatedVelocityField * from)
overridevirtual

Copy Periodic, VelocityScale, UseVectorComponents, VectorPrefix, Component0Prefix, Component1Prefix, Component2Prefix, and a deep copy of TimeStepsTable from another interpolated velocity field, provided it is (or derives from) vtkvmtkStaticTemporalInterpolatedVelocityField. Used internally when this velocity field is cloned, e.g. for multithreaded streamline integration.

Definition at line 400 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

401{
402 if (from->IsA("vtkvmtkStaticTemporalInterpolatedVelocityField"))
403 {
405 vtkTable* timeStepsTable = vtkTable::New();
406 timeStepsTable->DeepCopy(fromCast->GetTimeStepsTable());
407 this->SetTimeStepsTable(timeStepsTable);
408 this->SetPeriodic(fromCast->GetPeriodic());
409 this->SetVelocityScale(fromCast->GetVelocityScale());
411 this->SetVectorPrefix(fromCast->VectorPrefix);
412 this->SetComponent0Prefix(fromCast->Component0Prefix);
413 this->SetComponent1Prefix(fromCast->Component1Prefix);
414 this->SetComponent2Prefix(fromCast->Component2Prefix);
415 timeStepsTable->Delete();
416 }
417}
virtual void SetComponent1Prefix(const char *)
static vtkvmtkStaticTemporalInterpolatedVelocityField * SafeDownCast(vtkObjectBase *o)
virtual void SetComponent2Prefix(const char *)
virtual void SetVectorPrefix(const char *)
virtual void SetComponent0Prefix(const char *)

◆ FunctionValues()

int vtkvmtkStaticTemporalInterpolatedVelocityField::FunctionValues ( vtkDataSet * ds,
double * x,
double * f )
overrideprotectedvirtual

Evaluate the velocity field f at point (x, y, z) in a specified dataset by either involving vtkPointLocator, via vtkPointSet::FindCell(), in locating the next cell (for datasets of type vtkPointSet) or simply invoking vtkImageData/vtkRectilinearGrid::FindCell() to fulfill the same task if the point is outside the current cell.

Definition at line 177 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

178{
179 int i, j, subId , numPts, id;
180 vtkDataArray * vectorsPrev = NULL;
181 vtkDataArray * vectorsNext = NULL;
182 vtkDataArray * component0Prev = NULL;
183 vtkDataArray * component0Next = NULL;
184 vtkDataArray * component1Prev = NULL;
185 vtkDataArray * component1Next = NULL;
186 vtkDataArray * component2Prev = NULL;
187 vtkDataArray * component2Next = NULL;
188 double vecPrev[3], vecNext[3];
189 double dist2;
190 int ret;
191 char arrayName[1024];
192
193 f[0] = f[1] = f[2] = 0.0;
194
195 // See if a dataset has been specified and if there are input vectors
196 if ( !dataset )
197 {
198 vtkErrorMacro( << "Can't evaluate dataset!" );
199 return 0;
200 }
201
202 double time = x[3];
203
204 int prevRowId, nextRowId;
205 double timeP;
206 this->FindTimeRowId(time,prevRowId,nextRowId,timeP);
207
208 int prevTimeIndex = this->TimeStepsTable->GetValue(prevRowId,0).ToInt();
209 int nextTimeIndex = this->TimeStepsTable->GetValue(nextRowId,0).ToInt();
210
211 if (this->UseVectorComponents)
212 {
213 this->BuildArrayName(this->Component0Prefix,prevTimeIndex,arrayName);
214 component0Prev = dataset->GetPointData()->GetArray(arrayName);
215 this->BuildArrayName(this->Component1Prefix,prevTimeIndex,arrayName);
216 component1Prev = dataset->GetPointData()->GetArray(arrayName);
217 this->BuildArrayName(this->Component2Prefix,prevTimeIndex,arrayName);
218 component2Prev = dataset->GetPointData()->GetArray(arrayName);
219
220 if (!component0Prev || !component1Prev || !component2Prev)
221 {
222 vtkErrorMacro(<<"Component array not found for index "<<prevTimeIndex);
223 return 0;
224 }
225
226 this->BuildArrayName(this->Component0Prefix,nextTimeIndex,arrayName);
227 component0Next = dataset->GetPointData()->GetArray(arrayName);
228 this->BuildArrayName(this->Component1Prefix,nextTimeIndex,arrayName);
229 component1Next = dataset->GetPointData()->GetArray(arrayName);
230 this->BuildArrayName(this->Component2Prefix,nextTimeIndex,arrayName);
231 component2Next = dataset->GetPointData()->GetArray(arrayName);
232
233 if (timeP > 0.0 && (!component0Next || !component1Next || !component2Next))
234 {
235 vtkErrorMacro(<<"Component array not found for index "<<nextTimeIndex);
236 return 0;
237 }
238 }
239 else
240 {
241 this->BuildArrayName(this->VectorPrefix,prevTimeIndex,arrayName);
242 vectorsPrev = dataset->GetPointData()->GetArray(arrayName);
243
244 if (timeP > 0.0 && !vectorsPrev)
245 {
246 vtkErrorMacro(<<"Vector array not found for index "<<prevTimeIndex);
247 return 0;
248 }
249
250 this->BuildArrayName(this->VectorPrefix,nextTimeIndex,arrayName);
251 vectorsNext = dataset->GetPointData()->GetArray(arrayName);
252
253 if (!vectorsNext)
254 {
255 vtkErrorMacro(<<"Vector array not found for index "<<nextTimeIndex);
256 return 0;
257 }
258 }
259
260 double tol2 = dataset->GetLength() *
261 vtkAbstractInterpolatedVelocityField::TOLERANCE_SCALE;
262
263#if VMTK_VTK_HAS_REWORKED_IVF
264 if (this->Weights.size() < static_cast<size_t>(dataset->GetMaxCellSize()))
265 {
266 this->Weights.resize(dataset->GetMaxCellSize());
267 }
268 double* weights = this->Weights.data();
269 vtkGenericCell* genCell = this->TemporalGenCell;
270 vtkGenericCell* scratchCell = this->TemporalCell;
271#else
272 double* weights = this->Weights;
273 vtkGenericCell* genCell = this->GenCell;
274 vtkGenericCell* scratchCell = this->Cell;
275#endif
276
277 int found = 0;
278
279 if ( this->Caching )
280 {
281 // See if the point is in the cached cell
282 if ( this->LastCellId == -1 ||
283 !( ret = genCell->EvaluatePosition
284 ( x, 0, subId, this->LastPCoords, dist2, weights)
285 )
286 || ret == -1
287 )
288 {
289 // if not, find and get it
290 if ( this->LastCellId != - 1 )
291 {
292 this->CacheMiss ++;
293
294 dataset->GetCell( this->LastCellId, scratchCell );
295
296 this->LastCellId =
297 dataset->FindCell( x, scratchCell, genCell, this->LastCellId,
298 tol2, subId, this->LastPCoords, weights );
299
300 if ( this->LastCellId != -1 )
301 {
302 dataset->GetCell( this->LastCellId, genCell );
303 found = 1;
304 }
305 }
306 }
307 else
308 {
309 this->CacheHit ++;
310 found = 1;
311 }
312 }
313
314 if ( !found )
315 {
316 // if the cell is not found, do a global search (ignore initial
317 // cell if there is one)
318 this->LastCellId =
319 dataset->FindCell( x, 0, genCell, -1, tol2,
320 subId, this->LastPCoords, weights );
321
322 if ( this->LastCellId != -1 )
323 {
324 dataset->GetCell( this->LastCellId, genCell );
325 }
326 else
327 {
328 return 0;
329 }
330 }
331
332 // if the cell is valid
333 if ( this->LastCellId >= 0 )
334 {
335 numPts = genCell->GetNumberOfPoints();
336
337 // interpolate the vectors
338 for ( j = 0; j < numPts; j ++ )
339 {
340 id = genCell->PointIds->GetId( j );
341 if (this->UseVectorComponents)
342 {
343 vecPrev[0] = this->VelocityScale * component0Prev->GetTuple1(id);
344 vecPrev[1] = this->VelocityScale * component1Prev->GetTuple1(id);
345 vecPrev[2] = this->VelocityScale * component2Prev->GetTuple1(id);
346
347 if (timeP > 0.0)
348 {
349 vecNext[0] = this->VelocityScale * component0Next->GetTuple1(id);
350 vecNext[1] = this->VelocityScale * component1Next->GetTuple1(id);
351 vecNext[2] = this->VelocityScale * component2Next->GetTuple1(id);
352 }
353 }
354 else
355 {
356 vectorsPrev->GetTuple( id, vecPrev );
357 for ( i = 0; i < 3; i ++ )
358 {
359 vecPrev[i] *= this->VelocityScale;
360 }
361 if (timeP > 0.0)
362 {
363 vectorsNext->GetTuple( id, vecNext );
364 for ( i = 0; i < 3; i ++ )
365 {
366 vecNext[i] *= this->VelocityScale;
367 }
368 }
369 }
370 if (timeP > 0.0)
371 {
372 for ( i = 0; i < 3; i ++ )
373 {
374 f[i] += (timeP * vecNext[i] + (1.0 - timeP) * vecPrev[i]) * weights[j];
375 }
376 }
377 else
378 {
379 for ( i = 0; i < 3; i ++ )
380 {
381 f[i] += vecPrev[i] * weights[j];
382 }
383 }
384 }
385
386 if ( this->NormalizeVector == true )
387 {
388 vtkMath::Normalize( f );
389 }
390 }
391 // if not, return false
392 else
393 {
394 return 0;
395 }
396
397 return 1;
398}
void FindTimeRowId(double time, int &prevRowId, int &nextRowId, double &p)

◆ FindTimeRowId()

void vtkvmtkStaticTemporalInterpolatedVelocityField::FindTimeRowId ( double time,
int & prevRowId,
int & nextRowId,
double & p )
protected

Definition at line 106 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

107{
108 //cout<<"Time "<<time<<endl;
109 prevRowId = 0;
110 nextRowId = 0;
111 p = 0.0;
112 if (this->TimeStepsTable == NULL)
113 {
114 return;
115 }
116 int numberOfRows = this->TimeStepsTable->GetNumberOfRows();
117 if (this->TimeStepsTable->GetNumberOfColumns() < 2 || numberOfRows == 1)
118 {
119 return;
120 }
121 int previousRowIndex = this->TimeStepsTable->GetValue(0,0).ToInt();
122 double previousRowTime = this->TimeStepsTable->GetValue(0,1).ToDouble();
123 if (numberOfRows < 2 || previousRowTime == time)
124 {
125 return;
126 }
127
128 double shiftedTime = time;
129
130 double period = this->TimeStepsTable->GetValue(numberOfRows-1,1).ToDouble() - previousRowTime;
131
132 if (this->Periodic)
133 {
134 double ratio = (time - previousRowTime) / period;
135 shiftedTime = (ratio - floor(ratio)) * period + previousRowTime;
136 }
137
138 bool found = false;
139 int pRowId = 0;
140 for (int i=1; i<numberOfRows; i++)
141 {
142 int rowId = i;
143 //if (i == numberOfRows)
144 // {
145 // rowId = 0;
146 // }
147 int rowIndex = this->TimeStepsTable->GetValue(rowId,0).ToInt();
148 double rowTime = this->TimeStepsTable->GetValue(rowId,1).ToDouble();
149 if (shiftedTime > previousRowTime && shiftedTime <= rowTime)
150 {
151 prevRowId = pRowId;
152 nextRowId = rowId;
153 p = (shiftedTime - previousRowTime) / (rowTime - previousRowTime);
154 found = true;
155 break;
156 }
157 pRowId = rowId;
158 previousRowIndex = rowIndex;
159 previousRowTime = rowTime;
160 }
161
162 //cout<<"Index "<<prevRowId<<" "<<nextRowId<<endl;
163 if (!found)
164 {
165 //cout<<"Shifted time "<<shiftedTime<<endl;
166 prevRowId = numberOfRows - 2;
167 nextRowId = numberOfRows - 2;
168 p = 1.0;
169 }
170}

◆ BuildArrayName()

void vtkvmtkStaticTemporalInterpolatedVelocityField::BuildArrayName ( char * prefix,
int index,
char * name )
protected

Definition at line 172 of file vtkvmtkStaticTemporalInterpolatedVelocityField.cxx.

173{
174 sprintf(name,"%s%d",prefix,index);
175}

Member Data Documentation

◆ TimeStepsTable

vtkTable* vtkvmtkStaticTemporalInterpolatedVelocityField::TimeStepsTable
protected

◆ Periodic

int vtkvmtkStaticTemporalInterpolatedVelocityField::Periodic
protected

◆ VelocityScale

double vtkvmtkStaticTemporalInterpolatedVelocityField::VelocityScale
protected

◆ UseVectorComponents

int vtkvmtkStaticTemporalInterpolatedVelocityField::UseVectorComponents
protected

◆ VectorPrefix

char* vtkvmtkStaticTemporalInterpolatedVelocityField::VectorPrefix
protected

◆ Component0Prefix

char* vtkvmtkStaticTemporalInterpolatedVelocityField::Component0Prefix
protected

◆ Component1Prefix

char* vtkvmtkStaticTemporalInterpolatedVelocityField::Component1Prefix
protected

◆ Component2Prefix

char* vtkvmtkStaticTemporalInterpolatedVelocityField::Component2Prefix
protected

◆ LastDataSetIndex

int vtkvmtkStaticTemporalInterpolatedVelocityField::LastDataSetIndex
protected

The documentation for this class was generated from the following files: