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

Trace particle paths (streaklines) through an unsteady velocity field sampled at discrete time steps on a fixed mesh. More...

#include <vtkvmtkStaticTemporalStreamTracer.h>

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

Public Types

typedef vtkStreamTracer Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkStaticTemporalStreamTracer * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetSeedTime (double)
virtual double GetSeedTime ()
virtual void SetSeedTimesArrayName (const char *)
virtual char * GetSeedTimesArrayName ()
virtual void SetPeriodic (int)
virtual int GetPeriodic ()
virtual void PeriodicOn ()
virtual void PeriodicOff ()
virtual void SetVelocityScale (double)
virtual double GetVelocityScale ()
virtual vtkTable * GetTimeStepsTable ()
virtual void SetTimeStepsTable (vtkTable *)
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 ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkStaticTemporalStreamTracer ()
 ~vtkvmtkStaticTemporalStreamTracer ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void InitializeDefaultInterpolatorPrototype ()
int CheckInputs (vtkAbstractInterpolatedVelocityField *&func, int *maxCellSize)
void InitializeSeeds (vtkDataArray *&seeds, vtkIdList *&seedIds, vtkDoubleArray *&startTimes, vtkIntArray *&integrationDirections, vtkDataSet *source)
void Integrate (vtkDataSet *input, vtkPolyData *output, vtkDataArray *seedSource, vtkIdList *seedIds, vtkDoubleArray *startTimes, vtkIntArray *integrationDirections, double lastPoint[3], vtkAbstractInterpolatedVelocityField *func, int maxCellSize, double &propagation, vtkIdType &numSteps)

Protected Attributes

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

Detailed Description

Trace particle paths (streaklines) through an unsteady velocity field sampled at discrete time steps on a fixed mesh.

vtkvmtkStaticTemporalStreamTracer specializes vtkStreamTracer to integrate trajectories through a time-varying, but spatially static (non-deforming), velocity field: the input mesh does not move or change connectivity over time, but carries one velocity sample per time step, stored as separate point data arrays (see TimeStepsTable, VectorPrefix, Component0Prefix, Component1Prefix, Component2Prefix, UseVectorComponents). Internally it installs a vtkvmtkStaticTemporalInterpolatedVelocityField as its interpolator prototype, which linearly interpolates in time between the two bracketing time steps (optionally wrapping around cyclically, see Periodic) in addition to the usual spatial interpolation within cells. Each seed point starts its integration at a time given either by a uniform SeedTime or, if SeedTimesArrayName is found on the seed source, by a per-seed start time array – so, unlike a classic streamline tracer, trajectories seeded at the same location but different times generally trace different paths (streaklines) through the unsteady field. This is the tracer driving the vmtkparticletracer pype script, typically used to visualize/analyze particle transport in unsteady (e.g. pulsatile CFD) blood flow simulations.

See also
vtkvmtkStaticTemporalInterpolatedVelocityField

Definition at line 64 of file vtkvmtkStaticTemporalStreamTracer.h.

Member Typedef Documentation

◆ Superclass

Definition at line 67 of file vtkvmtkStaticTemporalStreamTracer.h.

Constructor & Destructor Documentation

◆ vtkvmtkStaticTemporalStreamTracer()

vtkvmtkStaticTemporalStreamTracer::vtkvmtkStaticTemporalStreamTracer ( )
protected

Definition at line 47 of file vtkvmtkStaticTemporalStreamTracer.cxx.

48{
49 this->SeedTime = 0.0;
50 this->SeedTimesArrayName = NULL;
51 this->Periodic = 0;
52 this->VelocityScale = 1.0;
53 this->TimeStepsTable = NULL;
54 this->UseVectorComponents = 0;
55 this->VectorPrefix = NULL;
56 this->Component0Prefix = NULL;
57 this->Component1Prefix = NULL;
58 this->Component2Prefix = NULL;
59}

◆ ~vtkvmtkStaticTemporalStreamTracer()

vtkvmtkStaticTemporalStreamTracer::~vtkvmtkStaticTemporalStreamTracer ( )
protected

Definition at line 61 of file vtkvmtkStaticTemporalStreamTracer.cxx.

62{
63 if (this->SeedTimesArrayName) {
64 delete[] this->SeedTimesArrayName;
65 this->SeedTimesArrayName = NULL;
66 }
67
68 if (this->VectorPrefix) {
69 delete[] this->VectorPrefix;
70 this->VectorPrefix = NULL;
71 }
72
73 if (this->Component0Prefix) {
74 delete[] this->Component0Prefix;
75 this->Component0Prefix = NULL;
76 }
77
78 if (this->Component1Prefix) {
79 delete[] this->Component1Prefix;
80 this->Component1Prefix = NULL;
81 }
82
83 if (this->Component2Prefix) {
84 delete[] this->Component2Prefix;
85 this->Component2Prefix = NULL;
86 }
87
88 this->SetTimeStepsTable(NULL);
89}
virtual void SetTimeStepsTable(vtkTable *)

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkStaticTemporalStreamTracer::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkStaticTemporalStreamTracer * vtkvmtkStaticTemporalStreamTracer::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 813 of file vtkvmtkStaticTemporalStreamTracer.cxx.

814{
815 this->Superclass::PrintSelf(os,indent);
816
817 os << indent << "Seed time: " << this->SeedTime
818 << " unit: time." << endl;
819}

◆ New()

vtkvmtkStaticTemporalStreamTracer * vtkvmtkStaticTemporalStreamTracer::New ( )
static

◆ SetSeedTime()

virtual void vtkvmtkStaticTemporalStreamTracer::SetSeedTime ( double )
virtual

Set/Get the time value at which every seed point starts its integration, used when SeedTimesArrayName does not name an existing point data array on the seed source. Default: 0.0.

◆ GetSeedTime()

virtual double vtkvmtkStaticTemporalStreamTracer::GetSeedTime ( )
virtual

Set/Get the time value at which every seed point starts its integration, used when SeedTimesArrayName does not name an existing point data array on the seed source. Default: 0.0.

◆ SetSeedTimesArrayName()

virtual void vtkvmtkStaticTemporalStreamTracer::SetSeedTimesArrayName ( const char * )
virtual

Set/Get the name of a point data array, on the seed source, holding a per-seed integration start time. When present, it overrides the uniform SeedTime for every corresponding seed point, allowing seeds released at different times to be traced in a single pass. Default: NULL (use SeedTime for all seeds).

◆ GetSeedTimesArrayName()

virtual char * vtkvmtkStaticTemporalStreamTracer::GetSeedTimesArrayName ( )
virtual

Set/Get the name of a point data array, on the seed source, holding a per-seed integration start time. When present, it overrides the uniform SeedTime for every corresponding seed point, allowing seeds released at different times to be traced in a single pass. Default: NULL (use SeedTime for all seeds).

◆ SetPeriodic()

virtual void vtkvmtkStaticTemporalStreamTracer::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 integration continues cyclically past the last time step (useful for cyclic flows, e.g. one cardiac cycle). Default: off.

◆ GetPeriodic()

virtual int vtkvmtkStaticTemporalStreamTracer::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 integration continues cyclically past the last time step (useful for cyclic flows, e.g. one cardiac cycle). Default: off.

◆ PeriodicOn()

virtual void vtkvmtkStaticTemporalStreamTracer::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 integration continues cyclically past the last time step (useful for cyclic flows, e.g. one cardiac cycle). Default: off.

◆ PeriodicOff()

virtual void vtkvmtkStaticTemporalStreamTracer::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 integration continues cyclically past the last time step (useful for cyclic flows, e.g. one cardiac cycle). Default: off.

◆ SetVelocityScale()

virtual void vtkvmtkStaticTemporalStreamTracer::SetVelocityScale ( double )
virtual

Set/Get a uniform scale factor applied to every interpolated velocity vector/component before integration. Default: 1.0.

◆ GetVelocityScale()

virtual double vtkvmtkStaticTemporalStreamTracer::GetVelocityScale ( )
virtual

Set/Get a uniform scale factor applied to every interpolated velocity vector/component before integration. Default: 1.0.

◆ GetTimeStepsTable()

virtual vtkTable * vtkvmtkStaticTemporalStreamTracer::GetTimeStepsTable ( )
virtual

Set/Get the table mapping time step index to time value, used to interpolate the velocity field 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.

◆ SetTimeStepsTable()

virtual void vtkvmtkStaticTemporalStreamTracer::SetTimeStepsTable ( vtkTable * )
virtual

Set/Get the table mapping time step index to time value, used to interpolate the velocity field 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.

◆ SetUseVectorComponents()

virtual void vtkvmtkStaticTemporalStreamTracer::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 vtkvmtkStaticTemporalStreamTracer::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 vtkvmtkStaticTemporalStreamTracer::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 vtkvmtkStaticTemporalStreamTracer::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 vtkvmtkStaticTemporalStreamTracer::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 * vtkvmtkStaticTemporalStreamTracer::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 vtkvmtkStaticTemporalStreamTracer::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 * vtkvmtkStaticTemporalStreamTracer::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 vtkvmtkStaticTemporalStreamTracer::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 * vtkvmtkStaticTemporalStreamTracer::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 vtkvmtkStaticTemporalStreamTracer::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 * vtkvmtkStaticTemporalStreamTracer::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.

◆ RequestData()

int vtkvmtkStaticTemporalStreamTracer::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 219 of file vtkvmtkStaticTemporalStreamTracer.cxx.

223{
224 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
225 vtkInformation *outInfo = outputVector->GetInformationObject(0);
226
227 if (!this->SetupOutput(inInfo, outInfo))
228 {
229 return 0;
230 }
231
232 vtkInformation *sourceInfo = inputVector[1]->GetInformationObject(0);
233 vtkDataSet *source = 0;
234 if (sourceInfo)
235 {
236 source = vtkDataSet::SafeDownCast(
237 sourceInfo->Get(vtkDataObject::DATA_OBJECT()));
238 }
239 vtkPolyData *output = vtkPolyData::SafeDownCast(
240 outInfo->Get(vtkDataObject::DATA_OBJECT()));
241
242 if (this->InterpolatorPrototype == 0)
243 {
245 }
246
247 vtkDataArray* seeds = 0;
248 vtkIdList* seedIds = 0;
249 vtkIntArray* integrationDirections = 0;
250 vtkDoubleArray* startTimes = 0;
251 this->InitializeSeeds(seeds, seedIds, startTimes, integrationDirections, source);
252
253 if (seeds)
254 {
255 double lastPoint[3];
256 vtkAbstractInterpolatedVelocityField * func;
257 int maxCellSize = 0;
258 if (this->CheckInputs(func, &maxCellSize) != VTK_OK)
259 {
260 vtkDebugMacro("No appropriate inputs have been found. Can not execute.");
261 func->Delete();
262 seeds->Delete();
263 startTimes->Delete();
264 integrationDirections->Delete();
265 seedIds->Delete();
266 this->InputData->UnRegister(this);
267 return 1;
268 }
269
270 vtkCompositeDataIterator* iter = this->InputData->NewIterator();
271 vtkSmartPointer<vtkCompositeDataIterator> iterP(iter);
272 iter->Delete();
273
274 iterP->GoToFirstItem();
275 vtkDataSet* input0 = 0;
276 if (!iterP->IsDoneWithTraversal())
277 {
278 input0 = vtkDataSet::SafeDownCast(iterP->GetCurrentDataObject());
279 }
280
281 double propagation = 0;
282 vtkIdType numSteps = 0;
283 this->Integrate(input0, output,
284 seeds, seedIds,
285 startTimes,
286 integrationDirections,
287 lastPoint, func,
288 maxCellSize,
289 propagation, numSteps);
290 func->Delete();
291 seeds->Delete();
292 }
293
294 startTimes->Delete();
295 integrationDirections->Delete();
296 seedIds->Delete();
297
298 this->InputData->UnRegister(this);
299 return 1;
300}
void Integrate(vtkDataSet *input, vtkPolyData *output, vtkDataArray *seedSource, vtkIdList *seedIds, vtkDoubleArray *startTimes, vtkIntArray *integrationDirections, double lastPoint[3], vtkAbstractInterpolatedVelocityField *func, int maxCellSize, double &propagation, vtkIdType &numSteps)
void InitializeSeeds(vtkDataArray *&seeds, vtkIdList *&seedIds, vtkDoubleArray *&startTimes, vtkIntArray *&integrationDirections, vtkDataSet *source)
int CheckInputs(vtkAbstractInterpolatedVelocityField *&func, int *maxCellSize)

◆ InitializeDefaultInterpolatorPrototype()

void vtkvmtkStaticTemporalStreamTracer::InitializeDefaultInterpolatorPrototype ( )
protected

Definition at line 91 of file vtkvmtkStaticTemporalStreamTracer.cxx.

92{
93 vtkvmtkStaticTemporalInterpolatedVelocityField* staticTemporalInterpolator = vtkvmtkStaticTemporalInterpolatedVelocityField::New();
94
95 staticTemporalInterpolator->SetUseVectorComponents(this->UseVectorComponents);
96 staticTemporalInterpolator->SetVectorPrefix(this->VectorPrefix);
97 staticTemporalInterpolator->SetComponent0Prefix(this->Component0Prefix);
98 staticTemporalInterpolator->SetComponent1Prefix(this->Component1Prefix);
99 staticTemporalInterpolator->SetComponent2Prefix(this->Component2Prefix);
100 staticTemporalInterpolator->SetTimeStepsTable(this->TimeStepsTable);
101 staticTemporalInterpolator->SetPeriodic(this->Periodic);
102 staticTemporalInterpolator->SetVelocityScale(this->VelocityScale);
103
104 this->SetInterpolatorPrototype(staticTemporalInterpolator);
105
106 staticTemporalInterpolator->Delete();
107}
virtual void SetComponent1Prefix(const char *)
virtual void SetComponent2Prefix(const char *)
virtual void SetVectorPrefix(const char *)
virtual void SetComponent0Prefix(const char *)
static vtkvmtkStaticTemporalInterpolatedVelocityField * New()

◆ CheckInputs()

int vtkvmtkStaticTemporalStreamTracer::CheckInputs ( vtkAbstractInterpolatedVelocityField *& func,
int * maxCellSize )
protected

Definition at line 137 of file vtkvmtkStaticTemporalStreamTracer.cxx.

139{
140 if (!this->InputData)
141 {
142 return VTK_ERROR;
143 }
144
145 vtkCompositeDataIterator* iter = this->InputData->NewIterator();
146 vtkSmartPointer<vtkCompositeDataIterator> iterP(iter);
147 iter->Delete();
148
149 iterP->GoToFirstItem();
150 if (iterP->IsDoneWithTraversal())
151 {
152 return VTK_ERROR;
153 }
154
155 // Set the function set to be integrated
156 if ( !this->InterpolatorPrototype )
157 {
159
160 // turn on the following segment, in place of the above line, if an
161 // interpolator equipped with a cell locator is dedired as the default
162 //
163 // func = vtkCellLocatorInterpolatedVelocityField::New();
164 // vtkSmartPointer< vtkModifiedBSPTree > locator =
165 // vtkSmartPointer< vtkModifiedBSPTree >::New();
166 // vtkCellLocatorInterpolatedVelocityField::SafeDownCast( func )
167 // ->SetCellLocatorPrototype( locator.GetPointer() );
168 }
169 else
170 {
171 func = this->InterpolatorPrototype->NewInstance();
172 func->CopyParameters(this->InterpolatorPrototype);
173 }
174
175 //vtkDataArray *vectors = this->GetInputArrayToProcess(
176 // 0,iterP->GetCurrentDataObject());
177 //if (!vectors)
178 // {
179 // return VTK_ERROR;
180 // }
181 //const char *vecName = vectors->GetName();
182 //func->SelectVectors(vecName);
183
184 // Add all the inputs ( except source, of course ) which
185 // have the appropriate vectors and compute the maximum
186 // cell size.
187 int numInputs = 0;
188 iterP->GoToFirstItem();
189 while (!iterP->IsDoneWithTraversal())
190 {
191 vtkDataSet* inp = vtkDataSet::SafeDownCast(iterP->GetCurrentDataObject());
192 if (inp)
193 {
194 //if (!inp->GetPointData()->GetVectors(vecName))
195 // {
196 // vtkDebugMacro("One of the input blocks does not contain a "
197 // "velocity vector.");
198 // iterP->GoToNextItem();
199 // continue;
200 // }
201 int cellSize = inp->GetMaxCellSize();
202 if ( cellSize > *maxCellSize )
203 {
204 *maxCellSize = cellSize;
205 }
206 VMTK_STIVF_SUPERCLASS::SafeDownCast(func)->AddDataSet(inp);
207 numInputs++;
208 }
209 iterP->GoToNextItem();
210 }
211 if ( numInputs == 0 )
212 {
213 vtkDebugMacro("No appropriate inputs have been found. Can not execute.");
214 return VTK_ERROR;
215 }
216 return VTK_OK;
217}

◆ InitializeSeeds()

void vtkvmtkStaticTemporalStreamTracer::InitializeSeeds ( vtkDataArray *& seeds,
vtkIdList *& seedIds,
vtkDoubleArray *& startTimes,
vtkIntArray *& integrationDirections,
vtkDataSet * source )
protected

Definition at line 109 of file vtkvmtkStaticTemporalStreamTracer.cxx.

114{
115 this->Superclass::InitializeSeeds(seeds,seedIds,integrationDirections,source);
116
117 startTimes = vtkDoubleArray::New();
118
119 if (!source)
120 {
121 return;
122 }
123
124 vtkDataArray* sourceSeedTimes = source->GetPointData()->GetArray(this->SeedTimesArrayName);
125
126 if (sourceSeedTimes)
127 {
128 startTimes->DeepCopy(sourceSeedTimes);
129 }
130 else
131 {
132 startTimes->SetNumberOfTuples(source->GetNumberOfPoints());
133 startTimes->FillComponent(0,this->SeedTime);
134 }
135}

◆ Integrate()

void vtkvmtkStaticTemporalStreamTracer::Integrate ( vtkDataSet * input,
vtkPolyData * output,
vtkDataArray * seedSource,
vtkIdList * seedIds,
vtkDoubleArray * startTimes,
vtkIntArray * integrationDirections,
double lastPoint[3],
vtkAbstractInterpolatedVelocityField * func,
int maxCellSize,
double & propagation,
vtkIdType & numSteps )
protected

Definition at line 302 of file vtkvmtkStaticTemporalStreamTracer.cxx.

313{
314 int i;
315 vtkIdType numLines = seedIds->GetNumberOfIds();
316 double propagation = inPropagation;
317 vtkIdType numSteps = inNumSteps;
318
319 // Useful pointers
320 vtkDataSetAttributes* outputPD = output->GetPointData();
321 vtkDataSetAttributes* outputCD = output->GetCellData();
322 vtkPointData* inputPD;
323 vtkDataSet* input;
324 //TODO: this one will potentially change at every evaluation.
325
326 int direction=1;
327
328 double* weights = 0;
329 if ( maxCellSize > 0 )
330 {
331 weights = new double[maxCellSize];
332 }
333
334 if (this->GetIntegrator() == 0)
335 {
336 vtkErrorMacro("No integrator is specified.");
337 return;
338 }
339
340 // Used in GetCell()
341 vtkGenericCell* cell = vtkGenericCell::New();
342
343 // Create a new integrator, the type is the same as Integrator
344 vtkInitialValueProblemSolver* integrator =
345 this->GetIntegrator()->NewInstance();
346 integrator->SetFunctionSet(func);
347
348 // Since we do not know what the total number of points
349 // will be, we do not allocate any. This is important for
350 // cases where a lot of streamers are used at once. If we
351 // were to allocate any points here, potentially, we can
352 // waste a lot of memory if a lot of streamers are used.
353 // Always insert the first point
354 vtkPoints* outputPoints = vtkPoints::New();
355 vtkCellArray* outputLines = vtkCellArray::New();
356
357 // We will keep track of integration time in this array
358 vtkDoubleArray* time = vtkDoubleArray::New();
359 time->SetName("IntegrationTime");
360
361 // This array explains why the integration stopped
362 vtkIntArray* retVals = vtkIntArray::New();
363 retVals->SetName("ReasonForTermination");
364
365 vtkDoubleArray* cellVectors = 0;
366 vtkDoubleArray* velocityArray = 0;
367 vtkDoubleArray* speedArray = 0;
368 vtkDoubleArray* vorticity = 0;
369 vtkDoubleArray* rotation = 0;
370 vtkDoubleArray* angularVel = 0;
371
372 velocityArray = vtkDoubleArray::New();
373 velocityArray->SetName("Velocity");
374 velocityArray->SetNumberOfComponents(3);
375
376 speedArray = vtkDoubleArray::New();
377 speedArray->SetName("Speed");
378
379 if (this->ComputeVorticity)
380 {
381 cellVectors = vtkDoubleArray::New();
382 cellVectors->SetNumberOfComponents(3);
383 cellVectors->Allocate(3*VTK_CELL_SIZE);
384
385 vorticity = vtkDoubleArray::New();
386 vorticity->SetName("Vorticity");
387 vorticity->SetNumberOfComponents(3);
388
389 rotation = vtkDoubleArray::New();
390 rotation->SetName("Rotation");
391
392 angularVel = vtkDoubleArray::New();
393 angularVel->SetName("AngularVelocity");
394 }
395
396 // We will interpolate all point attributes of the input on each point of
397 // the output (unless they are turned off). Note that we are using only
398 // the first input, if there are more than one, the attributes have to match.
399 //
400 // Note: We have to use a specific value (safe to employ the maximum number
401 // of steps) as the size of the initial memory allocation here. The
402 // use of the default argument might incur a crash problem (due to
403 // "insufficient memory") in the parallel mode. This is the case when
404 // a streamline intensely shuttles between two processes in an exactly
405 // interleaving fashion --- only one point is produced on each process
406 // (and actually two points, after point duplication, are saved to a
407 // vtkPolyData in vtkDistributedStreamTracer::NoBlockProcessTask) and
408 // as a consequence a large number of such small vtkPolyData objects
409 // are needed to represent a streamline, consuming up the memory before
410 // the intermediate memory is timely released.
411
412 // TODO: this one should be avoided - or at least we should interpolate all vectors that are not in the list of temporal vector fields
413 //outputPD->InterpolateAllocate( input0->GetPointData(),
414 // this->MaximumNumberOfSteps );
415
416 vtkIdType numPtsTotal=0;
417 double velocity[3];
418
419 int shouldAbort = 0;
420
421 for(int currentLine = 0; currentLine < numLines; currentLine++)
422 {
423 double progress = static_cast<double>(currentLine)/numLines;
424 this->UpdateProgress(progress);
425
426 switch (integrationDirections->GetValue(currentLine))
427 {
428 case FORWARD:
429 direction = 1;
430 break;
431 case BACKWARD:
432 direction = -1;
433 break;
434 }
435
436 // temporary variables used in the integration
437 double point1[3], point2[3], pcoords[3], vort[3], omega;
438 vtkIdType index, numPts=0;
439
440 // Clear the last cell to avoid starting a search from
441 // the last point in the streamline
442 func->ClearLastCellId();
443
444 double startTime = startTimes->GetValue(currentLine);
445
446 // Initial point
447 seedSource->GetTuple(seedIds->GetId(currentLine), point1);
448 memcpy(point2, point1, 3*sizeof(double));
449
450 double point1t[4];
451 memcpy(point1t, point1, 3*sizeof(double));
452 point1t[3] = startTime;
453
454 if (!func->FunctionValues(point1t, velocity))
455 {
456 continue;
457 }
458
459 if ( propagation >= this->MaximumPropagation ||
460 numSteps > this->MaximumNumberOfSteps)
461 {
462 continue;
463 }
464
465 numPts++;
466 numPtsTotal++;
467 vtkIdType nextPoint = outputPoints->InsertNextPoint(point1);
468
469 time->InsertNextValue(startTime);
470
471 // We will always pass an arc-length step size to the integrator.
472 // If the user specifies a step size in cell length unit, we will
473 // have to convert it to arc length.
474 vmtkIntervalInformation stepSize; // either positive or negative
475 stepSize.Unit = LENGTH_UNIT;
476 stepSize.Interval = 0;
477 vmtkIntervalInformation aStep; // always positive
478 aStep.Unit = LENGTH_UNIT;
479 double step, minStep=0, maxStep=0;
480 double stepTaken, accumTime=startTime;
481 double speed;
482 double cellLength;
483 int retVal=OUT_OF_LENGTH, tmp;
484
485 // Make sure we use the dataset found by the vtkAbstractInterpolatedVelocityField
486 input = func->GetLastDataSet();
487 inputPD = input->GetPointData();
488
489 // Convert intervals to arc-length unit
490 input->GetCell(func->GetLastCellId(), cell);
491 cellLength = sqrt(static_cast<double>(cell->GetLength2()));
492 speed = vtkMath::Norm(velocity);
493 // Never call conversion methods if speed == 0
494 if ( speed != 0.0 )
495 {
496 this->ConvertIntervals( stepSize.Interval, minStep, maxStep,
497 direction, cellLength );
498 }
499
500 // Interpolate all point attributes on first point
501 func->GetLastWeights(weights);
502 //TODO: avoid this at least for time vectors
503 //outputPD->InterpolatePoint(inputPD, nextPoint, cell->PointIds, weights);
504
505 velocityArray->InsertNextTuple(velocity);
506 speedArray->InsertNextValue(speed);
507
508 // Compute vorticity if required
509 // This can be used later for streamribbon generation.
510 if (this->ComputeVorticity)
511 {
512 //TODO: for vorticity to work, inVectors should be updated with the vector field at the correct time step
513 //inVectors->GetTuples(cell->PointIds, cellVectors);
514 func->GetLastLocalCoordinates(pcoords);
515 vort[0] = vort[1] = vort[2] = 0.0;
516 //vtkStreamTracer::CalculateVorticity(cell, pcoords, cellVectors, vort);
517 vorticity->InsertNextTuple(vort);
518 // rotation
519 // local rotation = vorticity . unit tangent ( i.e. velocity/speed )
520 if (speed != 0.0)
521 {
522 omega = vtkMath::Dot(vort, velocity);
523 omega /= speed;
524 omega *= this->RotationScale;
525 }
526 else
527 {
528 omega = 0.0;
529 }
530 angularVel->InsertNextValue(omega);
531 rotation->InsertNextValue(0.0);
532 }
533
534 double error = 0;
535 // Integrate until the maximum propagation length is reached,
536 // maximum number of steps is reached or until a boundary is encountered.
537 // Begin Integration
538 while ( propagation < this->MaximumPropagation )
539 {
540
541 if (numSteps > this->MaximumNumberOfSteps)
542 {
543 retVal = OUT_OF_STEPS;
544 break;
545 }
546
547 if ( numSteps++ % 1000 == 1 )
548 {
549 progress =
550 ( currentLine + propagation / this->MaximumPropagation ) / numLines;
551 this->UpdateProgress(progress);
552
553 if (this->GetAbortExecute())
554 {
555 shouldAbort = 1;
556 break;
557 }
558 }
559
560 // Never call conversion methods if speed == 0
561 if ( (speed == 0) || (speed <= this->TerminalSpeed) )
562 {
563 retVal = STAGNATION;
564 break;
565 }
566
567 // If, with the next step, propagation will be larger than
568 // max, reduce it so that it is (approximately) equal to max.
569 aStep.Interval = fabs( stepSize.Interval );
570
571 if ( ( propagation + aStep.Interval ) > this->MaximumPropagation )
572 {
573 aStep.Interval = this->MaximumPropagation - propagation;
574 if ( stepSize.Interval >= 0 )
575 {
576#if VMTK_USE_LEGACY_INTERVAL_INFORMATION
577 stepSize.Interval = this->ConvertToLength( aStep, cellLength );
578#else
579 stepSize.Interval = vtkIntervalInformation::ConvertToLength(aStep, cellLength);
580#endif
581 }
582 else
583 {
584#if VMTK_USE_LEGACY_INTERVAL_INFORMATION
585 stepSize.Interval = this->ConvertToLength(aStep, cellLength) * (-1.0);
586#else
587 stepSize.Interval = vtkIntervalInformation::ConvertToLength(aStep, cellLength) * (-1.0);
588#endif
589 }
590 maxStep = stepSize.Interval;
591 }
592 this->LastUsedStepSize = stepSize.Interval;
593
594 // Calculate the next step using the integrator provided
595 // Break if the next point is out of bounds.
596 func->SetNormalizeVector( true );
597 tmp = integrator->ComputeNextStep( point1, point2, accumTime, stepSize.Interval,
598 stepTaken, minStep, maxStep,
599 this->MaximumError, error );
600 func->SetNormalizeVector( false );
601 if ( tmp != 0 )
602 {
603 retVal = tmp;
604 memcpy(lastPoint, point2, 3*sizeof(double));
605 break;
606 }
607
608 // It is not enough to use the starting point for stagnation calculation
609 // Use delX/stepSize to calculate speed and check if it is below
610 // stagnation threshold
611 double disp[3];
612 for (i=0; i<3; i++)
613 {
614 disp[i] = point2[i] - point1[i];
615 }
616 if ( (stepSize.Interval == 0) ||
617 (vtkMath::Norm(disp) / fabs(stepSize.Interval) <= this->TerminalSpeed) )
618 {
619 retVal = STAGNATION;
620 break;
621 }
622
623 accumTime += stepTaken / speed;
624 // Calculate propagation (using the same units as MaximumPropagation
625 propagation += fabs( stepSize.Interval );
626
627 // This is the next starting point
628 for(i=0; i<3; i++)
629 {
630 point1[i] = point2[i];
631 }
632
633 double point2t[4];
634 memcpy(point2t, point2, 3*sizeof(double));
635 point2t[3] = accumTime;
636
637 // Interpolate the velocity at the next point
638 if ( !func->FunctionValues(point2t, velocity) )
639 {
640 retVal = OUT_OF_DOMAIN;
641 memcpy(lastPoint, point2, 3*sizeof(double));
642 break;
643 }
644 // Make sure we use the dataset found by the vtkAbstractInterpolatedVelocityField
645 input = func->GetLastDataSet();
646 inputPD = input->GetPointData();
647
648 // Point is valid. Insert it.
649 numPts++;
650 numPtsTotal++;
651 nextPoint = outputPoints->InsertNextPoint(point1);
652 time->InsertNextValue(accumTime);
653
654 // Calculate cell length and speed to be used in unit conversions
655 input->GetCell(func->GetLastCellId(), cell);
656 cellLength = sqrt(static_cast<double>(cell->GetLength2()));
657
658 velocityArray->InsertNextTuple(velocity);
659
660 speed = vtkMath::Norm(velocity);
661
662 speedArray->InsertNextValue(speed);
663
664 // Interpolate all point attributes on current point
665 func->GetLastWeights(weights);
666 //TODO: avoid this at least for time vectors
667 //outputPD->InterpolatePoint(inputPD, nextPoint, cell->PointIds, weights);
668
669 // Compute vorticity if required
670 // This can be used later for streamribbon generation.
671 if (this->ComputeVorticity)
672 {
673 //TODO
674 //inVectors->GetTuples(cell->PointIds, cellVectors);
675 func->GetLastLocalCoordinates(pcoords);
676 vort[0] = vort[1] = vort[2] = 0.0;
677 //vtkStreamTracer::CalculateVorticity(cell, pcoords, cellVectors, vort);
678 vorticity->InsertNextTuple(vort);
679 // rotation
680 // angular velocity = vorticity . unit tangent ( i.e. velocity/speed )
681 // rotation = sum ( angular velocity * stepSize )
682 omega = vtkMath::Dot(vort, velocity);
683 omega /= speed;
684 omega *= this->RotationScale;
685 index = angularVel->InsertNextValue(omega);
686 rotation->InsertNextValue(rotation->GetValue(index-1) +
687 (angularVel->GetValue(index-1) + omega)/2 *
688 (accumTime - time->GetValue(index-1)));
689 }
690
691 // Never call conversion methods if speed == 0
692 if ( (speed == 0) || (speed <= this->TerminalSpeed) )
693 {
694 retVal = STAGNATION;
695 break;
696 }
697
698 // Convert all intervals to arc length
699 this->ConvertIntervals( step, minStep, maxStep, direction, cellLength );
700
701
702 // If the solver is adaptive and the next step size (stepSize.Interval)
703 // that the solver wants to use is smaller than minStep or larger
704 // than maxStep, re-adjust it. This has to be done every step
705 // because minStep and maxStep can change depending on the cell
706 // size (unless it is specified in arc-length unit)
707 if (integrator->IsAdaptive())
708 {
709 if (fabs(stepSize.Interval) < fabs(minStep))
710 {
711 stepSize.Interval = fabs( minStep ) *
712 stepSize.Interval / fabs( stepSize.Interval );
713 }
714 else if (fabs(stepSize.Interval) > fabs(maxStep))
715 {
716 stepSize.Interval = fabs( maxStep ) *
717 stepSize.Interval / fabs( stepSize.Interval );
718 }
719 }
720 else
721 {
722 stepSize.Interval = step;
723 }
724
725 // End Integration
726 }
727
728 if (shouldAbort)
729 {
730 break;
731 }
732
733 if (numPts > 1)
734 {
735 outputLines->InsertNextCell(numPts);
736 for (i=numPtsTotal-numPts; i<numPtsTotal; i++)
737 {
738 outputLines->InsertCellPoint(i);
739 }
740 retVals->InsertNextValue(retVal);
741 }
742
743 // Initialize these to 0 before starting the next line.
744 // The values passed in the function call are only used
745 // for the first line.
746 inPropagation = propagation;
747 inNumSteps = numSteps;
748
749 propagation = 0;
750 numSteps = 0;
751 }
752
753 if (!shouldAbort)
754 {
755 // Create the output polyline
756 output->SetPoints(outputPoints);
757 outputPD->AddArray(time);
758 outputPD->AddArray(velocityArray);
759 outputPD->AddArray(speedArray);
760 if (vorticity)
761 {
762 outputPD->AddArray(vorticity);
763 outputPD->AddArray(rotation);
764 outputPD->AddArray(angularVel);
765 }
766
767 vtkIdType numPts = outputPoints->GetNumberOfPoints();
768 if ( numPts > 1 )
769 {
770 // Assign geometry and attributes
771 output->SetLines(outputLines);
772 if (this->GenerateNormalsInIntegrate)
773 {
775 //this->GenerateNormals(output, 0, vecName);
776 }
777
778 outputCD->AddArray(retVals);
779 }
780 }
781
782 velocityArray->Delete();
783 speedArray->Delete();
784
785 if (vorticity)
786 {
787 vorticity->Delete();
788 rotation->Delete();
789 angularVel->Delete();
790 }
791
792 if (cellVectors)
793 {
794 cellVectors->Delete();
795 }
796 retVals->Delete();
797
798 outputPoints->Delete();
799 outputLines->Delete();
800
801 time->Delete();
802
803
804 integrator->Delete();
805 cell->Delete();
806
807 delete[] weights;
808
809 output->Squeeze();
810 return;
811}
#define vmtkIntervalInformation

Member Data Documentation

◆ SeedTime

double vtkvmtkStaticTemporalStreamTracer::SeedTime
protected

Definition at line 205 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ SeedTimesArrayName

char* vtkvmtkStaticTemporalStreamTracer::SeedTimesArrayName
protected

Definition at line 206 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ Periodic

int vtkvmtkStaticTemporalStreamTracer::Periodic
protected

Definition at line 207 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ UseVectorComponents

int vtkvmtkStaticTemporalStreamTracer::UseVectorComponents
protected

Definition at line 209 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ VectorPrefix

char* vtkvmtkStaticTemporalStreamTracer::VectorPrefix
protected

Definition at line 211 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ Component0Prefix

char* vtkvmtkStaticTemporalStreamTracer::Component0Prefix
protected

Definition at line 212 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ Component1Prefix

char* vtkvmtkStaticTemporalStreamTracer::Component1Prefix
protected

Definition at line 213 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ Component2Prefix

char* vtkvmtkStaticTemporalStreamTracer::Component2Prefix
protected

Definition at line 214 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ TimeStepsTable

vtkTable* vtkvmtkStaticTemporalStreamTracer::TimeStepsTable
protected

Definition at line 216 of file vtkvmtkStaticTemporalStreamTracer.h.

◆ VelocityScale

double vtkvmtkStaticTemporalStreamTracer::VelocityScale
protected

Definition at line 218 of file vtkvmtkStaticTemporalStreamTracer.h.


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